From 445dc210816981a1367e6d3ef086d64bb8e386fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Tue, 16 Aug 2016 16:12:52 +0200 Subject: [PATCH 01/46] Removed no longer necessary nuget folder --- nuget/.gitignore | 2 - nuget/build-appveyor.ps1 | 35 --------- nuget/build-version.ps1 | 84 --------------------- nuget/build.ps1 | 1 - nuget/include.ps1 | 1 - nuget/template/Avalonia.Android.nuspec | 28 ------- nuget/template/Avalonia.Desktop.nuspec | 30 -------- nuget/template/Avalonia.Skia.Desktop.nuspec | 20 ----- nuget/template/Avalonia.iOS.nuspec | 27 ------- nuget/template/Avalonia.nuspec | 26 ------- 10 files changed, 254 deletions(-) delete mode 100644 nuget/.gitignore delete mode 100644 nuget/build-appveyor.ps1 delete mode 100644 nuget/build-version.ps1 delete mode 100644 nuget/build.ps1 delete mode 100644 nuget/include.ps1 delete mode 100644 nuget/template/Avalonia.Android.nuspec delete mode 100644 nuget/template/Avalonia.Desktop.nuspec delete mode 100644 nuget/template/Avalonia.Skia.Desktop.nuspec delete mode 100644 nuget/template/Avalonia.iOS.nuspec delete mode 100644 nuget/template/Avalonia.nuspec diff --git a/nuget/.gitignore b/nuget/.gitignore deleted file mode 100644 index 32f9557fad..0000000000 --- a/nuget/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -Avalonia -*.nupkg \ No newline at end of file diff --git a/nuget/build-appveyor.ps1 b/nuget/build-appveyor.ps1 deleted file mode 100644 index 1441a6a79a..0000000000 --- a/nuget/build-appveyor.ps1 +++ /dev/null @@ -1,35 +0,0 @@ -$ErrorActionPreference = "Stop" -$scriptpath = $MyInvocation.MyCommand.Path -$dir = Split-Path $scriptpath -Push-Location $dir - - -sv version $env:APPVEYOR_BUILD_NUMBER -#sv version "1-debug" - -sv version 0.4.1-build$version-alpha -sv key $env:myget_key - -. ".\include.ps1" -.\build-version.ps1 $version - -sv reponame $env:APPVEYOR_REPO_NAME -sv repobranch $env:APPVEYOR_REPO_BRANCH -sv pullreq $env:APPVEYOR_PULL_REQUEST_NUMBER - -echo "Checking for publishing" -echo "$reponame $repobranch $pullreq" -if ([string]::IsNullOrWhiteSpace($pullreq)) -{ - echo "Build is not a PR" - if($repobranch -eq "master") - { - echo "Repo branch matched" - foreach($pkg in $Packages) - { - nuget.exe push "$($pkg).$($version).nupkg" $key -Source https://www.myget.org/F/avalonia-ci/api/v2/package - } - } -} - - diff --git a/nuget/build-version.ps1 b/nuget/build-version.ps1 deleted file mode 100644 index c59789ddb8..0000000000 --- a/nuget/build-version.ps1 +++ /dev/null @@ -1,84 +0,0 @@ -$ErrorActionPreference = "Stop" - -. ".\include.ps1" - -foreach($pkg in $Packages) -{ - rm -Force -Recurse .\$pkg -ErrorAction SilentlyContinue -} - -rm -Force -Recurse *.nupkg -ErrorAction SilentlyContinue -Copy-Item template Avalonia -Recurse -sv lib "Avalonia\lib\portable-windows8+net45" -sv build "Avalonia.Desktop\lib\net45" - -sv skia_root "Avalonia.Skia.Desktop" -sv skia_lib "Avalonia.Skia.Desktop\lib\net45" -sv android "Avalonia.Android\lib\MonoAndroid10" -sv ios "Avalonia.iOS\lib\Xamarin.iOS10" - -mkdir $lib -ErrorAction SilentlyContinue -mkdir $build -ErrorAction SilentlyContinue -mkdir $skia_lib -mkdir $android -mkdir $ios - - -Copy-Item ..\src\Avalonia.Animation\bin\Release\Avalonia.Animation.dll $lib -Copy-Item ..\src\Avalonia.Animation\bin\Release\Avalonia.Animation.xml $lib -Copy-Item ..\src\Avalonia.Base\bin\Release\Avalonia.Base.dll $lib -Copy-Item ..\src\Avalonia.Base\bin\Release\Avalonia.Base.xml $lib -Copy-Item ..\src\Avalonia.Controls\bin\Release\Avalonia.Controls.dll $lib -Copy-Item ..\src\Avalonia.Controls\bin\Release\Avalonia.Controls.xml $lib -Copy-Item ..\src\Avalonia.DesignerSupport\bin\Release\Avalonia.DesignerSupport.dll $lib -Copy-Item ..\src\Avalonia.DesignerSupport\bin\Release\Avalonia.DesignerSupport.xml $lib -Copy-Item ..\src\Avalonia.Diagnostics\bin\Release\\Avalonia.Diagnostics.dll $lib -Copy-Item ..\src\Avalonia.Diagnostics\bin\Release\\Avalonia.Diagnostics.xml $lib -Copy-Item ..\src\Avalonia.Input\bin\Release\Avalonia.Input.dll $lib -Copy-Item ..\src\Avalonia.Input\bin\Release\Avalonia.Input.xml $lib -Copy-Item ..\src\Avalonia.Interactivity\bin\Release\Avalonia.Interactivity.dll $lib -Copy-Item ..\src\Avalonia.Interactivity\bin\Release\Avalonia.Interactivity.xml $lib -Copy-Item ..\src\Avalonia.Layout\bin\Release\Avalonia.Layout.dll $lib -Copy-Item ..\src\Avalonia.Layout\bin\Release\Avalonia.Layout.xml $lib -Copy-Item ..\src\Avalonia.Logging.Serilog\bin\Release\Avalonia.Logging.Serilog.dll $lib -Copy-Item ..\src\Avalonia.Logging.Serilog\bin\Release\Avalonia.Logging.Serilog.xml $lib -Copy-Item ..\src\Avalonia.SceneGraph\bin\Release\Avalonia.SceneGraph.dll $lib -Copy-Item ..\src\Avalonia.SceneGraph\bin\Release\Avalonia.SceneGraph.xml $lib -Copy-Item ..\src\Avalonia.Styling\bin\Release\Avalonia.Styling.dll $lib -Copy-Item ..\src\Avalonia.Styling\bin\Release\Avalonia.Styling.xml $lib -Copy-Item ..\src\Avalonia.Themes.Default\bin\Release\Avalonia.Themes.Default.dll $lib -Copy-Item ..\src\Avalonia.Themes.Default\bin\Release\Avalonia.Themes.Default.xml $lib -Copy-Item ..\src\Markup\Avalonia.Markup\bin\Release\Avalonia.Markup.dll $lib -Copy-Item ..\src\Markup\Avalonia.Markup\bin\Release\Avalonia.Markup.xml $lib -Copy-Item ..\src\Markup\Avalonia.Markup.Xaml\bin\Release\Avalonia.Markup.Xaml.dll $lib -Copy-Item ..\src\Markup\Avalonia.Markup.Xaml\bin\Release\Avalonia.Markup.Xaml.xml $lib -Copy-Item ..\src\Avalonia.HtmlRenderer\bin\Release\Avalonia.HtmlRenderer.dll $lib -Copy-Item ..\src\Avalonia.ReactiveUI\bin\Release\Avalonia.ReactiveUI.dll $lib - -Copy-Item ..\src\Windows\Avalonia.Direct2D1\bin\Release\Avalonia.Direct2D1.dll $build -Copy-Item ..\src\Windows\Avalonia.Win32\bin\Release\Avalonia.Win32.dll $build -Copy-Item ..\src\Gtk\Avalonia.Gtk\bin\Release\Avalonia.Gtk.dll $build -Copy-Item ..\src\Gtk\Avalonia.Cairo\bin\Release\Avalonia.Cairo.dll $build - -Copy-Item ..\src\Skia\Avalonia.Skia.Desktop\bin\x86\Release\Avalonia.Skia.Desktop.dll $skia_lib - -Copy-Item ..\src\Android\Avalonia.Android\bin\Release\Avalonia.Android.dll $android -Copy-Item ..\src\Skia\Avalonia.Skia.Android\bin\Release\Avalonia.Skia.Android.dll $android - -Copy-Item ..\src\iOS\Avalonia.iOS\bin\iPhone\Release\Avalonia.iOS.dll $ios -Copy-Item ..\src\Skia\Avalonia.Skia.iOS\bin\iPhone\Release\Avalonia.Skia.iOS.dll $ios - -foreach($pkg in $Packages) -{ - (gc Avalonia\$pkg.nuspec).replace('#VERSION#', $args[0]) | sc $pkg\$pkg.nuspec -} - -foreach($pkg in $Packages) -{ - nuget.exe pack $pkg\$pkg.nuspec -} - -foreach($pkg in $Packages) -{ - rm -Force -Recurse .\$pkg -} \ No newline at end of file diff --git a/nuget/build.ps1 b/nuget/build.ps1 deleted file mode 100644 index 43c3748bdf..0000000000 --- a/nuget/build.ps1 +++ /dev/null @@ -1 +0,0 @@ -.\build-version.ps1 0.4.1 \ No newline at end of file diff --git a/nuget/include.ps1 b/nuget/include.ps1 deleted file mode 100644 index bde8ebb731..0000000000 --- a/nuget/include.ps1 +++ /dev/null @@ -1 +0,0 @@ -$Packages = @("Avalonia", "Avalonia.Desktop", "Avalonia.Skia.Desktop", "Avalonia.Android", "Avalonia.iOS") \ No newline at end of file diff --git a/nuget/template/Avalonia.Android.nuspec b/nuget/template/Avalonia.Android.nuspec deleted file mode 100644 index cdba3b5b0e..0000000000 --- a/nuget/template/Avalonia.Android.nuspec +++ /dev/null @@ -1,28 +0,0 @@ - - - - Avalonia.Android - #VERSION# - Avalonia Team - stevenk - http://opensource.org/licenses/MIT - https://github.com/AvaloniaUI/Avalonia/ - false - The Avalonia UI framework - - Copyright 2015 - Avalonia - - - - - - - - - - - - - - \ No newline at end of file diff --git a/nuget/template/Avalonia.Desktop.nuspec b/nuget/template/Avalonia.Desktop.nuspec deleted file mode 100644 index 70bebd3349..0000000000 --- a/nuget/template/Avalonia.Desktop.nuspec +++ /dev/null @@ -1,30 +0,0 @@ - - - - Avalonia.Desktop - #VERSION# - Avalonia Team - stevenk - http://opensource.org/licenses/MIT - https://github.com/AvaloniaUI/Avalonia/ - false - The Avalonia UI framework - - Copyright 2015 - Avalonia - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/nuget/template/Avalonia.Skia.Desktop.nuspec b/nuget/template/Avalonia.Skia.Desktop.nuspec deleted file mode 100644 index 928b6d3e24..0000000000 --- a/nuget/template/Avalonia.Skia.Desktop.nuspec +++ /dev/null @@ -1,20 +0,0 @@ - - - - Avalonia.Skia.Desktop - #VERSION# - Avalonia Team - stevenk - http://opensource.org/licenses/MIT - https://github.com/AvaloniaUI/Avalonia/ - false - The Avalonia UI framework - - Copyright 2015 - Avalonia - - - - - - \ No newline at end of file diff --git a/nuget/template/Avalonia.iOS.nuspec b/nuget/template/Avalonia.iOS.nuspec deleted file mode 100644 index d6b8e3fbe6..0000000000 --- a/nuget/template/Avalonia.iOS.nuspec +++ /dev/null @@ -1,27 +0,0 @@ - - - - Avalonia.iOS - #VERSION# - Avalonia Team - stevenk - http://opensource.org/licenses/MIT - https://github.com/AvaloniaUI/Avalonia/ - false - The Avalonia UI framework - - Copyright 2015 - Avalonia - - - - - - - - - - - - - \ No newline at end of file diff --git a/nuget/template/Avalonia.nuspec b/nuget/template/Avalonia.nuspec deleted file mode 100644 index 55918715a1..0000000000 --- a/nuget/template/Avalonia.nuspec +++ /dev/null @@ -1,26 +0,0 @@ - - - - Avalonia - #VERSION# - Avalonia Team - stevenk - http://opensource.org/licenses/MIT - https://github.com/AvaloniaUI/Avalonia/ - false - The Avalonia UI framework - Initial alpha release. - Copyright 2015 - Avalonia - - - - - - - - - - - - \ No newline at end of file From 7cca79b4352d82e4e2ed407e2d7218c6d9d31978 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Tue, 16 Aug 2016 16:13:31 +0200 Subject: [PATCH 02/46] Updated projects and packages --- samples/BindingTest/BindingTest.csproj | 8 ++-- samples/BindingTest/packages.config | 5 ++- samples/ControlCatalog.Desktop/App.config | 8 ++-- .../ControlCatalog.Desktop.csproj | 10 ++--- .../ControlCatalog.Desktop/packages.config | 3 +- .../ControlCatalog.iOS.csproj | 10 +++++ samples/ControlCatalog.iOS/packages.config | 17 ++++++++ samples/ControlCatalog/ControlCatalog.csproj | 9 ++++ samples/ControlCatalog/packages.config | 13 +++++- .../TestApplication/TestApplication.csproj | 8 +--- samples/TestApplication/packages.config | 2 +- samples/VirtualizationTest/App.config | 8 ++-- .../VirtualizationTest.csproj | 8 ++-- samples/VirtualizationTest/packages.config | 9 ++-- .../XamlTestApplication.csproj | 12 +++--- samples/XamlTestApplication/packages.config | 5 ++- .../Avalonia.AndroidTestApplication.csproj | 9 ++-- .../packages.config | 8 +++- src/Avalonia.Base/Avalonia.Base.csproj | 4 +- src/Avalonia.Base/packages.config | 2 +- .../Avalonia.Controls.csproj | 4 +- src/Avalonia.Controls/packages.config | 2 +- .../Avalonia.Logging.Serilog.csproj | 18 ++++---- src/Avalonia.Logging.Serilog/packages.config | 13 +++++- src/Avalonia.Styling/Avalonia.Styling.csproj | 1 - .../Avalonia.Markup.Xaml.csproj | 4 +- .../Avalonia.Markup.Xaml/packages.config | 2 +- .../Avalonia.Skia.Android.TestApp.csproj | 4 ++ .../Resources/Resource.Designer.cs | 2 + .../Avalonia.Skia.iOS.TestApp.csproj | 8 +++- .../Avalonia.Designer.csproj | 6 +-- src/Windows/Avalonia.Designer/packages.config | 2 +- .../Avalonia.Base.UnitTests.csproj | 8 +++- tests/Avalonia.Base.UnitTests/packages.config | 3 +- tests/Avalonia.Benchmarks/App.config | 2 +- .../Avalonia.Benchmarks.csproj | 43 +++++++++++++++---- tests/Avalonia.Benchmarks/packages.config | 23 ++++++++-- .../Avalonia.Controls.UnitTests.csproj | 16 ++++--- tests/Avalonia.Controls.UnitTests/app.config | 2 +- .../packages.config | 7 +-- .../App.config | 6 +-- .../Avalonia.DesignerSupport.TestApp.csproj | 4 +- .../Properties/Resources.Designer.cs | 42 ++++++++---------- .../Properties/Settings.Designer.cs | 22 ++++------ .../Avalonia.DesignerSupport.Tests.csproj | 3 +- .../Avalonia.Input.UnitTests.csproj | 8 +++- .../Avalonia.Input.UnitTests/packages.config | 3 +- .../Avalonia.Layout.UnitTests.csproj | 16 ++++--- tests/Avalonia.Layout.UnitTests/app.config | 4 +- .../Avalonia.Layout.UnitTests/packages.config | 7 +-- .../Avalonia.LeakTests.csproj | 18 +++++--- tests/Avalonia.LeakTests/app.config | 4 +- tests/Avalonia.LeakTests/packages.config | 9 ++-- .../Avalonia.Markup.UnitTests.csproj | 19 +++++--- tests/Avalonia.Markup.UnitTests/app.config | 8 ++-- .../Avalonia.Markup.UnitTests/packages.config | 27 ++++++------ .../Avalonia.Markup.Xaml.UnitTests.csproj | 14 +++--- .../Avalonia.Markup.Xaml.UnitTests/app.config | 8 ++-- .../packages.config | 5 ++- .../Avalonia.Cairo.RenderTests.csproj | 2 +- .../Avalonia.Direct2D1.RenderTests.csproj | 2 +- .../Avalonia.Skia.RenderTests.csproj | 2 +- .../Controls/ImageTests.cs | 12 ++++++ .../Media/ImageBrushTests.cs | 8 +++- ...packages.Avalonia.Cairo.RenderTests.config | 2 +- ...ages.Avalonia.Direct2D1.RenderTests.config | 2 +- .../packages.Avalonia.Skia.RenderTests.config | 2 +- .../Avalonia.SceneGraph.UnitTests.csproj | 8 +++- .../packages.config | 3 +- .../Avalonia.Styling.UnitTests.csproj | 8 +++- .../packages.config | 3 +- .../Avalonia.UnitTests.csproj | 8 +++- tests/Avalonia.UnitTests/packages.config | 3 +- 73 files changed, 396 insertions(+), 224 deletions(-) create mode 100644 samples/ControlCatalog.iOS/packages.config diff --git a/samples/BindingTest/BindingTest.csproj b/samples/BindingTest/BindingTest.csproj index 3ed2671d0a..5940f358ed 100644 --- a/samples/BindingTest/BindingTest.csproj +++ b/samples/BindingTest/BindingTest.csproj @@ -37,12 +37,12 @@ - - ..\..\packages\Serilog.1.5.14\lib\net45\Serilog.dll + + ..\..\packages\Serilog.2.1.0\lib\net45\Serilog.dll True - - ..\..\packages\Serilog.1.5.14\lib\net45\Serilog.FullNetFx.dll + + ..\..\packages\Serilog.Sinks.Trace.2.0.0\lib\net45\Serilog.Sinks.Trace.dll True diff --git a/samples/BindingTest/packages.config b/samples/BindingTest/packages.config index 3c5f85de81..96d41d13ba 100644 --- a/samples/BindingTest/packages.config +++ b/samples/BindingTest/packages.config @@ -1,7 +1,8 @@  - - + + + \ No newline at end of file diff --git a/samples/ControlCatalog.Desktop/App.config b/samples/ControlCatalog.Desktop/App.config index 7ef9d715f8..2231c71e63 100644 --- a/samples/ControlCatalog.Desktop/App.config +++ b/samples/ControlCatalog.Desktop/App.config @@ -1,13 +1,13 @@ - + - + - - + + diff --git a/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj b/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj index f42902b534..e363bea129 100644 --- a/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj +++ b/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj @@ -34,12 +34,12 @@ 4 - - ..\..\packages\Serilog.1.5.14\lib\net45\Serilog.dll + + ..\..\packages\Serilog.2.1.0\lib\net45\Serilog.dll True - - ..\..\packages\Serilog.1.5.14\lib\net45\Serilog.FullNetFx.dll + + ..\..\packages\Serilog.Sinks.Trace.2.0.0\lib\net45\Serilog.Sinks.Trace.dll True @@ -54,10 +54,10 @@ - + diff --git a/samples/ControlCatalog.Desktop/packages.config b/samples/ControlCatalog.Desktop/packages.config index b3abe6f487..9f7215928e 100644 --- a/samples/ControlCatalog.Desktop/packages.config +++ b/samples/ControlCatalog.Desktop/packages.config @@ -1,4 +1,5 @@  - + + \ No newline at end of file diff --git a/samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj b/samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj index 0e85a4e865..73d430e2b6 100644 --- a/samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj +++ b/samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj @@ -90,8 +90,18 @@ + + + + ..\..\packages\Serilog.2.0.0\lib\netstandard1.3\Serilog.dll + True + + + ..\..\packages\Serilog.Sinks.Trace.2.0.0\lib\netstandard1.3\Serilog.Sinks.Trace.dll + True + diff --git a/samples/ControlCatalog.iOS/packages.config b/samples/ControlCatalog.iOS/packages.config new file mode 100644 index 0000000000..7c0b68fc9a --- /dev/null +++ b/samples/ControlCatalog.iOS/packages.config @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/ControlCatalog/ControlCatalog.csproj b/samples/ControlCatalog/ControlCatalog.csproj index daa8b0901a..c8da292ad5 100644 --- a/samples/ControlCatalog/ControlCatalog.csproj +++ b/samples/ControlCatalog/ControlCatalog.csproj @@ -215,6 +215,15 @@ Designer + + + + + + ..\..\packages\Serilog.2.1.0\lib\netstandard1.0\Serilog.dll + True + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/samples/interop/WindowsInteropTest/EmbedToWpfDemo.xaml b/samples/interop/WindowsInteropTest/EmbedToWpfDemo.xaml new file mode 100644 index 0000000000..1115cf5768 --- /dev/null +++ b/samples/interop/WindowsInteropTest/EmbedToWpfDemo.xaml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + diff --git a/samples/interop/WindowsInteropTest/EmbedToWpfDemo.xaml.cs b/samples/interop/WindowsInteropTest/EmbedToWpfDemo.xaml.cs new file mode 100644 index 0000000000..75d6f4f5d2 --- /dev/null +++ b/samples/interop/WindowsInteropTest/EmbedToWpfDemo.xaml.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Avalonia.Controls; +using ControlCatalog; +using Window = System.Windows.Window; + +namespace WindowsInteropTest +{ + /// + /// Interaction logic for EmbedToWpfDemo.xaml + /// + public partial class EmbedToWpfDemo : Window + { + public EmbedToWpfDemo() + { + InitializeComponent(); + Host.Child = new EmbeddableControl {Content = new ControlCatalogControl()}; + } + } +} diff --git a/samples/interop/WindowsInteropTest/Program.cs b/samples/interop/WindowsInteropTest/Program.cs new file mode 100644 index 0000000000..4770688ecf --- /dev/null +++ b/samples/interop/WindowsInteropTest/Program.cs @@ -0,0 +1,22 @@ +using System; +using Avalonia.Controls; +using ControlCatalog; +using Avalonia; + +namespace WindowsInteropTest +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + System.Windows.Forms.Application.EnableVisualStyles(); + System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); + AppBuilder.Configure().UseWin32().UseSkia().SetupWithoutStarting(); + System.Windows.Forms.Application.Run(new SelectorForm()); + } + } +} diff --git a/samples/interop/WindowsInteropTest/Properties/AssemblyInfo.cs b/samples/interop/WindowsInteropTest/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..087fdfe991 --- /dev/null +++ b/samples/interop/WindowsInteropTest/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +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("WindowsInteropTest")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("WindowsInteropTest")] +[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("c7a69145-60b6-4882-97d6-a3921dd43978")] + +// 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")] diff --git a/samples/interop/WindowsInteropTest/Properties/Resources.Designer.cs b/samples/interop/WindowsInteropTest/Properties/Resources.Designer.cs new file mode 100644 index 0000000000..c3223efc62 --- /dev/null +++ b/samples/interop/WindowsInteropTest/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +namespace WindowsInteropTest.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // 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() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [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("WindowsInteropTest.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/samples/interop/WindowsInteropTest/Properties/Resources.resx b/samples/interop/WindowsInteropTest/Properties/Resources.resx new file mode 100644 index 0000000000..af7dbebbac --- /dev/null +++ b/samples/interop/WindowsInteropTest/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/samples/interop/WindowsInteropTest/Properties/Settings.Designer.cs b/samples/interop/WindowsInteropTest/Properties/Settings.Designer.cs new file mode 100644 index 0000000000..4b768fb74f --- /dev/null +++ b/samples/interop/WindowsInteropTest/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +namespace WindowsInteropTest.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; + } + } + } +} diff --git a/samples/interop/WindowsInteropTest/Properties/Settings.settings b/samples/interop/WindowsInteropTest/Properties/Settings.settings new file mode 100644 index 0000000000..39645652af --- /dev/null +++ b/samples/interop/WindowsInteropTest/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/samples/interop/WindowsInteropTest/SelectorForm.Designer.cs b/samples/interop/WindowsInteropTest/SelectorForm.Designer.cs new file mode 100644 index 0000000000..7cf402913e --- /dev/null +++ b/samples/interop/WindowsInteropTest/SelectorForm.Designer.cs @@ -0,0 +1,76 @@ +namespace WindowsInteropTest +{ + partial class SelectorForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.btnEmbedToWinForms = new System.Windows.Forms.Button(); + this.btnEmbedToWpf = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // btnEmbedToWinForms + // + this.btnEmbedToWinForms.Location = new System.Drawing.Point(12, 12); + this.btnEmbedToWinForms.Name = "btnEmbedToWinForms"; + this.btnEmbedToWinForms.Size = new System.Drawing.Size(201, 86); + this.btnEmbedToWinForms.TabIndex = 0; + this.btnEmbedToWinForms.Text = "Embed to WinForms"; + this.btnEmbedToWinForms.UseVisualStyleBackColor = true; + this.btnEmbedToWinForms.Click += new System.EventHandler(this.btnEmbedToWinForms_Click); + // + // btnEmbedToWpf + // + this.btnEmbedToWpf.Location = new System.Drawing.Point(219, 12); + this.btnEmbedToWpf.Name = "btnEmbedToWpf"; + this.btnEmbedToWpf.Size = new System.Drawing.Size(201, 86); + this.btnEmbedToWpf.TabIndex = 1; + this.btnEmbedToWpf.Text = "Embed to WPF"; + this.btnEmbedToWpf.UseVisualStyleBackColor = true; + this.btnEmbedToWpf.Click += new System.EventHandler(this.btnEmbedToWpf_Click); + // + // SelectorForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(432, 284); + this.Controls.Add(this.btnEmbedToWpf); + this.Controls.Add(this.btnEmbedToWinForms); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.MaximizeBox = false; + this.Name = "SelectorForm"; + this.Text = "Interop"; + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button btnEmbedToWinForms; + private System.Windows.Forms.Button btnEmbedToWpf; + } +} + diff --git a/samples/interop/WindowsInteropTest/SelectorForm.cs b/samples/interop/WindowsInteropTest/SelectorForm.cs new file mode 100644 index 0000000000..6430694f79 --- /dev/null +++ b/samples/interop/WindowsInteropTest/SelectorForm.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace WindowsInteropTest +{ + public partial class SelectorForm : Form + { + public SelectorForm() + { + InitializeComponent(); + } + + private void btnEmbedToWinForms_Click(object sender, EventArgs e) + { + new EmbedToWinFormsDemo().ShowDialog(this); + } + + private void btnEmbedToWpf_Click(object sender, EventArgs e) + { + new EmbedToWpfDemo().ShowDialog(); + } + } +} diff --git a/samples/interop/WindowsInteropTest/SelectorForm.resx b/samples/interop/WindowsInteropTest/SelectorForm.resx new file mode 100644 index 0000000000..1af7de150c --- /dev/null +++ b/samples/interop/WindowsInteropTest/SelectorForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/samples/interop/WindowsInteropTest/WindowsInteropTest.csproj b/samples/interop/WindowsInteropTest/WindowsInteropTest.csproj new file mode 100644 index 0000000000..24f090a545 --- /dev/null +++ b/samples/interop/WindowsInteropTest/WindowsInteropTest.csproj @@ -0,0 +1,186 @@ + + + + + Debug + AnyCPU + {C7A69145-60B6-4882-97D6-A3921DD43978} + WinExe + Properties + WindowsInteropTest + WindowsInteropTest + v4.6 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + Form + + + EmbedToWinFormsDemo.cs + + + EmbedToWpfDemo.xaml + + + Form + + + SelectorForm.cs + + + + + EmbedToWinFormsDemo.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SelectorForm.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + {d211e587-d8bc-45b9-95a4-f297c8fa5200} + Avalonia.Animation + + + {b09b78d8-9b26-48b0-9149-d64a2f120f3f} + Avalonia.Base + + + {d2221c82-4a25-4583-9b43-d791e3f6820c} + Avalonia.Controls + + + {799a7bb5-3c2c-48b6-85a7-406a12c420da} + Avalonia.DesignerSupport + + + {7062ae20-5dcc-4442-9645-8195bdece63e} + Avalonia.Diagnostics + + + {62024b2d-53eb-4638-b26b-85eeaa54866e} + Avalonia.Input + + + {6b0ed19d-a08b-461c-a9d9-a9ee40b0c06b} + Avalonia.Interactivity + + + {42472427-4774-4c81-8aff-9f27b8e31721} + Avalonia.Layout + + + {6417b24e-49c2-4985-8db2-3ab9d898ec91} + Avalonia.ReactiveUI + + + {eb582467-6abb-43a1-b052-e981ba910e3a} + Avalonia.SceneGraph + + + {f1baa01a-f176-4c6a-b39d-5b40bb1b148f} + Avalonia.Styling + + + {3e10a5fa-e8da-48b1-ad44-6a5b6cb7750f} + Avalonia.Themes.Default + + + {3e53a01a-b331-47f3-b828-4a5717e77a24} + Avalonia.Markup.Xaml + + + {6417e941-21bc-467b-a771-0de389353ce6} + Avalonia.Markup + + + {925dd807-b651-475f-9f7c-cbeb974ce43d} + Avalonia.Skia.Desktop + + + {3e908f67-5543-4879-a1dc-08eace79b3cd} + Avalonia.Direct2D1 + + + {811a76cf-1cf6-440f-963b-bbe31bd72a82} + Avalonia.Win32 + + + {d0a739b9-3c68-4ba6-a328-41606954b6bd} + ControlCatalog + + + + + Designer + MSBuild:Compile + + + + + \ No newline at end of file diff --git a/src/Avalonia.Controls/Avalonia.Controls.csproj b/src/Avalonia.Controls/Avalonia.Controls.csproj index d6e5926727..339af5adca 100644 --- a/src/Avalonia.Controls/Avalonia.Controls.csproj +++ b/src/Avalonia.Controls/Avalonia.Controls.csproj @@ -56,6 +56,7 @@ + diff --git a/src/Avalonia.Controls/EmbeddableControl.cs b/src/Avalonia.Controls/EmbeddableControl.cs new file mode 100644 index 0000000000..a1c4fc9ed8 --- /dev/null +++ b/src/Avalonia.Controls/EmbeddableControl.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Avalonia.Controls.Platform; +using Avalonia.Input; +using Avalonia.Layout; +using Avalonia.Platform; +using Avalonia.Styling; + +namespace Avalonia.Controls +{ + public class EmbeddableControl : TopLevel, IStyleable, IFocusScope, ILayoutRoot, INameScope + { + public EmbeddableControl() : base(PlatformManager.CreateEmbeddableWindow()) + { + PlatformImpl.Show(); + } + + public void Prepare() + { + EnsureInitialized(); + ApplyTemplate(); + LayoutManager.Instance.ExecuteInitialLayoutPass(this); + PlatformImpl.Show(); + } + + + private void EnsureInitialized() + { + if (!this.IsInitialized) + { + var init = (ISupportInitialize)this; + init.BeginInit(); + init.EndInit(); + } + } + + protected override Size MeasureOverride(Size availableSize) + { + return PlatformImpl.ClientSize; + } + + private readonly NameScope _nameScope = new NameScope(); + public event EventHandler Registered + { + add { _nameScope.Registered += value; } + remove { _nameScope.Registered -= value; } + } + + public event EventHandler Unregistered + { + add { _nameScope.Unregistered += value; } + remove { _nameScope.Unregistered -= value; } + } + + public void Register(string name, object element) => _nameScope.Register(name, element); + + public object Find(string name) => _nameScope.Find(name); + + public void Unregister(string name) => _nameScope.Unregister(name); + + Type IStyleable.StyleKey => typeof(EmbeddableControl); + } +} diff --git a/src/Avalonia.Controls/Platform/PlatformManager.cs b/src/Avalonia.Controls/Platform/PlatformManager.cs index e75f3c162b..339b2356f3 100644 --- a/src/Avalonia.Controls/Platform/PlatformManager.cs +++ b/src/Avalonia.Controls/Platform/PlatformManager.cs @@ -43,6 +43,14 @@ namespace Avalonia.Controls.Platform return s_designerMode ? platform.CreateEmbeddableWindow() : platform.CreateWindow(); } + public static IWindowImpl CreateEmbeddableWindow() + { + var platform = AvaloniaLocator.Current.GetService(); + if (platform == null) + throw new Exception("Could not CreateEmbeddableWindow(): IWindowingPlatform is not registered."); + return platform.CreateEmbeddableWindow(); + } + public static IPopupImpl CreatePopup() { return AvaloniaLocator.Current.GetService().CreatePopup(); diff --git a/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj b/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj index f3f1714e2d..93b258d3f1 100644 --- a/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj +++ b/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj @@ -208,6 +208,11 @@ True + + + Designer + + + \ No newline at end of file diff --git a/samples/interop/GtkInteropDemo/MainWindow.cs b/samples/interop/GtkInteropDemo/MainWindow.cs new file mode 100644 index 0000000000..2d7521cd8c --- /dev/null +++ b/samples/interop/GtkInteropDemo/MainWindow.cs @@ -0,0 +1,28 @@ +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); + root.PackStart(new GtkAvaloniaControlHost() {Content = new ControlCatalogControl()}, true, true, 0); + Add(root); + + ShowAll(); + } + } +} diff --git a/samples/interop/GtkInteropDemo/Program.cs b/samples/interop/GtkInteropDemo/Program.cs new file mode 100644 index 0000000000..7dd39c74ca --- /dev/null +++ b/samples/interop/GtkInteropDemo/Program.cs @@ -0,0 +1,24 @@ +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 + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + AppBuilder.Configure().UseGtk().UseCairo().SetupWithoutStarting(); + new MainWindow().Show(); + Gtk.Application.Run(); + } + } +} diff --git a/samples/interop/GtkInteropDemo/Properties/AssemblyInfo.cs b/samples/interop/GtkInteropDemo/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..8aaf28c2f0 --- /dev/null +++ b/samples/interop/GtkInteropDemo/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +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")] diff --git a/samples/interop/GtkInteropDemo/Properties/Resources.Designer.cs b/samples/interop/GtkInteropDemo/Properties/Resources.Designer.cs new file mode 100644 index 0000000000..f79a8bf680 --- /dev/null +++ b/samples/interop/GtkInteropDemo/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +namespace GtkInteropDemo.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // 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() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [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; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/samples/interop/GtkInteropDemo/Properties/Resources.resx b/samples/interop/GtkInteropDemo/Properties/Resources.resx new file mode 100644 index 0000000000..af7dbebbac --- /dev/null +++ b/samples/interop/GtkInteropDemo/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/samples/interop/GtkInteropDemo/Properties/Settings.Designer.cs b/samples/interop/GtkInteropDemo/Properties/Settings.Designer.cs new file mode 100644 index 0000000000..8173ee7dfa --- /dev/null +++ b/samples/interop/GtkInteropDemo/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +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; + } + } + } +} diff --git a/samples/interop/GtkInteropDemo/Properties/Settings.settings b/samples/interop/GtkInteropDemo/Properties/Settings.settings new file mode 100644 index 0000000000..39645652af --- /dev/null +++ b/samples/interop/GtkInteropDemo/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/Avalonia.Controls/EmbeddableControlRoot.cs b/src/Avalonia.Controls/EmbeddableControlRoot.cs index 8d3e0fc6e2..02a34433a7 100644 --- a/src/Avalonia.Controls/EmbeddableControlRoot.cs +++ b/src/Avalonia.Controls/EmbeddableControlRoot.cs @@ -13,6 +13,11 @@ namespace Avalonia.Controls { public class EmbeddableControlRoot : TopLevel, IStyleable, IFocusScope, INameScope, IDisposable { + public EmbeddableControlRoot(IEmbeddableWindowImpl impl) : base(impl) + { + PlatformImpl.Show(); + } + public EmbeddableControlRoot() : base(PlatformManager.CreateEmbeddableWindow()) { PlatformImpl.Show(); @@ -24,8 +29,8 @@ namespace Avalonia.Controls { EnsureInitialized(); ApplyTemplate(); - LayoutManager.Instance.ExecuteInitialLayoutPass(this); PlatformImpl.Show(); + LayoutManager.Instance.ExecuteInitialLayoutPass(this); } diff --git a/src/Gtk/Avalonia.Cairo/CairoPlatform.cs b/src/Gtk/Avalonia.Cairo/CairoPlatform.cs index 5b85e6c68f..2b0fce8210 100644 --- a/src/Gtk/Avalonia.Cairo/CairoPlatform.cs +++ b/src/Gtk/Avalonia.Cairo/CairoPlatform.cs @@ -53,13 +53,21 @@ namespace Avalonia.Cairo public IRenderTarget CreateRenderer(IPlatformHandle handle) { var window = handle as Gtk.Window; - if (window == null) - throw new NotSupportedException(string.Format( - "Don't know how to create a Cairo renderer from a '{0}' handle which isn't Gtk.Window", - handle.HandleDescriptor)); - - window.DoubleBuffered = true; - return new RenderTarget(window); + if (window != null) + { + window.DoubleBuffered = true; + return new RenderTarget(window); + } + var area = handle as Gtk.DrawingArea; + if (area != null) + { + area.DoubleBuffered = true; + return new RenderTarget(area); + } + + throw new NotSupportedException(string.Format( + "Don't know how to create a Cairo renderer from a '{0}' handle which isn't Gtk.Window or Gtk.DrawingArea", + handle.HandleDescriptor)); } public IRenderTargetBitmapImpl CreateRenderTargetBitmap(int width, int height) diff --git a/src/Gtk/Avalonia.Cairo/RenderTarget.cs b/src/Gtk/Avalonia.Cairo/RenderTarget.cs index cb7241f32e..cfa51852d9 100644 --- a/src/Gtk/Avalonia.Cairo/RenderTarget.cs +++ b/src/Gtk/Avalonia.Cairo/RenderTarget.cs @@ -7,6 +7,7 @@ using Avalonia.Cairo.Media; using Avalonia.Media; using Avalonia.Platform; using Avalonia.Rendering; +using Gtk; using DrawingContext = Avalonia.Media.DrawingContext; namespace Avalonia.Cairo @@ -20,6 +21,7 @@ namespace Avalonia.Cairo { private readonly Surface _surface; private readonly Gtk.Window _window; + private readonly Gtk.DrawingArea _area; /// /// Initializes a new instance of the class. @@ -37,17 +39,25 @@ namespace Avalonia.Cairo _surface = surface; } + public RenderTarget(DrawingArea area) + { + _area = area; + } /// /// Creates a cairo surface that targets a platform-specific resource. /// /// A surface wrapped in an . - public DrawingContext CreateDrawingContext() + public DrawingContext CreateDrawingContext() => new DrawingContext(CreateMediaDrawingContext()); + public IDrawingContextImpl CreateMediaDrawingContext() { - var ctx = _surface != null - ? new Media.DrawingContext(_surface) - : new Media.DrawingContext(_window.GdkWindow); - return new DrawingContext(ctx); + if(_window!=null) + return new Media.DrawingContext(_window.GdkWindow); + if (_surface != null) + return new Media.DrawingContext(_surface); + if(_area!=null) + return new Media.DrawingContext(_area.GdkWindow); + throw new InvalidOperationException(); } public void Dispose() => _surface?.Dispose(); diff --git a/src/Gtk/Avalonia.Gtk/Avalonia.Gtk.csproj b/src/Gtk/Avalonia.Gtk/Avalonia.Gtk.csproj index fe075bca77..4cf732d56a 100644 --- a/src/Gtk/Avalonia.Gtk/Avalonia.Gtk.csproj +++ b/src/Gtk/Avalonia.Gtk/Avalonia.Gtk.csproj @@ -46,6 +46,8 @@ + + @@ -54,8 +56,10 @@ + + @@ -67,6 +71,10 @@ {B09B78D8-9B26-48B0-9149-D64A2F120F3F} Avalonia.Base + + {7062ae20-5dcc-4442-9645-8195bdece63e} + Avalonia.Diagnostics + {62024B2D-53EB-4638-B26B-85EEAA54866E} Avalonia.Input diff --git a/src/Gtk/Avalonia.Gtk/EmbeddableImpl.cs b/src/Gtk/Avalonia.Gtk/EmbeddableImpl.cs new file mode 100644 index 0000000000..fdac509e3f --- /dev/null +++ b/src/Gtk/Avalonia.Gtk/EmbeddableImpl.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reactive.Disposables; +using System.Text; +using System.Threading.Tasks; +using Avalonia.Platform; +using Gdk; +using Gtk; +using Action = System.Action; +using WindowEdge = Avalonia.Controls.WindowEdge; + +namespace Avalonia.Gtk +{ + class EmbeddableImpl : WindowImplBase, IEmbeddableWindowImpl + { + public event Action LostFocus; + + public EmbeddableImpl(DrawingArea area) : base(area) + { + area.Events = EventMask.AllEventsMask; + area.SizeAllocated += Plug_SizeAllocated; + } + + public EmbeddableImpl() : this(new PlatformHandleAwareDrawingArea()) + { + + } + + private void Plug_SizeAllocated(object o, SizeAllocatedArgs args) + { + Resized?.Invoke(new Size(args.Allocation.Width, args.Allocation.Height)); + } + + public override Size ClientSize + { + get { return new Size(Widget.Allocation.Width, Widget.Allocation.Height); } + set { } + } + + + //Stubs are needed for future GTK designer embedding support + public override void SetTitle(string title) + { + + } + + public override IDisposable ShowDialog() => Disposable.Create(() => { }); + + public override void SetSystemDecorations(bool enabled) + { + + } + + public override void SetIcon(IWindowIconImpl icon) + { + + } + + public override void BeginMoveDrag() + { + + } + + public override void BeginResizeDrag(WindowEdge edge) + { + + } + + public override Point Position + { + get { return new Point(); } + set + { + + } + } + } +} diff --git a/src/Gtk/Avalonia.Gtk/Embedding/GtkAvaloniaControlHost.cs b/src/Gtk/Avalonia.Gtk/Embedding/GtkAvaloniaControlHost.cs new file mode 100644 index 0000000000..07c211d32c --- /dev/null +++ b/src/Gtk/Avalonia.Gtk/Embedding/GtkAvaloniaControlHost.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Avalonia.Controls; +using Avalonia.Diagnostics; +using Avalonia.Layout; +using Avalonia.Platform; +using Gdk; +using Gtk; + +namespace Avalonia.Gtk.Embedding +{ + public class GtkAvaloniaControlHost : DrawingArea, IPlatformHandle + { + private EmbeddableControlRoot _root; + + public GtkAvaloniaControlHost() + { + _root = new EmbeddableControlRoot(new EmbeddableImpl(this)); + _root.Prepare(); + } + + private Control _content; + + public Control Content + { + get { return _content; } + set + { + _content = value; + if (_root != null) + { + _root.Content = value; + _root.Prepare(); + } + } + } + + protected override void OnSizeRequested(ref Requisition requisition) + { + requisition.Width = 700; + requisition.Height = 500; + + } + + + IntPtr IPlatformHandle.Handle => PlatformHandleAwareWindow.GetNativeWindow(GdkWindow); + + string IPlatformHandle.HandleDescriptor => "HWND"; + } +} diff --git a/src/Gtk/Avalonia.Gtk/GtkPlatform.cs b/src/Gtk/Avalonia.Gtk/GtkPlatform.cs index 4db3bd7894..3adf1c9b89 100644 --- a/src/Gtk/Avalonia.Gtk/GtkPlatform.cs +++ b/src/Gtk/Avalonia.Gtk/GtkPlatform.cs @@ -105,10 +105,7 @@ namespace Avalonia.Gtk return new WindowImpl(); } - public IEmbeddableWindowImpl CreateEmbeddableWindow() - { - throw new NotSupportedException(); - } + public IEmbeddableWindowImpl CreateEmbeddableWindow() => new EmbeddableImpl(); public IPopupImpl CreatePopup() { diff --git a/src/Gtk/Avalonia.Gtk/SystemDialogImpl.cs b/src/Gtk/Avalonia.Gtk/SystemDialogImpl.cs index a47a0a0ef8..ed92a25873 100644 --- a/src/Gtk/Avalonia.Gtk/SystemDialogImpl.cs +++ b/src/Gtk/Avalonia.Gtk/SystemDialogImpl.cs @@ -15,7 +15,7 @@ namespace Avalonia.Gtk public Task ShowFileDialogAsync(FileDialog dialog, IWindowImpl parent) { var tcs = new TaskCompletionSource(); - var dlg = new global::Gtk.FileChooserDialog(dialog.Title, ((WindowImpl)parent), + var dlg = new global::Gtk.FileChooserDialog(dialog.Title, ((WindowImplBase)parent).Widget.Toplevel as Window, dialog is OpenFileDialog ? FileChooserAction.Open : FileChooserAction.Save, @@ -57,7 +57,7 @@ namespace Avalonia.Gtk public Task ShowFolderDialogAsync(OpenFolderDialog dialog, IWindowImpl parent) { var tcs = new TaskCompletionSource(); - var dlg = new global::Gtk.FileChooserDialog(dialog.Title, ((WindowImpl)parent), + var dlg = new global::Gtk.FileChooserDialog(dialog.Title, ((WindowImplBase)parent).Widget.Toplevel as Window, FileChooserAction.SelectFolder, "Cancel", ResponseType.Cancel, "Select Folder", ResponseType.Accept) diff --git a/src/Gtk/Avalonia.Gtk/WindowImpl.cs b/src/Gtk/Avalonia.Gtk/WindowImpl.cs index 26ad52135d..c1a69e8932 100644 --- a/src/Gtk/Avalonia.Gtk/WindowImpl.cs +++ b/src/Gtk/Avalonia.Gtk/WindowImpl.cs @@ -1,404 +1,118 @@ -// 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. - using System; using System.Reactive.Disposables; -using System.Runtime.InteropServices; -using Gdk; -using Avalonia.Controls; -using Avalonia.Input.Raw; using Avalonia.Platform; -using Avalonia.Input; -using Avalonia.Threading; -using Action = System.Action; -using WindowEdge = Avalonia.Controls.WindowEdge; +using Gdk; namespace Avalonia.Gtk { using Gtk = global::Gtk; - - public class WindowImpl : Gtk.Window, IWindowImpl, IPlatformHandle + public class WindowImpl : WindowImplBase { - private IInputRoot _inputRoot; + private Gtk.Window _window; + private Gtk.Window Window => _window ?? (_window = (Gtk.Window) Widget); - private Size _lastClientSize; - private Gtk.IMContext _imContext; - private uint _lastKeyEventTimestamp; - - private static readonly Gdk.Cursor DefaultCursor = new Gdk.Cursor(CursorType.LeftPtr); - - public WindowImpl() - : base(Gtk.WindowType.Toplevel) + public WindowImpl(Gtk.WindowType type) : base(new PlatformHandleAwareWindow(type)) { - DefaultSize = new Gdk.Size(900, 480); Init(); } - public WindowImpl(Gtk.WindowType type) - : base(type) + public WindowImpl() + : base(new PlatformHandleAwareWindow(Gtk.WindowType.Toplevel) {DefaultSize = new Gdk.Size(900, 480)}) { Init(); } - private void Init() + void Init() { - Events = EventMask.PointerMotionMask | - EventMask.ButtonPressMask | - EventMask.ButtonReleaseMask; - _imContext = new Gtk.IMMulticontext(); - _imContext.Commit += ImContext_Commit; - DoubleBuffered = false; - Realize(); + Window.FocusActivated += OnFocusActivated; + Window.ConfigureEvent += OnConfigureEvent; _lastClientSize = ClientSize; } - - protected override void OnRealized () - { - base.OnRealized (); - _imContext.ClientWindow = this.GdkWindow; - } - - public Size ClientSize + private Size _lastClientSize; + void OnConfigureEvent(object o, Gtk.ConfigureEventArgs args) { - get - { - int width; - int height; - GetSize(out width, out height); - return new Size(width, height); - } - - set - { - Resize((int)value.Width, (int)value.Height); - } - } + var evnt = args.Event; + args.RetVal = true; + var newSize = new Size(evnt.Width, evnt.Height); - public Size MaxClientSize - { - get + if (newSize != _lastClientSize) { - // TODO: This should take into account things such as taskbar and window border - // thickness etc. - return new Size(Screen.Width, Screen.Height); + Resized(newSize); + _lastClientSize = newSize; } } - public Avalonia.Controls.WindowState WindowState + public override Size ClientSize { get { - switch (GdkWindow.State) - { - case Gdk.WindowState.Iconified: - return Controls.WindowState.Minimized; - case Gdk.WindowState.Maximized: - return Controls.WindowState.Maximized; - default: - return Controls.WindowState.Normal; - } + int width; + int height; + Window.GetSize(out width, out height); + return new Size(width, height); } set { - switch (value) - { - case Controls.WindowState.Minimized: - GdkWindow.Iconify(); - break; - case Controls.WindowState.Maximized: - GdkWindow.Maximize(); - break; - case Controls.WindowState.Normal: - GdkWindow.Deiconify(); - GdkWindow.Unmaximize(); - break; - } + Window.Resize((int)value.Width, (int)value.Height); } } - public double Scaling => 1; - - IPlatformHandle ITopLevelImpl.Handle => this; - - [DllImport("libgdk-win32-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] - extern static IntPtr gdk_win32_drawable_get_handle(IntPtr gdkWindow); - - [DllImport("libgtk-x11-2.0.so.0", CallingConvention = CallingConvention.Cdecl)] - extern static IntPtr gdk_x11_drawable_get_xid(IntPtr gdkWindow); - - [DllImport("libgdk-quartz-2.0-0.dylib", CallingConvention = CallingConvention.Cdecl)] - extern static IntPtr gdk_quartz_window_get_nswindow(IntPtr gdkWindow); - - IntPtr _nativeWindow; - - IntPtr GetNativeWindow() + public override void SetTitle(string title) { - IntPtr h = GdkWindow.Handle; - if (_nativeWindow != IntPtr.Zero) - return _nativeWindow; - //Try whatever backend that works - try - { - return _nativeWindow = gdk_quartz_window_get_nswindow(h); - } - catch - { - } - try - { - return _nativeWindow = gdk_x11_drawable_get_xid(h); - } - catch - { - } - return _nativeWindow = gdk_win32_drawable_get_handle(h); + Window.Title = title; } - - IntPtr IPlatformHandle.Handle => GetNativeWindow(); - public string HandleDescriptor => "HWND"; - - public Action Activated { get; set; } - - public Action Closed { get; set; } - - public Action Deactivated { get; set; } - - public Action Input { get; set; } - - public Action Paint { get; set; } - - public Action Resized { get; set; } - - public Action ScalingChanged { get; set; } - - public IPopupImpl CreatePopup() - { - return new PopupImpl(); - } - - public void Invalidate(Rect rect) - { - if (base.GdkWindow != null) - base.GdkWindow.InvalidateRect( - new Rectangle((int) rect.X, (int) rect.Y, (int) rect.Width, (int) rect.Height), true); - } - - public Point PointToClient(Point point) + void OnFocusActivated(object sender, EventArgs eventArgs) { - int x, y; - GdkWindow.GetDeskrelativeOrigin(out x, out y); - - return new Point(point.X - x, point.Y - y); - } - - public Point PointToScreen(Point point) - { - int x, y; - GdkWindow.GetDeskrelativeOrigin(out x, out y); - - return new Point(point.X + x, point.Y + y); - } - - public void SetInputRoot(IInputRoot inputRoot) - { - _inputRoot = inputRoot; - } - - public void SetTitle(string title) - { - Title = title; - } - - - public void SetCursor(IPlatformHandle cursor) - { - GdkWindow.Cursor = cursor != null ? new Gdk.Cursor(cursor.Handle) : DefaultCursor; + Activated(); } - public void BeginMoveDrag() + public override void BeginMoveDrag() { int x, y; ModifierType mod; - Screen.RootWindow.GetPointer(out x, out y, out mod); - BeginMoveDrag(1, x, y, 0); + Window.Screen.RootWindow.GetPointer(out x, out y, out mod); + Window.BeginMoveDrag(1, x, y, 0); } - public void BeginResizeDrag(WindowEdge edge) + public override void BeginResizeDrag(Controls.WindowEdge edge) { int x, y; ModifierType mod; - Screen.RootWindow.GetPointer(out x, out y, out mod); - BeginResizeDrag((Gdk.WindowEdge) (int) edge, 1, x, y, 0); + Window.Screen.RootWindow.GetPointer(out x, out y, out mod); + Window.BeginResizeDrag((Gdk.WindowEdge)(int)edge, 1, x, y, 0); } - public Point Position + public override Point Position { get { int x, y; - GetPosition(out x, out y); + Window.GetPosition(out x, out y); return new Point(x, y); } set { - Move((int)value.X, (int)value.Y); + Window.Move((int)value.X, (int)value.Y); } } - public IDisposable ShowDialog() + public override IDisposable ShowDialog() { - Modal = true; - Show(); + Window.Modal = true; + Window.Show(); return Disposable.Empty; } - public void SetSystemDecorations(bool enabled) => Decorated = enabled; - - void ITopLevelImpl.Activate() - { - Activate(); - } - - private static InputModifiers GetModifierKeys(ModifierType state) - { - var rv = InputModifiers.None; - if (state.HasFlag(ModifierType.ControlMask)) - rv |= InputModifiers.Control; - if (state.HasFlag(ModifierType.ShiftMask)) - rv |= InputModifiers.Shift; - if (state.HasFlag(ModifierType.Mod1Mask)) - rv |= InputModifiers.Control; - if(state.HasFlag(ModifierType.Button1Mask)) - rv |= InputModifiers.LeftMouseButton; - if (state.HasFlag(ModifierType.Button2Mask)) - rv |= InputModifiers.RightMouseButton; - if (state.HasFlag(ModifierType.Button3Mask)) - rv |= InputModifiers.MiddleMouseButton; - return rv; - } - - protected override bool OnButtonPressEvent(EventButton evnt) - { - - var e = new RawMouseEventArgs( - GtkMouseDevice.Instance, - evnt.Time, - _inputRoot, - evnt.Button == 1 - ? RawMouseEventType.LeftButtonDown - : evnt.Button == 3 ? RawMouseEventType.RightButtonDown : RawMouseEventType.MiddleButtonDown, - new Point(evnt.X, evnt.Y), GetModifierKeys(evnt.State)); - Input(e); - return true; - } - - protected override bool OnScrollEvent(EventScroll evnt) - { - double step = 1; - var delta = new Vector(); - if (evnt.Direction == ScrollDirection.Down) - delta = new Vector(0, -step); - else if (evnt.Direction == ScrollDirection.Up) - delta = new Vector(0, step); - else if (evnt.Direction == ScrollDirection.Right) - delta = new Vector(-step, 0); - if (evnt.Direction == ScrollDirection.Left) - delta = new Vector(step, 0); - var e = new RawMouseWheelEventArgs(GtkMouseDevice.Instance, evnt.Time, _inputRoot, new Point(evnt.X, evnt.Y), delta, GetModifierKeys(evnt.State)); - Input(e); - return base.OnScrollEvent(evnt); - } - - protected override bool OnButtonReleaseEvent(EventButton evnt) - { - var e = new RawMouseEventArgs( - GtkMouseDevice.Instance, - evnt.Time, - _inputRoot, - evnt.Button == 1 - ? RawMouseEventType.LeftButtonUp - : evnt.Button == 3 ? RawMouseEventType.RightButtonUp : RawMouseEventType.MiddleButtonUp, - new Point(evnt.X, evnt.Y), GetModifierKeys(evnt.State)); - Input(e); - return true; - } - - protected override bool OnConfigureEvent(EventConfigure evnt) - { - var newSize = new Size(evnt.Width, evnt.Height); - - if (newSize != _lastClientSize) - { - Resized(newSize); - _lastClientSize = newSize; - } - - return true; - } - - protected override void OnDestroyed() - { - Closed(); - } - - private bool ProcessKeyEvent(EventKey evnt) - { - _lastKeyEventTimestamp = evnt.Time; - if (_imContext.FilterKeypress(evnt)) - return true; - var e = new RawKeyEventArgs( - GtkKeyboardDevice.Instance, - evnt.Time, - evnt.Type == EventType.KeyPress ? RawKeyEventType.KeyDown : RawKeyEventType.KeyUp, - GtkKeyboardDevice.ConvertKey(evnt.Key), GetModifierKeys(evnt.State)); - Input(e); - return true; - } - - protected override bool OnKeyPressEvent(EventKey evnt) => ProcessKeyEvent(evnt); - - protected override bool OnKeyReleaseEvent(EventKey evnt) => ProcessKeyEvent(evnt); - - private void ImContext_Commit(object o, Gtk.CommitArgs args) - { - Input(new RawTextInputEventArgs(GtkKeyboardDevice.Instance, _lastKeyEventTimestamp, args.Str)); - } - - protected override bool OnExposeEvent(EventExpose evnt) - { - Paint(evnt.Area.ToAvalonia()); - return true; - } - - protected override void OnFocusActivated() - { - Activated(); - } - - protected override bool OnMotionNotifyEvent(EventMotion evnt) - { - var position = new Point(evnt.X, evnt.Y); - - GtkMouseDevice.Instance.SetClientPosition(position); - - var e = new RawMouseEventArgs( - GtkMouseDevice.Instance, - evnt.Time, - _inputRoot, - RawMouseEventType.Move, - position, GetModifierKeys(evnt.State)); - Input(e); - return true; - } + public override void SetSystemDecorations(bool enabled) => Window.Decorated = enabled; - public void SetIcon(IWindowIconImpl icon) + public override void SetIcon(IWindowIconImpl icon) { - Icon = ((IconImpl)icon).Pixbuf; + Window.Icon = ((IconImpl)icon).Pixbuf; } } -} +} \ No newline at end of file diff --git a/src/Gtk/Avalonia.Gtk/WindowImplBase.cs b/src/Gtk/Avalonia.Gtk/WindowImplBase.cs new file mode 100644 index 0000000000..b81387a678 --- /dev/null +++ b/src/Gtk/Avalonia.Gtk/WindowImplBase.cs @@ -0,0 +1,323 @@ +// 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. + +using System; +using System.Reactive.Disposables; +using System.Runtime.InteropServices; +using Gdk; +using Avalonia.Controls; +using Avalonia.Input.Raw; +using Avalonia.Platform; +using Avalonia.Input; +using Avalonia.Threading; +using Action = System.Action; +using WindowEdge = Avalonia.Controls.WindowEdge; + +namespace Avalonia.Gtk +{ + using Gtk = global::Gtk; + + public abstract class WindowImplBase : IWindowImpl + { + private IInputRoot _inputRoot; + protected Gtk.Widget _window; + public Gtk.Widget Widget => _window; + + + private Gtk.IMContext _imContext; + + private uint _lastKeyEventTimestamp; + + private static readonly Gdk.Cursor DefaultCursor = new Gdk.Cursor(CursorType.LeftPtr); + + + + protected WindowImplBase(Gtk.Widget window) + { + _window = window; + Init(); + } + + void Init() + { + Handle = _window as IPlatformHandle; + _window.Events = EventMask.AllEventsMask; + _imContext = new Gtk.IMMulticontext(); + _imContext.Commit += ImContext_Commit; + _window.Realized += OnRealized; + _window.DoubleBuffered = false; + _window.Realize(); + _window.ButtonPressEvent += OnButtonPressEvent; + _window.ButtonReleaseEvent += OnButtonReleaseEvent; + _window.ScrollEvent += OnScrollEvent; + _window.Destroyed += OnDestroyed; + _window.KeyPressEvent += OnKeyPressEvent; + _window.KeyReleaseEvent += OnKeyReleaseEvent; + _window.ExposeEvent += OnExposeEvent; + _window.MotionNotifyEvent += OnMotionNotifyEvent; + + } + + public IPlatformHandle Handle { get; private set; } + + void OnRealized (object sender, EventArgs eventArgs) + { + _imContext.ClientWindow = _window.GdkWindow; + } + + public abstract Size ClientSize { get; set; } + + + public Size MaxClientSize + { + get + { + // TODO: This should take into account things such as taskbar and window border + // thickness etc. + return new Size(_window.Screen.Width, _window.Screen.Height); + } + } + + public Avalonia.Controls.WindowState WindowState + { + get + { + switch (_window.GdkWindow.State) + { + case Gdk.WindowState.Iconified: + return Controls.WindowState.Minimized; + case Gdk.WindowState.Maximized: + return Controls.WindowState.Maximized; + default: + return Controls.WindowState.Normal; + } + } + + set + { + switch (value) + { + case Controls.WindowState.Minimized: + _window.GdkWindow.Iconify(); + break; + case Controls.WindowState.Maximized: + _window.GdkWindow.Maximize(); + break; + case Controls.WindowState.Normal: + _window.GdkWindow.Deiconify(); + _window.GdkWindow.Unmaximize(); + break; + } + } + } + + public double Scaling => 1; + + + + + + public Action Activated { get; set; } + + public Action Closed { get; set; } + + public Action Deactivated { get; set; } + + public Action Input { get; set; } + + public Action Paint { get; set; } + + public Action Resized { get; set; } + + public Action ScalingChanged { get; set; } + + public IPopupImpl CreatePopup() + { + return new PopupImpl(); + } + + public void Invalidate(Rect rect) + { + if (_window.GdkWindow != null) + _window.GdkWindow.InvalidateRect( + new Rectangle((int) rect.X, (int) rect.Y, (int) rect.Width, (int) rect.Height), true); + } + + public Point PointToClient(Point point) + { + int x, y; + _window.GdkWindow.GetDeskrelativeOrigin(out x, out y); + + return new Point(point.X - x, point.Y - y); + } + + public Point PointToScreen(Point point) + { + int x, y; + _window.GdkWindow.GetDeskrelativeOrigin(out x, out y); + + return new Point(point.X + x, point.Y + y); + } + + public void SetInputRoot(IInputRoot inputRoot) + { + _inputRoot = inputRoot; + } + + public abstract void SetTitle(string title); + public abstract IDisposable ShowDialog(); + public abstract void SetSystemDecorations(bool enabled); + public abstract void SetIcon(IWindowIconImpl icon); + + + public void SetCursor(IPlatformHandle cursor) + { + _window.GdkWindow.Cursor = cursor != null ? new Gdk.Cursor(cursor.Handle) : DefaultCursor; + } + + public void Show() => _window.Show(); + + public void Hide() => _window.Hide(); + public abstract void BeginMoveDrag(); + public abstract void BeginResizeDrag(WindowEdge edge); + public abstract Point Position { get; set; } + + + void ITopLevelImpl.Activate() + { + _window.Activate(); + } + + private static InputModifiers GetModifierKeys(ModifierType state) + { + var rv = InputModifiers.None; + if (state.HasFlag(ModifierType.ControlMask)) + rv |= InputModifiers.Control; + if (state.HasFlag(ModifierType.ShiftMask)) + rv |= InputModifiers.Shift; + if (state.HasFlag(ModifierType.Mod1Mask)) + rv |= InputModifiers.Control; + if(state.HasFlag(ModifierType.Button1Mask)) + rv |= InputModifiers.LeftMouseButton; + if (state.HasFlag(ModifierType.Button2Mask)) + rv |= InputModifiers.RightMouseButton; + if (state.HasFlag(ModifierType.Button3Mask)) + rv |= InputModifiers.MiddleMouseButton; + return rv; + } + + void OnButtonPressEvent(object o, Gtk.ButtonPressEventArgs args) + { + var evnt = args.Event; + var e = new RawMouseEventArgs( + GtkMouseDevice.Instance, + evnt.Time, + _inputRoot, + evnt.Button == 1 + ? RawMouseEventType.LeftButtonDown + : evnt.Button == 3 ? RawMouseEventType.RightButtonDown : RawMouseEventType.MiddleButtonDown, + new Point(evnt.X, evnt.Y), GetModifierKeys(evnt.State)); + Input(e); + } + + void OnScrollEvent(object o, Gtk.ScrollEventArgs args) + { + var evnt = args.Event; + double step = 1; + var delta = new Vector(); + if (evnt.Direction == ScrollDirection.Down) + delta = new Vector(0, -step); + else if (evnt.Direction == ScrollDirection.Up) + delta = new Vector(0, step); + else if (evnt.Direction == ScrollDirection.Right) + delta = new Vector(-step, 0); + if (evnt.Direction == ScrollDirection.Left) + delta = new Vector(step, 0); + var e = new RawMouseWheelEventArgs(GtkMouseDevice.Instance, evnt.Time, _inputRoot, new Point(evnt.X, evnt.Y), delta, GetModifierKeys(evnt.State)); + Input(e); + } + + protected void OnButtonReleaseEvent(object o, Gtk.ButtonReleaseEventArgs args) + { + var evnt = args.Event; + var e = new RawMouseEventArgs( + GtkMouseDevice.Instance, + evnt.Time, + _inputRoot, + evnt.Button == 1 + ? RawMouseEventType.LeftButtonUp + : evnt.Button == 3 ? RawMouseEventType.RightButtonUp : RawMouseEventType.MiddleButtonUp, + new Point(evnt.X, evnt.Y), GetModifierKeys(evnt.State)); + Input(e); + } + + + + void OnDestroyed(object sender, EventArgs eventArgs) + { + Closed(); + } + + private void ProcessKeyEvent(EventKey evnt) + { + + _lastKeyEventTimestamp = evnt.Time; + if (_imContext.FilterKeypress(evnt)) + return; + var e = new RawKeyEventArgs( + GtkKeyboardDevice.Instance, + evnt.Time, + evnt.Type == EventType.KeyPress ? RawKeyEventType.KeyDown : RawKeyEventType.KeyUp, + GtkKeyboardDevice.ConvertKey(evnt.Key), GetModifierKeys(evnt.State)); + Input(e); + } + + void OnKeyPressEvent(object o, Gtk.KeyPressEventArgs args) + { + args.RetVal = true; + ProcessKeyEvent(args.Event); + } + + + void OnKeyReleaseEvent(object o, Gtk.KeyReleaseEventArgs args) + { + args.RetVal = true; + ProcessKeyEvent(args.Event); + } + + private void ImContext_Commit(object o, Gtk.CommitArgs args) + { + Input(new RawTextInputEventArgs(GtkKeyboardDevice.Instance, _lastKeyEventTimestamp, args.Str)); + } + + void OnExposeEvent(object o, Gtk.ExposeEventArgs args) + { + Paint(args.Event.Area.ToAvalonia()); + args.RetVal = true; + } + + void OnMotionNotifyEvent(object o, Gtk.MotionNotifyEventArgs args) + { + var evnt = args.Event; + var position = new Point(evnt.X, evnt.Y); + + GtkMouseDevice.Instance.SetClientPosition(position); + + var e = new RawMouseEventArgs( + GtkMouseDevice.Instance, + evnt.Time, + _inputRoot, + RawMouseEventType.Move, + position, GetModifierKeys(evnt.State)); + Input(e); + args.RetVal = true; + } + + + + public void Dispose() + { + _window.Dispose(); + } + } +} diff --git a/src/Gtk/Avalonia.Gtk/Windows.cs b/src/Gtk/Avalonia.Gtk/Windows.cs new file mode 100644 index 0000000000..fe325f4114 --- /dev/null +++ b/src/Gtk/Avalonia.Gtk/Windows.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; +using Avalonia.Platform; +using Gdk; +using Gtk; +using Window = Gtk.Window; +using WindowType = Gtk.WindowType; + +namespace Avalonia.Gtk +{ + class PlatformHandleAwareWindow : Window, IPlatformHandle + { + public PlatformHandleAwareWindow(WindowType type) : base(type) + { + Events = EventMask.AllEventsMask; + } + + IntPtr IPlatformHandle.Handle => GetNativeWindow(); + public string HandleDescriptor => "HWND"; + + + [DllImport("libgdk-win32-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + static extern IntPtr gdk_win32_drawable_get_handle(IntPtr gdkWindow); + + [DllImport("libgtk-x11-2.0.so.0", CallingConvention = CallingConvention.Cdecl)] + static extern IntPtr gdk_x11_drawable_get_xid(IntPtr gdkWindow); + + [DllImport("libgdk-quartz-2.0-0.dylib", CallingConvention = CallingConvention.Cdecl)] + static extern IntPtr gdk_quartz_window_get_nswindow(IntPtr gdkWindow); + + IntPtr _nativeWindow; + + IntPtr GetNativeWindow() + { + if (_nativeWindow != IntPtr.Zero) + return _nativeWindow; + return _nativeWindow = GetNativeWindow(GdkWindow); + } + + public static IntPtr GetNativeWindow(Gdk.Window window) + { + IntPtr h = window.Handle; + + //Try whatever backend that works + try + { + return gdk_quartz_window_get_nswindow(h); + } + catch + { + } + try + { + return gdk_x11_drawable_get_xid(h); + } + catch + { + } + return gdk_win32_drawable_get_handle(h); + } + + protected override bool OnConfigureEvent(EventConfigure evnt) + { + base.OnConfigureEvent(evnt); + return false; + } + } + + class PlatformHandleAwareDrawingArea : DrawingArea, IPlatformHandle + { + + + + IntPtr IPlatformHandle.Handle => GetNativeWindow(); + public string HandleDescriptor => "HWND"; + IntPtr _nativeWindow; + + IntPtr GetNativeWindow() + { + + if (_nativeWindow != IntPtr.Zero) + return _nativeWindow; + Realize(); + return _nativeWindow = PlatformHandleAwareWindow.GetNativeWindow(GdkWindow); + } + } +} From a4f63f0ecfd87c0dee9378053ef9b05f59cfecfa Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 25 Aug 2016 10:18:13 +0100 Subject: [PATCH 10/46] added fontweight converter to the project file. --- src/Markup/Avalonia.Markup.Xaml/Avalonia.Markup.Xaml.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Markup/Avalonia.Markup.Xaml/Avalonia.Markup.Xaml.csproj b/src/Markup/Avalonia.Markup.Xaml/Avalonia.Markup.Xaml.csproj index 45280020c4..913eb76c77 100644 --- a/src/Markup/Avalonia.Markup.Xaml/Avalonia.Markup.Xaml.csproj +++ b/src/Markup/Avalonia.Markup.Xaml/Avalonia.Markup.Xaml.csproj @@ -60,6 +60,7 @@ + From 9cdcf6cb025de719acce7486099d54592b144d12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Thu, 25 Aug 2016 16:21:01 +0200 Subject: [PATCH 11/46] Revert "Updated projects and packages" This reverts commit 7cca79b4352d82e4e2ed407e2d7218c6d9d31978. --- samples/BindingTest/BindingTest.csproj | 8 ++-- samples/BindingTest/packages.config | 5 +-- samples/ControlCatalog.Desktop/App.config | 8 ++-- .../ControlCatalog.Desktop.csproj | 10 ++--- .../ControlCatalog.Desktop/packages.config | 3 +- .../ControlCatalog.iOS.csproj | 10 ----- samples/ControlCatalog.iOS/packages.config | 17 -------- samples/ControlCatalog/ControlCatalog.csproj | 9 ---- samples/ControlCatalog/packages.config | 13 +----- .../TestApplication/TestApplication.csproj | 8 +++- samples/TestApplication/packages.config | 2 +- samples/VirtualizationTest/App.config | 8 ++-- .../VirtualizationTest.csproj | 8 ++-- samples/VirtualizationTest/packages.config | 9 ++-- .../XamlTestApplication.csproj | 12 +++--- samples/XamlTestApplication/packages.config | 5 +-- .../Avalonia.AndroidTestApplication.csproj | 9 ++-- .../packages.config | 8 +--- src/Avalonia.Base/Avalonia.Base.csproj | 4 +- src/Avalonia.Base/packages.config | 2 +- .../Avalonia.Controls.csproj | 4 +- src/Avalonia.Controls/packages.config | 2 +- .../Avalonia.Logging.Serilog.csproj | 18 ++++---- src/Avalonia.Logging.Serilog/packages.config | 13 +----- src/Avalonia.Styling/Avalonia.Styling.csproj | 1 + .../Avalonia.Markup.Xaml.csproj | 4 +- .../Avalonia.Markup.Xaml/packages.config | 2 +- .../Avalonia.Skia.Android.TestApp.csproj | 4 -- .../Resources/Resource.Designer.cs | 2 - .../Avalonia.Skia.iOS.TestApp.csproj | 8 +--- .../Avalonia.Designer.csproj | 6 +-- src/Windows/Avalonia.Designer/packages.config | 2 +- .../Avalonia.Base.UnitTests.csproj | 8 +--- tests/Avalonia.Base.UnitTests/packages.config | 3 +- tests/Avalonia.Benchmarks/App.config | 2 +- .../Avalonia.Benchmarks.csproj | 43 ++++--------------- tests/Avalonia.Benchmarks/packages.config | 23 ++-------- .../Avalonia.Controls.UnitTests.csproj | 16 +++---- tests/Avalonia.Controls.UnitTests/app.config | 2 +- .../packages.config | 7 ++- .../App.config | 6 +-- .../Avalonia.DesignerSupport.TestApp.csproj | 4 +- .../Properties/Resources.Designer.cs | 42 ++++++++++-------- .../Properties/Settings.Designer.cs | 22 ++++++---- .../Avalonia.DesignerSupport.Tests.csproj | 3 +- .../Avalonia.Input.UnitTests.csproj | 8 +--- .../Avalonia.Input.UnitTests/packages.config | 3 +- .../Avalonia.Layout.UnitTests.csproj | 16 +++---- tests/Avalonia.Layout.UnitTests/app.config | 4 +- .../Avalonia.Layout.UnitTests/packages.config | 7 ++- .../Avalonia.LeakTests.csproj | 18 +++----- tests/Avalonia.LeakTests/app.config | 4 +- tests/Avalonia.LeakTests/packages.config | 9 ++-- .../Avalonia.Markup.UnitTests.csproj | 19 +++----- tests/Avalonia.Markup.UnitTests/app.config | 8 ++-- .../Avalonia.Markup.UnitTests/packages.config | 27 ++++++------ .../Avalonia.Markup.Xaml.UnitTests.csproj | 14 +++--- .../Avalonia.Markup.Xaml.UnitTests/app.config | 8 ++-- .../packages.config | 5 +-- .../Avalonia.Cairo.RenderTests.csproj | 2 +- .../Avalonia.Direct2D1.RenderTests.csproj | 2 +- .../Avalonia.Skia.RenderTests.csproj | 2 +- .../Controls/ImageTests.cs | 12 ------ .../Media/ImageBrushTests.cs | 8 +--- ...packages.Avalonia.Cairo.RenderTests.config | 2 +- ...ages.Avalonia.Direct2D1.RenderTests.config | 2 +- .../packages.Avalonia.Skia.RenderTests.config | 2 +- .../Avalonia.SceneGraph.UnitTests.csproj | 8 +--- .../packages.config | 3 +- .../Avalonia.Styling.UnitTests.csproj | 8 +--- .../packages.config | 3 +- .../Avalonia.UnitTests.csproj | 8 +--- tests/Avalonia.UnitTests/packages.config | 3 +- 73 files changed, 224 insertions(+), 396 deletions(-) delete mode 100644 samples/ControlCatalog.iOS/packages.config diff --git a/samples/BindingTest/BindingTest.csproj b/samples/BindingTest/BindingTest.csproj index 5940f358ed..3ed2671d0a 100644 --- a/samples/BindingTest/BindingTest.csproj +++ b/samples/BindingTest/BindingTest.csproj @@ -37,12 +37,12 @@ - - ..\..\packages\Serilog.2.1.0\lib\net45\Serilog.dll + + ..\..\packages\Serilog.1.5.14\lib\net45\Serilog.dll True - - ..\..\packages\Serilog.Sinks.Trace.2.0.0\lib\net45\Serilog.Sinks.Trace.dll + + ..\..\packages\Serilog.1.5.14\lib\net45\Serilog.FullNetFx.dll True diff --git a/samples/BindingTest/packages.config b/samples/BindingTest/packages.config index 96d41d13ba..3c5f85de81 100644 --- a/samples/BindingTest/packages.config +++ b/samples/BindingTest/packages.config @@ -1,8 +1,7 @@  - - - + + \ No newline at end of file diff --git a/samples/ControlCatalog.Desktop/App.config b/samples/ControlCatalog.Desktop/App.config index 2231c71e63..7ef9d715f8 100644 --- a/samples/ControlCatalog.Desktop/App.config +++ b/samples/ControlCatalog.Desktop/App.config @@ -1,13 +1,13 @@ - + - + - - + + diff --git a/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj b/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj index e363bea129..f42902b534 100644 --- a/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj +++ b/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj @@ -34,12 +34,12 @@ 4 - - ..\..\packages\Serilog.2.1.0\lib\net45\Serilog.dll + + ..\..\packages\Serilog.1.5.14\lib\net45\Serilog.dll True - - ..\..\packages\Serilog.Sinks.Trace.2.0.0\lib\net45\Serilog.Sinks.Trace.dll + + ..\..\packages\Serilog.1.5.14\lib\net45\Serilog.FullNetFx.dll True @@ -54,10 +54,10 @@ + - diff --git a/samples/ControlCatalog.Desktop/packages.config b/samples/ControlCatalog.Desktop/packages.config index 9f7215928e..b3abe6f487 100644 --- a/samples/ControlCatalog.Desktop/packages.config +++ b/samples/ControlCatalog.Desktop/packages.config @@ -1,5 +1,4 @@  - - + \ No newline at end of file diff --git a/samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj b/samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj index 73d430e2b6..0e85a4e865 100644 --- a/samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj +++ b/samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj @@ -90,18 +90,8 @@ - - - - ..\..\packages\Serilog.2.0.0\lib\netstandard1.3\Serilog.dll - True - - - ..\..\packages\Serilog.Sinks.Trace.2.0.0\lib\netstandard1.3\Serilog.Sinks.Trace.dll - True - diff --git a/samples/ControlCatalog.iOS/packages.config b/samples/ControlCatalog.iOS/packages.config deleted file mode 100644 index 7c0b68fc9a..0000000000 --- a/samples/ControlCatalog.iOS/packages.config +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/ControlCatalog/ControlCatalog.csproj b/samples/ControlCatalog/ControlCatalog.csproj index c8da292ad5..daa8b0901a 100644 --- a/samples/ControlCatalog/ControlCatalog.csproj +++ b/samples/ControlCatalog/ControlCatalog.csproj @@ -215,15 +215,6 @@ Designer - - - - - - ..\..\packages\Serilog.2.1.0\lib\netstandard1.0\Serilog.dll - True - - + \ No newline at end of file diff --git a/Avalonia.DotNetFrameworkRuntime/Properties/AssemblyInfo.cs b/Avalonia.DotNetFrameworkRuntime/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..f55d3056f6 --- /dev/null +++ b/Avalonia.DotNetFrameworkRuntime/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +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("Avalonia.DotNetFrameworkRuntime")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Avalonia.DotNetFrameworkRuntime")] +[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("4a1abb09-9047-4bd5-a4ad-a055e52c5ee0")] + +// 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")] diff --git a/Avalonia.DotNetFrameworkRuntime/packages.config b/Avalonia.DotNetFrameworkRuntime/packages.config new file mode 100644 index 0000000000..1e93a8c9e7 --- /dev/null +++ b/Avalonia.DotNetFrameworkRuntime/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Avalonia.sln b/Avalonia.sln index a67f75991a..d2b5d9c0d6 100644 --- a/Avalonia.sln +++ b/Avalonia.sln @@ -163,6 +163,8 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Avalonia.RenderTests", "tes EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VirtualizationTest", "samples\VirtualizationTest\VirtualizationTest.csproj", "{FBCAF3D0-2808-4934-8E96-3F607594517B}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.DotNetFrameworkRuntime", "Avalonia.DotNetFrameworkRuntime\Avalonia.DotNetFrameworkRuntime.csproj", "{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution src\Skia\Avalonia.Skia\Avalonia.Skia.projitems*{2f59f3d0-748d-4652-b01e-e0d954756308}*SharedItemsImports = 13 @@ -172,10 +174,9 @@ Global src\Shared\RenderHelpers\RenderHelpers.projitems*{47be08a7-5985-410b-9ffc-2264b8ea595f}*SharedItemsImports = 4 src\Skia\Avalonia.Skia\Avalonia.Skia.projitems*{47be08a7-5985-410b-9ffc-2264b8ea595f}*SharedItemsImports = 4 tests\Avalonia.RenderTests\Avalonia.RenderTests.projitems*{48840edd-24bf-495d-911e-2eb12ae75d3b}*SharedItemsImports = 13 - src\Shared\PlatformSupport\PlatformSupport.projitems*{54f237d5-a70a-4752-9656-0c70b1a7b047}*SharedItemsImports = 4 + src\Shared\PlatformSupport\PlatformSupport.projitems*{4a1abb09-9047-4bd5-a4ad-a055e52c5ee0}*SharedItemsImports = 4 samples\TestApplicationShared\TestApplicationShared.projitems*{78345174-5b52-4a14-b9fd-d5f2428137f0}*SharedItemsImports = 13 src\Shared\PlatformSupport\PlatformSupport.projitems*{7b92af71-6287-4693-9dcb-bd5b6e927e23}*SharedItemsImports = 4 - src\Shared\PlatformSupport\PlatformSupport.projitems*{811a76cf-1cf6-440f-963b-bbe31bd72a82}*SharedItemsImports = 4 src\Shared\PlatformSupport\PlatformSupport.projitems*{88060192-33d5-4932-b0f9-8bd2763e857d}*SharedItemsImports = 4 samples\TestApplicationShared\TestApplicationShared.projitems*{8c923867-8a8f-4f6b-8b80-47d9e8436166}*SharedItemsImports = 4 src\Shared\RenderHelpers\RenderHelpers.projitems*{925dd807-b651-475f-9f7c-cbeb974ce43d}*SharedItemsImports = 4 @@ -2242,6 +2243,46 @@ Global {FBCAF3D0-2808-4934-8E96-3F607594517B}.Release|Mono.Build.0 = Release|Any CPU {FBCAF3D0-2808-4934-8E96-3F607594517B}.Release|x86.ActiveCfg = Release|Any CPU {FBCAF3D0-2808-4934-8E96-3F607594517B}.Release|x86.Build.0 = Release|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Ad-Hoc|Mono.ActiveCfg = Release|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Ad-Hoc|Mono.Build.0 = Release|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Ad-Hoc|x86.ActiveCfg = Release|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Ad-Hoc|x86.Build.0 = Release|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.AppStore|Any CPU.ActiveCfg = Release|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.AppStore|Any CPU.Build.0 = Release|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.AppStore|iPhone.ActiveCfg = Release|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.AppStore|iPhone.Build.0 = Release|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.AppStore|Mono.ActiveCfg = Release|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.AppStore|Mono.Build.0 = Release|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.AppStore|x86.ActiveCfg = Release|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.AppStore|x86.Build.0 = Release|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Debug|iPhone.Build.0 = Debug|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Debug|Mono.ActiveCfg = Debug|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Debug|Mono.Build.0 = Debug|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Debug|x86.ActiveCfg = Debug|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Debug|x86.Build.0 = Debug|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Release|Any CPU.Build.0 = Release|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Release|iPhone.ActiveCfg = Release|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Release|iPhone.Build.0 = Release|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Release|Mono.ActiveCfg = Release|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Release|Mono.Build.0 = Release|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Release|x86.ActiveCfg = Release|Any CPU + {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/samples/BindingTest/BindingTest.csproj b/samples/BindingTest/BindingTest.csproj index 3ed2671d0a..1587f42ad5 100644 --- a/samples/BindingTest/BindingTest.csproj +++ b/samples/BindingTest/BindingTest.csproj @@ -93,6 +93,10 @@ + + {4a1abb09-9047-4bd5-a4ad-a055e52c5ee0} + Avalonia.DotNetFrameworkRuntime + {3e53a01a-b331-47f3-b828-4a5717e77a24} Avalonia.Markup.Xaml diff --git a/samples/ControlCatalog.Desktop/App.config b/samples/ControlCatalog.Desktop/App.config index 7ef9d715f8..2231c71e63 100644 --- a/samples/ControlCatalog.Desktop/App.config +++ b/samples/ControlCatalog.Desktop/App.config @@ -1,13 +1,13 @@ - + - + - - + + diff --git a/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj b/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj index f42902b534..18a52743e3 100644 --- a/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj +++ b/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj @@ -60,6 +60,10 @@ + + {4a1abb09-9047-4bd5-a4ad-a055e52c5ee0} + Avalonia.DotNetFrameworkRuntime + {799a7bb5-3c2c-48b6-85a7-406a12c420da} Avalonia.DesignerSupport diff --git a/samples/TestApplication/TestApplication.csproj b/samples/TestApplication/TestApplication.csproj index bb18d97766..21594da6d0 100644 --- a/samples/TestApplication/TestApplication.csproj +++ b/samples/TestApplication/TestApplication.csproj @@ -83,6 +83,10 @@ + + {4a1abb09-9047-4bd5-a4ad-a055e52c5ee0} + Avalonia.DotNetFrameworkRuntime + {FB05AC90-89BA-4F2F-A924-F37875FB547C} Avalonia.Cairo diff --git a/samples/VirtualizationTest/App.config b/samples/VirtualizationTest/App.config index 7ef9d715f8..2231c71e63 100644 --- a/samples/VirtualizationTest/App.config +++ b/samples/VirtualizationTest/App.config @@ -1,13 +1,13 @@ - + - + - - + + diff --git a/samples/VirtualizationTest/VirtualizationTest.csproj b/samples/VirtualizationTest/VirtualizationTest.csproj index 98ca3ab970..8b81a012c1 100644 --- a/samples/VirtualizationTest/VirtualizationTest.csproj +++ b/samples/VirtualizationTest/VirtualizationTest.csproj @@ -83,6 +83,10 @@ + + {4a1abb09-9047-4bd5-a4ad-a055e52c5ee0} + Avalonia.DotNetFrameworkRuntime + {d211e587-d8bc-45b9-95a4-f297c8fa5200} Avalonia.Animation diff --git a/samples/XamlTestApplication/XamlTestApplication.csproj b/samples/XamlTestApplication/XamlTestApplication.csproj index f70928c398..d07f22cffb 100644 --- a/samples/XamlTestApplication/XamlTestApplication.csproj +++ b/samples/XamlTestApplication/XamlTestApplication.csproj @@ -91,6 +91,10 @@ + + {4a1abb09-9047-4bd5-a4ad-a055e52c5ee0} + Avalonia.DotNetFrameworkRuntime + {6417e941-21bc-467b-a771-0de389353ce6} Avalonia.Markup diff --git a/src/Android/Avalonia.Android/AndroidPlatform.cs b/src/Android/Avalonia.Android/AndroidPlatform.cs index 1840e90886..7ab6bf8a3c 100644 --- a/src/Android/Avalonia.Android/AndroidPlatform.cs +++ b/src/Android/Avalonia.Android/AndroidPlatform.cs @@ -49,7 +49,7 @@ namespace Avalonia.Android public void Init(Type applicationType) { - SharedPlatform.Register(applicationType.Assembly); + StandardRuntimePlatformServices.Register(applicationType.Assembly); } public IWindowImpl CreateWindow() diff --git a/src/Avalonia.Base/Avalonia.Base.csproj b/src/Avalonia.Base/Avalonia.Base.csproj index 107c0e7071..1dfc5cf65b 100644 --- a/src/Avalonia.Base/Avalonia.Base.csproj +++ b/src/Avalonia.Base/Avalonia.Base.csproj @@ -85,7 +85,7 @@ - + diff --git a/src/Avalonia.Base/AvaloniaDisposable.cs b/src/Avalonia.Base/AvaloniaDisposable.cs index 773c7a6e67..9e43a65f26 100644 --- a/src/Avalonia.Base/AvaloniaDisposable.cs +++ b/src/Avalonia.Base/AvaloniaDisposable.cs @@ -20,7 +20,7 @@ namespace Avalonia { IsDisposed = true; #if DEBUG_DISPOSE - DisposedAt = AvaloniaLocator.Current.GetService().GetStackTrace(); + DisposedAt = AvaloniaLocator.Current.GetService().GetStackTrace(); #endif DoDispose(); } diff --git a/src/Avalonia.Base/Platform/IPclPlatformWrapper.cs b/src/Avalonia.Base/Platform/IRuntimePlatform.cs similarity index 90% rename from src/Avalonia.Base/Platform/IPclPlatformWrapper.cs rename to src/Avalonia.Base/Platform/IRuntimePlatform.cs index 2a21f20f91..63a4795a74 100644 --- a/src/Avalonia.Base/Platform/IPclPlatformWrapper.cs +++ b/src/Avalonia.Base/Platform/IRuntimePlatform.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace Avalonia.Platform { - public interface IPclPlatformWrapper + public interface IRuntimePlatform { Assembly[] GetLoadedAssemblies(); void PostThreadPoolItem(Action cb); diff --git a/src/Avalonia.Base/Threading/SingleThreadDispatcher.cs b/src/Avalonia.Base/Threading/SingleThreadDispatcher.cs index 815d95ac6e..76d47b30b0 100644 --- a/src/Avalonia.Base/Threading/SingleThreadDispatcher.cs +++ b/src/Avalonia.Base/Threading/SingleThreadDispatcher.cs @@ -33,7 +33,7 @@ namespace Avalonia.Threading } public IDisposable StartTimer(TimeSpan interval, Action tick) - => AvaloniaLocator.Current.GetService().StartSystemTimer(interval, + => AvaloniaLocator.Current.GetService().StartSystemTimer(interval, () => _timerJobRunner.Post(tick, DispatcherPriority.Normal)); public void Signal() => _evnt.Set(); @@ -50,7 +50,7 @@ namespace Avalonia.Threading public static Dispatcher StartNew(CancellationToken token) { var dispatcher = new SingleThreadDispatcher(); - AvaloniaLocator.Current.GetService().PostThreadPoolItem(() => + AvaloniaLocator.Current.GetService().PostThreadPoolItem(() => { dispatcher.MainLoop(token); }); diff --git a/src/Avalonia.Controls/AppBuilder.cs b/src/Avalonia.Controls/AppBuilder.cs index 8b3e0e731a..82698acde7 100644 --- a/src/Avalonia.Controls/AppBuilder.cs +++ b/src/Avalonia.Controls/AppBuilder.cs @@ -3,14 +3,25 @@ using System; using System.Reflection; +using Avalonia.Platform; namespace Avalonia.Controls { /// /// Initializes up platform-specific services for an . /// - public class AppBuilder + public abstract class AppBuilderBase where AppBuilder : AppBuilderBase, new() { + /// + /// Gets or sets the instance. + /// + public IRuntimePlatform RuntimePlatform { get; set; } + + /// + /// Gets or sets a method to call the initialize the runtime platform services (e. g. AssetLoader) + /// + public Action RuntimePlatformServices { get; set; } + /// /// Gets or sets the instance being initialized. /// @@ -32,6 +43,12 @@ namespace Avalonia.Controls /// public Action BeforeStartCallback { get; set; } + protected AppBuilderBase(IRuntimePlatform platform, Action platformSevices) + { + RuntimePlatform = platform; + RuntimePlatformServices = platformSevices; + } + /// /// Begin configuring an . /// @@ -57,6 +74,8 @@ namespace Avalonia.Controls }; } + protected AppBuilder Self => (AppBuilder) this; + /// /// Registers a callback to call before is called on the /// . @@ -66,7 +85,7 @@ namespace Avalonia.Controls public AppBuilder BeforeStarting(Action callback) { BeforeStartCallback = callback; - return this; + return Self; } /// @@ -77,7 +96,7 @@ namespace Avalonia.Controls where TMainWindow : Window, new() { Setup(); - BeforeStartCallback?.Invoke(this); + BeforeStartCallback?.Invoke(Self); var window = new TMainWindow(); window.Show(); @@ -91,7 +110,7 @@ namespace Avalonia.Controls public AppBuilder SetupWithoutStarting() { Setup(); - return this; + return Self; } /// @@ -102,7 +121,7 @@ namespace Avalonia.Controls public AppBuilder UseWindowingSubsystem(Action initializer) { WindowingSubsystem = initializer; - return this; + return Self; } /// @@ -120,7 +139,7 @@ namespace Avalonia.Controls public AppBuilder UseRenderingSubsystem(Action initializer) { RenderingSubsystem = initializer; - return this; + return Self; } /// @@ -140,23 +159,6 @@ namespace Avalonia.Controls init.Invoke(null, null); }; - public AppBuilder UsePlatformDetect() - { - var platformId = (int) - ((dynamic) Type.GetType("System.Environment").GetRuntimeProperty("OSVersion").GetValue(null)).Platform; - if (platformId == 4 || platformId == 6) - { - UseRenderingSubsystem("Avalonia.Cairo"); - UseWindowingSubsystem("Avalonia.Gtk"); - } - else - { - UseRenderingSubsystem("Avalonia.Direct2D1"); - UseWindowingSubsystem("Avalonia.Win32"); - } - return this; - } - /// /// Sets up the platform-speciic services for the . /// @@ -167,6 +169,11 @@ namespace Avalonia.Controls throw new InvalidOperationException("No App instance configured."); } + if (RuntimePlatformServices == null) + { + throw new InvalidOperationException("No runtime platform services configured."); + } + if (WindowingSubsystem == null) { throw new InvalidOperationException("No windowing system configured."); @@ -178,6 +185,7 @@ namespace Avalonia.Controls } Instance.RegisterServices(); + RuntimePlatformServices(); WindowingSubsystem(); RenderingSubsystem(); Instance.Initialize(); diff --git a/src/Avalonia.DesignerSupport/DesignerAssist.cs b/src/Avalonia.DesignerSupport/DesignerAssist.cs index 8787144665..95e7345227 100644 --- a/src/Avalonia.DesignerSupport/DesignerAssist.cs +++ b/src/Avalonia.DesignerSupport/DesignerAssist.cs @@ -37,8 +37,11 @@ namespace Avalonia.DesignerSupport { Design.IsDesignMode = true; Api = new DesignerApi(shared) {UpdateXaml = UpdateXaml, UpdateXaml2 = UpdateXaml2, SetScalingFactor = SetScalingFactor}; - var plat = (IPclPlatformWrapper) Activator.CreateInstance(Assembly.Load(new AssemblyName("Avalonia.Win32")) - .DefinedTypes.First(typeof (IPclPlatformWrapper).GetTypeInfo().IsAssignableFrom).AsType()); + + var runtimeAssembly = Assembly.Load(new AssemblyName("Avalonia.DotNetFrameworkRuntime")); + + var plat = (IRuntimePlatform) Activator.CreateInstance(runtimeAssembly + .DefinedTypes.First(typeof (IRuntimePlatform).GetTypeInfo().IsAssignableFrom).AsType()); TypeInfo app = null; var asms = plat.GetLoadedAssemblies(); @@ -58,7 +61,12 @@ namespace Avalonia.DesignerSupport //Ignore, Assembly.DefinedTypes threw an exception, we can't do anything about that } } - AppBuilder.Configure(app == null ? new DesignerApp() : (Application) Activator.CreateInstance(app.AsType())) + + var builderType = runtimeAssembly.GetType("Avalonia.AppBuilder"); + + var builder = (dynamic)Activator.CreateInstance(builderType, + app == null ? new DesignerApp() : (Application) Activator.CreateInstance(app.AsType())); + builder .UseWindowingSubsystem("Avalonia.Win32") .UseRenderingSubsystem("Avalonia.Direct2D1") .SetupWithoutStarting(); diff --git a/src/Gtk/Avalonia.Cairo/CairoPlatform.cs b/src/Gtk/Avalonia.Cairo/CairoPlatform.cs index 5b85e6c68f..3b0d7d08da 100644 --- a/src/Gtk/Avalonia.Cairo/CairoPlatform.cs +++ b/src/Gtk/Avalonia.Cairo/CairoPlatform.cs @@ -12,7 +12,7 @@ namespace Avalonia { public static class GtkApplicationExtensions { - public static AppBuilder UseCairo(this AppBuilder builder) + public static T UseCairo(this T builder) where T : AppBuilderBase, new() { builder.RenderingSubsystem = Avalonia.Cairo.CairoPlatform.Initialize; return builder; diff --git a/src/Gtk/Avalonia.Gtk/Avalonia.Gtk.csproj b/src/Gtk/Avalonia.Gtk/Avalonia.Gtk.csproj index fe075bca77..2a47aa99fa 100644 --- a/src/Gtk/Avalonia.Gtk/Avalonia.Gtk.csproj +++ b/src/Gtk/Avalonia.Gtk/Avalonia.Gtk.csproj @@ -95,5 +95,4 @@ - \ No newline at end of file diff --git a/src/Gtk/Avalonia.Gtk/GtkPlatform.cs b/src/Gtk/Avalonia.Gtk/GtkPlatform.cs index 4169f5949d..c8246fc9f5 100644 --- a/src/Gtk/Avalonia.Gtk/GtkPlatform.cs +++ b/src/Gtk/Avalonia.Gtk/GtkPlatform.cs @@ -8,14 +8,13 @@ using Avalonia.Controls.Platform; using Avalonia.Input.Platform; using Avalonia.Input; using Avalonia.Platform; -using Avalonia.Shared.PlatformSupport; using Avalonia.Controls; namespace Avalonia { public static class GtkApplicationExtensions { - public static AppBuilder UseGtk(this AppBuilder builder) + public static T UseGtk(this T builder) where T : AppBuilderBase, new() { builder.WindowingSubsystem = Avalonia.Gtk.GtkPlatform.Initialize; return builder; @@ -56,7 +55,6 @@ namespace Avalonia.Gtk .Bind().ToConstant(s_instance) .Bind().ToSingleton() .Bind().ToConstant(s_instance); - SharedPlatform.Register(); _uiThread = Thread.CurrentThread; } diff --git a/src/Markup/Avalonia.Markup.Xaml/Context/AvaloniaNamespaceRegistry.cs b/src/Markup/Avalonia.Markup.Xaml/Context/AvaloniaNamespaceRegistry.cs index 11205972fe..b591654621 100644 --- a/src/Markup/Avalonia.Markup.Xaml/Context/AvaloniaNamespaceRegistry.cs +++ b/src/Markup/Avalonia.Markup.Xaml/Context/AvaloniaNamespaceRegistry.cs @@ -168,7 +168,7 @@ namespace Avalonia.Markup.Xaml.Context private void ScanNewAssemblies() { IEnumerable assemblies = AvaloniaLocator.Current - .GetService() + .GetService() ?.GetLoadedAssemblies(); if (assemblies != null) diff --git a/src/Shared/PlatformSupport/PlatformSupport.projitems b/src/Shared/PlatformSupport/PlatformSupport.projitems index 0bf2184e09..a9b6a8fa2a 100644 --- a/src/Shared/PlatformSupport/PlatformSupport.projitems +++ b/src/Shared/PlatformSupport/PlatformSupport.projitems @@ -1,4 +1,4 @@ - + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) @@ -10,7 +10,7 @@ - - + + \ No newline at end of file diff --git a/src/Shared/PlatformSupport/PclPlatformWrapper.cs b/src/Shared/PlatformSupport/StandardRuntimePlatform.cs similarity index 93% rename from src/Shared/PlatformSupport/PclPlatformWrapper.cs rename to src/Shared/PlatformSupport/StandardRuntimePlatform.cs index ba705c7634..9c0b7bcc73 100644 --- a/src/Shared/PlatformSupport/PclPlatformWrapper.cs +++ b/src/Shared/PlatformSupport/StandardRuntimePlatform.cs @@ -10,7 +10,7 @@ using Avalonia.Platform; namespace Avalonia.Shared.PlatformSupport { - internal class PclPlatformWrapper : IPclPlatformWrapper + internal class StandardRuntimePlatform : IRuntimePlatform { public Assembly[] GetLoadedAssemblies() => AppDomain.CurrentDomain.GetAssemblies(); public void PostThreadPoolItem(Action cb) => ThreadPool.UnsafeQueueUserWorkItem(_ => cb(), null); @@ -23,6 +23,8 @@ namespace Avalonia.Shared.PlatformSupport return Disposable.Create(() => timer.Dispose()); } + + public string GetStackTrace() => Environment.StackTrace; } } \ No newline at end of file diff --git a/src/Shared/PlatformSupport/SharedPlatform.cs b/src/Shared/PlatformSupport/StandardRuntimePlatformServices.cs similarity index 74% rename from src/Shared/PlatformSupport/SharedPlatform.cs rename to src/Shared/PlatformSupport/StandardRuntimePlatformServices.cs index 0db01367bb..70601fdf4a 100644 --- a/src/Shared/PlatformSupport/SharedPlatform.cs +++ b/src/Shared/PlatformSupport/StandardRuntimePlatformServices.cs @@ -6,12 +6,12 @@ using Avalonia.Platform; namespace Avalonia.Shared.PlatformSupport { - static class SharedPlatform + static class StandardRuntimePlatformServices { public static void Register(Assembly assembly = null) { AvaloniaLocator.CurrentMutable - .Bind().ToSingleton() + .Bind().ToSingleton() .Bind().ToConstant(new AssetLoader(assembly)); } } diff --git a/src/Skia/Avalonia.Skia/SkiaPlatform.cs b/src/Skia/Avalonia.Skia/SkiaPlatform.cs index 1d93089e45..3f9e49d3c3 100644 --- a/src/Skia/Avalonia.Skia/SkiaPlatform.cs +++ b/src/Skia/Avalonia.Skia/SkiaPlatform.cs @@ -8,7 +8,7 @@ namespace Avalonia { public static class SkiaApplicationExtensions { - public static AppBuilder UseSkia(this AppBuilder builder) + public static T UseSkia(this T builder) where T : AppBuilderBase, new() { builder.RenderingSubsystem = Avalonia.Skia.SkiaPlatform.Initialize; return builder; diff --git a/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs b/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs index 6ad64aced1..10f32861e8 100644 --- a/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs +++ b/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs @@ -12,7 +12,7 @@ namespace Avalonia { public static class Direct2DApplicationExtensions { - public static AppBuilder UseDirect2D1(this AppBuilder builder) + public static T UseDirect2D1(this T builder) where T : AppBuilderBase, new() { builder.RenderingSubsystem = Avalonia.Direct2D1.Direct2D1Platform.Initialize; return builder; diff --git a/src/Windows/Avalonia.Win32/Avalonia.Win32.csproj b/src/Windows/Avalonia.Win32/Avalonia.Win32.csproj index e9627e2033..3fdde9339f 100644 --- a/src/Windows/Avalonia.Win32/Avalonia.Win32.csproj +++ b/src/Windows/Avalonia.Win32/Avalonia.Win32.csproj @@ -114,7 +114,6 @@ - - \ No newline at end of file + From c08673fed5c154d95d23e264d872dd24c345c477 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Wed, 31 Aug 2016 01:02:21 +0300 Subject: [PATCH 40/46] Fix for layout --- src/Avalonia.Controls/EmbeddableControlRoot.cs | 1 + src/Avalonia.Controls/Platform/PlatformManager.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/EmbeddableControlRoot.cs b/src/Avalonia.Controls/EmbeddableControlRoot.cs index 02a34433a7..fa0d7ab6e7 100644 --- a/src/Avalonia.Controls/EmbeddableControlRoot.cs +++ b/src/Avalonia.Controls/EmbeddableControlRoot.cs @@ -46,6 +46,7 @@ namespace Avalonia.Controls protected override Size MeasureOverride(Size availableSize) { + base.MeasureOverride(PlatformImpl.ClientSize); return PlatformImpl.ClientSize; } diff --git a/src/Avalonia.Controls/Platform/PlatformManager.cs b/src/Avalonia.Controls/Platform/PlatformManager.cs index 339b2356f3..e57eb21b91 100644 --- a/src/Avalonia.Controls/Platform/PlatformManager.cs +++ b/src/Avalonia.Controls/Platform/PlatformManager.cs @@ -43,7 +43,7 @@ namespace Avalonia.Controls.Platform return s_designerMode ? platform.CreateEmbeddableWindow() : platform.CreateWindow(); } - public static IWindowImpl CreateEmbeddableWindow() + public static IEmbeddableWindowImpl CreateEmbeddableWindow() { var platform = AvaloniaLocator.Current.GetService(); if (platform == null) From d1ac5a40022077f61f31b217f87e014f46eee231 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Wed, 31 Aug 2016 01:35:57 +0300 Subject: [PATCH 41/46] Code cleanup --- samples/ControlCatalog.Desktop/Program.cs | 4 ++-- samples/ControlCatalog/ControlCatalog.csproj | 6 +++--- .../{ControlCatalogControl.xaml => MainView.xaml} | 0 ...ntrolCatalogControl.xaml.cs => MainView.xaml.cs} | 4 ++-- samples/ControlCatalog/MainWindow.xaml | 2 +- samples/ControlCatalog/MainWindow.xaml.cs | 2 ++ samples/interop/GtkInteropDemo/MainWindow.cs | 4 +++- .../WindowsInteropTest/EmbedToWinFormsDemo.cs | 2 +- .../WindowsInteropTest/EmbedToWpfDemo.xaml.cs | 2 +- src/Avalonia.Controls/Avalonia.Controls.csproj | 2 +- .../{ => Embedding}/EmbeddableControlRoot.cs | 7 +------ src/Avalonia.Controls/Properties/AssemblyInfo.cs | 1 + src/Gtk/Avalonia.Cairo/RenderTarget.cs | 9 +++++---- src/Gtk/Avalonia.Gtk/EmbeddableImpl.cs | 13 ++----------- .../Embedding/GtkAvaloniaControlHost.cs | 9 +-------- src/Gtk/Avalonia.Gtk/WindowImplBase.cs | 13 ------------- .../Embedding/WinFormsAvaloniaControlHost.cs | 1 + 17 files changed, 27 insertions(+), 54 deletions(-) rename samples/ControlCatalog/{ControlCatalogControl.xaml => MainView.xaml} (100%) rename samples/ControlCatalog/{ControlCatalogControl.xaml.cs => MainView.xaml.cs} (75%) rename src/Avalonia.Controls/{ => Embedding}/EmbeddableControlRoot.cs (94%) diff --git a/samples/ControlCatalog.Desktop/Program.cs b/samples/ControlCatalog.Desktop/Program.cs index d039cce83c..b67c5ea51d 100644 --- a/samples/ControlCatalog.Desktop/Program.cs +++ b/samples/ControlCatalog.Desktop/Program.cs @@ -16,8 +16,8 @@ namespace ControlCatalog // TODO: Make this work with GTK/Skia/Cairo depending on command-line args // again. - AppBuilder.Configure().UseGtk().UseCairo() - //.UsePlatformDetect() + AppBuilder.Configure() + .UsePlatformDetect() .Start(); } diff --git a/samples/ControlCatalog/ControlCatalog.csproj b/samples/ControlCatalog/ControlCatalog.csproj index 7761d792ad..63c82d9e8a 100644 --- a/samples/ControlCatalog/ControlCatalog.csproj +++ b/samples/ControlCatalog/ControlCatalog.csproj @@ -38,7 +38,7 @@ Designer - + Designer @@ -88,8 +88,8 @@ App.xaml - - ControlCatalogControl.xaml + + MainView.xaml MainWindow.xaml diff --git a/samples/ControlCatalog/ControlCatalogControl.xaml b/samples/ControlCatalog/MainView.xaml similarity index 100% rename from samples/ControlCatalog/ControlCatalogControl.xaml rename to samples/ControlCatalog/MainView.xaml diff --git a/samples/ControlCatalog/ControlCatalogControl.xaml.cs b/samples/ControlCatalog/MainView.xaml.cs similarity index 75% rename from samples/ControlCatalog/ControlCatalogControl.xaml.cs rename to samples/ControlCatalog/MainView.xaml.cs index 062a6665a8..2e1f7d38b2 100644 --- a/samples/ControlCatalog/ControlCatalogControl.xaml.cs +++ b/samples/ControlCatalog/MainView.xaml.cs @@ -4,9 +4,9 @@ using Avalonia.Markup.Xaml; namespace ControlCatalog { - public class ControlCatalogControl : UserControl + public class MainView : UserControl { - public ControlCatalogControl() + public MainView() { this.InitializeComponent(); } diff --git a/samples/ControlCatalog/MainWindow.xaml b/samples/ControlCatalog/MainWindow.xaml index a46a0bfdd9..f39beced1a 100644 --- a/samples/ControlCatalog/MainWindow.xaml +++ b/samples/ControlCatalog/MainWindow.xaml @@ -2,5 +2,5 @@ Title="Avalonia Control Gallery" Icon="resm:ControlCatalog.Assets.test_icon.ico?assembly=ControlCatalog" xmlns:local="clr-namespace:ControlCatalog;assembly=ControlCatalog"> - + \ No newline at end of file diff --git a/samples/ControlCatalog/MainWindow.xaml.cs b/samples/ControlCatalog/MainWindow.xaml.cs index c7c61e2b4e..41ba013c16 100644 --- a/samples/ControlCatalog/MainWindow.xaml.cs +++ b/samples/ControlCatalog/MainWindow.xaml.cs @@ -20,6 +20,8 @@ namespace ControlCatalog var theme = new Avalonia.Themes.Default.DefaultTheme(); theme.FindResource("Button"); AvaloniaXamlLoader.Load(this); + + PointerPressed += delegate { Measure(new Size(1, 1)); }; } } } diff --git a/samples/interop/GtkInteropDemo/MainWindow.cs b/samples/interop/GtkInteropDemo/MainWindow.cs index 2d7521cd8c..2c193f24e8 100644 --- a/samples/interop/GtkInteropDemo/MainWindow.cs +++ b/samples/interop/GtkInteropDemo/MainWindow.cs @@ -19,7 +19,9 @@ namespace GtkInteropDemo left.Add(new Button("I'm GTK button")); left.Add(new Calendar()); root.PackEnd(left, false, false, 0); - root.PackStart(new GtkAvaloniaControlHost() {Content = new ControlCatalogControl()}, true, true, 0); + var host = new GtkAvaloniaControlHost() {Content = new MainView()}; + host.SetSizeRequest(600, 600); + root.PackStart(host, true, true, 0); Add(root); ShowAll(); diff --git a/samples/interop/WindowsInteropTest/EmbedToWinFormsDemo.cs b/samples/interop/WindowsInteropTest/EmbedToWinFormsDemo.cs index 1aa271d9b1..bc627f57ce 100644 --- a/samples/interop/WindowsInteropTest/EmbedToWinFormsDemo.cs +++ b/samples/interop/WindowsInteropTest/EmbedToWinFormsDemo.cs @@ -17,7 +17,7 @@ namespace WindowsInteropTest public EmbedToWinFormsDemo() { InitializeComponent(); - avaloniaHost.Content = new ControlCatalogControl(); + avaloniaHost.Content = new MainView(); } } } diff --git a/samples/interop/WindowsInteropTest/EmbedToWpfDemo.xaml.cs b/samples/interop/WindowsInteropTest/EmbedToWpfDemo.xaml.cs index 2486bc932d..e60c9ced0a 100644 --- a/samples/interop/WindowsInteropTest/EmbedToWpfDemo.xaml.cs +++ b/samples/interop/WindowsInteropTest/EmbedToWpfDemo.xaml.cs @@ -25,7 +25,7 @@ namespace WindowsInteropTest public EmbedToWpfDemo() { InitializeComponent(); - Host.Content = new ControlCatalogControl(); + Host.Content = new MainView(); } } } diff --git a/src/Avalonia.Controls/Avalonia.Controls.csproj b/src/Avalonia.Controls/Avalonia.Controls.csproj index 925b38ec9d..86c2fe2408 100644 --- a/src/Avalonia.Controls/Avalonia.Controls.csproj +++ b/src/Avalonia.Controls/Avalonia.Controls.csproj @@ -56,7 +56,7 @@ - + diff --git a/src/Avalonia.Controls/EmbeddableControlRoot.cs b/src/Avalonia.Controls/Embedding/EmbeddableControlRoot.cs similarity index 94% rename from src/Avalonia.Controls/EmbeddableControlRoot.cs rename to src/Avalonia.Controls/Embedding/EmbeddableControlRoot.cs index fa0d7ab6e7..fc58e751f4 100644 --- a/src/Avalonia.Controls/EmbeddableControlRoot.cs +++ b/src/Avalonia.Controls/Embedding/EmbeddableControlRoot.cs @@ -1,15 +1,11 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Avalonia.Controls.Platform; using Avalonia.Input; using Avalonia.Layout; using Avalonia.Platform; using Avalonia.Styling; -namespace Avalonia.Controls +namespace Avalonia.Controls.Embedding { public class EmbeddableControlRoot : TopLevel, IStyleable, IFocusScope, INameScope, IDisposable { @@ -33,7 +29,6 @@ namespace Avalonia.Controls LayoutManager.Instance.ExecuteInitialLayoutPass(this); } - private void EnsureInitialized() { if (!this.IsInitialized) diff --git a/src/Avalonia.Controls/Properties/AssemblyInfo.cs b/src/Avalonia.Controls/Properties/AssemblyInfo.cs index f87897267b..ae8c88f7e8 100644 --- a/src/Avalonia.Controls/Properties/AssemblyInfo.cs +++ b/src/Avalonia.Controls/Properties/AssemblyInfo.cs @@ -11,6 +11,7 @@ using Avalonia.Metadata; [assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia")] [assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Controls")] +[assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Controls.Embedding")] [assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Controls.Presenters")] [assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Controls.Primitives")] [assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Controls.Shapes")] diff --git a/src/Gtk/Avalonia.Cairo/RenderTarget.cs b/src/Gtk/Avalonia.Cairo/RenderTarget.cs index cfa51852d9..d285986762 100644 --- a/src/Gtk/Avalonia.Cairo/RenderTarget.cs +++ b/src/Gtk/Avalonia.Cairo/RenderTarget.cs @@ -49,17 +49,18 @@ namespace Avalonia.Cairo /// /// A surface wrapped in an . public DrawingContext CreateDrawingContext() => new DrawingContext(CreateMediaDrawingContext()); + public IDrawingContextImpl CreateMediaDrawingContext() { - if(_window!=null) + if (_window != null) return new Media.DrawingContext(_window.GdkWindow); if (_surface != null) return new Media.DrawingContext(_surface); - if(_area!=null) + if (_area != null) return new Media.DrawingContext(_area.GdkWindow); - throw new InvalidOperationException(); + throw new InvalidOperationException("Unspecified render target"); } - + public void Dispose() => _surface?.Dispose(); } } diff --git a/src/Gtk/Avalonia.Gtk/EmbeddableImpl.cs b/src/Gtk/Avalonia.Gtk/EmbeddableImpl.cs index fdac509e3f..62b2513856 100644 --- a/src/Gtk/Avalonia.Gtk/EmbeddableImpl.cs +++ b/src/Gtk/Avalonia.Gtk/EmbeddableImpl.cs @@ -24,7 +24,6 @@ namespace Avalonia.Gtk public EmbeddableImpl() : this(new PlatformHandleAwareDrawingArea()) { - } private void Plug_SizeAllocated(object o, SizeAllocatedArgs args) @@ -35,45 +34,37 @@ namespace Avalonia.Gtk public override Size ClientSize { get { return new Size(Widget.Allocation.Width, Widget.Allocation.Height); } - set { } + set {} } //Stubs are needed for future GTK designer embedding support public override void SetTitle(string title) { - } public override IDisposable ShowDialog() => Disposable.Create(() => { }); public override void SetSystemDecorations(bool enabled) { - } public override void SetIcon(IWindowIconImpl icon) { - } public override void BeginMoveDrag() { - } public override void BeginResizeDrag(WindowEdge edge) { - } public override Point Position { get { return new Point(); } - set - { - - } + set {} } } } diff --git a/src/Gtk/Avalonia.Gtk/Embedding/GtkAvaloniaControlHost.cs b/src/Gtk/Avalonia.Gtk/Embedding/GtkAvaloniaControlHost.cs index 07c211d32c..b29a5a1be6 100644 --- a/src/Gtk/Avalonia.Gtk/Embedding/GtkAvaloniaControlHost.cs +++ b/src/Gtk/Avalonia.Gtk/Embedding/GtkAvaloniaControlHost.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Avalonia.Controls; +using Avalonia.Controls.Embedding; using Avalonia.Diagnostics; using Avalonia.Layout; using Avalonia.Platform; @@ -38,14 +39,6 @@ namespace Avalonia.Gtk.Embedding } } - protected override void OnSizeRequested(ref Requisition requisition) - { - requisition.Width = 700; - requisition.Height = 500; - - } - - IntPtr IPlatformHandle.Handle => PlatformHandleAwareWindow.GetNativeWindow(GdkWindow); string IPlatformHandle.HandleDescriptor => "HWND"; diff --git a/src/Gtk/Avalonia.Gtk/WindowImplBase.cs b/src/Gtk/Avalonia.Gtk/WindowImplBase.cs index b81387a678..c0020f5e6f 100644 --- a/src/Gtk/Avalonia.Gtk/WindowImplBase.cs +++ b/src/Gtk/Avalonia.Gtk/WindowImplBase.cs @@ -29,8 +29,6 @@ namespace Avalonia.Gtk private uint _lastKeyEventTimestamp; private static readonly Gdk.Cursor DefaultCursor = new Gdk.Cursor(CursorType.LeftPtr); - - protected WindowImplBase(Gtk.Widget window) { @@ -113,10 +111,6 @@ namespace Avalonia.Gtk public double Scaling => 1; - - - - public Action Activated { get; set; } public Action Closed { get; set; } @@ -155,7 +149,6 @@ namespace Avalonia.Gtk { int x, y; _window.GdkWindow.GetDeskrelativeOrigin(out x, out y); - return new Point(point.X + x, point.Y + y); } @@ -182,7 +175,6 @@ namespace Avalonia.Gtk public abstract void BeginResizeDrag(WindowEdge edge); public abstract Point Position { get; set; } - void ITopLevelImpl.Activate() { _window.Activate(); @@ -251,8 +243,6 @@ namespace Avalonia.Gtk Input(e); } - - void OnDestroyed(object sender, EventArgs eventArgs) { Closed(); @@ -278,7 +268,6 @@ namespace Avalonia.Gtk ProcessKeyEvent(args.Event); } - void OnKeyReleaseEvent(object o, Gtk.KeyReleaseEventArgs args) { args.RetVal = true; @@ -313,8 +302,6 @@ namespace Avalonia.Gtk args.RetVal = true; } - - public void Dispose() { _window.Dispose(); diff --git a/src/Windows/Avalonia.Win32/Embedding/WinFormsAvaloniaControlHost.cs b/src/Windows/Avalonia.Win32/Embedding/WinFormsAvaloniaControlHost.cs index fa9f018d18..3b52090493 100644 --- a/src/Windows/Avalonia.Win32/Embedding/WinFormsAvaloniaControlHost.cs +++ b/src/Windows/Avalonia.Win32/Embedding/WinFormsAvaloniaControlHost.cs @@ -2,6 +2,7 @@ using System.ComponentModel; using System.Windows.Forms; using Avalonia.Controls; +using Avalonia.Controls.Embedding; using Avalonia.Input; using Avalonia.VisualTree; using Avalonia.Win32.Interop; From fa2c3ab4a8a5b1a9b3faf133548f60e8eff15a46 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Wed, 31 Aug 2016 01:43:37 +0300 Subject: [PATCH 42/46] Fixed keyboard focus for gtk --- .../Embedding/GtkAvaloniaControlHost.cs | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/Gtk/Avalonia.Gtk/Embedding/GtkAvaloniaControlHost.cs b/src/Gtk/Avalonia.Gtk/Embedding/GtkAvaloniaControlHost.cs index b29a5a1be6..5594a3c13f 100644 --- a/src/Gtk/Avalonia.Gtk/Embedding/GtkAvaloniaControlHost.cs +++ b/src/Gtk/Avalonia.Gtk/Embedding/GtkAvaloniaControlHost.cs @@ -6,8 +6,11 @@ using System.Threading.Tasks; using Avalonia.Controls; using Avalonia.Controls.Embedding; using Avalonia.Diagnostics; +using Avalonia.Input; +using Avalonia.Interactivity; using Avalonia.Layout; using Avalonia.Platform; +using Avalonia.VisualTree; using Gdk; using Gtk; @@ -21,6 +24,34 @@ namespace Avalonia.Gtk.Embedding { _root = new EmbeddableControlRoot(new EmbeddableImpl(this)); _root.Prepare(); + if (_root.IsFocused) + Unfocus(); + _root.GotFocus += RootGotFocus; + CanFocus = true; + } + + void Unfocus() + { + var focused = (IVisual)FocusManager.Instance.Current; + if (focused == null) + return; + while (focused.VisualParent != null) + focused = focused.VisualParent; + + if (focused == _root) + KeyboardDevice.Instance.SetFocusedElement(null, NavigationMethod.Unspecified, InputModifiers.None); + } + + protected override bool OnFocusOutEvent(EventFocus evnt) + { + Unfocus(); + return false; + } + + private void RootGotFocus(object sender, RoutedEventArgs e) + { + this.HasFocus = true; + GdkWindow.Focus(0); } private Control _content; From 3c660eb21aebd49e28e73d2d45046c0816e74e5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Wed, 31 Aug 2016 15:22:22 +0200 Subject: [PATCH 43/46] Added missing DotNetFrameworkRuntime reference --- samples/interop/GtkInteropDemo/GtkInteropDemo.csproj | 4 ++++ samples/interop/WindowsInteropTest/WindowsInteropTest.csproj | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/samples/interop/GtkInteropDemo/GtkInteropDemo.csproj b/samples/interop/GtkInteropDemo/GtkInteropDemo.csproj index 9f69090ce5..0d87af8838 100644 --- a/samples/interop/GtkInteropDemo/GtkInteropDemo.csproj +++ b/samples/interop/GtkInteropDemo/GtkInteropDemo.csproj @@ -92,6 +92,10 @@ {7062ae20-5dcc-4442-9645-8195bdece63e} Avalonia.Diagnostics + + {4a1abb09-9047-4bd5-a4ad-a055e52c5ee0} + Avalonia.DotNetFrameworkRuntime + {62024b2d-53eb-4638-b26b-85eeaa54866e} Avalonia.Input diff --git a/samples/interop/WindowsInteropTest/WindowsInteropTest.csproj b/samples/interop/WindowsInteropTest/WindowsInteropTest.csproj index 24f090a545..827f73d7ae 100644 --- a/samples/interop/WindowsInteropTest/WindowsInteropTest.csproj +++ b/samples/interop/WindowsInteropTest/WindowsInteropTest.csproj @@ -116,6 +116,10 @@ {7062ae20-5dcc-4442-9645-8195bdece63e} Avalonia.Diagnostics + + {4a1abb09-9047-4bd5-a4ad-a055e52c5ee0} + Avalonia.DotNetFrameworkRuntime + {62024b2d-53eb-4638-b26b-85eeaa54866e} Avalonia.Input From 54dd77c66cf186f313ae0366652b458323af0720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Wed, 31 Aug 2016 15:27:06 +0200 Subject: [PATCH 44/46] Disable windows related projects for mono builds --- Avalonia.sln | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Avalonia.sln b/Avalonia.sln index 1878d07234..67fc548fed 100644 --- a/Avalonia.sln +++ b/Avalonia.sln @@ -168,6 +168,7 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsInteropTest", "samples\interop\WindowsInteropTest\WindowsInteropTest.csproj", "{C7A69145-60B6-4882-97D6-A3921DD43978}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GtkInteropDemo", "samples\interop\GtkInteropDemo\GtkInteropDemo.csproj", "{BD7F352C-6DC1-4740-BAF2-2D34A038728C}" +EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.DotNetFrameworkRuntime", "src\Avalonia.DotNetFrameworkRuntime\Avalonia.DotNetFrameworkRuntime.csproj", "{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}" EndProject Global @@ -2252,7 +2253,6 @@ Global {C7A69145-60B6-4882-97D6-A3921DD43978}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU {C7A69145-60B6-4882-97D6-A3921DD43978}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU {C7A69145-60B6-4882-97D6-A3921DD43978}.Ad-Hoc|Mono.ActiveCfg = Release|Any CPU - {C7A69145-60B6-4882-97D6-A3921DD43978}.Ad-Hoc|Mono.Build.0 = Release|Any CPU {C7A69145-60B6-4882-97D6-A3921DD43978}.Ad-Hoc|x86.ActiveCfg = Release|Any CPU {C7A69145-60B6-4882-97D6-A3921DD43978}.Ad-Hoc|x86.Build.0 = Release|Any CPU {C7A69145-60B6-4882-97D6-A3921DD43978}.AppStore|Any CPU.ActiveCfg = Release|Any CPU @@ -2262,7 +2262,6 @@ Global {C7A69145-60B6-4882-97D6-A3921DD43978}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU {C7A69145-60B6-4882-97D6-A3921DD43978}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU {C7A69145-60B6-4882-97D6-A3921DD43978}.AppStore|Mono.ActiveCfg = Release|Any CPU - {C7A69145-60B6-4882-97D6-A3921DD43978}.AppStore|Mono.Build.0 = Release|Any CPU {C7A69145-60B6-4882-97D6-A3921DD43978}.AppStore|x86.ActiveCfg = Release|Any CPU {C7A69145-60B6-4882-97D6-A3921DD43978}.AppStore|x86.Build.0 = Release|Any CPU {C7A69145-60B6-4882-97D6-A3921DD43978}.Debug|Any CPU.ActiveCfg = Debug|Any CPU @@ -2272,7 +2271,6 @@ Global {C7A69145-60B6-4882-97D6-A3921DD43978}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU {C7A69145-60B6-4882-97D6-A3921DD43978}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU {C7A69145-60B6-4882-97D6-A3921DD43978}.Debug|Mono.ActiveCfg = Debug|Any CPU - {C7A69145-60B6-4882-97D6-A3921DD43978}.Debug|Mono.Build.0 = Debug|Any CPU {C7A69145-60B6-4882-97D6-A3921DD43978}.Debug|x86.ActiveCfg = Debug|Any CPU {C7A69145-60B6-4882-97D6-A3921DD43978}.Debug|x86.Build.0 = Debug|Any CPU {C7A69145-60B6-4882-97D6-A3921DD43978}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -2282,7 +2280,6 @@ Global {C7A69145-60B6-4882-97D6-A3921DD43978}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {C7A69145-60B6-4882-97D6-A3921DD43978}.Release|iPhoneSimulator.Build.0 = Release|Any CPU {C7A69145-60B6-4882-97D6-A3921DD43978}.Release|Mono.ActiveCfg = Release|Any CPU - {C7A69145-60B6-4882-97D6-A3921DD43978}.Release|Mono.Build.0 = Release|Any CPU {C7A69145-60B6-4882-97D6-A3921DD43978}.Release|x86.ActiveCfg = Release|Any CPU {C7A69145-60B6-4882-97D6-A3921DD43978}.Release|x86.Build.0 = Release|Any CPU {BD7F352C-6DC1-4740-BAF2-2D34A038728C}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU From 8b035ffb2b90edb447bdb584d9da754b714ce659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Wed, 31 Aug 2016 15:34:29 +0200 Subject: [PATCH 45/46] Renamed typeparam to fix build --- src/Avalonia.Controls/AppBuilder.cs | 39 +++++++++++++++-------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/Avalonia.Controls/AppBuilder.cs b/src/Avalonia.Controls/AppBuilder.cs index 82698acde7..5afbb444ee 100644 --- a/src/Avalonia.Controls/AppBuilder.cs +++ b/src/Avalonia.Controls/AppBuilder.cs @@ -10,7 +10,8 @@ namespace Avalonia.Controls /// /// Initializes up platform-specific services for an . /// - public abstract class AppBuilderBase where AppBuilder : AppBuilderBase, new() + /// + public abstract class AppBuilderBase where TAppBuilder : AppBuilderBase, new() { /// /// Gets or sets the instance. @@ -41,7 +42,7 @@ namespace Avalonia.Controls /// Gets or sets a method to call before is called on the /// . /// - public Action BeforeStartCallback { get; set; } + public Action BeforeStartCallback { get; set; } protected AppBuilderBase(IRuntimePlatform platform, Action platformSevices) { @@ -53,8 +54,8 @@ namespace Avalonia.Controls /// Begin configuring an . /// /// The subclass of to configure. - /// An instance. - public static AppBuilder Configure() + /// An instance. + public static TAppBuilder Configure() where TApp : Application, new() { return Configure(new TApp()); @@ -63,26 +64,26 @@ namespace Avalonia.Controls /// /// Begin configuring an . /// - /// An instance. - public static AppBuilder Configure(Application app) + /// An instance. + public static TAppBuilder Configure(Application app) { AvaloniaLocator.CurrentMutable.BindToSelf(app); - return new AppBuilder() + return new TAppBuilder() { Instance = app, }; } - protected AppBuilder Self => (AppBuilder) this; + protected TAppBuilder Self => (TAppBuilder) this; /// /// Registers a callback to call before is called on the /// . /// /// The callback. - /// An instance. - public AppBuilder BeforeStarting(Action callback) + /// An instance. + public TAppBuilder BeforeStarting(Action callback) { BeforeStartCallback = callback; return Self; @@ -107,7 +108,7 @@ namespace Avalonia.Controls /// Sets up the platform-specific services for the application, but does not run it. /// /// - public AppBuilder SetupWithoutStarting() + public TAppBuilder SetupWithoutStarting() { Setup(); return Self; @@ -117,8 +118,8 @@ namespace Avalonia.Controls /// Specifies a windowing subsystem to use. /// /// The method to call to initialize the windowing subsystem. - /// An instance. - public AppBuilder UseWindowingSubsystem(Action initializer) + /// An instance. + public TAppBuilder UseWindowingSubsystem(Action initializer) { WindowingSubsystem = initializer; return Self; @@ -128,15 +129,15 @@ namespace Avalonia.Controls /// Specifies a windowing subsystem to use. /// /// The dll in which to look for subsystem. - /// An instance. - public AppBuilder UseWindowingSubsystem(string dll) => UseWindowingSubsystem(GetInitializer(dll)); + /// An instance. + public TAppBuilder UseWindowingSubsystem(string dll) => UseWindowingSubsystem(GetInitializer(dll)); /// /// Specifies a rendering subsystem to use. /// /// The method to call to initialize the rendering subsystem. - /// An instance. - public AppBuilder UseRenderingSubsystem(Action initializer) + /// An instance. + public TAppBuilder UseRenderingSubsystem(Action initializer) { RenderingSubsystem = initializer; return Self; @@ -146,8 +147,8 @@ namespace Avalonia.Controls /// Specifies a rendering subsystem to use. /// /// The dll in which to look for subsystem. - /// An instance. - public AppBuilder UseRenderingSubsystem(string dll) => UseRenderingSubsystem(GetInitializer(dll)); + /// An instance. + public TAppBuilder UseRenderingSubsystem(string dll) => UseRenderingSubsystem(GetInitializer(dll)); static Action GetInitializer(string assemblyName) => () => { From 028c5c2f2fb156ad21d05642541e410662c4f1eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Wed, 31 Aug 2016 15:35:26 +0200 Subject: [PATCH 46/46] Renamed file name same as class --- src/Avalonia.Controls/{AppBuilder.cs => AppBuilderBase.cs} | 0 src/Avalonia.Controls/Avalonia.Controls.csproj | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename src/Avalonia.Controls/{AppBuilder.cs => AppBuilderBase.cs} (100%) diff --git a/src/Avalonia.Controls/AppBuilder.cs b/src/Avalonia.Controls/AppBuilderBase.cs similarity index 100% rename from src/Avalonia.Controls/AppBuilder.cs rename to src/Avalonia.Controls/AppBuilderBase.cs diff --git a/src/Avalonia.Controls/Avalonia.Controls.csproj b/src/Avalonia.Controls/Avalonia.Controls.csproj index 86c2fe2408..7a04e0747c 100644 --- a/src/Avalonia.Controls/Avalonia.Controls.csproj +++ b/src/Avalonia.Controls/Avalonia.Controls.csproj @@ -43,7 +43,7 @@ Properties\SharedAssemblyInfo.cs - +