Browse Source
# Conflicts: # samples/ControlCatalog.NetCore/Program.cs # samples/ControlCatalog/MainWindow.xaml.cs # src/Gtk/Avalonia.Gtk3/Gtk3Platform.cs # src/Gtk/Avalonia.Gtk3/Interop/GlibTimeout.cspull/1105/head
398 changed files with 7473 additions and 5254 deletions
@ -1,6 +1,7 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<DefaultTestTimeout>1000</DefaultTestTimeout> |
|||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|||
<PreviouslyBuiltSuccessfully>True</PreviouslyBuiltSuccessfully> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,9 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<IgnoredTests> |
|||
<NamedTestSelector> |
|||
<TestName>Avalonia.Markup.UnitTests.Data.Plugins.DataAnnotationsValidationPluginTests.Produces_Aggregate_BindingNotificationsx</TestName> |
|||
</NamedTestSelector> |
|||
</IgnoredTests> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -1,6 +1,7 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<DefaultTestTimeout>1000</DefaultTestTimeout> |
|||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|||
<PreviouslyBuiltSuccessfully>True</PreviouslyBuiltSuccessfully> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,5 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="MonoMac.NetStandard" Version="0.0.3" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -1,6 +1,4 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="System.Threading.ThreadPool" Version="4.3.0" /> |
|||
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="1.1.0" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
|
|||
@ -0,0 +1,6 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<PropertyGroup Condition=" '$(TargetFramework)' == 'net461' and '$(OS)' == 'Unix' "> |
|||
<FrameworkPathOverride>/usr/lib/mono/4.6.1-api</FrameworkPathOverride> |
|||
<FrameworkPathOverride Condition="$([MSBuild]::IsOsPlatform('OSX'))">/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.6.1-api</FrameworkPathOverride> |
|||
</PropertyGroup> |
|||
</Project> |
|||
@ -0,0 +1,5 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="reactiveui" Version="8.0.0-alpha0073" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -1,11 +1,10 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="System.Reactive" Version="3.0.0" /> |
|||
<PackageReference Include="System.Reactive.Core" Version="3.0.0" /> |
|||
<PackageReference Include="System.Reactive.Interfaces" Version="3.0.0" /> |
|||
<PackageReference Include="System.Reactive.Linq" Version="3.0.0" /> |
|||
<PackageReference Include="System.Reactive.PlatformServices" Version="3.0.0" /> |
|||
<PackageReference Condition="'$(TargetFramework)' == 'net45'" Include="System.Reactive.Windows.Threading" Version="3.0.0" /> |
|||
<PackageReference Condition="'$(TargetFramework)' == 'net461'" Include="System.Reactive.Windows.Threading" Version="3.0.0" /> |
|||
<PackageReference Include="System.Reactive" Version="3.1.1" /> |
|||
<PackageReference Include="System.Reactive.Core" Version="3.1.1" /> |
|||
<PackageReference Include="System.Reactive.Interfaces" Version="3.1.1" /> |
|||
<PackageReference Include="System.Reactive.Linq" Version="3.1.1" /> |
|||
<PackageReference Include="System.Reactive.PlatformServices" Version="3.1.1" /> |
|||
<PackageReference Condition="$(TargetFramework.StartsWith('net4'))" Include="System.Reactive.Windows.Threading" Version="3.1.1" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
|
|||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 172 KiB |
@ -0,0 +1,33 @@ |
|||
<Window xmlns="https://github.com/avaloniaui" MinWidth="500" MinHeight="300" |
|||
Title="Avalonia Control Gallery" |
|||
Icon="resm:ControlCatalog.Assets.test_icon.ico?assembly=ControlCatalog" |
|||
xmlns:local="clr-namespace:ControlCatalog;assembly=ControlCatalog" HasSystemDecorations="False"> |
|||
<Grid RowDefinitions="5,*,5" ColumnDefinitions="5,*,5"> |
|||
<DockPanel Grid.Column="1" Grid.Row="1" > |
|||
<Grid Name="TitleBar" Background="LightBlue" DockPanel.Dock="Top" ColumnDefinitions="Auto,*,Auto"> |
|||
<TextBlock VerticalAlignment="Center" Margin="5,0,0,0">Title</TextBlock> |
|||
<StackPanel Grid.Column="2" Orientation="Horizontal"> |
|||
<StackPanel.Styles> |
|||
<Style Selector="Button"> |
|||
<Setter Property="Margin" Value="2"/> |
|||
</Style> |
|||
</StackPanel.Styles> |
|||
<Button Name="MinimizeButton">_</Button> |
|||
<Button Name="MaximizeButton">[ ]</Button> |
|||
<Button Name="CloseButton">X</Button> |
|||
</StackPanel> |
|||
</Grid> |
|||
<Border Background="White" Margin="5"> |
|||
<TextBlock>Hello world!</TextBlock> |
|||
</Border> |
|||
</DockPanel> |
|||
<Border Name="TopLeft" Background="Red"/> |
|||
<Border Name="TopRight" Background="Red" Grid.Column="2" /> |
|||
<Border Name="BottomLeft" Background="Red" Grid.Row="2" /> |
|||
<Border Name="BottomRight" Background="Red" Grid.Row="2" Grid.Column="2"/> |
|||
<Border Name="Top" Background="Blue" Grid.Column="1" /> |
|||
<Border Name="Right" Background="Blue" Grid.Row="1" Grid.Column="2" /> |
|||
<Border Name="Bottom" Background="Blue" Grid.Row="2" Grid.Column="1" /> |
|||
<Border Name="Left" Background="Blue" Grid.Row="1" /> |
|||
</Grid> |
|||
</Window> |
|||
@ -0,0 +1,53 @@ |
|||
using Avalonia; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Markup.Xaml; |
|||
using System; |
|||
using Avalonia.Input; |
|||
|
|||
namespace ControlCatalog |
|||
{ |
|||
public class DecoratedWindow : Window |
|||
{ |
|||
public DecoratedWindow() |
|||
{ |
|||
this.InitializeComponent(); |
|||
this.AttachDevTools(); |
|||
} |
|||
|
|||
void SetupSide(string name, StandardCursorType cursor, WindowEdge edge) |
|||
{ |
|||
var ctl = this.FindControl<Control>(name); |
|||
ctl.Cursor = new Cursor(cursor); |
|||
ctl.PointerPressed += delegate |
|||
{ |
|||
PlatformImpl.BeginResizeDrag(edge); |
|||
}; |
|||
} |
|||
|
|||
private void InitializeComponent() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
this.FindControl<Control>("TitleBar").PointerPressed += delegate |
|||
{ |
|||
PlatformImpl.BeginMoveDrag(); |
|||
}; |
|||
SetupSide("Left", StandardCursorType.LeftSide, WindowEdge.West); |
|||
SetupSide("Right", StandardCursorType.RightSide, WindowEdge.East); |
|||
SetupSide("Top", StandardCursorType.TopSide, WindowEdge.North); |
|||
SetupSide("Bottom", StandardCursorType.BottomSize, WindowEdge.South); |
|||
SetupSide("TopLeft", StandardCursorType.TopLeftCorner, WindowEdge.NorthWest); |
|||
SetupSide("TopRight", StandardCursorType.TopRightCorner, WindowEdge.NorthEast); |
|||
SetupSide("BottomLeft", StandardCursorType.BottomLeftCorner, WindowEdge.SouthWest); |
|||
SetupSide("BottomRight", StandardCursorType.BottomRightCorner, WindowEdge.SouthEast); |
|||
this.FindControl<Button>("MinimizeButton").Click += delegate { this.WindowState = WindowState.Minimized; }; |
|||
this.FindControl<Button>("MaximizeButton").Click += delegate |
|||
{ |
|||
WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized; |
|||
}; |
|||
this.FindControl<Button>("CloseButton").Click += delegate |
|||
{ |
|||
Close(); |
|||
}; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
<UserControl xmlns="https://github.com/avaloniaui"> |
|||
<StackPanel Orientation="Vertical" Gap="4" Margin="4"> |
|||
<Button Name="OpenFile">Open File</Button> |
|||
<Button Name="SaveFile">Save File</Button> |
|||
<Button Name="SelectFolder">Select Folder</Button> |
|||
<StackPanel Orientation="Horizontal"> |
|||
<CheckBox Name="IsModal" IsChecked="True"/> |
|||
<TextBlock>Modal to window</TextBlock> |
|||
</StackPanel> |
|||
<Button Name="DecoratedWindow">Decorated window</Button> |
|||
</StackPanel> |
|||
</UserControl> |
|||
@ -0,0 +1,46 @@ |
|||
using Avalonia.Controls; |
|||
using Avalonia.Markup.Xaml; |
|||
#pragma warning disable 4014
|
|||
|
|||
namespace ControlCatalog.Pages |
|||
{ |
|||
public class DialogsPage : UserControl |
|||
{ |
|||
public DialogsPage() |
|||
{ |
|||
this.InitializeComponent(); |
|||
this.FindControl<Button>("OpenFile").Click += delegate |
|||
{ |
|||
new OpenFileDialog() |
|||
{ |
|||
Title = "Open file" |
|||
}.ShowAsync(GetWindow()); |
|||
}; |
|||
this.FindControl<Button>("SaveFile").Click += delegate |
|||
{ |
|||
new SaveFileDialog() |
|||
{ |
|||
Title = "Save file" |
|||
}.ShowAsync(GetWindow()); |
|||
}; |
|||
this.FindControl<Button>("SelectFolder").Click += delegate |
|||
{ |
|||
new OpenFolderDialog() |
|||
{ |
|||
Title = "Select folder" |
|||
}.ShowAsync(GetWindow()); |
|||
}; |
|||
this.FindControl<Button>("DecoratedWindow").Click += delegate |
|||
{ |
|||
new DecoratedWindow().Show(); |
|||
}; |
|||
} |
|||
|
|||
Window GetWindow() => this.FindControl<CheckBox>("IsModal").IsChecked ? (Window)this.VisualRoot : null; |
|||
|
|||
private void InitializeComponent() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
<UserControl xmlns="https://github.com/avaloniaui"> |
|||
<StackPanel Orientation="Vertical" Gap="4"> |
|||
<TextBlock Classes="h1">ProgressBar</TextBlock> |
|||
<TextBlock Classes="h2">A progress bar control</TextBlock> |
|||
|
|||
<StackPanel> |
|||
<StackPanel Orientation="Horizontal" |
|||
Margin="0,16,0,0" |
|||
HorizontalAlignment="Center" |
|||
Gap="16"> |
|||
<StackPanel Gap="16"> |
|||
<ProgressBar Value="{Binding #hprogress.Value}" /> |
|||
<ProgressBar IsIndeterminate="True"/> |
|||
</StackPanel> |
|||
<ProgressBar Value="{Binding #vprogress.Value}" Orientation="Vertical" /> |
|||
<ProgressBar Orientation="Vertical" IsIndeterminate="True" /> |
|||
</StackPanel> |
|||
<StackPanel Margin="16"> |
|||
<Slider Name="hprogress" Maximum="100" Value="40"/> |
|||
<Slider Name="vprogress" Maximum="100" Value="60"/> |
|||
</StackPanel> |
|||
</StackPanel> |
|||
</StackPanel> |
|||
</UserControl> |
|||
@ -0,0 +1,18 @@ |
|||
using Avalonia.Controls; |
|||
using Avalonia.Markup.Xaml; |
|||
|
|||
namespace ControlCatalog.Pages |
|||
{ |
|||
public class ProgressBarPage : UserControl |
|||
{ |
|||
public ProgressBarPage() |
|||
{ |
|||
this.InitializeComponent(); |
|||
} |
|||
|
|||
private void InitializeComponent() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,62 @@ |
|||
using System; |
|||
using Avalonia; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Markup.Xaml; |
|||
using Avalonia.Media; |
|||
using Avalonia.Platform; |
|||
|
|||
namespace ControlCatalog.Pages |
|||
{ |
|||
public class ScreenPage : UserControl |
|||
{ |
|||
private double _leftMost; |
|||
|
|||
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) |
|||
{ |
|||
base.OnAttachedToVisualTree(e); |
|||
Window w = (Window)VisualRoot; |
|||
w.PositionChanged += (sender, args) => InvalidateVisual(); |
|||
} |
|||
|
|||
public override void Render(DrawingContext context) |
|||
{ |
|||
base.Render(context); |
|||
Window w = (Window)VisualRoot; |
|||
Screen[] screens = w.Screens.All; |
|||
|
|||
Pen p = new Pen(Brushes.Black); |
|||
if (screens != null) |
|||
foreach (Screen screen in screens) |
|||
{ |
|||
if (screen.Bounds.X / 10f < _leftMost) |
|||
{ |
|||
_leftMost = screen.Bounds.X / 10f; |
|||
InvalidateVisual(); |
|||
return; |
|||
} |
|||
|
|||
Rect boundsRect = new Rect(screen.Bounds.X / 10f + Math.Abs(_leftMost), screen.Bounds.Y / 10f, screen.Bounds.Width / 10f, |
|||
screen.Bounds.Height / 10f); |
|||
Rect workingAreaRect = new Rect(screen.WorkingArea.X / 10f + Math.Abs(_leftMost), screen.WorkingArea.Y / 10f, screen.WorkingArea.Width / 10f, |
|||
screen.WorkingArea.Height / 10f); |
|||
context.DrawRectangle(p, boundsRect); |
|||
context.DrawRectangle(p, workingAreaRect); |
|||
|
|||
FormattedText text = new FormattedText(); |
|||
text.Text = $"Bounds: {screen.Bounds.Width}:{screen.Bounds.Height}"; |
|||
context.DrawText(Brushes.Black, boundsRect.Position.WithY(boundsRect.Size.Height), text); |
|||
|
|||
text.Text = $"WorkArea: {screen.WorkingArea.Width}:{screen.WorkingArea.Height}"; |
|||
context.DrawText(Brushes.Black, boundsRect.Position.WithY(boundsRect.Size.Height + 20), text); |
|||
|
|||
text.Text = $"Primary: {screen.Primary}"; |
|||
context.DrawText(Brushes.Black, boundsRect.Position.WithY(boundsRect.Size.Height + 40), text); |
|||
|
|||
text.Text = $"Current: {screen.Equals(w.Screens.ScreenFromBounds(new Rect(w.Position, w.Bounds.Size)))}"; |
|||
context.DrawText(Brushes.Black, boundsRect.Position.WithY(boundsRect.Size.Height + 60), text); |
|||
} |
|||
|
|||
context.DrawRectangle(p, new Rect(w.Position.X / 10f + Math.Abs(_leftMost), w.Position.Y / 10, w.Bounds.Width / 10, w.Bounds.Height / 10)); |
|||
} |
|||
} |
|||
} |
|||
@ -1,126 +0,0 @@ |
|||
using Avalonia.Logging.Serilog; |
|||
using Serilog; |
|||
using System; |
|||
using System.Linq; |
|||
using Avalonia; |
|||
|
|||
namespace ControlCatalog |
|||
{ |
|||
internal class Program |
|||
{ |
|||
static void Main(string[] args) |
|||
{ |
|||
InitializeLogging(); |
|||
|
|||
new App() |
|||
.ConfigureRenderSystem(args) |
|||
.LoadFromXaml() |
|||
.RunWithMainWindow<MainWindow>(); |
|||
} |
|||
|
|||
// This will be made into a runtime configuration extension soon!
|
|||
private static void InitializeLogging() |
|||
{ |
|||
#if DEBUG
|
|||
SerilogLogger.Initialize(new LoggerConfiguration() |
|||
.MinimumLevel.Warning() |
|||
.WriteTo.Trace(outputTemplate: "{Area}: {Message}") |
|||
.CreateLogger()); |
|||
#endif
|
|||
} |
|||
|
|||
} |
|||
|
|||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|||
// Experimental: Would like to move this into a shared location once I figure out the best place for it
|
|||
// considering all common libraries are PCL and do not have access to Environment.OSVersion.Platform
|
|||
// nor do they have access to the platform specific render/subsystem extensions.
|
|||
//
|
|||
// Perhaps via DI we register each system with a priority/rank
|
|||
//
|
|||
public static class RenderSystemExtensions |
|||
{ |
|||
[Flags] |
|||
enum RenderSystem |
|||
{ |
|||
None = 0, |
|||
GTK = 1, |
|||
Skia = 2, |
|||
Direct2D = 4 |
|||
}; |
|||
|
|||
/// <summary>
|
|||
/// Default (Optimal) render system for a particular platform
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
private static RenderSystem DefaultRenderSystem() |
|||
{ |
|||
switch (Environment.OSVersion.Platform) |
|||
{ |
|||
case PlatformID.MacOSX: |
|||
return RenderSystem.GTK; |
|||
|
|||
case PlatformID.Unix: |
|||
return RenderSystem.GTK; |
|||
|
|||
case PlatformID.Win32Windows: |
|||
return RenderSystem.Direct2D; |
|||
} |
|||
|
|||
return RenderSystem.None; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Returns an array of avalidable rendering systems in priority order
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
private static RenderSystem[] AvailableRenderSystems() |
|||
{ |
|||
switch (Environment.OSVersion.Platform) |
|||
{ |
|||
case PlatformID.MacOSX: |
|||
return new RenderSystem[] { RenderSystem.GTK, RenderSystem.Skia }; |
|||
|
|||
case PlatformID.Unix: |
|||
return new RenderSystem[] { RenderSystem.GTK, RenderSystem.Skia }; |
|||
|
|||
case PlatformID.Win32Windows: |
|||
return new RenderSystem[] { RenderSystem.Direct2D, RenderSystem.Skia, RenderSystem.GTK }; |
|||
} |
|||
|
|||
return new RenderSystem[0]; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Selects the optimal render system for desktop platforms. Supports cmd line overrides
|
|||
/// </summary>
|
|||
/// <param name="app"></param>
|
|||
/// <param name="args"></param>
|
|||
public static TApp ConfigureRenderSystem<TApp>(this TApp app, string[] args) where TApp : Application |
|||
{ |
|||
// So this all works great under Windows where it can support
|
|||
// ALL configurations. But on OSX/Unix we cannot use Direct2D
|
|||
//
|
|||
if (args.Contains("--gtk") || DefaultRenderSystem() == RenderSystem.GTK) |
|||
{ |
|||
app.UseGtk(); |
|||
app.UseCairo(); |
|||
} |
|||
else |
|||
{ |
|||
app.UseWin32(); |
|||
|
|||
if (args.Contains("--skia") || DefaultRenderSystem() == RenderSystem.Skia) |
|||
{ |
|||
app.UseSkia(); |
|||
} |
|||
else |
|||
{ |
|||
app.UseDirect2D(); |
|||
} |
|||
} |
|||
|
|||
return app; |
|||
} |
|||
} |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8" ?> |
|||
<configuration> |
|||
<startup> |
|||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" /> |
|||
</startup> |
|||
</configuration> |
|||
@ -1,154 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> |
|||
<PropertyGroup> |
|||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|||
<ProjectGuid>{BD7F352C-6DC1-4740-BAF2-2D34A038728C}</ProjectGuid> |
|||
<OutputType>WinExe</OutputType> |
|||
<AppDesignerFolder>Properties</AppDesignerFolder> |
|||
<RootNamespace>GtkInteropDemo</RootNamespace> |
|||
<AssemblyName>GtkInteropDemo</AssemblyName> |
|||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> |
|||
<FileAlignment>512</FileAlignment> |
|||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|||
<PlatformTarget>AnyCPU</PlatformTarget> |
|||
<DebugSymbols>true</DebugSymbols> |
|||
<DebugType>full</DebugType> |
|||
<Optimize>false</Optimize> |
|||
<OutputPath>bin\Debug\</OutputPath> |
|||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
<UseVSHostingProcess>false</UseVSHostingProcess> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|||
<PlatformTarget>AnyCPU</PlatformTarget> |
|||
<DebugType>pdbonly</DebugType> |
|||
<Optimize>true</Optimize> |
|||
<OutputPath>bin\Release\</OutputPath> |
|||
<DefineConstants>TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f, processorArchitecture=MSIL" /> |
|||
<Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f, processorArchitecture=MSIL" /> |
|||
<Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f, processorArchitecture=MSIL" /> |
|||
<Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f, processorArchitecture=MSIL" /> |
|||
<Reference Include="System" /> |
|||
<Reference Include="System.Core" /> |
|||
<Reference Include="System.Xml.Linq" /> |
|||
<Reference Include="System.Data.DataSetExtensions" /> |
|||
<Reference Include="Microsoft.CSharp" /> |
|||
<Reference Include="System.Data" /> |
|||
<Reference Include="System.Deployment" /> |
|||
<Reference Include="System.Drawing" /> |
|||
<Reference Include="System.Net.Http" /> |
|||
<Reference Include="System.Xml" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Compile Include="MainWindow.cs" /> |
|||
<Compile Include="Program.cs" /> |
|||
<Compile Include="Properties\AssemblyInfo.cs" /> |
|||
<EmbeddedResource Include="Properties\Resources.resx"> |
|||
<Generator>ResXFileCodeGenerator</Generator> |
|||
<LastGenOutput>Resources.Designer.cs</LastGenOutput> |
|||
<SubType>Designer</SubType> |
|||
</EmbeddedResource> |
|||
<Compile Include="Properties\Resources.Designer.cs"> |
|||
<AutoGen>True</AutoGen> |
|||
<DependentUpon>Resources.resx</DependentUpon> |
|||
</Compile> |
|||
<None Include="Properties\Settings.settings"> |
|||
<Generator>SettingsSingleFileGenerator</Generator> |
|||
<LastGenOutput>Settings.Designer.cs</LastGenOutput> |
|||
</None> |
|||
<Compile Include="Properties\Settings.Designer.cs"> |
|||
<AutoGen>True</AutoGen> |
|||
<DependentUpon>Settings.settings</DependentUpon> |
|||
<DesignTimeSharedInput>True</DesignTimeSharedInput> |
|||
</Compile> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<None Include="App.config" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Animation\Avalonia.Animation.csproj"> |
|||
<Project>{d211e587-d8bc-45b9-95a4-f297c8fa5200}</Project> |
|||
<Name>Avalonia.Animation</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Base\Avalonia.Base.csproj"> |
|||
<Project>{b09b78d8-9b26-48b0-9149-d64a2f120f3f}</Project> |
|||
<Name>Avalonia.Base</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Controls\Avalonia.Controls.csproj"> |
|||
<Project>{d2221c82-4a25-4583-9b43-d791e3f6820c}</Project> |
|||
<Name>Avalonia.Controls</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj"> |
|||
<Project>{7062ae20-5dcc-4442-9645-8195bdece63e}</Project> |
|||
<Name>Avalonia.Diagnostics</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.DotNetFrameworkRuntime\Avalonia.DotNetFrameworkRuntime.csproj"> |
|||
<Project>{4a1abb09-9047-4bd5-a4ad-a055e52c5ee0}</Project> |
|||
<Name>Avalonia.DotNetFrameworkRuntime</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Input\Avalonia.Input.csproj"> |
|||
<Project>{62024b2d-53eb-4638-b26b-85eeaa54866e}</Project> |
|||
<Name>Avalonia.Input</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Interactivity\Avalonia.Interactivity.csproj"> |
|||
<Project>{6b0ed19d-a08b-461c-a9d9-a9ee40b0c06b}</Project> |
|||
<Name>Avalonia.Interactivity</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Layout\Avalonia.Layout.csproj"> |
|||
<Project>{42472427-4774-4c81-8aff-9f27b8e31721}</Project> |
|||
<Name>Avalonia.Layout</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.ReactiveUI\Avalonia.ReactiveUI.csproj"> |
|||
<Project>{6417b24e-49c2-4985-8db2-3ab9d898ec91}</Project> |
|||
<Name>Avalonia.ReactiveUI</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Visuals\Avalonia.Visuals.csproj"> |
|||
<Project>{eb582467-6abb-43a1-b052-e981ba910e3a}</Project> |
|||
<Name>Avalonia.Visuals</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Styling\Avalonia.Styling.csproj"> |
|||
<Project>{f1baa01a-f176-4c6a-b39d-5b40bb1b148f}</Project> |
|||
<Name>Avalonia.Styling</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Themes.Default\Avalonia.Themes.Default.csproj"> |
|||
<Project>{3e10a5fa-e8da-48b1-ad44-6a5b6cb7750f}</Project> |
|||
<Name>Avalonia.Themes.Default</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Gtk\Avalonia.Cairo\Avalonia.Cairo.csproj"> |
|||
<Project>{fb05ac90-89ba-4f2f-a924-f37875fb547c}</Project> |
|||
<Name>Avalonia.Cairo</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Gtk\Avalonia.Gtk\Avalonia.Gtk.csproj"> |
|||
<Project>{54f237d5-a70a-4752-9656-0c70b1a7b047}</Project> |
|||
<Name>Avalonia.Gtk</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Markup\Avalonia.Markup.Xaml\Avalonia.Markup.Xaml.csproj"> |
|||
<Project>{3e53a01a-b331-47f3-b828-4a5717e77a24}</Project> |
|||
<Name>Avalonia.Markup.Xaml</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Markup\Avalonia.Markup\Avalonia.Markup.csproj"> |
|||
<Project>{6417e941-21bc-467b-a771-0de389353ce6}</Project> |
|||
<Name>Avalonia.Markup</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Skia\Avalonia.Skia\Avalonia.Skia.csproj"> |
|||
<Project>{7d2d3083-71dd-4cc9-8907-39a0d86fb322}</Project> |
|||
<Name>Avalonia.Skia</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\ControlCatalog\ControlCatalog.csproj"> |
|||
<Project>{d0a739b9-3c68-4ba6-a328-41606954b6bd}</Project> |
|||
<Name>ControlCatalog</Name> |
|||
</ProjectReference> |
|||
</ItemGroup> |
|||
<Import Project="..\..\..\build\Rx.props" /> |
|||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
|||
</Project> |
|||
@ -1,30 +0,0 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Avalonia.Diagnostics; |
|||
using Avalonia.Gtk.Embedding; |
|||
using ControlCatalog; |
|||
using Gtk; |
|||
|
|||
namespace GtkInteropDemo |
|||
{ |
|||
class MainWindow : Window |
|||
{ |
|||
public MainWindow() : base("Gtk Embedding Demo") |
|||
{ |
|||
var root = new HBox(); |
|||
var left = new VBox(); |
|||
left.Add(new Button("I'm GTK button")); |
|||
left.Add(new Calendar()); |
|||
root.PackEnd(left, false, false, 0); |
|||
var host = new GtkAvaloniaControlHost() {Content = new MainView()}; |
|||
host.SetSizeRequest(600, 600); |
|||
root.PackStart(host, true, true, 0); |
|||
Add(root); |
|||
|
|||
ShowAll(); |
|||
} |
|||
} |
|||
} |
|||
@ -1,24 +0,0 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Avalonia; |
|||
using Avalonia.Controls; |
|||
using ControlCatalog; |
|||
|
|||
namespace GtkInteropDemo |
|||
{ |
|||
static class Program |
|||
{ |
|||
/// <summary>
|
|||
/// The main entry point for the application.
|
|||
/// </summary>
|
|||
[STAThread] |
|||
static void Main() |
|||
{ |
|||
AppBuilder.Configure<App>().UseGtk().UseCairo().SetupWithoutStarting(); |
|||
new MainWindow().Show(); |
|||
Gtk.Application.Run(); |
|||
} |
|||
} |
|||
} |
|||
@ -1,36 +0,0 @@ |
|||
using System.Reflection; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
// General Information about an assembly is controlled through the following
|
|||
// set of attributes. Change these attribute values to modify the information
|
|||
// associated with an assembly.
|
|||
[assembly: AssemblyTitle("GtkInteropDemo")] |
|||
[assembly: AssemblyDescription("")] |
|||
[assembly: AssemblyConfiguration("")] |
|||
[assembly: AssemblyCompany("")] |
|||
[assembly: AssemblyProduct("GtkInteropDemo")] |
|||
[assembly: AssemblyCopyright("Copyright © 2016")] |
|||
[assembly: AssemblyTrademark("")] |
|||
[assembly: AssemblyCulture("")] |
|||
|
|||
// Setting ComVisible to false makes the types in this assembly not visible
|
|||
// to COM components. If you need to access a type in this assembly from
|
|||
// COM, set the ComVisible attribute to true on that type.
|
|||
[assembly: ComVisible(false)] |
|||
|
|||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
|||
[assembly: Guid("bd7f352c-6dc1-4740-baf2-2d34a038728c")] |
|||
|
|||
// Version information for an assembly consists of the following four values:
|
|||
//
|
|||
// Major Version
|
|||
// Minor Version
|
|||
// Build Number
|
|||
// Revision
|
|||
//
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
|||
// by using the '*' as shown below:
|
|||
// [assembly: AssemblyVersion("1.0.*")]
|
|||
[assembly: AssemblyVersion("1.0.0.0")] |
|||
[assembly: AssemblyFileVersion("1.0.0.0")] |
|||
@ -1,71 +0,0 @@ |
|||
//------------------------------------------------------------------------------
|
|||
// <auto-generated>
|
|||
// This code was generated by a tool.
|
|||
// Runtime Version:4.0.30319.42000
|
|||
//
|
|||
// Changes to this file may cause incorrect behavior and will be lost if
|
|||
// the code is regenerated.
|
|||
// </auto-generated>
|
|||
//------------------------------------------------------------------------------
|
|||
|
|||
namespace GtkInteropDemo.Properties |
|||
{ |
|||
|
|||
|
|||
/// <summary>
|
|||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
|||
/// </summary>
|
|||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
|||
// class via a tool like ResGen or Visual Studio.
|
|||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
|||
// with the /str option, or rebuild your VS project.
|
|||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] |
|||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
|||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] |
|||
internal class Resources |
|||
{ |
|||
|
|||
private static global::System.Resources.ResourceManager resourceMan; |
|||
|
|||
private static global::System.Globalization.CultureInfo resourceCulture; |
|||
|
|||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] |
|||
internal Resources() |
|||
{ |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Returns the cached ResourceManager instance used by this class.
|
|||
/// </summary>
|
|||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] |
|||
internal static global::System.Resources.ResourceManager ResourceManager |
|||
{ |
|||
get |
|||
{ |
|||
if ((resourceMan == null)) |
|||
{ |
|||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("GtkInteropDemo.Properties.Resources", typeof(Resources).Assembly); |
|||
resourceMan = temp; |
|||
} |
|||
return resourceMan; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Overrides the current thread's CurrentUICulture property for all
|
|||
/// resource lookups using this strongly typed resource class.
|
|||
/// </summary>
|
|||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] |
|||
internal static global::System.Globalization.CultureInfo Culture |
|||
{ |
|||
get |
|||
{ |
|||
return resourceCulture; |
|||
} |
|||
set |
|||
{ |
|||
resourceCulture = value; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,117 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<root> |
|||
<!-- |
|||
Microsoft ResX Schema |
|||
|
|||
Version 2.0 |
|||
|
|||
The primary goals of this format is to allow a simple XML format |
|||
that is mostly human readable. The generation and parsing of the |
|||
various data types are done through the TypeConverter classes |
|||
associated with the data types. |
|||
|
|||
Example: |
|||
|
|||
... ado.net/XML headers & schema ... |
|||
<resheader name="resmimetype">text/microsoft-resx</resheader> |
|||
<resheader name="version">2.0</resheader> |
|||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> |
|||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> |
|||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> |
|||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> |
|||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> |
|||
<value>[base64 mime encoded serialized .NET Framework object]</value> |
|||
</data> |
|||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
|||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> |
|||
<comment>This is a comment</comment> |
|||
</data> |
|||
|
|||
There are any number of "resheader" rows that contain simple |
|||
name/value pairs. |
|||
|
|||
Each data row contains a name, and value. The row also contains a |
|||
type or mimetype. Type corresponds to a .NET class that support |
|||
text/value conversion through the TypeConverter architecture. |
|||
Classes that don't support this are serialized and stored with the |
|||
mimetype set. |
|||
|
|||
The mimetype is used for serialized objects, and tells the |
|||
ResXResourceReader how to depersist the object. This is currently not |
|||
extensible. For a given mimetype the value must be set accordingly: |
|||
|
|||
Note - application/x-microsoft.net.object.binary.base64 is the format |
|||
that the ResXResourceWriter will generate, however the reader can |
|||
read any of the formats listed below. |
|||
|
|||
mimetype: application/x-microsoft.net.object.binary.base64 |
|||
value : The object must be serialized with |
|||
: System.Serialization.Formatters.Binary.BinaryFormatter |
|||
: and then encoded with base64 encoding. |
|||
|
|||
mimetype: application/x-microsoft.net.object.soap.base64 |
|||
value : The object must be serialized with |
|||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
|||
: and then encoded with base64 encoding. |
|||
|
|||
mimetype: application/x-microsoft.net.object.bytearray.base64 |
|||
value : The object must be serialized into a byte array |
|||
: using a System.ComponentModel.TypeConverter |
|||
: and then encoded with base64 encoding. |
|||
--> |
|||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> |
|||
<xsd:element name="root" msdata:IsDataSet="true"> |
|||
<xsd:complexType> |
|||
<xsd:choice maxOccurs="unbounded"> |
|||
<xsd:element name="metadata"> |
|||
<xsd:complexType> |
|||
<xsd:sequence> |
|||
<xsd:element name="value" type="xsd:string" minOccurs="0" /> |
|||
</xsd:sequence> |
|||
<xsd:attribute name="name" type="xsd:string" /> |
|||
<xsd:attribute name="type" type="xsd:string" /> |
|||
<xsd:attribute name="mimetype" type="xsd:string" /> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
<xsd:element name="assembly"> |
|||
<xsd:complexType> |
|||
<xsd:attribute name="alias" type="xsd:string" /> |
|||
<xsd:attribute name="name" type="xsd:string" /> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
<xsd:element name="data"> |
|||
<xsd:complexType> |
|||
<xsd:sequence> |
|||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
|||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> |
|||
</xsd:sequence> |
|||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> |
|||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> |
|||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
<xsd:element name="resheader"> |
|||
<xsd:complexType> |
|||
<xsd:sequence> |
|||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
|||
</xsd:sequence> |
|||
<xsd:attribute name="name" type="xsd:string" use="required" /> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
</xsd:choice> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
</xsd:schema> |
|||
<resheader name="resmimetype"> |
|||
<value>text/microsoft-resx</value> |
|||
</resheader> |
|||
<resheader name="version"> |
|||
<value>2.0</value> |
|||
</resheader> |
|||
<resheader name="reader"> |
|||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
|||
</resheader> |
|||
<resheader name="writer"> |
|||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
|||
</resheader> |
|||
</root> |
|||
@ -1,30 +0,0 @@ |
|||
//------------------------------------------------------------------------------
|
|||
// <auto-generated>
|
|||
// This code was generated by a tool.
|
|||
// Runtime Version:4.0.30319.42000
|
|||
//
|
|||
// Changes to this file may cause incorrect behavior and will be lost if
|
|||
// the code is regenerated.
|
|||
// </auto-generated>
|
|||
//------------------------------------------------------------------------------
|
|||
|
|||
namespace GtkInteropDemo.Properties |
|||
{ |
|||
|
|||
|
|||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] |
|||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] |
|||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase |
|||
{ |
|||
|
|||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); |
|||
|
|||
public static Settings Default |
|||
{ |
|||
get |
|||
{ |
|||
return defaultInstance; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,7 +0,0 @@ |
|||
<?xml version='1.0' encoding='utf-8'?> |
|||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)"> |
|||
<Profiles> |
|||
<Profile Name="(Default)" /> |
|||
</Profiles> |
|||
<Settings /> |
|||
</SettingsFile> |
|||
@ -1,60 +0,0 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Avalonia.Platform; |
|||
|
|||
namespace Avalonia.Threading |
|||
{ |
|||
public class SingleThreadDispatcher : Dispatcher |
|||
{ |
|||
class ThreadingInterface : IPlatformThreadingInterface |
|||
{ |
|||
private readonly AutoResetEvent _evnt = new AutoResetEvent(false); |
|||
private readonly JobRunner _timerJobRunner; |
|||
|
|||
public ThreadingInterface() |
|||
{ |
|||
_timerJobRunner = new JobRunner(this); |
|||
} |
|||
|
|||
public void RunLoop(CancellationToken cancellationToken) |
|||
{ |
|||
while (!cancellationToken.IsCancellationRequested) |
|||
{ |
|||
_evnt.WaitOne(); |
|||
if (cancellationToken.IsCancellationRequested) |
|||
return; |
|||
Signaled?.Invoke(); |
|||
_timerJobRunner.RunJobs(); |
|||
} |
|||
} |
|||
|
|||
public IDisposable StartTimer(TimeSpan interval, Action tick) |
|||
=> AvaloniaLocator.Current.GetService<IRuntimePlatform>().StartSystemTimer(interval, |
|||
() => _timerJobRunner.Post(tick, DispatcherPriority.Normal)); |
|||
|
|||
public void Signal() => _evnt.Set(); |
|||
//TODO: Actually perform a check
|
|||
public bool CurrentThreadIsLoopThread => true; |
|||
|
|||
public event Action Signaled; |
|||
} |
|||
|
|||
public SingleThreadDispatcher() : base(new ThreadingInterface()) |
|||
{ |
|||
} |
|||
|
|||
public static Dispatcher StartNew(CancellationToken token) |
|||
{ |
|||
var dispatcher = new SingleThreadDispatcher(); |
|||
AvaloniaLocator.Current.GetService<IRuntimePlatform>().PostThreadPoolItem(() => |
|||
{ |
|||
dispatcher.MainLoop(token); |
|||
}); |
|||
return dispatcher; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
namespace Avalonia.Controls |
|||
{ |
|||
/// <summary>
|
|||
/// Defines vertical or horizontal orientation.
|
|||
/// </summary>
|
|||
public enum Orientation |
|||
{ |
|||
/// <summary>
|
|||
/// Horizontal orientation.
|
|||
/// </summary>
|
|||
Horizontal, |
|||
|
|||
/// <summary>
|
|||
/// Vertical orientation.
|
|||
/// </summary>
|
|||
Vertical, |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
namespace Avalonia.Platform |
|||
{ |
|||
public interface IScreenImpl |
|||
{ |
|||
int ScreenCount { get; } |
|||
|
|||
Screen[] AllScreens { get; } |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
namespace Avalonia.Platform |
|||
{ |
|||
public class Screen |
|||
{ |
|||
public Rect Bounds { get; } |
|||
|
|||
public Rect WorkingArea { get; } |
|||
|
|||
public bool Primary { get; } |
|||
|
|||
public Screen(Rect bounds, Rect workingArea, bool primary) |
|||
{ |
|||
this.Bounds = bounds; |
|||
this.WorkingArea = workingArea; |
|||
this.Primary = primary; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,82 @@ |
|||
using System; |
|||
using Avalonia.Input; |
|||
using Avalonia.Threading; |
|||
|
|||
namespace Avalonia.Controls |
|||
{ |
|||
public class RepeatButton : Button |
|||
{ |
|||
/// <summary>
|
|||
/// Defines the <see cref="Delay"/> property.
|
|||
/// </summary>
|
|||
public static readonly StyledProperty<int> DelayProperty = |
|||
AvaloniaProperty.Register<Button, int>(nameof(Delay), 100); |
|||
|
|||
private DispatcherTimer _repeatTimer; |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the amount of time, in milliseconds, of repeating clicks.
|
|||
/// </summary>
|
|||
public int Delay |
|||
{ |
|||
get { return GetValue(DelayProperty); } |
|||
set { SetValue(DelayProperty, value); } |
|||
} |
|||
|
|||
private void StartTimer() |
|||
{ |
|||
if (_repeatTimer == null) |
|||
{ |
|||
_repeatTimer = new DispatcherTimer(); |
|||
_repeatTimer.Tick += (o, e) => OnClick(); |
|||
} |
|||
|
|||
if (_repeatTimer.IsEnabled) return; |
|||
|
|||
_repeatTimer.Interval = TimeSpan.FromMilliseconds(Delay); |
|||
_repeatTimer.Start(); |
|||
} |
|||
|
|||
private void StopTimer() |
|||
{ |
|||
_repeatTimer?.Stop(); |
|||
} |
|||
|
|||
protected override void OnKeyDown(KeyEventArgs e) |
|||
{ |
|||
base.OnKeyDown(e); |
|||
|
|||
if (e.Key == Key.Space) |
|||
{ |
|||
StartTimer(); |
|||
} |
|||
} |
|||
|
|||
protected override void OnKeyUp(KeyEventArgs e) |
|||
{ |
|||
base.OnKeyUp(e); |
|||
|
|||
StopTimer(); |
|||
} |
|||
|
|||
protected override void OnPointerPressed(PointerPressedEventArgs e) |
|||
{ |
|||
base.OnPointerPressed(e); |
|||
|
|||
if (e.MouseButton == MouseButton.Left) |
|||
{ |
|||
StartTimer(); |
|||
} |
|||
} |
|||
|
|||
protected override void OnPointerReleased(PointerReleasedEventArgs e) |
|||
{ |
|||
base.OnPointerReleased(e); |
|||
|
|||
if (e.MouseButton == MouseButton.Left) |
|||
{ |
|||
StopTimer(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,54 @@ |
|||
using System.Linq; |
|||
using Avalonia.Platform; |
|||
using Avalonia.Utilities; |
|||
using Avalonia.VisualTree; |
|||
|
|||
namespace Avalonia.Controls |
|||
{ |
|||
public class Screens |
|||
{ |
|||
private readonly IScreenImpl _iScreenImpl; |
|||
|
|||
public int ScreenCount => _iScreenImpl.ScreenCount; |
|||
public Screen[] All => _iScreenImpl?.AllScreens; |
|||
public Screen Primary => All.FirstOrDefault(x => x.Primary); |
|||
|
|||
public Screens(IScreenImpl iScreenImpl) |
|||
{ |
|||
_iScreenImpl = iScreenImpl; |
|||
} |
|||
|
|||
public Screen ScreenFromBounds(Rect bounds){ |
|||
|
|||
Screen currMaxScreen = null; |
|||
double maxAreaSize = 0; |
|||
foreach (Screen screen in All) |
|||
{ |
|||
double left = MathUtilities.Clamp(bounds.X, screen.Bounds.X, screen.Bounds.X + screen.Bounds.Width); |
|||
double top = MathUtilities.Clamp(bounds.Y, screen.Bounds.Y, screen.Bounds.Y + screen.Bounds.Height); |
|||
double right = MathUtilities.Clamp(bounds.X + bounds.Width, screen.Bounds.X, screen.Bounds.X + screen.Bounds.Width); |
|||
double bottom = MathUtilities.Clamp(bounds.Y + bounds.Height, screen.Bounds.Y, screen.Bounds.Y + screen.Bounds.Height); |
|||
double area = (right - left) * (bottom - top); |
|||
if (area > maxAreaSize) |
|||
{ |
|||
maxAreaSize = area; |
|||
currMaxScreen = screen; |
|||
} |
|||
} |
|||
|
|||
return currMaxScreen; |
|||
} |
|||
|
|||
public Screen SceenFromPoint(Point point) |
|||
{ |
|||
return All.FirstOrDefault(x=>x.Bounds.Contains(point)); |
|||
} |
|||
|
|||
public Screen ScreenFromVisual(IVisual visual) |
|||
{ |
|||
Point tl = visual.PointToScreen(visual.Bounds.TopLeft); |
|||
Point br = visual.PointToScreen(visual.Bounds.BottomRight); |
|||
return ScreenFromBounds(new Rect(tl,br)); |
|||
} |
|||
} |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue