Browse Source

Merge pull request #875 from kekekeks/netstandard-ftw

.NET Core support
pull/878/head
Steven Kirk 9 years ago
committed by GitHub
parent
commit
a844dceeb1
  1. 2
      .gitignore
  2. 181
      Avalonia.sln
  3. 109
      build.cake
  4. 7
      samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj
  5. 5
      src/Android/Avalonia.AndroidTestApplication/Avalonia.AndroidTestApplication.csproj
  6. 3
      src/Android/Avalonia.AndroidTestApplication/packages.config
  7. 4
      src/Avalonia.Animation/Avalonia.Animation.csproj
  8. 4
      src/Avalonia.Base/Avalonia.Base.csproj
  9. 4
      src/Avalonia.Controls/Avalonia.Controls.csproj
  10. 4
      src/Avalonia.DesignerSupport/Avalonia.DesignerSupport.csproj
  11. 4
      src/Avalonia.Diagnostics/Avalonia.Diagnostics.csproj
  12. 53
      src/Avalonia.DotNetCoreRuntime/AppBuilder.cs
  13. 89
      src/Avalonia.DotNetCoreRuntime/Avalonia.DotNetCoreRuntime.csproj
  14. 47
      src/Avalonia.DotNetCoreRuntime/NetCoreRuntimePlatform.cs
  15. 41
      src/Avalonia.DotNetCoreRuntime/RuntimeInfo.cs
  16. 11
      src/Avalonia.DotNetCoreRuntime/project.json
  17. 4
      src/Avalonia.DotNetFrameworkRuntime/Avalonia.DotNetFrameworkRuntime.csproj
  18. 4
      src/Avalonia.HtmlRenderer/Avalonia.HtmlRenderer.csproj
  19. 4
      src/Avalonia.Input/Avalonia.Input.csproj
  20. 4
      src/Avalonia.Interactivity/Avalonia.Interactivity.csproj
  21. 4
      src/Avalonia.Layout/Avalonia.Layout.csproj
  22. 4
      src/Avalonia.Logging.Serilog/Avalonia.Logging.Serilog.csproj
  23. 4
      src/Avalonia.ReactiveUI/Avalonia.ReactiveUI.csproj
  24. 4
      src/Avalonia.Styling/Avalonia.Styling.csproj
  25. 4
      src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj
  26. 4
      src/Avalonia.Visuals/Avalonia.Visuals.csproj
  27. 1
      src/Gtk/Avalonia.Gtk/Avalonia.Gtk.csproj
  28. 209
      src/Gtk/Avalonia.Gtk/Input/GtkKeyboardDevice.cs
  29. 224
      src/Gtk/Avalonia.Gtk/KeyTransform.cs
  30. 2
      src/Gtk/Avalonia.Gtk/WindowImplBase.cs
  31. 1
      src/Gtk/Avalonia.Gtk3/.gitignore
  32. 102
      src/Gtk/Avalonia.Gtk3/Avalonia.Gtk3.csproj
  33. 53
      src/Gtk/Avalonia.Gtk3/ClipboardImpl.cs
  34. 79
      src/Gtk/Avalonia.Gtk3/CursorFactory.cs
  35. 42
      src/Gtk/Avalonia.Gtk3/FramebufferManager.cs
  36. 91
      src/Gtk/Avalonia.Gtk3/GdkCursor.cs
  37. 1347
      src/Gtk/Avalonia.Gtk3/GdkKey.cs
  38. 116
      src/Gtk/Avalonia.Gtk3/Gtk3Platform.cs
  39. 63
      src/Gtk/Avalonia.Gtk3/ImageSurfaceFramebuffer.cs
  40. 129
      src/Gtk/Avalonia.Gtk3/Interop/DynLoader.cs
  41. 33
      src/Gtk/Avalonia.Gtk3/Interop/GException.cs
  42. 62
      src/Gtk/Avalonia.Gtk3/Interop/GObject.cs
  43. 64
      src/Gtk/Avalonia.Gtk3/Interop/GlibTimeout.cs
  44. 17
      src/Gtk/Avalonia.Gtk3/Interop/ICustomGtk3NativeLibraryResolver.cs
  45. 571
      src/Gtk/Avalonia.Gtk3/Interop/Native.cs
  46. 24
      src/Gtk/Avalonia.Gtk3/Interop/NativeException.cs
  47. 68
      src/Gtk/Avalonia.Gtk3/Interop/Pixbuf.cs
  48. 155
      src/Gtk/Avalonia.Gtk3/Interop/Resolver.cs
  49. 50
      src/Gtk/Avalonia.Gtk3/Interop/Signal.cs
  50. 45
      src/Gtk/Avalonia.Gtk3/Interop/Utf8Buffer.cs
  51. 20
      src/Gtk/Avalonia.Gtk3/PlatformIconLoader.cs
  52. 24
      src/Gtk/Avalonia.Gtk3/PopupImpl.cs
  53. 30
      src/Gtk/Avalonia.Gtk3/Properties/AssemblyInfo.cs
  54. 8
      src/Gtk/Avalonia.Gtk3/README.md
  55. 92
      src/Gtk/Avalonia.Gtk3/SystemDialogs.cs
  56. 334
      src/Gtk/Avalonia.Gtk3/TopLevelImpl.cs
  57. 45
      src/Gtk/Avalonia.Gtk3/WindowImpl.cs
  58. 10
      src/Gtk/Avalonia.Gtk3/project.json
  59. 5
      src/Markup/Avalonia.Markup.Xaml/Avalonia.Markup.Xaml.csproj
  60. 6
      src/Markup/Avalonia.Markup.Xaml/packages.config
  61. 6
      src/Shared/PlatformSupport/AssetLoader.cs
  62. 9
      src/Shared/PlatformSupport/StandardRuntimePlatform.cs
  63. 5
      src/Skia/Avalonia.Skia.Android/Avalonia.Skia.Android.csproj
  64. 2
      src/Skia/Avalonia.Skia.Android/packages.config
  65. 91
      src/Skia/Avalonia.Skia.Desktop.NetStandard/Avalonia.Skia.Desktop.NetStandard.csproj
  66. 11
      src/Skia/Avalonia.Skia.Desktop.NetStandard/project.json
  67. 9
      src/Skia/Avalonia.Skia.Desktop/Avalonia.Skia.Desktop.csproj
  68. 2
      src/Skia/Avalonia.Skia.Desktop/packages.config
  69. 5
      src/Skia/Avalonia.Skia.iOS/Avalonia.Skia.iOS.csproj
  70. 2
      src/Skia/Avalonia.Skia.iOS/packages.config
  71. 94
      src/Windows/Avalonia.Win32.NetStandard/Avalonia.Win32.NetStandard.csproj
  72. 19
      src/Windows/Avalonia.Win32.NetStandard/IconImpl.cs
  73. 20
      src/Windows/Avalonia.Win32.NetStandard/NativeWin32Platform.cs
  74. 12
      src/Windows/Avalonia.Win32.NetStandard/Win32Exception.cs
  75. 11
      src/Windows/Avalonia.Win32.NetStandard/project.json
  76. 31
      src/Windows/Avalonia.Win32/Avalonia.Win32.Shared.projitems
  77. 13
      src/Windows/Avalonia.Win32/Avalonia.Win32.Shared.shproj
  78. 26
      src/Windows/Avalonia.Win32/Avalonia.Win32.csproj
  79. 23
      src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs
  80. 26
      src/Windows/Avalonia.Win32/SystemDialogImpl.cs
  81. 59
      src/Windows/Avalonia.Win32/Win32Platform.cs
  82. 47
      src/Windows/Avalonia.Win32/WinFormsWin32Platform.cs
  83. 8
      src/Windows/Avalonia.Win32/WindowFramebuffer.cs
  84. 11
      src/Windows/Avalonia.Win32/WindowImpl.cs
  85. 5
      tests/Avalonia.Markup.Xaml.UnitTests/Avalonia.Markup.Xaml.UnitTests.csproj
  86. 2
      tests/Avalonia.Markup.Xaml.UnitTests/packages.config

2
.gitignore

@ -161,3 +161,5 @@ tools/
.nuget .nuget
artifacts/ artifacts/
nuget nuget
Avalonia.XBuild.sln
project.lock.json

181
Avalonia.sln

@ -128,6 +128,9 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ControlCatalog", "samples\ControlCatalog\ControlCatalog.csproj", "{D0A739B9-3C68-4BA6-A328-41606954B6BD}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ControlCatalog", "samples\ControlCatalog\ControlCatalog.csproj", "{D0A739B9-3C68-4BA6-A328-41606954B6BD}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ControlCatalog.Desktop", "samples\ControlCatalog.Desktop\ControlCatalog.Desktop.csproj", "{2B888490-D14A-4BCA-AB4B-48676FA93C9B}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ControlCatalog.Desktop", "samples\ControlCatalog.Desktop\ControlCatalog.Desktop.csproj", "{2B888490-D14A-4BCA-AB4B-48676FA93C9B}"
ProjectSection(ProjectDependencies) = postProject
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658} = {BB1F7BB5-6AD4-4776-94D9-C09D0A972658}
EndProjectSection
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ControlCatalog.iOS", "samples\ControlCatalog.iOS\ControlCatalog.iOS.csproj", "{57E0455D-D565-44BB-B069-EE1AA20F8337}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ControlCatalog.iOS", "samples\ControlCatalog.iOS\ControlCatalog.iOS.csproj", "{57E0455D-D565-44BB-B069-EE1AA20F8337}"
EndProject EndProject
@ -153,19 +156,35 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RenderTest", "samples\Rende
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ControlCatalog.Android", "samples\ControlCatalog.Android\ControlCatalog.Android.csproj", "{29132311-1848-4FD6-AE0C-4FF841151BD3}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ControlCatalog.Android", "samples\ControlCatalog.Android\ControlCatalog.Android.csproj", "{29132311-1848-4FD6-AE0C-4FF841151BD3}"
EndProject EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Avalonia.Win32.Shared", "src\Windows\Avalonia.Win32\Avalonia.Win32.Shared.shproj", "{9DEFC6B7-845B-4D8F-AFC0-D32BF0032B8C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Win32.NetStandard", "src\Windows\Avalonia.Win32.NetStandard\Avalonia.Win32.NetStandard.csproj", "{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.DotNetCoreRuntime", "src\Avalonia.DotNetCoreRuntime\Avalonia.DotNetCoreRuntime.csproj", "{7863EA94-F0FB-4386-BF8C-E5BFA761560A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Skia.Desktop.NetStandard", "src\Skia\Avalonia.Skia.Desktop.NetStandard\Avalonia.Skia.Desktop.NetStandard.csproj", "{7D2D3083-71DD-4CC9-8907-39A0D86FB322}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Gtk3", "src\Gtk\Avalonia.Gtk3\Avalonia.Gtk3.csproj", "{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}"
EndProject
Global Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\Skia\Avalonia.Skia\Avalonia.Skia.projitems*{2f59f3d0-748d-4652-b01e-e0d954756308}*SharedItemsImports = 13 src\Skia\Avalonia.Skia\Avalonia.Skia.projitems*{2f59f3d0-748d-4652-b01e-e0d954756308}*SharedItemsImports = 13
src\Shared\RenderHelpers\RenderHelpers.projitems*{3c4c0cb4-0c0f-4450-a37b-148c84ff905f}*SharedItemsImports = 13 src\Shared\RenderHelpers\RenderHelpers.projitems*{3c4c0cb4-0c0f-4450-a37b-148c84ff905f}*SharedItemsImports = 13
src\Shared\RenderHelpers\RenderHelpers.projitems*{3e908f67-5543-4879-a1dc-08eace79b3cd}*SharedItemsImports = 4 src\Shared\RenderHelpers\RenderHelpers.projitems*{3e908f67-5543-4879-a1dc-08eace79b3cd}*SharedItemsImports = 4
src\Windows\Avalonia.Win32\Avalonia.Win32.Shared.projitems*{40759a76-d0f2-464e-8000-6ff0f5c4bd7c}*SharedItemsImports = 4
src\Shared\PlatformSupport\PlatformSupport.projitems*{4488ad85-1495-4809-9aa4-ddfe0a48527e}*SharedItemsImports = 4 src\Shared\PlatformSupport\PlatformSupport.projitems*{4488ad85-1495-4809-9aa4-ddfe0a48527e}*SharedItemsImports = 4
src\Shared\RenderHelpers\RenderHelpers.projitems*{47be08a7-5985-410b-9ffc-2264b8ea595f}*SharedItemsImports = 4 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 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 tests\Avalonia.RenderTests\Avalonia.RenderTests.projitems*{48840edd-24bf-495d-911e-2eb12ae75d3b}*SharedItemsImports = 13
src\Shared\PlatformSupport\PlatformSupport.projitems*{4a1abb09-9047-4bd5-a4ad-a055e52c5ee0}*SharedItemsImports = 4 src\Shared\PlatformSupport\PlatformSupport.projitems*{4a1abb09-9047-4bd5-a4ad-a055e52c5ee0}*SharedItemsImports = 4
src\Shared\PlatformSupport\PlatformSupport.projitems*{7863ea94-f0fb-4386-bf8c-e5bfa761560a}*SharedItemsImports = 4
src\Shared\PlatformSupport\PlatformSupport.projitems*{7b92af71-6287-4693-9dcb-bd5b6e927e23}*SharedItemsImports = 4 src\Shared\PlatformSupport\PlatformSupport.projitems*{7b92af71-6287-4693-9dcb-bd5b6e927e23}*SharedItemsImports = 4
src\Shared\RenderHelpers\RenderHelpers.projitems*{7d2d3083-71dd-4cc9-8907-39a0d86fb322}*SharedItemsImports = 4
src\Skia\Avalonia.Skia\Avalonia.Skia.projitems*{7d2d3083-71dd-4cc9-8907-39a0d86fb322}*SharedItemsImports = 4
src\Windows\Avalonia.Win32\Avalonia.Win32.Shared.projitems*{811a76cf-1cf6-440f-963b-bbe31bd72a82}*SharedItemsImports = 4
src\Shared\RenderHelpers\RenderHelpers.projitems*{925dd807-b651-475f-9f7c-cbeb974ce43d}*SharedItemsImports = 4 src\Shared\RenderHelpers\RenderHelpers.projitems*{925dd807-b651-475f-9f7c-cbeb974ce43d}*SharedItemsImports = 4
src\Skia\Avalonia.Skia\Avalonia.Skia.projitems*{925dd807-b651-475f-9f7c-cbeb974ce43d}*SharedItemsImports = 4 src\Skia\Avalonia.Skia\Avalonia.Skia.projitems*{925dd807-b651-475f-9f7c-cbeb974ce43d}*SharedItemsImports = 4
src\Windows\Avalonia.Win32\Avalonia.Win32.Shared.projitems*{9defc6b7-845b-4d8f-afc0-d32bf0032b8c}*SharedItemsImports = 13
src\Shared\RenderHelpers\RenderHelpers.projitems*{bd43f7c0-396b-4aa1-bad9-dfde54d51298}*SharedItemsImports = 4 src\Shared\RenderHelpers\RenderHelpers.projitems*{bd43f7c0-396b-4aa1-bad9-dfde54d51298}*SharedItemsImports = 4
src\Skia\Avalonia.Skia\Avalonia.Skia.projitems*{bd43f7c0-396b-4aa1-bad9-dfde54d51298}*SharedItemsImports = 4 src\Skia\Avalonia.Skia\Avalonia.Skia.projitems*{bd43f7c0-396b-4aa1-bad9-dfde54d51298}*SharedItemsImports = 4
tests\Avalonia.RenderTests\Avalonia.RenderTests.projitems*{d35a9f3d-8bb0-496e-bf72-444038a7debb}*SharedItemsImports = 4 tests\Avalonia.RenderTests\Avalonia.RenderTests.projitems*{d35a9f3d-8bb0-496e-bf72-444038a7debb}*SharedItemsImports = 4
@ -2295,6 +2314,164 @@ Global
{29132311-1848-4FD6-AE0C-4FF841151BD3}.Release|x86.ActiveCfg = Release|Any CPU {29132311-1848-4FD6-AE0C-4FF841151BD3}.Release|x86.ActiveCfg = Release|Any CPU
{29132311-1848-4FD6-AE0C-4FF841151BD3}.Release|x86.Build.0 = Release|Any CPU {29132311-1848-4FD6-AE0C-4FF841151BD3}.Release|x86.Build.0 = Release|Any CPU
{29132311-1848-4FD6-AE0C-4FF841151BD3}.Release|x86.Deploy.0 = Release|Any CPU {29132311-1848-4FD6-AE0C-4FF841151BD3}.Release|x86.Deploy.0 = Release|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.Ad-Hoc|Mono.ActiveCfg = Release|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.Ad-Hoc|Mono.Build.0 = Release|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.Ad-Hoc|x86.ActiveCfg = Release|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.Ad-Hoc|x86.Build.0 = Release|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.AppStore|Any CPU.Build.0 = Release|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.AppStore|iPhone.ActiveCfg = Release|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.AppStore|iPhone.Build.0 = Release|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.AppStore|Mono.ActiveCfg = Release|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.AppStore|Mono.Build.0 = Release|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.AppStore|x86.ActiveCfg = Release|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.AppStore|x86.Build.0 = Release|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.Debug|iPhone.Build.0 = Debug|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.Debug|Mono.ActiveCfg = Debug|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.Debug|x86.ActiveCfg = Debug|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.Debug|x86.Build.0 = Debug|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.Release|Any CPU.Build.0 = Release|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.Release|iPhone.ActiveCfg = Release|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.Release|iPhone.Build.0 = Release|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.Release|Mono.ActiveCfg = Release|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.Release|x86.ActiveCfg = Release|Any CPU
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}.Release|x86.Build.0 = Release|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.Ad-Hoc|Mono.ActiveCfg = Release|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.Ad-Hoc|Mono.Build.0 = Release|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.Ad-Hoc|x86.ActiveCfg = Release|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.Ad-Hoc|x86.Build.0 = Release|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.AppStore|Any CPU.Build.0 = Release|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.AppStore|iPhone.ActiveCfg = Release|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.AppStore|iPhone.Build.0 = Release|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.AppStore|Mono.ActiveCfg = Release|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.AppStore|Mono.Build.0 = Release|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.AppStore|x86.ActiveCfg = Release|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.AppStore|x86.Build.0 = Release|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.Debug|iPhone.Build.0 = Debug|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.Debug|Mono.ActiveCfg = Debug|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.Debug|Mono.Build.0 = Debug|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.Debug|x86.ActiveCfg = Debug|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.Debug|x86.Build.0 = Debug|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.Release|Any CPU.Build.0 = Release|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.Release|iPhone.ActiveCfg = Release|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.Release|iPhone.Build.0 = Release|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.Release|Mono.ActiveCfg = Release|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.Release|Mono.Build.0 = Release|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.Release|x86.ActiveCfg = Release|Any CPU
{7863EA94-F0FB-4386-BF8C-E5BFA761560A}.Release|x86.Build.0 = Release|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.Ad-Hoc|Mono.ActiveCfg = Release|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.Ad-Hoc|Mono.Build.0 = Release|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.Ad-Hoc|x86.ActiveCfg = Release|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.Ad-Hoc|x86.Build.0 = Release|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.AppStore|Any CPU.Build.0 = Release|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.AppStore|iPhone.ActiveCfg = Release|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.AppStore|iPhone.Build.0 = Release|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.AppStore|Mono.ActiveCfg = Release|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.AppStore|Mono.Build.0 = Release|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.AppStore|x86.ActiveCfg = Release|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.AppStore|x86.Build.0 = Release|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.Debug|iPhone.Build.0 = Debug|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.Debug|Mono.ActiveCfg = Debug|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.Debug|Mono.Build.0 = Debug|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.Debug|x86.ActiveCfg = Debug|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.Debug|x86.Build.0 = Debug|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.Release|Any CPU.Build.0 = Release|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.Release|iPhone.ActiveCfg = Release|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.Release|iPhone.Build.0 = Release|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.Release|Mono.ActiveCfg = Release|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.Release|Mono.Build.0 = Release|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.Release|x86.ActiveCfg = Release|Any CPU
{7D2D3083-71DD-4CC9-8907-39A0D86FB322}.Release|x86.Build.0 = Release|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.Ad-Hoc|Mono.ActiveCfg = Release|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.Ad-Hoc|Mono.Build.0 = Release|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.Ad-Hoc|x86.ActiveCfg = Release|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.Ad-Hoc|x86.Build.0 = Release|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.AppStore|Any CPU.Build.0 = Release|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.AppStore|iPhone.ActiveCfg = Release|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.AppStore|iPhone.Build.0 = Release|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.AppStore|Mono.ActiveCfg = Release|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.AppStore|Mono.Build.0 = Release|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.AppStore|x86.ActiveCfg = Release|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.AppStore|x86.Build.0 = Release|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.Debug|iPhone.Build.0 = Debug|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.Debug|Mono.ActiveCfg = Debug|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.Debug|Mono.Build.0 = Debug|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.Debug|x86.ActiveCfg = Debug|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.Debug|x86.Build.0 = Debug|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.Release|Any CPU.Build.0 = Release|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.Release|iPhone.ActiveCfg = Release|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.Release|iPhone.Build.0 = Release|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.Release|Mono.ActiveCfg = Release|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.Release|Mono.Build.0 = Release|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.Release|x86.ActiveCfg = Release|Any CPU
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -2347,5 +2524,9 @@ Global
{BD7F352C-6DC1-4740-BAF2-2D34A038728C} = {A0CC0258-D18C-4AB3-854F-7101680FC3F9} {BD7F352C-6DC1-4740-BAF2-2D34A038728C} = {A0CC0258-D18C-4AB3-854F-7101680FC3F9}
{F1FDC5B0-4654-416F-AE69-E3E9BBD87801} = {9B9E3891-2366-4253-A952-D08BCEB71098} {F1FDC5B0-4654-416F-AE69-E3E9BBD87801} = {9B9E3891-2366-4253-A952-D08BCEB71098}
{29132311-1848-4FD6-AE0C-4FF841151BD3} = {9B9E3891-2366-4253-A952-D08BCEB71098} {29132311-1848-4FD6-AE0C-4FF841151BD3} = {9B9E3891-2366-4253-A952-D08BCEB71098}
{9DEFC6B7-845B-4D8F-AFC0-D32BF0032B8C} = {B39A8919-9F95-48FE-AD7B-76E08B509888}
{40759A76-D0F2-464E-8000-6FF0F5C4BD7C} = {B39A8919-9F95-48FE-AD7B-76E08B509888}
{7D2D3083-71DD-4CC9-8907-39A0D86FB322} = {3743B0F2-CC41-4F14-A8C8-267F579BF91E}
{BB1F7BB5-6AD4-4776-94D9-C09D0A972658} = {B9894058-278A-46B5-B6ED-AD613FCC03B3}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

109
build.cake

@ -42,7 +42,7 @@ var AssemblyInfoPath = File("./src/Shared/SharedAssemblyInfo.cs");
var ReleasePlatform = "Any CPU"; var ReleasePlatform = "Any CPU";
var ReleaseConfiguration = "Release"; var ReleaseConfiguration = "Release";
var MSBuildSolution = "./Avalonia.sln"; var MSBuildSolution = "./Avalonia.sln";
var XBuildSolution = "./Avalonia.sln"; var XBuildSolution = "./Avalonia.XBuild.sln";
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// PARAMETERS // PARAMETERS
@ -69,7 +69,7 @@ var isNuGetRelease = isTagged && isReleasable;
// VERSION // VERSION
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
var version = ParseAssemblyInfo(AssemblyInfoPath).AssemblyVersion; var version = Argument("force-nuget-version", ParseAssemblyInfo(AssemblyInfoPath).AssemblyVersion);
if (isRunningOnAppVeyor) if (isRunningOnAppVeyor)
{ {
@ -115,7 +115,9 @@ var buildDirs =
(DirectoryPath)Directory("./src/Skia/Avalonia.Skia.Android.TestApp/bin/" + dirSuffix) + (DirectoryPath)Directory("./src/Skia/Avalonia.Skia.Android.TestApp/bin/" + dirSuffix) +
(DirectoryPath)Directory("./src/Skia/Avalonia.Skia.Android.TestApp/obj/" + dirSuffix) + (DirectoryPath)Directory("./src/Skia/Avalonia.Skia.Android.TestApp/obj/" + dirSuffix) +
(DirectoryPath)Directory("./src/Skia/Avalonia.Skia.Desktop/bin/" + dirSuffixSkia) + (DirectoryPath)Directory("./src/Skia/Avalonia.Skia.Desktop/bin/" + dirSuffixSkia) +
(DirectoryPath)Directory("./src/Skia/Avalonia.Skia.Desktop/obj/" + dirSuffixSkia) + (DirectoryPath)Directory("./src/Skia/Avalonia.Skia.Desktop/obj/" + dirSuffixSkia) +
(DirectoryPath)Directory("./src/Skia/Avalonia.Skia.Desktop.NetStandard/bin/" + dirSuffix) +
(DirectoryPath)Directory("./src/Skia/Avalonia.Skia.Desktop.NetStandard/obj/" + dirSuffix) +
(DirectoryPath)Directory("./src/Skia/Avalonia.Skia.iOS/bin/" + dirSuffixIOS) + (DirectoryPath)Directory("./src/Skia/Avalonia.Skia.iOS/bin/" + dirSuffixIOS) +
(DirectoryPath)Directory("./src/Skia/Avalonia.Skia.iOS/obj/" + dirSuffixIOS) + (DirectoryPath)Directory("./src/Skia/Avalonia.Skia.iOS/obj/" + dirSuffixIOS) +
(DirectoryPath)Directory("./src/Skia/Avalonia.Skia.iOS.TestApp/bin/" + dirSuffixIOS) + (DirectoryPath)Directory("./src/Skia/Avalonia.Skia.iOS.TestApp/bin/" + dirSuffixIOS) +
@ -273,6 +275,12 @@ var win32CoreLibrariesNuSpecContent = coreLibrariesFiles.Select((file) => {
}; };
}); });
var netcoreappCoreLibrariesNuSpecContent = coreLibrariesFiles.Select((file) => {
return new NuSpecContent {
Source = file.FullPath, Target = "lib/netcoreapp1.0"
};
});
var net45RuntimePlatformExtensions = new [] {".xml", ".dll"}; var net45RuntimePlatformExtensions = new [] {".xml", ".dll"};
var net45RuntimePlatform = net45RuntimePlatformExtensions.Select(libSuffix => { var net45RuntimePlatform = net45RuntimePlatformExtensions.Select(libSuffix => {
return new NuSpecContent { return new NuSpecContent {
@ -281,6 +289,15 @@ var net45RuntimePlatform = net45RuntimePlatformExtensions.Select(libSuffix => {
}; };
}); });
var netCoreRuntimePlatformExtensions = new [] {".xml", ".dll"};
var netCoreRuntimePlatform = netCoreRuntimePlatformExtensions.Select(libSuffix => {
return new NuSpecContent {
Source = ((FilePath)File("./src/Avalonia.DotNetCoreRuntime/bin/" + dirSuffix + "/Avalonia.DotNetCoreRuntime" + libSuffix)).FullPath,
Target = "lib/netcoreapp1.0"
};
});
var nuspecNuGetSettingsCore = new [] var nuspecNuGetSettingsCore = new []
{ {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -294,9 +311,20 @@ var nuspecNuGetSettingsCore = new []
new NuSpecDependency() { Id = "Serilog", Version = SerilogVersion }, new NuSpecDependency() { Id = "Serilog", Version = SerilogVersion },
new NuSpecDependency() { Id = "Splat", Version = SplatVersion }, new NuSpecDependency() { Id = "Splat", Version = SplatVersion },
new NuSpecDependency() { Id = "Sprache", Version = SpracheVersion }, new NuSpecDependency() { Id = "Sprache", Version = SpracheVersion },
new NuSpecDependency() { Id = "System.Reactive", Version = SystemReactiveVersion } new NuSpecDependency() { Id = "System.Reactive", Version = SystemReactiveVersion },
new NuSpecDependency() { Id = "System.Threading.ThreadPool", TargetFramework = "netcoreapp1.0", Version = "4.3.0" },
//.NET Core
new NuSpecDependency() { Id = "NETStandard.Library", TargetFramework = "netcoreapp1.0", Version = "1.6.0" },
new NuSpecDependency() { Id = "Microsoft.NETCore.Portable.Compatibility", TargetFramework = "netcoreapp1.0", Version = "1.0.1" },
new NuSpecDependency() { Id = "Splat", TargetFramework = "netcoreapp1.0", Version = "2.0.0" },
new NuSpecDependency() { Id = "Serilog", TargetFramework = "netcoreapp1.0", Version = "2.3.0" },
new NuSpecDependency() { Id = "Sprache", TargetFramework = "netcoreapp1.0", Version = SpracheVersion },
new NuSpecDependency() { Id = "System.Reactive", TargetFramework = "netcoreapp1.0", Version = SystemReactiveVersion }
}, },
Files = coreLibrariesNuSpecContent.Concat(win32CoreLibrariesNuSpecContent).Concat(net45RuntimePlatform).ToList(), Files = coreLibrariesNuSpecContent
.Concat(win32CoreLibrariesNuSpecContent).Concat(net45RuntimePlatform)
.Concat(netcoreappCoreLibrariesNuSpecContent).Concat(netCoreRuntimePlatform)
.ToList(),
BasePath = Directory("./"), BasePath = Directory("./"),
OutputDirectory = nugetRoot OutputDirectory = nugetRoot
}, },
@ -427,9 +455,10 @@ var nuspecNuGetSettingsDesktop = new []
}, },
Files = new [] Files = new []
{ {
new NuSpecContent { Source = "Avalonia.Win32.dll", Target = "lib/net45" } new NuSpecContent { Source = "Avalonia.Win32/bin/" + dirSuffix + "/Avalonia.Win32.dll", Target = "lib/net45" },
new NuSpecContent { Source = "Avalonia.Win32.NetStandard/bin/" + dirSuffix + "/Avalonia.Win32.dll", Target = "lib/netstandard1.1" }
}, },
BasePath = Directory("./src/Windows/Avalonia.Win32/bin/" + dirSuffix), BasePath = Directory("./src/Windows"),
OutputDirectory = nugetRoot OutputDirectory = nugetRoot
}, },
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -471,6 +500,23 @@ var nuspecNuGetSettingsDesktop = new []
OutputDirectory = nugetRoot OutputDirectory = nugetRoot
}, },
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Avalonia.Gtk3
///////////////////////////////////////////////////////////////////////////////
new NuGetPackSettings()
{
Id = "Avalonia.Gtk3",
Dependencies = new []
{
new NuSpecDependency() { Id = "Avalonia", Version = version }
},
Files = new []
{
new NuSpecContent { Source = "Avalonia.Gtk3.dll", Target = "lib/netstandard1.1" }
},
BasePath = Directory("./src/Gtk/Avalonia.Gtk3/bin/" + dirSuffix),
OutputDirectory = nugetRoot
},
///////////////////////////////////////////////////////////////////////////////
// Avalonia.Cairo // Avalonia.Cairo
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
new NuGetPackSettings() new NuGetPackSettings()
@ -496,13 +542,19 @@ var nuspecNuGetSettingsDesktop = new []
Dependencies = new [] Dependencies = new []
{ {
new NuSpecDependency() { Id = "Avalonia", Version = version }, new NuSpecDependency() { Id = "Avalonia", Version = version },
new NuSpecDependency() { Id = "SkiaSharp", Version = SkiaSharpVersion } new NuSpecDependency() { Id = "SkiaSharp", Version = SkiaSharpVersion },
//.NET Core
new NuSpecDependency() { Id = "Avalonia", TargetFramework = "netcoreapp1.0", Version = version },
new NuSpecDependency() { Id = "SkiaSharp", TargetFramework = "netcoreapp1.0", Version = SkiaSharpVersion },
new NuSpecDependency() { Id = "NETStandard.Library", TargetFramework = "netcoreapp1.0", Version = "1.6.0" },
new NuSpecDependency() { Id = "Microsoft.NETCore.Portable.Compatibility", TargetFramework = "netcoreapp1.0", Version = "1.0.1" }
}, },
Files = new [] Files = new []
{ {
new NuSpecContent { Source = "Avalonia.Skia.Desktop.dll", Target = "lib/net45" } new NuSpecContent { Source = "Avalonia.Skia.Desktop/bin/" + dirSuffixSkia + "/Avalonia.Skia.Desktop.dll", Target = "lib/net45" },
new NuSpecContent { Source = "Avalonia.Skia.Desktop.NetStandard/bin/" + dirSuffix + "/Avalonia.Skia.Desktop.dll", Target = "lib/netcoreapp1.0" }
}, },
BasePath = Directory("./src/Skia/Avalonia.Skia.Desktop/bin/" + dirSuffixSkia), BasePath = Directory("./src/Skia/"),
OutputDirectory = nugetRoot OutputDirectory = nugetRoot
}, },
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -592,9 +644,46 @@ Task("Clean")
CleanDirectory(binRoot); CleanDirectory(binRoot);
CleanDirectory(testsRoot); CleanDirectory(testsRoot);
}); });
Task("Prepare-XBuild-Solution")
.Does(() =>
{
var blacklistedProjects = new[]
{
"Avalonia.Win32.NetStandard",
"Avalonia.DotNetCoreRuntime",
"Avalonia.Skia.Desktop.NetStandard",
"Avalonia.Gtk3"
};
var blacklistedGuids = System.IO.File.ReadAllLines(MSBuildSolution)
.Where(l=>l.StartsWith("Project") && blacklistedProjects.Any(p=>l.Contains(p)))
.Select(l => l.Split(',').Select(part => part.Trim()).FirstOrDefault(part => part.StartsWith("\"{")))
.Where(g=>g!=null)
.Select(l=>l.Trim(new[]{'"', '}', '{'}).ToLower()).ToArray();
Console.WriteLine("Blacklisted guids are: " + string.Join(",", blacklistedGuids));
var removeUntilEndProject = false;
System.IO.File.WriteAllLines(XBuildSolution, System.IO.File.ReadAllLines(MSBuildSolution)
.Where(l =>
{
if(removeUntilEndProject)
{
if(l.StartsWith("EndProject"))
removeUntilEndProject = false;
return false;
}
var blacklist = blacklistedGuids.Any(g => l.ToLower().Contains(g));
if(blacklist && l.StartsWith("Project"))
removeUntilEndProject = true;
return !blacklist;
}));
});
Task("Restore-NuGet-Packages") Task("Restore-NuGet-Packages")
.IsDependentOn("Clean") .IsDependentOn("Clean")
.IsDependentOn("Prepare-XBuild-Solution")
.Does(() => .Does(() =>
{ {
var maxRetryCount = 5; var maxRetryCount = 5;

7
samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj

@ -33,6 +33,9 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Serilog, Version=1.5.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL"> <Reference Include="Serilog, Version=1.5.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
<HintPath>..\..\packages\Serilog.1.5.14\lib\net45\Serilog.dll</HintPath> <HintPath>..\..\packages\Serilog.1.5.14\lib\net45\Serilog.dll</HintPath>
@ -72,6 +75,10 @@
<Project>{FB05AC90-89BA-4F2F-A924-F37875FB547C}</Project> <Project>{FB05AC90-89BA-4F2F-A924-F37875FB547C}</Project>
<Name>Avalonia.Cairo</Name> <Name>Avalonia.Cairo</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\src\Gtk\Avalonia.Gtk3\Avalonia.Gtk3.csproj">
<Project>{bb1f7bb5-6ad4-4776-94d9-c09d0a972658}</Project>
<Name>Avalonia.Gtk3</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Gtk\Avalonia.Gtk\Avalonia.Gtk.csproj"> <ProjectReference Include="..\..\src\Gtk\Avalonia.Gtk\Avalonia.Gtk.csproj">
<Project>{54F237D5-A70A-4752-9656-0C70B1A7B047}</Project> <Project>{54F237D5-A70A-4752-9656-0C70B1A7B047}</Project>
<Name>Avalonia.Gtk</Name> <Name>Avalonia.Gtk</Name>

5
src/Android/Avalonia.AndroidTestApplication/Avalonia.AndroidTestApplication.csproj

@ -72,9 +72,8 @@
<HintPath>..\..\..\packages\Splat.1.6.2\lib\monoandroid\Splat.dll</HintPath> <HintPath>..\..\..\packages\Splat.1.6.2\lib\monoandroid\Splat.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Sprache, Version=2.0.0.51, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Sprache, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Sprache.2.0.0.51\lib\portable-net4+netcore45+win8+wp8+sl5+MonoAndroid+Xamarin.iOS10+MonoTouch\Sprache.dll</HintPath> <HintPath>..\..\..\packages\Sprache.2.1.0\lib\netstandard1.0\Sprache.dll</HintPath>
<Private>True</Private>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />

3
src/Android/Avalonia.AndroidTestApplication/packages.config

@ -2,7 +2,7 @@
<packages> <packages>
<package id="Serilog" version="1.5.14" targetFramework="monoandroid44" /> <package id="Serilog" version="1.5.14" targetFramework="monoandroid44" />
<package id="Splat" version="1.6.2" targetFramework="monoandroid51" /> <package id="Splat" version="1.6.2" targetFramework="monoandroid51" />
<package id="Sprache" version="2.0.0.51" targetFramework="monoandroid44" /> <package id="Sprache" version="2.1.0" targetFramework="monoandroid44" />
<package id="System.Collections" version="4.0.11" targetFramework="monoandroid44" /> <package id="System.Collections" version="4.0.11" targetFramework="monoandroid44" />
<package id="System.Collections.Concurrent" version="4.0.12" targetFramework="monoandroid44" /> <package id="System.Collections.Concurrent" version="4.0.12" targetFramework="monoandroid44" />
<package id="System.ComponentModel" version="4.0.1" targetFramework="monoandroid44" /> <package id="System.ComponentModel" version="4.0.1" targetFramework="monoandroid44" />
@ -19,6 +19,7 @@
<package id="System.Resources.ResourceManager" version="4.0.1" targetFramework="monoandroid44" /> <package id="System.Resources.ResourceManager" version="4.0.1" targetFramework="monoandroid44" />
<package id="System.Runtime" version="4.1.0" targetFramework="monoandroid44" /> <package id="System.Runtime" version="4.1.0" targetFramework="monoandroid44" />
<package id="System.Runtime.Extensions" version="4.1.0" targetFramework="monoandroid44" /> <package id="System.Runtime.Extensions" version="4.1.0" targetFramework="monoandroid44" />
<package id="System.Text.RegularExpressions" version="4.1.0" targetFramework="monoandroid44" />
<package id="System.Threading" version="4.0.11" targetFramework="monoandroid44" /> <package id="System.Threading" version="4.0.11" targetFramework="monoandroid44" />
<package id="System.Threading.Tasks" version="4.0.11" targetFramework="monoandroid44" /> <package id="System.Threading.Tasks" version="4.0.11" targetFramework="monoandroid44" />
</packages> </packages>

4
src/Avalonia.Animation/Avalonia.Animation.csproj

@ -16,7 +16,7 @@
<TargetFrameworkProfile>Profile7</TargetFrameworkProfile> <TargetFrameworkProfile>Profile7</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
@ -27,7 +27,7 @@
<DocumentationFile>bin\Debug\Avalonia.Animation.XML</DocumentationFile> <DocumentationFile>bin\Debug\Avalonia.Animation.XML</DocumentationFile>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>

4
src/Avalonia.Base/Avalonia.Base.csproj

@ -18,7 +18,7 @@
<NuGetPackageImportStamp> <NuGetPackageImportStamp>
</NuGetPackageImportStamp> </NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
@ -29,7 +29,7 @@
<DocumentationFile>bin\Debug\Avalonia.Base.XML</DocumentationFile> <DocumentationFile>bin\Debug\Avalonia.Base.XML</DocumentationFile>
<NoWarn>CS1591</NoWarn> <NoWarn>CS1591</NoWarn>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>

4
src/Avalonia.Controls/Avalonia.Controls.csproj

@ -18,7 +18,7 @@
<NuGetPackageImportStamp> <NuGetPackageImportStamp>
</NuGetPackageImportStamp> </NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
@ -29,7 +29,7 @@
<DocumentationFile>bin\Debug\Avalonia.Controls.XML</DocumentationFile> <DocumentationFile>bin\Debug\Avalonia.Controls.XML</DocumentationFile>
<NoWarn>CS1591</NoWarn> <NoWarn>CS1591</NoWarn>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>

4
src/Avalonia.DesignerSupport/Avalonia.DesignerSupport.csproj

@ -18,7 +18,7 @@
<NuGetPackageImportStamp> <NuGetPackageImportStamp>
</NuGetPackageImportStamp> </NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
@ -29,7 +29,7 @@
<DocumentationFile>bin\Debug\Avalonia.DesignerSupport.xml</DocumentationFile> <DocumentationFile>bin\Debug\Avalonia.DesignerSupport.xml</DocumentationFile>
<NoWarn>CS1591</NoWarn> <NoWarn>CS1591</NoWarn>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>

4
src/Avalonia.Diagnostics/Avalonia.Diagnostics.csproj

@ -18,7 +18,7 @@
<NuGetPackageImportStamp> <NuGetPackageImportStamp>
</NuGetPackageImportStamp> </NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
@ -29,7 +29,7 @@
<DocumentationFile>bin\Debug\Avalonia.Diagnostics.XML</DocumentationFile> <DocumentationFile>bin\Debug\Avalonia.Diagnostics.XML</DocumentationFile>
<NoWarn>CS1591</NoWarn> <NoWarn>CS1591</NoWarn>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>

53
src/Avalonia.DotNetCoreRuntime/AppBuilder.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.Platform;
using Avalonia.Shared.PlatformSupport;
namespace Avalonia
{
public sealed class AppBuilder : AppBuilderBase<AppBuilder>
{
/// <summary>
/// Initializes a new instance of the <see cref="AppBuilder"/> class.
/// </summary>
public AppBuilder()
: base(new StandardRuntimePlatform(), () => StandardRuntimePlatformServices.Register())
{
}
/// <summary>
/// Initializes a new instance of the <see cref="AppBuilder"/> class.
/// </summary>
/// <param name="app">The <see cref="Application"/> instance.</param>
public AppBuilder(Application app) : this()
{
Instance = app;
}
/// <summary>
/// Instructs the <see cref="AppBuilder"/> to use the best settings for the platform.
/// </summary>
/// <returns>An <see cref="AppBuilder"/> instance.</returns>
public AppBuilder UsePlatformDetect()
{
//We don't have the ability to load every assembly right now, so we are
//stuck with manual configuration here
//Helpers are extracted to separate methods to take the advantage of the fact
//that CLR doesn't try to load dependencies before referencing method is jitted
if (RuntimePlatform.GetRuntimeInfo().OperatingSystem == OperatingSystemType.WinNT)
LoadWin32();
else
LoadGtk3();
this.UseSkia();
return this;
}
void LoadWin32() => this.UseWin32();
void LoadGtk3() => this.UseGtk3();
}
}

89
src/Avalonia.DotNetCoreRuntime/Avalonia.DotNetCoreRuntime.csproj

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{7863EA94-F0FB-4386-BF8C-E5BFA761560A}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Avalonia.DotNetCoreRuntime</RootNamespace>
<AssemblyName>Avalonia.DotNetCoreRuntime</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;NETSTANDARD</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\Avalonia.DotNetCoreRuntime.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;NETSTANDARD</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Avalonia.DotNetCoreRuntime.XML</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .NET Framework is automatically included -->
<None Include="project.json" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Shared\SharedAssemblyInfo.cs">
<Link>SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="AppBuilder.cs" />
<Compile Include="NetCoreRuntimePlatform.cs" />
<Compile Include="RuntimeInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Avalonia.Base\Avalonia.Base.csproj">
<Project>{b09b78d8-9b26-48b0-9149-d64a2f120f3f}</Project>
<Name>Avalonia.Base</Name>
</ProjectReference>
<ProjectReference Include="..\Avalonia.Controls\Avalonia.Controls.csproj">
<Project>{d2221c82-4a25-4583-9b43-d791e3f6820c}</Project>
<Name>Avalonia.Controls</Name>
</ProjectReference>
<ProjectReference Include="..\Avalonia.Visuals\Avalonia.Visuals.csproj">
<Project>{eb582467-6abb-43a1-b052-e981ba910e3a}</Project>
<Name>Avalonia.Visuals</Name>
</ProjectReference>
<ProjectReference Include="..\Gtk\Avalonia.Gtk3\Avalonia.Gtk3.csproj">
<Project>{bb1f7bb5-6ad4-4776-94d9-c09d0a972658}</Project>
<Name>Avalonia.Gtk3</Name>
</ProjectReference>
<ProjectReference Include="..\Skia\Avalonia.Skia.Desktop.NetStandard\Avalonia.Skia.Desktop.NetStandard.csproj">
<Project>{7d2d3083-71dd-4cc9-8907-39a0d86fb322}</Project>
<Name>Avalonia.Skia.Desktop.NetStandard</Name>
</ProjectReference>
<ProjectReference Include="..\Windows\Avalonia.Win32.NetStandard\Avalonia.Win32.NetStandard.csproj">
<Project>{40759a76-d0f2-464e-8000-6ff0f5c4bd7c}</Project>
<Name>Avalonia.Win32.NetStandard</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<Import Project="..\Shared\PlatformSupport\PlatformSupport.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

47
src/Avalonia.DotNetCoreRuntime/NetCoreRuntimePlatform.cs

@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace Avalonia.Shared.PlatformSupport
{
internal partial class StandardRuntimePlatform
{
private static readonly Lazy<Assembly[]> Assemblies = new Lazy<Assembly[]>(LoadAssemblies);
public Assembly[] GetLoadedAssemblies() => Assemblies.Value;
static Assembly[] LoadAssemblies()
{
var rv = new List<Assembly>();
var entry = Assembly.GetEntryAssembly();
rv.Add(entry);
var queue = new Queue<AssemblyName>(entry.GetReferencedAssemblies());
var aset = new HashSet<string>(queue.Select(r => r.ToString()));
while (queue.Count > 0)
{
Assembly asm;
try
{
asm = Assembly.Load(queue.Dequeue());
}
catch (Exception e)
{
Debug.Write(e.ToString());
continue;
}
rv.Add(asm);
foreach (var r in asm.GetReferencedAssemblies())
{
if (aset.Add(r.ToString()))
queue.Enqueue(r);
}
}
return rv.Distinct().ToArray();
}
}
}

41
src/Avalonia.DotNetCoreRuntime/RuntimeInfo.cs

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using Avalonia.Platform;
namespace Avalonia.Shared.PlatformSupport
{
internal partial class StandardRuntimePlatform
{
private static readonly Lazy<RuntimePlatformInfo> Info = new Lazy<RuntimePlatformInfo>(() =>
{
OperatingSystemType os;
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
os = OperatingSystemType.OSX;
else if(RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
os = OperatingSystemType.Linux;
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
os = OperatingSystemType.WinNT;
else
throw new Exception("Unknown OS platform " + RuntimeInformation.OSDescription);
return new RuntimePlatformInfo
{
IsCoreClr = true,
IsDesktop = true,
IsDotNetFramework = false,
IsMono = false,
IsMobile = false,
IsUnix = os != OperatingSystemType.WinNT,
OperatingSystem = os,
};
});
public RuntimePlatformInfo GetRuntimeInfo() => Info.Value;
}
}

11
src/Avalonia.DotNetCoreRuntime/project.json

@ -0,0 +1,11 @@
{
"supports": {},
"dependencies": {
"Microsoft.NETCore.Portable.Compatibility": "1.0.1",
"NETStandard.Library": "1.6.0",
"System.Threading.ThreadPool": "4.3.0"
},
"frameworks": {
"netstandard1.5": {}
}
}

4
src/Avalonia.DotNetFrameworkRuntime/Avalonia.DotNetFrameworkRuntime.csproj

@ -13,7 +13,7 @@
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<TargetFrameworkProfile /> <TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
@ -23,7 +23,7 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\Avalonia.DotNetFrameworkRuntime.xml</DocumentationFile> <DocumentationFile>bin\Debug\Avalonia.DotNetFrameworkRuntime.xml</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>

4
src/Avalonia.HtmlRenderer/Avalonia.HtmlRenderer.csproj

@ -18,7 +18,7 @@
<NuGetPackageImportStamp> <NuGetPackageImportStamp>
</NuGetPackageImportStamp> </NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
@ -27,7 +27,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>

4
src/Avalonia.Input/Avalonia.Input.csproj

@ -18,7 +18,7 @@
<NuGetPackageImportStamp> <NuGetPackageImportStamp>
</NuGetPackageImportStamp> </NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
@ -29,7 +29,7 @@
<DocumentationFile>bin\Debug\Avalonia.Input.XML</DocumentationFile> <DocumentationFile>bin\Debug\Avalonia.Input.XML</DocumentationFile>
<NoWarn>CS1591</NoWarn> <NoWarn>CS1591</NoWarn>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>

4
src/Avalonia.Interactivity/Avalonia.Interactivity.csproj

@ -18,7 +18,7 @@
<NuGetPackageImportStamp> <NuGetPackageImportStamp>
</NuGetPackageImportStamp> </NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
@ -29,7 +29,7 @@
<DocumentationFile>bin\Debug\Avalonia.Interactivity.XML</DocumentationFile> <DocumentationFile>bin\Debug\Avalonia.Interactivity.XML</DocumentationFile>
<NoWarn>CS1591</NoWarn> <NoWarn>CS1591</NoWarn>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>

4
src/Avalonia.Layout/Avalonia.Layout.csproj

@ -18,7 +18,7 @@
<NuGetPackageImportStamp> <NuGetPackageImportStamp>
</NuGetPackageImportStamp> </NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
@ -29,7 +29,7 @@
<DocumentationFile>bin\Debug\Avalonia.Layout.XML</DocumentationFile> <DocumentationFile>bin\Debug\Avalonia.Layout.XML</DocumentationFile>
<NoWarn>CS1591</NoWarn> <NoWarn>CS1591</NoWarn>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>

4
src/Avalonia.Logging.Serilog/Avalonia.Logging.Serilog.csproj

@ -16,7 +16,7 @@
<TargetFrameworkProfile>Profile7</TargetFrameworkProfile> <TargetFrameworkProfile>Profile7</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
@ -26,7 +26,7 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\Avalonia.Logging.Serilog.XML</DocumentationFile> <DocumentationFile>bin\Debug\Avalonia.Logging.Serilog.XML</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>

4
src/Avalonia.ReactiveUI/Avalonia.ReactiveUI.csproj

@ -16,7 +16,7 @@
<TargetFrameworkProfile>Profile259</TargetFrameworkProfile> <TargetFrameworkProfile>Profile259</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
@ -25,7 +25,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>

4
src/Avalonia.Styling/Avalonia.Styling.csproj

@ -18,7 +18,7 @@
<NuGetPackageImportStamp> <NuGetPackageImportStamp>
</NuGetPackageImportStamp> </NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
@ -29,7 +29,7 @@
<DocumentationFile>bin\Debug\Avalonia.Styling.XML</DocumentationFile> <DocumentationFile>bin\Debug\Avalonia.Styling.XML</DocumentationFile>
<NoWarn>CS1591</NoWarn> <NoWarn>CS1591</NoWarn>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>

4
src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj

@ -18,7 +18,7 @@
<NuGetPackageImportStamp> <NuGetPackageImportStamp>
</NuGetPackageImportStamp> </NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
@ -28,7 +28,7 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\Avalonia.Themes.Default.XML</DocumentationFile> <DocumentationFile>bin\Debug\Avalonia.Themes.Default.XML</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>

4
src/Avalonia.Visuals/Avalonia.Visuals.csproj

@ -18,7 +18,7 @@
<NuGetPackageImportStamp> <NuGetPackageImportStamp>
</NuGetPackageImportStamp> </NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
@ -29,7 +29,7 @@
<DocumentationFile>bin\Debug\Avalonia.Visuals.xml</DocumentationFile> <DocumentationFile>bin\Debug\Avalonia.Visuals.xml</DocumentationFile>
<NoWarn>CS1591</NoWarn> <NoWarn>CS1591</NoWarn>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>

1
src/Gtk/Avalonia.Gtk/Avalonia.Gtk.csproj

@ -52,6 +52,7 @@
<Compile Include="Embedding\GtkAvaloniaControlHost.cs" /> <Compile Include="Embedding\GtkAvaloniaControlHost.cs" />
<Compile Include="FramebufferManager.cs" /> <Compile Include="FramebufferManager.cs" />
<Compile Include="IconImpl.cs" /> <Compile Include="IconImpl.cs" />
<Compile Include="KeyTransform.cs" />
<Compile Include="SurfaceFramebuffer.cs" /> <Compile Include="SurfaceFramebuffer.cs" />
<Compile Include="SystemDialogImpl.cs" /> <Compile Include="SystemDialogImpl.cs" />
<Compile Include="CursorFactory.cs" /> <Compile Include="CursorFactory.cs" />

209
src/Gtk/Avalonia.Gtk/Input/GtkKeyboardDevice.cs

@ -8,218 +8,11 @@ using System.Reflection;
using System.Text; using System.Text;
using Avalonia.Input; using Avalonia.Input;
namespace Avalonia.Gtk namespace Avalonia.Gtk
{ {
public class GtkKeyboardDevice : KeyboardDevice public class GtkKeyboardDevice : KeyboardDevice
{ {
private static readonly Dictionary<Gdk.Key, Key> KeyDic = new Dictionary<Gdk.Key, Key>
{
{ Gdk.Key.Cancel, Key.Cancel },
{ Gdk.Key.BackSpace, Key.Back },
{ Gdk.Key.Tab, Key.Tab },
{ Gdk.Key.Linefeed, Key.LineFeed },
{ Gdk.Key.Clear, Key.Clear },
{ Gdk.Key.Return, Key.Return },
{ Gdk.Key.Pause, Key.Pause },
//{ Gdk.Key.?, Key.CapsLock }
//{ Gdk.Key.?, Key.HangulMode }
//{ Gdk.Key.?, Key.JunjaMode }
//{ Gdk.Key.?, Key.FinalMode }
//{ Gdk.Key.?, Key.KanjiMode }
{ Gdk.Key.Escape, Key.Escape },
//{ Gdk.Key.?, Key.ImeConvert }
//{ Gdk.Key.?, Key.ImeNonConvert }
//{ Gdk.Key.?, Key.ImeAccept }
//{ Gdk.Key.?, Key.ImeModeChange }
{ Gdk.Key.space, Key.Space },
{ Gdk.Key.Prior, Key.Prior },
//{ Gdk.Key.?, Key.PageDown }
{ Gdk.Key.End, Key.End },
{ Gdk.Key.Home, Key.Home },
{ Gdk.Key.Left, Key.Left },
{ Gdk.Key.Up, Key.Up },
{ Gdk.Key.Right, Key.Right },
{ Gdk.Key.Down, Key.Down },
{ Gdk.Key.Select, Key.Select },
{ Gdk.Key.Print, Key.Print },
{ Gdk.Key.Execute, Key.Execute },
//{ Gdk.Key.?, Key.Snapshot }
{ Gdk.Key.Insert, Key.Insert },
{ Gdk.Key.Delete, Key.Delete },
{ Gdk.Key.Help, Key.Help },
//{ Gdk.Key.?, Key.D0 }
//{ Gdk.Key.?, Key.D1 }
//{ Gdk.Key.?, Key.D2 }
//{ Gdk.Key.?, Key.D3 }
//{ Gdk.Key.?, Key.D4 }
//{ Gdk.Key.?, Key.D5 }
//{ Gdk.Key.?, Key.D6 }
//{ Gdk.Key.?, Key.D7 }
//{ Gdk.Key.?, Key.D8 }
//{ Gdk.Key.?, Key.D9 }
{ Gdk.Key.A, Key.A },
{ Gdk.Key.B, Key.B },
{ Gdk.Key.C, Key.C },
{ Gdk.Key.D, Key.D },
{ Gdk.Key.E, Key.E },
{ Gdk.Key.F, Key.F },
{ Gdk.Key.G, Key.G },
{ Gdk.Key.H, Key.H },
{ Gdk.Key.I, Key.I },
{ Gdk.Key.J, Key.J },
{ Gdk.Key.K, Key.K },
{ Gdk.Key.L, Key.L },
{ Gdk.Key.M, Key.M },
{ Gdk.Key.N, Key.N },
{ Gdk.Key.O, Key.O },
{ Gdk.Key.P, Key.P },
{ Gdk.Key.Q, Key.Q },
{ Gdk.Key.R, Key.R },
{ Gdk.Key.S, Key.S },
{ Gdk.Key.T, Key.T },
{ Gdk.Key.U, Key.U },
{ Gdk.Key.V, Key.V },
{ Gdk.Key.W, Key.W },
{ Gdk.Key.X, Key.X },
{ Gdk.Key.Y, Key.Y },
{ Gdk.Key.Z, Key.Z },
{ Gdk.Key.a, Key.A },
{ Gdk.Key.b, Key.B },
{ Gdk.Key.c, Key.C },
{ Gdk.Key.d, Key.D },
{ Gdk.Key.e, Key.E },
{ Gdk.Key.f, Key.F },
{ Gdk.Key.g, Key.G },
{ Gdk.Key.h, Key.H },
{ Gdk.Key.i, Key.I },
{ Gdk.Key.j, Key.J },
{ Gdk.Key.k, Key.K },
{ Gdk.Key.l, Key.L },
{ Gdk.Key.m, Key.M },
{ Gdk.Key.n, Key.N },
{ Gdk.Key.o, Key.O },
{ Gdk.Key.p, Key.P },
{ Gdk.Key.q, Key.Q },
{ Gdk.Key.r, Key.R },
{ Gdk.Key.s, Key.S },
{ Gdk.Key.t, Key.T },
{ Gdk.Key.u, Key.U },
{ Gdk.Key.v, Key.V },
{ Gdk.Key.w, Key.W },
{ Gdk.Key.x, Key.X },
{ Gdk.Key.y, Key.Y },
{ Gdk.Key.z, Key.Z },
//{ Gdk.Key.?, Key.LWin }
//{ Gdk.Key.?, Key.RWin }
//{ Gdk.Key.?, Key.Apps }
//{ Gdk.Key.?, Key.Sleep }
//{ Gdk.Key.?, Key.NumPad0 }
//{ Gdk.Key.?, Key.NumPad1 }
//{ Gdk.Key.?, Key.NumPad2 }
//{ Gdk.Key.?, Key.NumPad3 }
//{ Gdk.Key.?, Key.NumPad4 }
//{ Gdk.Key.?, Key.NumPad5 }
//{ Gdk.Key.?, Key.NumPad6 }
//{ Gdk.Key.?, Key.NumPad7 }
//{ Gdk.Key.?, Key.NumPad8 }
//{ Gdk.Key.?, Key.NumPad9 }
{ Gdk.Key.multiply, Key.Multiply },
//{ Gdk.Key.?, Key.Add }
//{ Gdk.Key.?, Key.Separator }
//{ Gdk.Key.?, Key.Subtract }
//{ Gdk.Key.?, Key.Decimal }
//{ Gdk.Key.?, Key.Divide }
{ Gdk.Key.F1, Key.F1 },
{ Gdk.Key.F2, Key.F2 },
{ Gdk.Key.F3, Key.F3 },
{ Gdk.Key.F4, Key.F4 },
{ Gdk.Key.F5, Key.F5 },
{ Gdk.Key.F6, Key.F6 },
{ Gdk.Key.F7, Key.F7 },
{ Gdk.Key.F8, Key.F8 },
{ Gdk.Key.F9, Key.F9 },
{ Gdk.Key.F10, Key.F10 },
{ Gdk.Key.F11, Key.F11 },
{ Gdk.Key.F12, Key.F12 },
{ Gdk.Key.L3, Key.F13 },
{ Gdk.Key.F14, Key.F14 },
{ Gdk.Key.L5, Key.F15 },
{ Gdk.Key.F16, Key.F16 },
{ Gdk.Key.F17, Key.F17 },
{ Gdk.Key.L8, Key.F18 },
{ Gdk.Key.L9, Key.F19 },
{ Gdk.Key.L10, Key.F20 },
{ Gdk.Key.R1, Key.F21 },
{ Gdk.Key.R2, Key.F22 },
{ Gdk.Key.F23, Key.F23 },
{ Gdk.Key.R4, Key.F24 },
//{ Gdk.Key.?, Key.NumLock }
//{ Gdk.Key.?, Key.Scroll }
//{ Gdk.Key.?, Key.LeftShift }
//{ Gdk.Key.?, Key.RightShift }
//{ Gdk.Key.?, Key.LeftCtrl }
//{ Gdk.Key.?, Key.RightCtrl }
//{ Gdk.Key.?, Key.LeftAlt }
//{ Gdk.Key.?, Key.RightAlt }
//{ Gdk.Key.?, Key.BrowserBack }
//{ Gdk.Key.?, Key.BrowserForward }
//{ Gdk.Key.?, Key.BrowserRefresh }
//{ Gdk.Key.?, Key.BrowserStop }
//{ Gdk.Key.?, Key.BrowserSearch }
//{ Gdk.Key.?, Key.BrowserFavorites }
//{ Gdk.Key.?, Key.BrowserHome }
//{ Gdk.Key.?, Key.VolumeMute }
//{ Gdk.Key.?, Key.VolumeDown }
//{ Gdk.Key.?, Key.VolumeUp }
//{ Gdk.Key.?, Key.MediaNextTrack }
//{ Gdk.Key.?, Key.MediaPreviousTrack }
//{ Gdk.Key.?, Key.MediaStop }
//{ Gdk.Key.?, Key.MediaPlayPause }
//{ Gdk.Key.?, Key.LaunchMail }
//{ Gdk.Key.?, Key.SelectMedia }
//{ Gdk.Key.?, Key.LaunchApplication1 }
//{ Gdk.Key.?, Key.LaunchApplication2 }
//{ Gdk.Key.?, Key.OemSemicolon }
//{ Gdk.Key.?, Key.OemPlus }
//{ Gdk.Key.?, Key.OemComma }
//{ Gdk.Key.?, Key.OemMinus }
//{ Gdk.Key.?, Key.OemPeriod }
//{ Gdk.Key.?, Key.Oem2 }
//{ Gdk.Key.?, Key.OemTilde }
//{ Gdk.Key.?, Key.AbntC1 }
//{ Gdk.Key.?, Key.AbntC2 }
//{ Gdk.Key.?, Key.Oem4 }
//{ Gdk.Key.?, Key.OemPipe }
//{ Gdk.Key.?, Key.OemCloseBrackets }
//{ Gdk.Key.?, Key.Oem7 }
//{ Gdk.Key.?, Key.Oem8 }
//{ Gdk.Key.?, Key.Oem102 }
//{ Gdk.Key.?, Key.ImeProcessed }
//{ Gdk.Key.?, Key.System }
//{ Gdk.Key.?, Key.OemAttn }
//{ Gdk.Key.?, Key.OemFinish }
//{ Gdk.Key.?, Key.DbeHiragana }
//{ Gdk.Key.?, Key.OemAuto }
//{ Gdk.Key.?, Key.DbeDbcsChar }
//{ Gdk.Key.?, Key.OemBackTab }
//{ Gdk.Key.?, Key.Attn }
//{ Gdk.Key.?, Key.DbeEnterWordRegisterMode }
//{ Gdk.Key.?, Key.DbeEnterImeConfigureMode }
//{ Gdk.Key.?, Key.EraseEof }
//{ Gdk.Key.?, Key.Play }
//{ Gdk.Key.?, Key.Zoom }
//{ Gdk.Key.?, Key.NoName }
//{ Gdk.Key.?, Key.DbeEnterDialogConversionMode }
//{ Gdk.Key.?, Key.OemClear }
//{ Gdk.Key.?, Key.DeadCharProcessed }
};
public new static GtkKeyboardDevice Instance { get; } = new GtkKeyboardDevice(); public new static GtkKeyboardDevice Instance { get; } = new GtkKeyboardDevice();
public static Key ConvertKey(Gdk.Key key)
{
Key result;
return KeyDic.TryGetValue(key, out result) ? result : Key.None;
}
} }
} }

224
src/Gtk/Avalonia.Gtk/KeyTransform.cs

@ -0,0 +1,224 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Avalonia.Input;
#if GTK3_PINVOKE
using Avalonia.Gtk3;
#else
using GdkKey = Gdk.Key;
#endif
namespace Avalonia.Gtk.Common
{
static class KeyTransform
{
private static readonly Dictionary<GdkKey, Key> KeyDic = new Dictionary<GdkKey, Key>
{
{ GdkKey.Cancel, Key.Cancel },
{ GdkKey.BackSpace, Key.Back },
{ GdkKey.Tab, Key.Tab },
{ GdkKey.Linefeed, Key.LineFeed },
{ GdkKey.Clear, Key.Clear },
{ GdkKey.Return, Key.Return },
{ GdkKey.Pause, Key.Pause },
//{ GdkKey.?, Key.CapsLock }
//{ GdkKey.?, Key.HangulMode }
//{ GdkKey.?, Key.JunjaMode }
//{ GdkKey.?, Key.FinalMode }
//{ GdkKey.?, Key.KanjiMode }
{ GdkKey.Escape, Key.Escape },
//{ GdkKey.?, Key.ImeConvert }
//{ GdkKey.?, Key.ImeNonConvert }
//{ GdkKey.?, Key.ImeAccept }
//{ GdkKey.?, Key.ImeModeChange }
{ GdkKey.space, Key.Space },
{ GdkKey.Prior, Key.Prior },
//{ GdkKey.?, Key.PageDown }
{ GdkKey.End, Key.End },
{ GdkKey.Home, Key.Home },
{ GdkKey.Left, Key.Left },
{ GdkKey.Up, Key.Up },
{ GdkKey.Right, Key.Right },
{ GdkKey.Down, Key.Down },
{ GdkKey.Select, Key.Select },
{ GdkKey.Print, Key.Print },
{ GdkKey.Execute, Key.Execute },
//{ GdkKey.?, Key.Snapshot }
{ GdkKey.Insert, Key.Insert },
{ GdkKey.Delete, Key.Delete },
{ GdkKey.Help, Key.Help },
//{ GdkKey.?, Key.D0 }
//{ GdkKey.?, Key.D1 }
//{ GdkKey.?, Key.D2 }
//{ GdkKey.?, Key.D3 }
//{ GdkKey.?, Key.D4 }
//{ GdkKey.?, Key.D5 }
//{ GdkKey.?, Key.D6 }
//{ GdkKey.?, Key.D7 }
//{ GdkKey.?, Key.D8 }
//{ GdkKey.?, Key.D9 }
{ GdkKey.A, Key.A },
{ GdkKey.B, Key.B },
{ GdkKey.C, Key.C },
{ GdkKey.D, Key.D },
{ GdkKey.E, Key.E },
{ GdkKey.F, Key.F },
{ GdkKey.G, Key.G },
{ GdkKey.H, Key.H },
{ GdkKey.I, Key.I },
{ GdkKey.J, Key.J },
{ GdkKey.K, Key.K },
{ GdkKey.L, Key.L },
{ GdkKey.M, Key.M },
{ GdkKey.N, Key.N },
{ GdkKey.O, Key.O },
{ GdkKey.P, Key.P },
{ GdkKey.Q, Key.Q },
{ GdkKey.R, Key.R },
{ GdkKey.S, Key.S },
{ GdkKey.T, Key.T },
{ GdkKey.U, Key.U },
{ GdkKey.V, Key.V },
{ GdkKey.W, Key.W },
{ GdkKey.X, Key.X },
{ GdkKey.Y, Key.Y },
{ GdkKey.Z, Key.Z },
{ GdkKey.a, Key.A },
{ GdkKey.b, Key.B },
{ GdkKey.c, Key.C },
{ GdkKey.d, Key.D },
{ GdkKey.e, Key.E },
{ GdkKey.f, Key.F },
{ GdkKey.g, Key.G },
{ GdkKey.h, Key.H },
{ GdkKey.i, Key.I },
{ GdkKey.j, Key.J },
{ GdkKey.k, Key.K },
{ GdkKey.l, Key.L },
{ GdkKey.m, Key.M },
{ GdkKey.n, Key.N },
{ GdkKey.o, Key.O },
{ GdkKey.p, Key.P },
{ GdkKey.q, Key.Q },
{ GdkKey.r, Key.R },
{ GdkKey.s, Key.S },
{ GdkKey.t, Key.T },
{ GdkKey.u, Key.U },
{ GdkKey.v, Key.V },
{ GdkKey.w, Key.W },
{ GdkKey.x, Key.X },
{ GdkKey.y, Key.Y },
{ GdkKey.z, Key.Z },
//{ GdkKey.?, Key.LWin }
//{ GdkKey.?, Key.RWin }
//{ GdkKey.?, Key.Apps }
//{ GdkKey.?, Key.Sleep }
//{ GdkKey.?, Key.NumPad0 }
//{ GdkKey.?, Key.NumPad1 }
//{ GdkKey.?, Key.NumPad2 }
//{ GdkKey.?, Key.NumPad3 }
//{ GdkKey.?, Key.NumPad4 }
//{ GdkKey.?, Key.NumPad5 }
//{ GdkKey.?, Key.NumPad6 }
//{ GdkKey.?, Key.NumPad7 }
//{ GdkKey.?, Key.NumPad8 }
//{ GdkKey.?, Key.NumPad9 }
{ GdkKey.multiply, Key.Multiply },
//{ GdkKey.?, Key.Add }
//{ GdkKey.?, Key.Separator }
//{ GdkKey.?, Key.Subtract }
//{ GdkKey.?, Key.Decimal }
//{ GdkKey.?, Key.Divide }
{ GdkKey.F1, Key.F1 },
{ GdkKey.F2, Key.F2 },
{ GdkKey.F3, Key.F3 },
{ GdkKey.F4, Key.F4 },
{ GdkKey.F5, Key.F5 },
{ GdkKey.F6, Key.F6 },
{ GdkKey.F7, Key.F7 },
{ GdkKey.F8, Key.F8 },
{ GdkKey.F9, Key.F9 },
{ GdkKey.F10, Key.F10 },
{ GdkKey.F11, Key.F11 },
{ GdkKey.F12, Key.F12 },
{ GdkKey.L3, Key.F13 },
{ GdkKey.F14, Key.F14 },
{ GdkKey.L5, Key.F15 },
{ GdkKey.F16, Key.F16 },
{ GdkKey.F17, Key.F17 },
{ GdkKey.L8, Key.F18 },
{ GdkKey.L9, Key.F19 },
{ GdkKey.L10, Key.F20 },
{ GdkKey.R1, Key.F21 },
{ GdkKey.R2, Key.F22 },
{ GdkKey.F23, Key.F23 },
{ GdkKey.R4, Key.F24 },
//{ GdkKey.?, Key.NumLock }
//{ GdkKey.?, Key.Scroll }
//{ GdkKey.?, Key.LeftShift }
//{ GdkKey.?, Key.RightShift }
//{ GdkKey.?, Key.LeftCtrl }
//{ GdkKey.?, Key.RightCtrl }
//{ GdkKey.?, Key.LeftAlt }
//{ GdkKey.?, Key.RightAlt }
//{ GdkKey.?, Key.BrowserBack }
//{ GdkKey.?, Key.BrowserForward }
//{ GdkKey.?, Key.BrowserRefresh }
//{ GdkKey.?, Key.BrowserStop }
//{ GdkKey.?, Key.BrowserSearch }
//{ GdkKey.?, Key.BrowserFavorites }
//{ GdkKey.?, Key.BrowserHome }
//{ GdkKey.?, Key.VolumeMute }
//{ GdkKey.?, Key.VolumeDown }
//{ GdkKey.?, Key.VolumeUp }
//{ GdkKey.?, Key.MediaNextTrack }
//{ GdkKey.?, Key.MediaPreviousTrack }
//{ GdkKey.?, Key.MediaStop }
//{ GdkKey.?, Key.MediaPlayPause }
//{ GdkKey.?, Key.LaunchMail }
//{ GdkKey.?, Key.SelectMedia }
//{ GdkKey.?, Key.LaunchApplication1 }
//{ GdkKey.?, Key.LaunchApplication2 }
//{ GdkKey.?, Key.OemSemicolon }
//{ GdkKey.?, Key.OemPlus }
//{ GdkKey.?, Key.OemComma }
//{ GdkKey.?, Key.OemMinus }
//{ GdkKey.?, Key.OemPeriod }
//{ GdkKey.?, Key.Oem2 }
//{ GdkKey.?, Key.OemTilde }
//{ GdkKey.?, Key.AbntC1 }
//{ GdkKey.?, Key.AbntC2 }
//{ GdkKey.?, Key.Oem4 }
//{ GdkKey.?, Key.OemPipe }
//{ GdkKey.?, Key.OemCloseBrackets }
//{ GdkKey.?, Key.Oem7 }
//{ GdkKey.?, Key.Oem8 }
//{ GdkKey.?, Key.Oem102 }
//{ GdkKey.?, Key.ImeProcessed }
//{ GdkKey.?, Key.System }
//{ GdkKey.?, Key.OemAttn }
//{ GdkKey.?, Key.OemFinish }
//{ GdkKey.?, Key.DbeHiragana }
//{ GdkKey.?, Key.OemAuto }
//{ GdkKey.?, Key.DbeDbcsChar }
//{ GdkKey.?, Key.OemBackTab }
//{ GdkKey.?, Key.Attn }
//{ GdkKey.?, Key.DbeEnterWordRegisterMode }
//{ GdkKey.?, Key.DbeEnterImeConfigureMode }
//{ GdkKey.?, Key.EraseEof }
//{ GdkKey.?, Key.Play }
//{ GdkKey.?, Key.Zoom }
//{ GdkKey.?, Key.NoName }
//{ GdkKey.?, Key.DbeEnterDialogConversionMode }
//{ GdkKey.?, Key.OemClear }
//{ GdkKey.?, Key.DeadCharProcessed }
};
public static Key ConvertKey(GdkKey key)
{
Key result;
return KeyDic.TryGetValue(key, out result) ? result : Key.None;
}
}
}

2
src/Gtk/Avalonia.Gtk/WindowImplBase.cs

@ -267,7 +267,7 @@ namespace Avalonia.Gtk
GtkKeyboardDevice.Instance, GtkKeyboardDevice.Instance,
evnt.Time, evnt.Time,
evnt.Type == EventType.KeyPress ? RawKeyEventType.KeyDown : RawKeyEventType.KeyUp, evnt.Type == EventType.KeyPress ? RawKeyEventType.KeyDown : RawKeyEventType.KeyUp,
GtkKeyboardDevice.ConvertKey(evnt.Key), GetModifierKeys(evnt.State)); Common.KeyTransform.ConvertKey(evnt.Key), GetModifierKeys(evnt.State));
Input(e); Input(e);
} }

1
src/Gtk/Avalonia.Gtk3/.gitignore

@ -0,0 +1 @@
project.lock.json

102
src/Gtk/Avalonia.Gtk3/Avalonia.Gtk3.csproj

@ -0,0 +1,102 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{BB1F7BB5-6AD4-4776-94D9-C09D0A972658}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Avalonia.Gtk3</RootNamespace>
<AssemblyName>Avalonia.Gtk3</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;GTK3_PINVOKE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;GTK3_PINVOKE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .NET Framework is automatically included -->
<None Include="project.json" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Avalonia.Gtk\KeyTransform.cs">
<Link>KeyTransform.cs</Link>
</Compile>
<Compile Include="ClipboardImpl.cs" />
<Compile Include="CursorFactory.cs" />
<Compile Include="FramebufferManager.cs" />
<Compile Include="GdkCursor.cs" />
<Compile Include="GdkKey.cs" />
<Compile Include="Gtk3Platform.cs" />
<Compile Include="Interop\GException.cs" />
<Compile Include="Interop\GObject.cs" />
<Compile Include="Interop\ICustomGtk3NativeLibraryResolver.cs" />
<Compile Include="Interop\DynLoader.cs" />
<Compile Include="Interop\GlibTimeout.cs" />
<Compile Include="Interop\Native.cs" />
<Compile Include="Interop\NativeException.cs" />
<Compile Include="Interop\Pixbuf.cs" />
<Compile Include="Interop\Resolver.cs" />
<Compile Include="Interop\Signal.cs" />
<Compile Include="ImageSurfaceFramebuffer.cs" />
<Compile Include="PlatformIconLoader.cs" />
<Compile Include="PopupImpl.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SystemDialogs.cs" />
<Compile Include="TopLevelImpl.cs" />
<Compile Include="Interop\Utf8Buffer.cs" />
<Compile Include="WindowImpl.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Avalonia.Base\Avalonia.Base.csproj">
<Project>{B09B78D8-9B26-48B0-9149-D64A2F120F3F}</Project>
<Name>Avalonia.Base</Name>
</ProjectReference>
<ProjectReference Include="..\..\Avalonia.Controls\Avalonia.Controls.csproj">
<Project>{D2221C82-4A25-4583-9B43-D791E3F6820C}</Project>
<Name>Avalonia.Controls</Name>
</ProjectReference>
<ProjectReference Include="..\..\Avalonia.Input\Avalonia.Input.csproj">
<Project>{62024B2D-53EB-4638-B26B-85EEAA54866E}</Project>
<Name>Avalonia.Input</Name>
</ProjectReference>
<ProjectReference Include="..\..\Avalonia.Interactivity\Avalonia.Interactivity.csproj">
<Project>{6b0ed19d-a08b-461c-a9d9-a9ee40b0c06b}</Project>
<Name>Avalonia.Interactivity</Name>
</ProjectReference>
<ProjectReference Include="..\..\Avalonia.Visuals\Avalonia.Visuals.csproj">
<Project>{EB582467-6ABB-43A1-B052-E981BA910E3A}</Project>
<Name>Avalonia.SceneGraph</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

53
src/Gtk/Avalonia.Gtk3/ClipboardImpl.cs

@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using Avalonia.Gtk3.Interop;
using Avalonia.Input.Platform;
namespace Avalonia.Gtk3
{
class ClipboardImpl : IClipboard
{
IntPtr GetClipboard() => Native.GtkClipboardGetForDisplay(Native.GdkGetDefaultDisplay(), IntPtr.Zero);
static void OnText(IntPtr clipboard, IntPtr utf8string, IntPtr userdata)
{
var handle = GCHandle.FromIntPtr(userdata);
((TaskCompletionSource<string>) handle.Target)
.TrySetResult(Utf8Buffer.StringFromPtr(utf8string));
handle.Free();
}
private static readonly Native.D.GtkClipboardTextReceivedFunc OnTextDelegate = OnText;
static ClipboardImpl()
{
GCHandle.Alloc(OnTextDelegate);
}
public Task<string> GetTextAsync()
{
var tcs = new TaskCompletionSource<string>();
Native.GtkClipboardRequestText(GetClipboard(), OnTextDelegate, GCHandle.ToIntPtr(GCHandle.Alloc(tcs)));
return tcs.Task;
}
public Task SetTextAsync(string text)
{
using (var buf = new Utf8Buffer(text))
Native.GtkClipboardSetText(GetClipboard(), buf, buf.ByteLen);
return Task.FromResult(0);
}
public Task ClearAsync()
{
Native.GtkClipboardRequestClear(GetClipboard());
return Task.FromResult(0);
}
}
}

79
src/Gtk/Avalonia.Gtk3/CursorFactory.cs

@ -0,0 +1,79 @@
using System;
using System.Collections.Generic;
using Avalonia.Gtk3.Interop;
using Avalonia.Input;
using Avalonia.Platform;
using CursorType = Avalonia.Gtk3.GdkCursorType;
namespace Avalonia.Gtk3
{
class CursorFactory : IStandardCursorFactory
{
private static readonly Dictionary<StandardCursorType, object> CursorTypeMapping = new Dictionary
<StandardCursorType, object>
{
{StandardCursorType.AppStarting, CursorType.Watch},
{StandardCursorType.Arrow, CursorType.LeftPtr},
{StandardCursorType.Cross, CursorType.Cross},
{StandardCursorType.Hand, CursorType.Hand1},
{StandardCursorType.Ibeam, CursorType.Xterm},
{StandardCursorType.No, "gtk-cancel"},
{StandardCursorType.SizeAll, CursorType.Sizing},
//{ StandardCursorType.SizeNorthEastSouthWest, 32643 },
{StandardCursorType.SizeNorthSouth, CursorType.SbVDoubleArrow},
//{ StandardCursorType.SizeNorthWestSouthEast, 32642 },
{StandardCursorType.SizeWestEast, CursorType.SbHDoubleArrow},
{StandardCursorType.UpArrow, CursorType.BasedArrowUp},
{StandardCursorType.Wait, CursorType.Watch},
{StandardCursorType.Help, "gtk-help"},
{StandardCursorType.TopSide, CursorType.TopSide},
{StandardCursorType.BottomSize, CursorType.BottomSide},
{StandardCursorType.LeftSide, CursorType.LeftSide},
{StandardCursorType.RightSide, CursorType.RightSide},
{StandardCursorType.TopLeftCorner, CursorType.TopLeftCorner},
{StandardCursorType.TopRightCorner, CursorType.TopRightCorner},
{StandardCursorType.BottomLeftCorner, CursorType.BottomLeftCorner},
{StandardCursorType.BottomRightCorner, CursorType.BottomRightCorner}
};
private static readonly Dictionary<StandardCursorType, IPlatformHandle> Cache =
new Dictionary<StandardCursorType, IPlatformHandle>();
private IntPtr GetCursor(object desc)
{
IntPtr rv;
var name = desc as string;
if (name != null)
{
var theme = Native.GtkIconThemeGetDefault();
IntPtr icon, error;
using (var u = new Utf8Buffer(name))
icon = Native.GtkIconThemeLoadIcon(theme, u, 32, 0, out error);
rv = icon == IntPtr.Zero
? Native.GdkCursorNew(GdkCursorType.XCursor)
: Native.GdkCursorNewFromPixbuf(Native.GdkGetDefaultDisplay(), icon, 0, 0);
}
else
{
rv = Native.GdkCursorNew((CursorType)desc);
}
return rv;
}
public IPlatformHandle GetCursor(StandardCursorType cursorType)
{
IPlatformHandle rv;
if (!Cache.TryGetValue(cursorType, out rv))
{
Cache[cursorType] =
rv =
new PlatformHandle(
GetCursor(CursorTypeMapping[cursorType]),
"GTKCURSOR");
}
return rv;
}
}
}

42
src/Gtk/Avalonia.Gtk3/FramebufferManager.cs

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Avalonia.Controls.Platform.Surfaces;
namespace Avalonia.Gtk3
{
class FramebufferManager : IFramebufferPlatformSurface, IDisposable
{
private readonly TopLevelImpl _window;
private ImageSurfaceFramebuffer _fb;
public FramebufferManager(TopLevelImpl window)
{
_window = window;
}
public void Dispose()
{
_fb?.Deallocate();
}
public ILockedFramebuffer Lock()
{
if(_window.CurrentCairoContext == IntPtr.Zero)
throw new InvalidOperationException("Window is not in drawing state");
var ctx = _window.CurrentCairoContext;
var width = (int) _window.ClientSize.Width;
var height = (int) _window.ClientSize.Height;
if (_fb == null || _fb.Width != width ||
_fb.Height != height)
{
_fb?.Dispose();
_fb = new ImageSurfaceFramebuffer(width, height);
}
_fb.Prepare(ctx);
return _fb;
}
}
}

91
src/Gtk/Avalonia.Gtk3/GdkCursor.cs

@ -0,0 +1,91 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Avalonia.Gtk3
{
enum GdkCursorType
{
CursorIsPixmap = -1,
XCursor = 0,
Arrow = 2,
BasedArrowDown = 4,
BasedArrowUp = 6,
Boat = 8,
Bogosity = 10,
BottomLeftCorner = 12,
BottomRightCorner = 14,
BottomSide = 16,
BottomTee = 18,
BoxSpiral = 20,
CenterPtr = 22,
Circle = 24,
Clock = 26,
CoffeeMug = 28,
Cross = 30,
CrossReverse = 32,
Crosshair = 34,
DiamondCross = 36,
Dot = 38,
Dotbox = 40,
DoubleArrow = 42,
DraftLarge = 44,
DraftSmall = 46,
DrapedBox = 48,
Exchange = 50,
Fleur = 52,
Gobbler = 54,
Gumby = 56,
Hand1 = 58,
Hand2 = 60,
Heart = 62,
Icon = 64,
IronCross = 66,
LeftPtr = 68,
LeftSide = 70,
LeftTee = 72,
Leftbutton = 74,
LlAngle = 76,
LrAngle = 78,
Man = 80,
Middlebutton = 82,
Mouse = 84,
Pencil = 86,
Pirate = 88,
Plus = 90,
QuestionArrow = 92,
RightPtr = 94,
RightSide = 96,
RightTee = 98,
Rightbutton = 100,
RtlLogo = 102,
Sailboat = 104,
SbDownArrow = 106,
SbHDoubleArrow = 108,
SbLeftArrow = 110,
SbRightArrow = 112,
SbUpArrow = 114,
SbVDoubleArrow = 116,
Shuttle = 118,
Sizing = 120,
Spider = 122,
Spraycan = 124,
Star = 126,
Target = 128,
Tcross = 130,
TopLeftArrow = 132,
TopLeftCorner = 134,
TopRightCorner = 136,
TopSide = 138,
TopTee = 140,
Trek = 142,
UlAngle = 144,
Umbrella = 146,
UrAngle = 148,
Watch = 150,
Xterm = 152,
LastCursor = 153,
}
}

1347
src/Gtk/Avalonia.Gtk3/GdkKey.cs

File diff suppressed because it is too large

116
src/Gtk/Avalonia.Gtk3/Gtk3Platform.cs

@ -0,0 +1,116 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Controls.Platform;
using Avalonia.Gtk3.Interop;
using Avalonia.Input;
using Avalonia.Input.Platform;
using Avalonia.Platform;
using Avalonia.Rendering;
using Avalonia.Gtk3;
namespace Avalonia.Gtk3
{
public class Gtk3Platform : IWindowingPlatform, IPlatformSettings, IPlatformThreadingInterface
{
internal static readonly Gtk3Platform Instance = new Gtk3Platform();
internal static readonly MouseDevice Mouse = new MouseDevice();
internal static readonly KeyboardDevice Keyboard = new KeyboardDevice();
internal static IntPtr App { get; set; }
public static void Initialize()
{
Resolver.Resolve();
Native.GtkInit(0, IntPtr.Zero);
using (var utf = new Utf8Buffer("avalonia.app." + Guid.NewGuid()))
App = Native.GtkApplicationNew(utf, 0);
//Mark current thread as UI thread
s_tlsMarker = true;
AvaloniaLocator.CurrentMutable.Bind<IWindowingPlatform>().ToConstant(Instance)
.Bind<IClipboard>().ToSingleton<ClipboardImpl>()
.Bind<IStandardCursorFactory>().ToConstant(new CursorFactory())
.Bind<IKeyboardDevice>().ToConstant(Keyboard)
.Bind<IMouseDevice>().ToConstant(Mouse)
.Bind<IPlatformSettings>().ToConstant(Instance)
.Bind<IPlatformThreadingInterface>().ToConstant(Instance)
.Bind<ISystemDialogImpl>().ToSingleton<SystemDialog>()
.Bind<IRenderLoop>().ToConstant(new DefaultRenderLoop(60))
.Bind<IPlatformIconLoader>().ToConstant(new PlatformIconLoader());
}
public IWindowImpl CreateWindow() => new WindowImpl();
public IEmbeddableWindowImpl CreateEmbeddableWindow()
{
throw new NotImplementedException();
}
public IPopupImpl CreatePopup() => new PopupImpl();
public Size DoubleClickSize => new Size(4, 4);
public TimeSpan DoubleClickTime => TimeSpan.FromMilliseconds(100); //STUB
public double RenderScalingFactor { get; } = 1;
public double LayoutScalingFactor { get; } = 1;
public void RunLoop(CancellationToken cancellationToken)
{
while (!cancellationToken.IsCancellationRequested)
Native.GtkMainIteration();
}
public IDisposable StartTimer(TimeSpan interval, Action tick)
{
return GlibTimeout.StarTimer((uint) interval.TotalMilliseconds, tick);
}
private bool _signaled = false;
object _lock = new object();
public void Signal()
{
lock(_lock)
if (!_signaled)
{
_signaled = true;
GlibTimeout.Add(0, () =>
{
lock (_lock)
{
_signaled = false;
}
Signaled?.Invoke();
return false;
});
}
}
public event Action Signaled;
[ThreadStatic]
private static bool s_tlsMarker;
public bool CurrentThreadIsLoopThread => s_tlsMarker;
}
}
namespace Avalonia
{
public static class Gtk3AppBuilderExtensions
{
public static T UseGtk3<T>(this AppBuilderBase<T> builder, ICustomGtk3NativeLibraryResolver resolver = null)
where T : AppBuilderBase<T>, new()
{
Resolver.Custom = resolver;
return builder.UseWindowingSubsystem(Gtk3Platform.Initialize, "GTK3");
}
}
}

63
src/Gtk/Avalonia.Gtk3/ImageSurfaceFramebuffer.cs

@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Avalonia.Controls.Platform.Surfaces;
using Avalonia.Gtk3.Interop;
using Avalonia.Platform;
namespace Avalonia.Gtk3
{
class ImageSurfaceFramebuffer : ILockedFramebuffer
{
private IntPtr _context;
private IntPtr _surface;
public ImageSurfaceFramebuffer(int width, int height)
{
_surface = Native.CairoImageSurfaceCreate(1, width, height);
Width = width;
Height = height;
Address = Native.CairoImageSurfaceGetData(_surface);
RowBytes = Native.CairoImageSurfaceGetStride(_surface);
Native.CairoSurfaceFlush(_surface);
}
public void Prepare(IntPtr context)
{
_context = context;
}
public void Deallocate()
{
Native.CairoSurfaceDestroy(_surface);
_surface = IntPtr.Zero;
}
public void Dispose()
{
if(_context == IntPtr.Zero || _surface == IntPtr.Zero)
return;
Native.CairoSurfaceMarkDirty(_surface);
Native.CairoSetSourceSurface(_context, _surface, 0, 0);
Native.CairoPaint(_context);
_context = IntPtr.Zero;
}
public IntPtr Address { get; }
public int Width { get; }
public int Height { get; }
public int RowBytes { get; }
//TODO: Proper DPI detect
public Size Dpi => new Size(96, 96);
public PixelFormat Format => PixelFormat.Bgra8888;
}
}

129
src/Gtk/Avalonia.Gtk3/Interop/DynLoader.cs

@ -0,0 +1,129 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
/*
* Source code imported from https://github.com/kekekeks/evhttp-sharp
* Source is provided under MIT license for Avalonia project and derived works
*/
namespace Avalonia.Gtk3.Interop
{
internal interface IDynLoader
{
IntPtr LoadLibrary(string dll);
IntPtr GetProcAddress(IntPtr dll, string proc);
}
class UnixLoader : IDynLoader
{
// ReSharper disable InconsistentNaming
static class LinuxImports
{
[DllImport("libdl.so.2")]
private static extern IntPtr dlopen(string path, int flags);
[DllImport("libdl.so.2")]
private static extern IntPtr dlsym(IntPtr handle, string symbol);
[DllImport("libdl.so.2")]
private static extern IntPtr dlerror();
public static void Init()
{
DlOpen = dlopen;
DlSym = dlsym;
DlError = dlerror;
}
}
static class OsXImports
{
[DllImport("/usr/lib/libSystem.dylib")]
private static extern IntPtr dlopen(string path, int flags);
[DllImport("/usr/lib/libSystem.dylib")]
private static extern IntPtr dlsym(IntPtr handle, string symbol);
[DllImport("/usr/lib/libSystem.dylib")]
private static extern IntPtr dlerror();
public static void Init()
{
DlOpen = dlopen;
DlSym = dlsym;
DlError = dlerror;
}
}
[DllImport("libc")]
static extern int uname(IntPtr buf);
static UnixLoader()
{
var buffer = Marshal.AllocHGlobal(0x1000);
uname(buffer);
var unixName = Marshal.PtrToStringAnsi(buffer);
Marshal.FreeHGlobal(buffer);
if(unixName == "Darwin")
OsXImports.Init();
else
LinuxImports.Init();
}
private static Func<string, int, IntPtr> DlOpen;
private static Func<IntPtr, string, IntPtr> DlSym;
private static Func<IntPtr> DlError;
// ReSharper restore InconsistentNaming
static string DlErrorString() => Marshal.PtrToStringAnsi(DlError());
public IntPtr LoadLibrary(string dll)
{
var handle = DlOpen(dll, 1);
if (handle == IntPtr.Zero)
throw new NativeException(DlErrorString());
return handle;
}
public IntPtr GetProcAddress(IntPtr dll, string proc)
{
var ptr = DlSym(dll, proc);
if (ptr == IntPtr.Zero)
throw new NativeException(DlErrorString());
return ptr;
}
}
internal class Win32Loader : IDynLoader
{
[DllImport("kernel32", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
private static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
[DllImport("kernel32", EntryPoint = "LoadLibraryW", SetLastError = true, CharSet = CharSet.Unicode)]
private static extern IntPtr LoadLibrary(string lpszLib);
IntPtr IDynLoader.LoadLibrary(string dll)
{
var handle = LoadLibrary(dll);
if (handle != IntPtr.Zero)
return handle;
var err = Marshal.GetLastWin32Error();
throw new NativeException("Error loading " + dll + " error " + err);
}
IntPtr IDynLoader.GetProcAddress(IntPtr dll, string proc)
{
var ptr = GetProcAddress(dll, proc);
if (ptr == IntPtr.Zero)
throw new NativeException("Error " + Marshal.GetLastWin32Error());
return ptr;
}
}
}

33
src/Gtk/Avalonia.Gtk3/Interop/GException.cs

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace Avalonia.Gtk3.Interop
{
public class GException : Exception
{
[StructLayout(LayoutKind.Sequential)]
struct GError
{
UInt32 domain;
int code;
public IntPtr message;
};
static unsafe string GetError(IntPtr error)
{
if (error == IntPtr.Zero)
return "Unknown error";
return Utf8Buffer.StringFromPtr(((GError*) error)->message);
}
public GException(IntPtr error) : base(GetError(error))
{
}
}
}

62
src/Gtk/Avalonia.Gtk3/Interop/GObject.cs

@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace Avalonia.Gtk3.Interop
{
class GObject : SafeHandle
{
public GObject() : base(IntPtr.Zero, true)
{
}
public GObject(IntPtr handle, bool owned = true) : base(IntPtr.Zero, owned)
{
this.handle = handle;
}
protected override bool ReleaseHandle()
{
if (handle != IntPtr.Zero)
Native.GObjectUnref(handle);
handle = IntPtr.Zero;
return true;
}
public override bool IsInvalid => handle == IntPtr.Zero;
}
class GInputStream : GObject
{
}
class GtkWidget : GObject
{
}
class GtkWindow : GtkWidget
{
}
class GtkImContext : GObject
{
}
class GtkDialog : GtkWindow
{
}
class GtkFileChooser : GtkDialog
{
}
}

64
src/Gtk/Avalonia.Gtk3/Interop/GlibTimeout.cs

@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace Avalonia.Gtk3.Interop
{
static class GlibTimeout
{
static bool Handler(IntPtr data)
{
var handle = GCHandle.FromIntPtr(data);
var cb = (Func<bool>) handle.Target;
if (!cb())
{
handle.Free();
return false;
}
return true;
}
private static readonly GCHandle PinnedHandle;
private static readonly Native.D.timeout_callback PinnedHandler;
static GlibTimeout()
{
PinnedHandler = Handler;
}
public static void Add(uint interval, Func<bool> callback)
{
var handle = GCHandle.Alloc(callback);
Native.GTimeoutAdd(interval, PinnedHandler, GCHandle.ToIntPtr(handle));
}
class Timer : IDisposable
{
public bool Stopped;
public void Dispose()
{
Stopped = true;
}
}
public static IDisposable StarTimer(uint interval, Action tick)
{
var timer = new Timer ();
GlibTimeout.Add(interval,
() =>
{
if (timer.Stopped)
return false;
tick();
return !timer.Stopped;
});
return timer;
}
}
}

17
src/Gtk/Avalonia.Gtk3/Interop/ICustomGtk3NativeLibraryResolver.cs

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Avalonia.Gtk3.Interop;
namespace Avalonia.Gtk3
{
public interface ICustomGtk3NativeLibraryResolver
{
string GetName(GtkDll dll);
string BasePath { get; }
bool TrySystemFirst { get; }
string Lookup(GtkDll dll);
}
}

571
src/Gtk/Avalonia.Gtk3/Interop/Native.cs

@ -0,0 +1,571 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using Avalonia.Controls;
using gint8 = System.Byte;
using gint16 = System.Int16;
using gint32 = System.Int32;
using gint = System.Int32;
using guint16 = System.UInt16;
using guint32 = System.UInt32;
using guint = System.UInt32;
using gdouble = System.Double;
namespace Avalonia.Gtk3.Interop
{
static class Native
{
public static class D
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate IntPtr gtk_application_new(Utf8Buffer appId, int flags);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate void gtk_main_iteration();
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate GtkWindow gtk_window_new(GtkWindowType windowType);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate IntPtr gtk_init(int argc, IntPtr argv);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate void gtk_window_present(GtkWindow gtkWindow);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate void gtk_widget_hide(GtkWidget gtkWidget);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate void gtk_window_set_icon(GtkWindow window, Pixbuf pixbuf);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate void gtk_window_set_modal(GtkWindow window, bool modal);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] //No manual import
public delegate IntPtr gdk_get_native_handle(IntPtr gdkWindow);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate IntPtr gtk_widget_get_window(GtkWidget gtkWidget);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate IntPtr gtk_widget_get_screen(GtkWidget gtkWidget);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate IntPtr gtk_widget_set_double_buffered(GtkWidget gtkWidget, bool value);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate IntPtr gtk_widget_set_events(GtkWidget gtkWidget, uint flags);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gdk)]
public delegate int gdk_screen_get_height(IntPtr screen);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gdk)]
public delegate int gdk_screen_get_width(IntPtr screen);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gdk)]
public delegate IntPtr gdk_display_get_default();
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gdk)]
public delegate int gdk_window_get_origin(IntPtr gdkWindow, out int x, out int y);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gdk)]
public delegate void gdk_window_resize(IntPtr gtkWindow, int width, int height);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate void gtk_widget_realize(GtkWidget gtkWidget);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate void gtk_window_set_title(GtkWindow gtkWindow, Utf8Buffer title);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate void gtk_window_set_decorated(GtkWindow gtkWindow, bool decorated);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate void gtk_window_get_size(GtkWindow gtkWindow, out int width, out int height);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate void gtk_window_resize(GtkWindow gtkWindow, int width, int height);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate void gtk_widget_set_size_request(GtkWidget widget, int width, int height);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate void gtk_window_set_default_size(GtkWindow gtkWindow, int width, int height);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate void gtk_window_get_position(GtkWindow gtkWindow, out int x, out int y);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate void gtk_window_move(GtkWindow gtkWindow, int x, int y);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate GtkFileChooser gtk_file_chooser_dialog_new(Utf8Buffer title, GtkWindow parent, GtkFileChooserAction action, IntPtr ignore);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public unsafe delegate GSList* gtk_file_chooser_get_filenames(GtkFileChooser chooser);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate void gtk_file_chooser_set_select_multiple(GtkFileChooser chooser, bool allow);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate void gtk_file_chooser_set_filename(GtkFileChooser chooser, Utf8Buffer file);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate void gtk_dialog_add_button(GtkDialog raw, Utf8Buffer button_text, GtkResponseType response_id);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Cairo)]
public delegate IntPtr cairo_image_surface_create(int format, int width, int height);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Cairo)]
public delegate IntPtr cairo_image_surface_get_data(IntPtr surface);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Cairo)]
public delegate int cairo_image_surface_get_stride(IntPtr surface);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Cairo)]
public delegate void cairo_surface_mark_dirty(IntPtr surface);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Cairo)]
public delegate void cairo_surface_flush(IntPtr surface);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Cairo)]
public delegate void cairo_surface_destroy(IntPtr surface);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Cairo)]
public delegate void cairo_set_source_surface(IntPtr cr, IntPtr surface, double x, double y);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Cairo)]
public delegate void cairo_paint(IntPtr context);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate void gtk_widget_queue_draw_area(GtkWidget widget, int x, int y, int width, int height);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate GtkImContext gtk_im_multicontext_new();
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate IntPtr gtk_im_context_set_client_window(GtkImContext context, IntPtr window);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate bool gtk_im_context_filter_keypress(GtkImContext context, IntPtr ev);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate void gtk_widget_activate(GtkWidget widget);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gdk)]
public delegate IntPtr gdk_screen_get_root_window(IntPtr screen);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gdk)]
public delegate IntPtr gdk_cursor_new(GdkCursorType type);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gdk)]
public delegate IntPtr gdk_window_get_pointer(IntPtr raw, out int x, out int y, out int mask);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gdk)]
public delegate void gtk_window_set_geometry_hints(GtkWindow window, IntPtr geometry_widget, ref GdkGeometry geometry, GdkWindowHints geom_mask);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gdk)]
public delegate void gdk_window_invalidate_rect(IntPtr window, ref GdkRectangle rect, bool invalidate_children);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gdk)]
public delegate void gdk_window_begin_move_drag(IntPtr window, gint button, gint root_x, gint root_y, guint32 timestamp);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gdk)]
public delegate void gdk_window_begin_resize_drag(IntPtr window, WindowEdge edge, gint button, gint root_x, gint root_y, guint32 timestamp);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gdk)]
public delegate void gdk_event_request_motions(IntPtr ev);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate IntPtr gtk_clipboard_get_for_display(IntPtr display, IntPtr atom);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate void gtk_clipboard_request_text(IntPtr clipboard, GtkClipboardTextReceivedFunc callback, IntPtr user_data);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate void gtk_clipboard_set_text(IntPtr clipboard, Utf8Buffer text, int len);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate void gtk_clipboard_clear(IntPtr clipboard);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.GdkPixBuf)]
public delegate IntPtr gdk_pixbuf_new_from_file(Utf8Buffer filename, out IntPtr error);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate IntPtr gtk_icon_theme_get_default();
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate IntPtr gtk_icon_theme_load_icon(IntPtr icon_theme, Utf8Buffer icon_name, gint size, int flags,out IntPtr error);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gdk)]
public delegate IntPtr gdk_cursor_new_from_pixbuf(IntPtr disp, IntPtr pixbuf, int x, int y);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gdk)]
public delegate IntPtr gdk_window_set_cursor(IntPtr window, IntPtr cursor);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.GdkPixBuf)]
public delegate IntPtr gdk_pixbuf_new_from_stream(GInputStream stream, IntPtr cancel, out IntPtr error);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.GdkPixBuf)]
public delegate bool gdk_pixbuf_save_to_bufferv(Pixbuf pixbuf, out IntPtr buffer, out IntPtr buffer_size,
Utf8Buffer type, IntPtr option_keys, IntPtr option_values, out IntPtr error);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gobject)]
public delegate void g_object_unref(IntPtr instance);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gobject)]
public delegate void g_object_ref(GObject instance);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gobject)]
public delegate ulong g_signal_connect_object(GObject instance, Utf8Buffer signal, IntPtr handler, IntPtr userData, int flags);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gobject)]
public delegate ulong g_signal_handler_disconnect(GObject instance, ulong connectionId);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Glib)]
public delegate ulong g_timeout_add(uint interval, timeout_callback callback, IntPtr data);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Glib)]
public delegate ulong g_free(IntPtr data);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Glib)]
public unsafe delegate void g_slist_free(GSList* data);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gio)]
public delegate GInputStream g_memory_input_stream_new_from_data(IntPtr ptr, IntPtr len, IntPtr destroyCallback);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate bool signal_widget_draw(IntPtr gtkWidget, IntPtr cairoContext, IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate bool signal_generic(IntPtr gtkWidget, IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate bool signal_dialog_response(IntPtr gtkWidget, GtkResponseType response, IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate bool signal_onevent(IntPtr gtkWidget, IntPtr ev, IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate bool signal_commit(IntPtr gtkWidget, IntPtr utf8string, IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate bool timeout_callback(IntPtr data);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void GtkClipboardTextReceivedFunc(IntPtr clipboard, IntPtr utf8string, IntPtr userdata);
}
public static D.gtk_window_set_decorated GtkWindowSetDecorated;
public static D.gtk_window_set_title GtkWindowSetTitle;
public static D.gtk_application_new GtkApplicationNew;
public static D.gtk_main_iteration GtkMainIteration;
public static D.gtk_window_new GtkWindowNew;
public static D.gtk_window_set_icon GtkWindowSetIcon;
public static D.gtk_window_set_modal GtkWindowSetModal;
public static D.gtk_init GtkInit;
public static D.gtk_window_present GtkWindowPresent;
public static D.gtk_widget_hide GtkWidgetHide;
public static D.gdk_get_native_handle GetNativeGdkWindowHandle;
public static D.gtk_widget_get_window GtkWidgetGetWindow;
public static D.gtk_widget_get_screen GtkWidgetGetScreen;
public static D.gtk_widget_realize GtkWidgetRealize;
public static D.gtk_window_get_size GtkWindowGetSize;
public static D.gtk_window_resize GtkWindowResize;
public static D.gdk_window_resize GdkWindowResize;
public static D.gtk_widget_set_size_request GtkWindowSetSizeRequest;
public static D.gtk_window_set_default_size GtkWindowSetDefaultSize;
public static D.gtk_window_get_position GtkWindowGetPosition;
public static D.gtk_window_move GtkWindowMove;
public static D.gtk_file_chooser_dialog_new GtkFileChooserDialogNew;
public static D.gtk_file_chooser_set_select_multiple GtkFileChooserSetSelectMultiple;
public static D.gtk_file_chooser_set_filename GtkFileChooserSetFilename;
public static D.gtk_file_chooser_get_filenames GtkFileChooserGetFilenames;
public static D.gtk_dialog_add_button GtkDialogAddButton;
public static D.g_object_unref GObjectUnref;
public static D.g_object_ref GObjectRef;
public static D.g_signal_connect_object GSignalConnectObject;
public static D.g_signal_handler_disconnect GSignalHandlerDisconnect;
public static D.g_timeout_add GTimeoutAdd;
public static D.g_free GFree;
public static D.g_slist_free GSlistFree;
public static D.g_memory_input_stream_new_from_data GMemoryInputStreamNewFromData;
public static D.gtk_widget_set_double_buffered GtkWidgetSetDoubleBuffered;
public static D.gtk_widget_set_events GtkWidgetSetEvents;
public static D.gdk_window_invalidate_rect GdkWindowInvalidateRect;
public static D.gtk_widget_queue_draw_area GtkWidgetQueueDrawArea;
public static D.gtk_widget_activate GtkWidgetActivate;
public static D.gtk_clipboard_get_for_display GtkClipboardGetForDisplay;
public static D.gtk_clipboard_request_text GtkClipboardRequestText;
public static D.gtk_clipboard_set_text GtkClipboardSetText;
public static D.gtk_clipboard_clear GtkClipboardRequestClear;
public static D.gtk_im_multicontext_new GtkImMulticontextNew;
public static D.gtk_im_context_filter_keypress GtkImContextFilterKeypress;
public static D.gtk_im_context_set_client_window GtkImContextSetClientWindow;
public static D.gdk_screen_get_height GdkScreenGetHeight;
public static D.gdk_display_get_default GdkGetDefaultDisplay;
public static D.gdk_screen_get_width GdkScreenGetWidth;
public static D.gdk_screen_get_root_window GdkScreenGetRootWindow;
public static D.gdk_cursor_new GdkCursorNew;
public static D.gdk_window_get_origin GdkWindowGetOrigin;
public static D.gdk_window_get_pointer GdkWindowGetPointer;
public static D.gdk_window_begin_move_drag GdkWindowBeginMoveDrag;
public static D.gdk_window_begin_resize_drag GdkWindowBeginResizeDrag;
public static D.gdk_event_request_motions GdkEventRequestMotions;
public static D.gdk_pixbuf_new_from_file GdkPixbufNewFromFile;
public static D.gtk_icon_theme_get_default GtkIconThemeGetDefault;
public static D.gtk_icon_theme_load_icon GtkIconThemeLoadIcon;
public static D.gdk_cursor_new_from_pixbuf GdkCursorNewFromPixbuf;
public static D.gdk_window_set_cursor GdkWindowSetCursor;
public static D.gdk_pixbuf_new_from_stream GdkPixbufNewFromStream;
public static D.gdk_pixbuf_save_to_bufferv GdkPixbufSaveToBufferv;
public static D.cairo_image_surface_create CairoImageSurfaceCreate;
public static D.cairo_image_surface_get_data CairoImageSurfaceGetData;
public static D.cairo_image_surface_get_stride CairoImageSurfaceGetStride;
public static D.cairo_surface_mark_dirty CairoSurfaceMarkDirty;
public static D.cairo_surface_flush CairoSurfaceFlush;
public static D.cairo_surface_destroy CairoSurfaceDestroy;
public static D.cairo_set_source_surface CairoSetSourceSurface;
public static D.cairo_paint CairoPaint;
}
public enum GtkWindowType
{
TopLevel,
Popup
}
[StructLayout(LayoutKind.Sequential)]
public struct GdkRectangle
{
public int X, Y, Width, Height;
public static GdkRectangle FromRect(Rect rect)
{
return new GdkRectangle
{
X = (int) rect.X,
Y = (int) rect.Y,
Width = (int) rect.Width,
Height = (int) rect.Height
};
}
}
enum GdkEventType
{
Nothing = -1,
Delete = 0,
Destroy = 1,
Expose = 2,
MotionNotify = 3,
ButtonPress = 4,
TwoButtonPress = 5,
ThreeButtonPress = 6,
ButtonRelease = 7,
KeyPress = 8,
KeyRelease = 9,
EnterNotify = 10,
LeaveNotify = 11,
FocusChange = 12,
Configure = 13,
Map = 14,
Unmap = 15,
PropertyNotify = 16,
SelectionClear = 17,
SelectionRequest = 18,
SelectionNotify = 19,
ProximityIn = 20,
ProximityOut = 21,
DragEnter = 22,
DragLeave = 23,
DragMotion = 24,
DragStatus = 25,
DropStart = 26,
DropFinished = 27,
ClientEvent = 28,
VisibilityNotify = 29,
NoExpose = 30,
Scroll = 31,
WindowState = 32,
Setting = 33,
OwnerChange = 34,
GrabBroken = 35,
}
enum GdkModifierType
{
ShiftMask = 1,
LockMask = 2,
ControlMask = 4,
Mod1Mask = 8,
Mod2Mask = 16,
Mod3Mask = 32,
Mod4Mask = 64,
Mod5Mask = 128,
Button1Mask = 256,
Button2Mask = 512,
Button3Mask = 1024,
Button4Mask = 2048,
Button5Mask = 4096,
SuperMask = 67108864,
HyperMask = 134217728,
MetaMask = 268435456,
ReleaseMask = 1073741824,
ModifierMask = ReleaseMask | Button5Mask | Button4Mask | Button3Mask | Button2Mask | Button1Mask | Mod5Mask | Mod4Mask | Mod3Mask | Mod2Mask | Mod1Mask | ControlMask | LockMask | ShiftMask,
None = 0,
}
enum GdkScrollDirection
{
Up,
Down,
Left,
Right,
Smooth
}
[StructLayout(LayoutKind.Sequential)]
unsafe struct GdkEventButton
{
public GdkEventType type;
public IntPtr window;
public gint8 send_event;
public guint32 time;
public gdouble x;
public gdouble y;
public gdouble* axes;
public GdkModifierType state;
public guint button;
public IntPtr device;
public gdouble x_root, y_root;
}
[StructLayout(LayoutKind.Sequential)]
unsafe struct GdkEventMotion
{
public GdkEventType type;
public IntPtr window;
public gint8 send_event;
public guint32 time;
public gdouble x;
public gdouble y;
public gdouble* axes;
public GdkModifierType state;
public gint16 is_hint;
public IntPtr device;
public gdouble x_root, y_root;
}
[StructLayout(LayoutKind.Sequential)]
unsafe struct GdkEventScroll
{
public GdkEventType type;
public IntPtr window;
public gint8 send_event;
public guint32 time;
public gdouble x;
public gdouble y;
public GdkModifierType state;
public GdkScrollDirection direction;
public IntPtr device;
public gdouble x_root, y_root;
public gdouble delta_x;
public gdouble delta_y;
}
[StructLayout(LayoutKind.Sequential)]
unsafe struct GdkEventWindowState
{
public GdkEventType type;
public IntPtr window;
gint8 send_event;
public GdkWindowState changed_mask;
public GdkWindowState new_window_state;
}
[StructLayout(LayoutKind.Sequential)]
unsafe struct GdkEventKey
{
public GdkEventType type;
public IntPtr window;
public gint8 send_event;
public guint32 time;
public guint state;
public guint keyval;
public gint length;
public IntPtr pstring;
public guint16 hardware_keycode;
public byte group;
public guint is_modifier;
}
[StructLayout(LayoutKind.Sequential)]
unsafe struct GSList
{
public IntPtr Data;
public GSList* Next;
}
[Flags]
public enum GdkWindowState
{
Withdrawn = 1,
Iconified = 2,
Maximized = 4,
Sticky = 8,
Fullscreen = 16,
Above = 32,
Below = 64,
Focused = 128,
Ttiled = 256
}
public enum GtkResponseType
{
Help = -11,
Apply = -10,
No = -9,
Yes = -8,
Close = -7,
Cancel = -6,
Ok = -5,
DeleteEvent = -4,
Accept = -3,
Reject = -2,
None = -1,
}
public enum GtkFileChooserAction
{
Open,
Save,
SelectFolder,
CreateFolder,
}
[StructLayout(LayoutKind.Sequential)]
struct GdkGeometry
{
gint min_width;
gint min_height;
gint max_width;
gint max_height;
gint base_width;
gint base_height;
gint width_inc;
gint height_inc;
gdouble min_aspect;
gdouble max_aspect;
gint win_gravity;
}
enum GdkWindowHints
{
GDK_HINT_POS = 1 << 0,
GDK_HINT_MIN_SIZE = 1 << 1,
GDK_HINT_MAX_SIZE = 1 << 2,
GDK_HINT_BASE_SIZE = 1 << 3,
GDK_HINT_ASPECT = 1 << 4,
GDK_HINT_RESIZE_INC = 1 << 5,
GDK_HINT_WIN_GRAVITY = 1 << 6,
GDK_HINT_USER_POS = 1 << 7,
GDK_HINT_USER_SIZE = 1 << 8
}
}

24
src/Gtk/Avalonia.Gtk3/Interop/NativeException.cs

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Avalonia.Gtk3.Interop
{
public class NativeException : Exception
{
public NativeException()
{
}
public NativeException(string message) : base(message)
{
}
public NativeException(string message, Exception inner) : base(message, inner)
{
}
}
}

68
src/Gtk/Avalonia.Gtk3/Interop/Pixbuf.cs

@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using Avalonia.Platform;
namespace Avalonia.Gtk3.Interop
{
internal class Pixbuf : GObject, IWindowIconImpl
{
Pixbuf(IntPtr handle) : base(handle)
{
}
public static Pixbuf NewFromFile(string filename)
{
using (var ub = new Utf8Buffer(filename))
{
IntPtr err;
var rv = Native.GdkPixbufNewFromFile(ub, out err);
if(rv != IntPtr.Zero)
return new Pixbuf(rv);
throw new GException(err);
}
}
public static unsafe Pixbuf NewFromBytes(byte[] data)
{
fixed (void* bytes = data)
{
using (var stream = Native.GMemoryInputStreamNewFromData(new IntPtr(bytes), new IntPtr(data.Length), IntPtr.Zero))
{
IntPtr err;
var rv = Native.GdkPixbufNewFromStream(stream, IntPtr.Zero, out err);
if (rv != IntPtr.Zero)
return new Pixbuf(rv);
throw new GException(err);
}
}
}
public static Pixbuf NewFromStream(Stream s)
{
if (s is MemoryStream)
return NewFromBytes(((MemoryStream) s).ToArray());
var ms = new MemoryStream();
s.CopyTo(ms);
return NewFromBytes(ms.ToArray());
}
public void Save(Stream outputStream)
{
IntPtr buffer, bufferLen, error;
using (var png = new Utf8Buffer("png"))
if (!Native.GdkPixbufSaveToBufferv(this, out buffer, out bufferLen, png,
IntPtr.Zero, IntPtr.Zero, out error))
throw new GException(error);
var data = new byte[bufferLen.ToInt32()];
Marshal.Copy(buffer, data, 0, bufferLen.ToInt32());
Native.GFree(buffer);
outputStream.Write(data, 0, data.Length);
}
}
}

155
src/Gtk/Avalonia.Gtk3/Interop/Resolver.cs

@ -0,0 +1,155 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using Avalonia.Platform;
namespace Avalonia.Gtk3.Interop
{
internal class GtkImportAttribute : Attribute
{
public GtkDll Dll { get; set; }
public string Name { get; set; }
public bool Optional { get; set; }
public GtkImportAttribute(GtkDll dll, string name = null, bool optional = false)
{
Dll = dll;
Name = name;
Optional = optional;
}
}
public enum GtkDll
{
Gdk,
Gtk,
Glib,
Gio,
Gobject,
Cairo,
GdkPixBuf
}
static class Resolver
{
private static Lazy<OperatingSystemType> Platform =
new Lazy<OperatingSystemType>(
() => AvaloniaLocator.Current.GetService<IRuntimePlatform>().GetRuntimeInfo().OperatingSystem);
public static ICustomGtk3NativeLibraryResolver Custom { get; set; }
static string FormatName(string name, int version = 0)
{
if (Platform.Value == OperatingSystemType.WinNT)
return "lib" + name + "-" + version + ".dll";
if (Platform.Value == OperatingSystemType.Linux)
return "lib" + name + ".so" + "." + version;
if (Platform.Value == OperatingSystemType.OSX)
return "lib" + name + "." + version + ".dylib";
throw new Exception("Unknown platform, use custom name resolver");
}
static string GetDllName(GtkDll dll)
{
var name = Custom?.GetName(dll);
if (name != null)
return name;
switch (dll)
{
case GtkDll.Cairo:
return FormatName("cairo", 2);
case GtkDll.Gdk:
return FormatName("gdk-3");
case GtkDll.Glib:
return FormatName("glib-2.0");
case GtkDll.Gio:
return FormatName("gio-2.0");
case GtkDll.Gtk:
return FormatName("gtk-3");
case GtkDll.Gobject:
return FormatName("gobject-2.0");
case GtkDll.GdkPixBuf:
return FormatName("gdk_pixbuf-2.0");
default:
throw new ArgumentException("Unknown lib: " + dll);
}
}
static IntPtr LoadDll(IDynLoader loader, GtkDll dll)
{
var exceptions = new List<Exception>();
var name = GetDllName(dll);
if (Custom?.TrySystemFirst != false)
{
try
{
return loader.LoadLibrary(name);
}
catch (Exception e)
{
exceptions.Add(e);
}
}
var path = Custom?.Lookup(dll);
if (path == null && Custom?.BasePath != null)
path = Path.Combine(Custom.BasePath, name);
try
{
return loader.LoadLibrary(path);
}
catch (Exception e)
{
exceptions.Add(e);
}
throw new AggregateException("Unable to load " + dll, exceptions);
}
public static void Resolve(string basePath = null)
{
var loader = Platform.Value == OperatingSystemType.WinNT ? (IDynLoader)new Win32Loader() : new UnixLoader();
var dlls = Enum.GetValues(typeof(GtkDll)).Cast<GtkDll>().ToDictionary(x => x, x => LoadDll(loader, x));
foreach (var fieldInfo in typeof(Native).GetTypeInfo().DeclaredFields)
{
var import = fieldInfo.FieldType.GetTypeInfo().GetCustomAttributes(typeof(GtkImportAttribute), true).Cast<GtkImportAttribute>().FirstOrDefault();
if(import == null)
continue;
IntPtr lib = dlls[import.Dll];
var funcPtr = loader.GetProcAddress(lib, import.Name ?? fieldInfo.FieldType.Name);
fieldInfo.SetValue(null, Marshal.GetDelegateForFunctionPointer(funcPtr, fieldInfo.FieldType));
}
var nativeHandleNames = new[] { "gdk_win32_window_get_handle", "gdk_x11_window_get_xid", "gdk_quartz_window_get_nswindow" };
foreach (var name in nativeHandleNames)
{
try
{
Native.GetNativeGdkWindowHandle = (Native.D.gdk_get_native_handle)Marshal
.GetDelegateForFunctionPointer(loader.GetProcAddress(dlls[GtkDll.Gdk], name), typeof(Native.D.gdk_get_native_handle));
break;
}
catch { }
}
if (Native.GetNativeGdkWindowHandle == null)
throw new Exception($"Unable to locate any of [{string.Join(", ", nativeHandleNames)}] in libgdk");
}
}
}

50
src/Gtk/Avalonia.Gtk3/Interop/Signal.cs

@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace Avalonia.Gtk3.Interop
{
class Signal
{
class ConnectedSignal : IDisposable
{
private readonly GObject _instance;
private GCHandle _handle;
private readonly ulong _id;
public ConnectedSignal(GObject instance, GCHandle handle, ulong id)
{
_instance = instance;
Native.GObjectRef(instance);
_handle = handle;
_id = id;
}
public void Dispose()
{
if (_handle.IsAllocated)
{
Native.GObjectUnref(_instance.DangerousGetHandle());
Native.GSignalHandlerDisconnect(_instance, _id);
_handle.Free();
}
}
}
public static IDisposable Connect<T>(GObject obj, string name, T handler)
{
var handle = GCHandle.Alloc(handler);
var ptr = Marshal.GetFunctionPointerForDelegate((Delegate)(object)handler);
using (var utf = new Utf8Buffer(name))
{
var id = Native.GSignalConnectObject(obj, utf, ptr, IntPtr.Zero, 0);
if (id == 0)
throw new ArgumentException("Unable to connect to signal " + name);
return new ConnectedSignal(obj, handle, id);
}
}
}
}

45
src/Gtk/Avalonia.Gtk3/Interop/Utf8Buffer.cs

@ -0,0 +1,45 @@
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace Avalonia.Gtk3.Interop
{
class Utf8Buffer : SafeHandle
{
private GCHandle _gchandle;
private byte[] _data;
public Utf8Buffer(string s) : base(IntPtr.Zero, true)
{
_data = Encoding.UTF8.GetBytes(s);
_gchandle = GCHandle.Alloc(_data, GCHandleType.Pinned);
handle = _gchandle.AddrOfPinnedObject();
}
public int ByteLen => _data.Length;
protected override bool ReleaseHandle()
{
if (handle != IntPtr.Zero)
{
handle = IntPtr.Zero;
_data = null;
_gchandle.Free();
}
return true;
}
public override bool IsInvalid => handle == IntPtr.Zero;
public static unsafe string StringFromPtr(IntPtr s)
{
var pstr = (byte*)s;
int len;
for (len = 0; pstr[len] != 0; len++) ;
var bytes = new byte[len];
Marshal.Copy(s, bytes, 0, len);
return Encoding.UTF8.GetString(bytes, 0, len);
}
}
}

20
src/Gtk/Avalonia.Gtk3/PlatformIconLoader.cs

@ -0,0 +1,20 @@
using System.IO;
using Avalonia.Gtk3.Interop;
using Avalonia.Platform;
namespace Avalonia.Gtk3
{
class PlatformIconLoader : IPlatformIconLoader
{
public IWindowIconImpl LoadIcon(string fileName) => Pixbuf.NewFromFile(fileName);
public IWindowIconImpl LoadIcon(Stream stream) => Pixbuf.NewFromStream(stream);
public IWindowIconImpl LoadIcon(IBitmapImpl bitmap)
{
var ms = new MemoryStream();
bitmap.Save(ms);
return Pixbuf.NewFromBytes(ms.ToArray());
}
}
}

24
src/Gtk/Avalonia.Gtk3/PopupImpl.cs

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Avalonia.Gtk3.Interop;
using Avalonia.Platform;
namespace Avalonia.Gtk3
{
class PopupImpl : TopLevelImpl, IPopupImpl
{
static GtkWindow CreateWindow()
{
var window = Native.GtkWindowNew(GtkWindowType.Popup);
return window;
}
public PopupImpl() : base(CreateWindow())
{
}
}
}

30
src/Gtk/Avalonia.Gtk3/Properties/AssemblyInfo.cs

@ -0,0 +1,30 @@
using System.Resources;
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.Gtk3")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Avalonia.Gtk3")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("en")]
// 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")]

8
src/Gtk/Avalonia.Gtk3/README.md

@ -0,0 +1,8 @@
P/Invoke based GTK3 backend
===========================
Code is EXPERIMENTAL at this point. It also needs Direct2D/Skia for rendering.
Windows GTK3 binaries aren't included in the repo, you need to download them from https://sourceforge.net/projects/gtk3win/
On Linux it should work out of the box with system-provided GTK3. On OSX you should be able to wire GTK3 using DYLD_LIBRARY_PATH environment variable.

92
src/Gtk/Avalonia.Gtk3/SystemDialogs.cs

@ -0,0 +1,92 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Controls.Platform;
using Avalonia.Gtk3.Interop;
using Avalonia.Input.Platform;
using Avalonia.Platform;
namespace Avalonia.Gtk3
{
class SystemDialog : ISystemDialogImpl
{
unsafe static Task<string[]> ShowDialog(string title, GtkWindow parent, GtkFileChooserAction action,
bool multiselect, string initialFileName)
{
GtkFileChooser dlg;
using (var name = title != null ? new Utf8Buffer(title) : null)
dlg = Native.GtkFileChooserDialogNew(name, parent, action, IntPtr.Zero);
if (multiselect)
Native.GtkFileChooserSetSelectMultiple(dlg, true);
Native.GtkWindowSetModal(dlg, true);
var tcs = new TaskCompletionSource<string[]>();
List<IDisposable> disposables = null;
Action dispose = () =>
{
foreach (var d in disposables)
d.Dispose();
disposables.Clear();
};
disposables = new List<IDisposable>
{
Signal.Connect<Native.D.signal_generic>(dlg, "close", delegate
{
tcs.TrySetResult(null);
dispose();
return false;
}),
Signal.Connect<Native.D.signal_dialog_response>(dlg, "response", (_, resp, __)=>
{
string[] result = null;
if (resp == GtkResponseType.Accept)
{
var rlst = new List<string>();
var gs = Native.GtkFileChooserGetFilenames(dlg);
var cgs = gs;
while (cgs != null)
{
if (cgs->Data != IntPtr.Zero)
rlst.Add(Utf8Buffer.StringFromPtr(cgs->Data));
cgs = cgs->Next;
}
Native.GSlistFree(gs);
result = rlst.ToArray();
}
Native.GtkWidgetHide(dlg);
dispose();
tcs.TrySetResult(result);
return false;
}),
dlg
};
using (var open = new Utf8Buffer("Open"))
Native.GtkDialogAddButton(dlg, open, GtkResponseType.Accept);
using (var open = new Utf8Buffer("Cancel"))
Native.GtkDialogAddButton(dlg, open, GtkResponseType.Cancel);
if(initialFileName!=null)
using (var fn = new Utf8Buffer(initialFileName))
Native.GtkFileChooserSetFilename(dlg, fn);
Native.GtkWindowPresent(dlg);
return tcs.Task;
}
public Task<string[]> ShowFileDialogAsync(FileDialog dialog, IWindowImpl parent)
{
return ShowDialog(dialog.Title, ((TopLevelImpl) parent)?.GtkWidget,
dialog is OpenFileDialog ? GtkFileChooserAction.Open : GtkFileChooserAction.Save,
(dialog as OpenFileDialog)?.AllowMultiple ?? false, dialog.InitialFileName);
}
public async Task<string> ShowFolderDialogAsync(OpenFolderDialog dialog, IWindowImpl parent)
{
var res = await ShowDialog(dialog.Title, ((TopLevelImpl) parent)?.GtkWidget,
GtkFileChooserAction.SelectFolder, false, dialog.InitialDirectory);
return res?.FirstOrDefault();
}
}
}

334
src/Gtk/Avalonia.Gtk3/TopLevelImpl.cs

@ -0,0 +1,334 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using Avalonia.Controls;
using Avalonia.Gtk3.Interop;
using Avalonia.Input;
using Avalonia.Input.Raw;
using Avalonia.Platform;
namespace Avalonia.Gtk3
{
abstract class TopLevelImpl : ITopLevelImpl, IPlatformHandle
{
public readonly GtkWindow GtkWidget;
private IInputRoot _inputRoot;
private readonly GtkImContext _imContext;
private readonly FramebufferManager _framebuffer;
protected readonly List<IDisposable> Disposables = new List<IDisposable>();
private Size _lastSize;
private Point _lastPosition;
private uint _lastKbdEvent;
private uint _lastSmoothScrollEvent;
public TopLevelImpl(GtkWindow gtkWidget)
{
GtkWidget = gtkWidget;
Disposables.Add(gtkWidget);
_framebuffer = new FramebufferManager(this);
_imContext = Native.GtkImMulticontextNew();
Disposables.Add(_imContext);
Native.GtkWidgetSetEvents(gtkWidget, 0xFFFFFE);
Disposables.Add(Signal.Connect<Native.D.signal_commit>(_imContext, "commit", OnCommit));
Connect<Native.D.signal_widget_draw>("draw", OnDraw);
Connect<Native.D.signal_generic>("realize", OnRealized);
ConnectEvent("configure-event", OnConfigured);
ConnectEvent("button-press-event", OnButton);
ConnectEvent("button-release-event", OnButton);
ConnectEvent("motion-notify-event", OnMotion);
ConnectEvent("scroll-event", OnScroll);
ConnectEvent("window-state-event", OnStateChanged);
ConnectEvent("key-press-event", OnKeyEvent);
ConnectEvent("key-release-event", OnKeyEvent);
Connect<Native.D.signal_generic>("destroy", OnDestroy);
Native.GtkWidgetRealize(gtkWidget);
_lastSize = ClientSize;
}
private bool OnConfigured(IntPtr gtkwidget, IntPtr ev, IntPtr userdata)
{
var size = ClientSize;
if (_lastSize != size)
{
Resized?.Invoke(size);
_lastSize = size;
}
var pos = Position;
if (_lastPosition != pos)
{
PositionChanged?.Invoke(pos);
_lastPosition = pos;
}
return false;
}
private bool OnRealized(IntPtr gtkwidget, IntPtr userdata)
{
Native.GtkImContextSetClientWindow(_imContext, Native.GtkWidgetGetWindow(GtkWidget));
return false;
}
private bool OnDestroy(IntPtr gtkwidget, IntPtr userdata)
{
Closed?.Invoke();
return false;
}
private static InputModifiers GetModifierKeys(GdkModifierType state)
{
var rv = InputModifiers.None;
if (state.HasFlag(GdkModifierType.ControlMask))
rv |= InputModifiers.Control;
if (state.HasFlag(GdkModifierType.ShiftMask))
rv |= InputModifiers.Shift;
if (state.HasFlag(GdkModifierType.Mod1Mask))
rv |= InputModifiers.Control;
if (state.HasFlag(GdkModifierType.Button1Mask))
rv |= InputModifiers.LeftMouseButton;
if (state.HasFlag(GdkModifierType.Button2Mask))
rv |= InputModifiers.RightMouseButton;
if (state.HasFlag(GdkModifierType.Button3Mask))
rv |= InputModifiers.MiddleMouseButton;
return rv;
}
private unsafe bool OnButton(IntPtr w, IntPtr ev, IntPtr userdata)
{
var evnt = (GdkEventButton*)ev;
var e = new RawMouseEventArgs(
Gtk3Platform.Mouse,
evnt->time,
_inputRoot,
evnt->type == GdkEventType.ButtonRelease
? evnt->button == 1
? RawMouseEventType.LeftButtonUp
: evnt->button == 3 ? RawMouseEventType.RightButtonUp : RawMouseEventType.MiddleButtonUp
: evnt->button == 1
? RawMouseEventType.LeftButtonDown
: evnt->button == 3 ? RawMouseEventType.RightButtonDown : RawMouseEventType.MiddleButtonDown,
new Point(evnt->x, evnt->y), GetModifierKeys(evnt->state));
Input?.Invoke(e);
return true;
}
protected virtual unsafe bool OnStateChanged(IntPtr w, IntPtr pev, IntPtr userData)
{
var ev = (GdkEventWindowState*) pev;
if (ev->changed_mask.HasFlag(GdkWindowState.Focused))
{
if(ev->new_window_state.HasFlag(GdkWindowState.Focused))
Activated?.Invoke();
else
Deactivated?.Invoke();
}
return true;
}
private unsafe bool OnMotion(IntPtr w, IntPtr ev, IntPtr userdata)
{
var evnt = (GdkEventMotion*)ev;
var position = new Point(evnt->x, evnt->y);
Native.GdkEventRequestMotions(ev);
var e = new RawMouseEventArgs(
Gtk3Platform.Mouse,
evnt->time,
_inputRoot,
RawMouseEventType.Move,
position, GetModifierKeys(evnt->state));
Input(e);
return true;
}
private unsafe bool OnScroll(IntPtr w, IntPtr ev, IntPtr userdata)
{
var evnt = (GdkEventScroll*)ev;
//Ignore duplicates
if (evnt->time - _lastSmoothScrollEvent < 10 && evnt->direction != GdkScrollDirection.Smooth)
return true;
var delta = new Vector();
const double step = (double) 1;
if (evnt->direction == GdkScrollDirection.Down)
delta = new Vector(0, -step);
else if (evnt->direction == GdkScrollDirection.Up)
delta = new Vector(0, step);
else if (evnt->direction == GdkScrollDirection.Right)
delta = new Vector(-step, 0);
else if (evnt->direction == GdkScrollDirection.Left)
delta = new Vector(step, 0);
else if (evnt->direction == GdkScrollDirection.Smooth)
{
delta = new Vector(-evnt->delta_x, -evnt->delta_y);
_lastSmoothScrollEvent = evnt->time;
}
var e = new RawMouseWheelEventArgs(Gtk3Platform.Mouse, evnt->time, _inputRoot,
new Point(evnt->x, evnt->y), delta, GetModifierKeys(evnt->state));
Input(e);
return true;
}
private unsafe bool OnKeyEvent(IntPtr w, IntPtr pev, IntPtr userData)
{
var evnt = (GdkEventKey*) pev;
_lastKbdEvent = evnt->time;
if (Native.GtkImContextFilterKeypress(_imContext, pev))
return true;
var e = new RawKeyEventArgs(
Gtk3Platform.Keyboard,
evnt->time,
evnt->type == GdkEventType.KeyPress ? RawKeyEventType.KeyDown : RawKeyEventType.KeyUp,
Avalonia.Gtk.Common.KeyTransform.ConvertKey((GdkKey)evnt->keyval), GetModifierKeys((GdkModifierType)evnt->state));
Input(e);
return true;
}
private unsafe bool OnCommit(IntPtr gtkwidget, IntPtr utf8string, IntPtr userdata)
{
Input(new RawTextInputEventArgs(Gtk3Platform.Keyboard, _lastKbdEvent, Utf8Buffer.StringFromPtr(utf8string)));
return true;
}
void ConnectEvent(string name, Native.D.signal_onevent handler)
=> Disposables.Add(Signal.Connect<Native.D.signal_onevent>(GtkWidget, name, handler));
void Connect<T>(string name, T handler) => Disposables.Add(Signal.Connect(GtkWidget, name, handler));
internal IntPtr CurrentCairoContext { get; private set; }
private bool OnDraw(IntPtr gtkwidget, IntPtr cairocontext, IntPtr userdata)
{
CurrentCairoContext = cairocontext;
Paint?.Invoke(new Rect(ClientSize));
CurrentCairoContext = IntPtr.Zero;
return true;
}
public void Dispose()
{
Closed?.Invoke();
foreach(var d in Disposables.AsEnumerable().Reverse())
d.Dispose();
Disposables.Clear();
}
public Size MaxClientSize
{
get
{
var s = Native.GtkWidgetGetScreen(GtkWidget);
return new Size(Native.GdkScreenGetWidth(s), Native.GdkScreenGetHeight(s));
}
}
public double Scaling => 1; //TODO: Implement scaling
public IPlatformHandle Handle => this;
string IPlatformHandle.HandleDescriptor => "HWND";
public Action Activated { get; set; }
public Action Closed { get; set; }
public Action Deactivated { get; set; }
public Action<RawInputEventArgs> Input { get; set; }
public Action<Rect> Paint { get; set; }
public Action<Size> Resized { get; set; }
public Action<double> ScalingChanged { get; set; } //TODO
public Action<Point> PositionChanged { get; set; }
public void Activate() => Native.GtkWidgetActivate(GtkWidget);
public void Invalidate(Rect rect)
{
if(GtkWidget.IsClosed)
return;
Native.GtkWidgetQueueDrawArea(GtkWidget, (int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height);
}
public void SetInputRoot(IInputRoot inputRoot) => _inputRoot = inputRoot;
public Point PointToClient(Point point)
{
int x, y;
Native.GdkWindowGetOrigin(Native.GtkWidgetGetWindow(GtkWidget), out x, out y);
return new Point(point.X - x, point.Y - y);
}
public Point PointToScreen(Point point)
{
int x, y;
Native.GdkWindowGetOrigin(Native.GtkWidgetGetWindow(GtkWidget), out x, out y);
return new Point(point.X + x, point.Y + y);
}
public void SetCursor(IPlatformHandle cursor)
{
if (GtkWidget.IsClosed)
return;
Native.GdkWindowSetCursor(Native.GtkWidgetGetWindow(GtkWidget), cursor?.Handle ?? IntPtr.Zero);
}
public void Show() => Native.GtkWindowPresent(GtkWidget);
public void Hide() => Native.GtkWidgetHide(GtkWidget);
void GetGlobalPointer(out int x, out int y)
{
int mask;
Native.GdkWindowGetPointer(Native.GdkScreenGetRootWindow(Native.GtkWidgetGetScreen(GtkWidget)),
out x, out y, out mask);
}
public void BeginMoveDrag()
{
int x, y;
GetGlobalPointer(out x, out y);
Native.GdkWindowBeginMoveDrag(Native.GtkWidgetGetWindow(GtkWidget), 1, x, y, 0);
}
public void BeginResizeDrag(WindowEdge edge)
{
int x, y;
GetGlobalPointer(out x, out y);
Native.GdkWindowBeginResizeDrag(Native.GtkWidgetGetWindow(GtkWidget), edge, 1, x, y, 0);
}
public Size ClientSize
{
get
{
if (GtkWidget.IsClosed)
return new Size();
int w, h;
Native.GtkWindowGetSize(GtkWidget, out w, out h);
return new Size(w, h);
}
set
{
if (GtkWidget.IsClosed)
return;
Native.GtkWindowResize(GtkWidget, (int)value.Width, (int)value.Height);
}
}
public Point Position
{
get
{
int x, y;
Native.GtkWindowGetPosition(GtkWidget, out x, out y);
return new Point(x, y);
}
set { Native.GtkWindowMove(GtkWidget, (int)value.X, (int)value.Y); }
}
IntPtr IPlatformHandle.Handle => Native.GetNativeGdkWindowHandle(Native.GtkWidgetGetWindow(GtkWidget));
public IEnumerable<object> Surfaces => new object[] {Handle, _framebuffer};
}
}

45
src/Gtk/Avalonia.Gtk3/WindowImpl.cs

@ -0,0 +1,45 @@
using System;
using Avalonia.Controls;
using Avalonia.Gtk3.Interop;
using Avalonia.Platform;
namespace Avalonia.Gtk3
{
class WindowImpl : TopLevelImpl, IWindowImpl
{
public WindowState WindowState { get; set; } //STUB
public void SetTitle(string title)
{
using (var t = new Utf8Buffer(title))
Native.GtkWindowSetTitle(GtkWidget, t);
}
class EmptyDisposable : IDisposable
{
public void Dispose()
{
}
}
public IDisposable ShowDialog()
{
Native.GtkWindowSetModal(GtkWidget, true);
Show();
return new EmptyDisposable();
}
public void SetSystemDecorations(bool enabled) => Native.GtkWindowSetDecorated(GtkWidget, enabled);
public void SetIcon(IWindowIconImpl icon) => Native.GtkWindowSetIcon(GtkWidget, (Pixbuf) icon);
public WindowImpl() : base(Native.GtkWindowNew(GtkWindowType.TopLevel))
{
}
public void SetCoverTaskbarWhenMaximized(bool enable)
{
//Why do we even have that?
}
}
}

10
src/Gtk/Avalonia.Gtk3/project.json

@ -0,0 +1,10 @@
{
"supports": {},
"dependencies": {
"Microsoft.NETCore.Portable.Compatibility": "1.0.1",
"NETStandard.Library": "1.6.0"
},
"frameworks": {
"netstandard1.1": {}
}
}

5
src/Markup/Avalonia.Markup.Xaml/Avalonia.Markup.Xaml.csproj

@ -322,9 +322,8 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Sprache, Version=2.0.0.51, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Sprache, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Sprache.2.0.0.51\lib\portable-net4+netcore45+win8+wp8+sl5+MonoAndroid+Xamarin.iOS10+MonoTouch\Sprache.dll</HintPath> <HintPath>..\..\..\packages\Sprache.2.1.0\lib\netstandard1.0\Sprache.dll</HintPath>
<Private>True</Private>
</Reference> </Reference>
<Reference Include="System.Reactive.Core, Version=3.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL"> <Reference Include="System.Reactive.Core, Version=3.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\System.Reactive.Core.3.0.0\lib\netstandard1.1\System.Reactive.Core.dll</HintPath> <HintPath>..\..\..\packages\System.Reactive.Core.3.0.0\lib\netstandard1.1\System.Reactive.Core.dll</HintPath>

6
src/Markup/Avalonia.Markup.Xaml/packages.config

@ -1,9 +1,13 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Sprache" version="2.0.0.51" targetFramework="portable45-net45+win8" /> <package id="Sprache" version="2.1.0" targetFramework="portable45-net45+win8" />
<package id="System.Globalization" version="4.0.11" targetFramework="portable45-net45+win8" />
<package id="System.Linq" version="4.1.0" targetFramework="portable45-net45+win8" />
<package id="System.Reactive" version="3.0.0" targetFramework="portable45-net45+win8" /> <package id="System.Reactive" version="3.0.0" targetFramework="portable45-net45+win8" />
<package id="System.Reactive.Core" version="3.0.0" targetFramework="portable45-net45+win8" /> <package id="System.Reactive.Core" version="3.0.0" targetFramework="portable45-net45+win8" />
<package id="System.Reactive.Interfaces" version="3.0.0" targetFramework="portable45-net45+win8" /> <package id="System.Reactive.Interfaces" version="3.0.0" targetFramework="portable45-net45+win8" />
<package id="System.Reactive.Linq" version="3.0.0" targetFramework="portable45-net45+win8" /> <package id="System.Reactive.Linq" version="3.0.0" targetFramework="portable45-net45+win8" />
<package id="System.Reactive.PlatformServices" version="3.0.0" targetFramework="portable45-net45+win8" /> <package id="System.Reactive.PlatformServices" version="3.0.0" targetFramework="portable45-net45+win8" />
<package id="System.Runtime" version="4.1.0" targetFramework="portable45-net45+win8" />
<package id="System.Text.RegularExpressions" version="4.1.0" targetFramework="portable45-net45+win8" />
</packages> </packages>

6
src/Shared/PlatformSupport/AssetLoader.cs

@ -138,7 +138,7 @@ namespace Avalonia.Shared.PlatformSupport
AssemblyDescriptor rv; AssemblyDescriptor rv;
if (!AssemblyNameCache.TryGetValue(name, out rv)) if (!AssemblyNameCache.TryGetValue(name, out rv))
{ {
var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies(); var loadedAssemblies = AvaloniaLocator.Current.GetService<IRuntimePlatform>().GetLoadedAssemblies();
var match = loadedAssemblies.FirstOrDefault(a => a.GetName().Name == name); var match = loadedAssemblies.FirstOrDefault(a => a.GetName().Name == name);
if (match != null) if (match != null)
{ {
@ -148,7 +148,9 @@ namespace Avalonia.Shared.PlatformSupport
{ {
// iOS does not support loading assemblies dynamically! // iOS does not support loading assemblies dynamically!
// //
#if !__IOS__ #if NETSTANDARD
AssemblyNameCache[name] = rv = new AssemblyDescriptor(Assembly.Load(new AssemblyName(name)));
#elif !__IOS__
AssemblyNameCache[name] = rv = new AssemblyDescriptor(Assembly.Load(name)); AssemblyNameCache[name] = rv = new AssemblyDescriptor(Assembly.Load(name));
#endif #endif
} }

9
src/Shared/PlatformSupport/StandardRuntimePlatform.cs

@ -2,7 +2,6 @@
// Licensed under the MIT license. See licence.md file in the project root for full license information. // Licensed under the MIT license. See licence.md file in the project root for full license information.
using System; using System;
using System.Reactive.Disposables;
using System.Reflection; using System.Reflection;
using System.Resources; using System.Resources;
using System.Threading; using System.Threading;
@ -12,12 +11,16 @@ namespace Avalonia.Shared.PlatformSupport
{ {
internal partial class StandardRuntimePlatform : IRuntimePlatform internal partial class StandardRuntimePlatform : IRuntimePlatform
{ {
#if NETSTANDARD
public void PostThreadPoolItem(Action cb) => ThreadPool.QueueUserWorkItem(_ => cb(), null);
#else
public Assembly[] GetLoadedAssemblies() => AppDomain.CurrentDomain.GetAssemblies(); public Assembly[] GetLoadedAssemblies() => AppDomain.CurrentDomain.GetAssemblies();
public void PostThreadPoolItem(Action cb) => ThreadPool.UnsafeQueueUserWorkItem(_ => cb(), null); public void PostThreadPoolItem(Action cb) => ThreadPool.UnsafeQueueUserWorkItem(_ => cb(), null);
#endif
public IDisposable StartSystemTimer(TimeSpan interval, Action tick) public IDisposable StartSystemTimer(TimeSpan interval, Action tick)
{ {
var timer = new Timer(_ => tick(), null, interval, interval); return new Timer(_ => tick(), null, interval, interval);
return Disposable.Create(() => timer.Dispose());
} }

5
src/Skia/Avalonia.Skia.Android/Avalonia.Skia.Android.csproj

@ -40,9 +40,8 @@
<ItemGroup> <ItemGroup>
<Reference Include="Mono.Android" /> <Reference Include="Mono.Android" />
<Reference Include="mscorlib" /> <Reference Include="mscorlib" />
<Reference Include="SkiaSharp, Version=1.54.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL"> <Reference Include="SkiaSharp, Version=1.56.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\SkiaSharp.1.54.1\lib\MonoAndroid\SkiaSharp.dll</HintPath> <HintPath>..\..\..\packages\SkiaSharp.1.56.1-beta\lib\MonoAndroid\SkiaSharp.dll</HintPath>
<Private>True</Private>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />

2
src/Skia/Avalonia.Skia.Android/packages.config

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="SkiaSharp" version="1.54.1" targetFramework="monoandroid44" /> <package id="SkiaSharp" version="1.56.1-beta" targetFramework="monoandroid44" />
</packages> </packages>

91
src/Skia/Avalonia.Skia.Desktop.NetStandard/Avalonia.Skia.Desktop.NetStandard.csproj

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{7D2D3083-71DD-4CC9-8907-39A0D86FB322}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Avalonia.Skia.Desktop</RootNamespace>
<AssemblyName>Avalonia.Skia.Desktop</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .NET Framework is automatically included -->
<None Include="project.json" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Shared\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="..\Avalonia.Skia.Desktop\PlatformRenderInterfaceDesktop.cs">
<Link>PlatformRenderInterfaceDesktop.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Avalonia.Base\Avalonia.Base.csproj">
<Project>{b09b78d8-9b26-48b0-9149-d64a2f120f3f}</Project>
<Name>Avalonia.Base</Name>
</ProjectReference>
<ProjectReference Include="..\..\Avalonia.Controls\Avalonia.Controls.csproj">
<Project>{d2221c82-4a25-4583-9b43-d791e3f6820c}</Project>
<Name>Avalonia.Controls</Name>
</ProjectReference>
<ProjectReference Include="..\..\Avalonia.Input\Avalonia.Input.csproj">
<Project>{62024b2d-53eb-4638-b26b-85eeaa54866e}</Project>
<Name>Avalonia.Input</Name>
</ProjectReference>
<ProjectReference Include="..\..\Avalonia.Interactivity\Avalonia.Interactivity.csproj">
<Project>{6b0ed19d-a08b-461c-a9d9-a9ee40b0c06b}</Project>
<Name>Avalonia.Interactivity</Name>
</ProjectReference>
<ProjectReference Include="..\..\Avalonia.Layout\Avalonia.Layout.csproj">
<Project>{42472427-4774-4c81-8aff-9f27b8e31721}</Project>
<Name>Avalonia.Layout</Name>
</ProjectReference>
<ProjectReference Include="..\..\Avalonia.Styling\Avalonia.Styling.csproj">
<Project>{f1baa01a-f176-4c6a-b39d-5b40bb1b148f}</Project>
<Name>Avalonia.Styling</Name>
</ProjectReference>
<ProjectReference Include="..\..\Avalonia.Visuals\Avalonia.Visuals.csproj">
<Project>{eb582467-6abb-43a1-b052-e981ba910e3a}</Project>
<Name>Avalonia.Visuals</Name>
</ProjectReference>
</ItemGroup>
<Import Project="..\Avalonia.Skia\Avalonia.Skia.projitems" Label="Shared" />
<Import Project="..\..\Shared\RenderHelpers\RenderHelpers.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

11
src/Skia/Avalonia.Skia.Desktop.NetStandard/project.json

@ -0,0 +1,11 @@
{
"supports": {},
"dependencies": {
"Microsoft.NETCore.Portable.Compatibility": "1.0.1",
"NETStandard.Library": "1.6.0",
"SkiaSharp": "1.56.1-beta"
},
"frameworks": {
"netstandard1.3": {}
}
}

9
src/Skia/Avalonia.Skia.Desktop/Avalonia.Skia.Desktop.csproj

@ -57,9 +57,8 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="SkiaSharp, Version=1.54.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL"> <Reference Include="SkiaSharp, Version=1.56.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\SkiaSharp.1.54.1\lib\net45\SkiaSharp.dll</HintPath> <HintPath>..\..\..\packages\SkiaSharp.1.56.1-beta\lib\net45\SkiaSharp.dll</HintPath>
<Private>True</Private>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
@ -115,12 +114,12 @@
<Import Project="..\Avalonia.Skia\Avalonia.Skia.projitems" Label="Shared" /> <Import Project="..\Avalonia.Skia\Avalonia.Skia.projitems" Label="Shared" />
<Import Project="..\..\Shared\RenderHelpers\RenderHelpers.projitems" Label="Shared" /> <Import Project="..\..\Shared\RenderHelpers\RenderHelpers.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\..\..\packages\SkiaSharp.1.54.1\build\net45\SkiaSharp.targets" Condition="Exists('..\..\..\packages\SkiaSharp.1.54.1\build\net45\SkiaSharp.targets')" /> <Import Project="..\..\..\packages\SkiaSharp.1.56.1-beta\build\net45\SkiaSharp.targets" Condition="Exists('..\..\..\packages\SkiaSharp.1.56.1-beta\build\net45\SkiaSharp.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup> <PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup> </PropertyGroup>
<Error Condition="!Exists('..\..\..\packages\SkiaSharp.1.54.1\build\net45\SkiaSharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\SkiaSharp.1.54.1\build\net45\SkiaSharp.targets'))" /> <Error Condition="!Exists('..\..\..\packages\SkiaSharp.1.56.1-beta\build\net45\SkiaSharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\SkiaSharp.1.56.1-beta\build\net45\SkiaSharp.targets'))" />
</Target> </Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

2
src/Skia/Avalonia.Skia.Desktop/packages.config

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="SkiaSharp" version="1.54.1" targetFramework="net45" /> <package id="SkiaSharp" version="1.56.1-beta" targetFramework="net45" />
</packages> </packages>

5
src/Skia/Avalonia.Skia.iOS/Avalonia.Skia.iOS.csproj

@ -44,9 +44,8 @@
<Compile Include="WindowDrawingContextImpl.cs" /> <Compile Include="WindowDrawingContextImpl.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="SkiaSharp, Version=1.54.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL"> <Reference Include="SkiaSharp, Version=1.56.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\SkiaSharp.1.54.1\lib\XamariniOS\SkiaSharp.dll</HintPath> <HintPath>..\..\..\packages\SkiaSharp.1.56.1-beta\lib\XamariniOS\SkiaSharp.dll</HintPath>
<Private>True</Private>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />

2
src/Skia/Avalonia.Skia.iOS/packages.config

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="SkiaSharp" version="1.54.1" targetFramework="xamarinios10" /> <package id="SkiaSharp" version="1.56.1-beta" targetFramework="xamarinios10" />
</packages> </packages>

94
src/Windows/Avalonia.Win32.NetStandard/Avalonia.Win32.NetStandard.csproj

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{40759A76-D0F2-464E-8000-6FF0F5C4BD7C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Avalonia.Win32</RootNamespace>
<AssemblyName>Avalonia.Win32</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;NETSTANDARD</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;NETSTANDARD</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .NET Framework is automatically included -->
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Avalonia.Animation\Avalonia.Animation.csproj">
<Project>{d211e587-d8bc-45b9-95a4-f297c8fa5200}</Project>
<Name>Avalonia.Animation</Name>
</ProjectReference>
<ProjectReference Include="..\..\Avalonia.Base\Avalonia.Base.csproj">
<Project>{b09b78d8-9b26-48b0-9149-d64a2f120f3f}</Project>
<Name>Avalonia.Base</Name>
</ProjectReference>
<ProjectReference Include="..\..\Avalonia.Controls\Avalonia.Controls.csproj">
<Project>{d2221c82-4a25-4583-9b43-d791e3f6820c}</Project>
<Name>Avalonia.Controls</Name>
</ProjectReference>
<ProjectReference Include="..\..\Avalonia.Input\Avalonia.Input.csproj">
<Project>{62024b2d-53eb-4638-b26b-85eeaa54866e}</Project>
<Name>Avalonia.Input</Name>
</ProjectReference>
<ProjectReference Include="..\..\Avalonia.Interactivity\Avalonia.Interactivity.csproj">
<Project>{6b0ed19d-a08b-461c-a9d9-a9ee40b0c06b}</Project>
<Name>Avalonia.Interactivity</Name>
</ProjectReference>
<ProjectReference Include="..\..\Avalonia.Layout\Avalonia.Layout.csproj">
<Project>{42472427-4774-4c81-8aff-9f27b8e31721}</Project>
<Name>Avalonia.Layout</Name>
</ProjectReference>
<ProjectReference Include="..\..\Avalonia.Styling\Avalonia.Styling.csproj">
<Project>{f1baa01a-f176-4c6a-b39d-5b40bb1b148f}</Project>
<Name>Avalonia.Styling</Name>
</ProjectReference>
<ProjectReference Include="..\..\Avalonia.Visuals\Avalonia.Visuals.csproj">
<Project>{eb582467-6abb-43a1-b052-e981ba910e3a}</Project>
<Name>Avalonia.Visuals</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="IconImpl.cs" />
<Compile Include="NativeWin32Platform.cs" />
<Compile Include="Win32Exception.cs" />
</ItemGroup>
<ItemGroup>
<None Include="project.json" />
</ItemGroup>
<Import Project="..\Avalonia.Win32\Avalonia.Win32.Shared.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

19
src/Windows/Avalonia.Win32.NetStandard/IconImpl.cs

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Avalonia.Platform;
namespace Avalonia.Win32
{
public class IconImpl : IWindowIconImpl
{
public IntPtr HIcon { get; set; }
public void Save(Stream outputStream)
{
throw new NotImplementedException();
}
}
}

20
src/Windows/Avalonia.Win32.NetStandard/NativeWin32Platform.cs

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Avalonia.Platform;
namespace Avalonia.Win32
{
partial class Win32Platform
{
//TODO: An actual implementation
public IWindowIconImpl LoadIcon(string fileName) => new IconImpl();
public IWindowIconImpl LoadIcon(Stream stream) => new IconImpl();
public IWindowIconImpl LoadIcon(IBitmapImpl bitmap) => new IconImpl();
}
}

12
src/Windows/Avalonia.Win32.NetStandard/Win32Exception.cs

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Avalonia.Win32.NetStandard
{
class AvaloniaWin32Exception : Exception
{
}
}

11
src/Windows/Avalonia.Win32.NetStandard/project.json

@ -0,0 +1,11 @@
{
"supports": {},
"dependencies": {
"Microsoft.NETCore.Portable.Compatibility": "1.0.1",
"NETStandard.Library": "1.6.0",
"System.Reactive.Core": "3.0.0"
},
"frameworks": {
"netstandard1.1": {}
}
}

31
src/Windows/Avalonia.Win32/Avalonia.Win32.Shared.projitems

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>9defc6b7-845b-4d8f-afc0-d32bf0032b8c</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>Avalonia.Win32.Shared</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)ClipboardImpl.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CursorFactory.cs" />
<Compile Include="$(MSBuildThisFileDirectory)FramebufferManager.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Input\KeyInterop.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Input\WindowsKeyboardDevice.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Input\WindowsMouseDevice.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\UnmanagedMethods.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PlatformConstants.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PopupImpl.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Properties\AssemblyInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RenderLoop.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SystemDialogImpl.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Win32Platform.cs" />
<Compile Include="$(MSBuildThisFileDirectory)WindowFramebuffer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)WindowImpl.cs" />
<Compile Include="..\..\Shared\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
</ItemGroup>
</Project>

13
src/Windows/Avalonia.Win32/Avalonia.Win32.Shared.shproj

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>9defc6b7-845b-4d8f-afc0-d32bf0032b8c</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<PropertyGroup />
<Import Project="Avalonia.Win32.Shared.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>

26
src/Windows/Avalonia.Win32/Avalonia.Win32.csproj

@ -61,30 +61,13 @@
<Reference Include="WindowsFormsIntegration" /> <Reference Include="WindowsFormsIntegration" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="..\..\Shared\SharedAssemblyInfo.cs"> <Compile Include="Embedding\EmbeddedWindowImpl.cs" />
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="ClipboardImpl.cs" />
<Compile Include="Embedding\WinFormsAvaloniaControlHost.cs"> <Compile Include="Embedding\WinFormsAvaloniaControlHost.cs">
<SubType>Component</SubType> <SubType>Component</SubType>
</Compile> </Compile>
<Compile Include="Embedding\WpfAvaloniaControlHost.cs" /> <Compile Include="Embedding\WpfAvaloniaControlHost.cs" />
<Compile Include="WindowFramebuffer.cs" />
<Compile Include="FramebufferManager.cs" />
<Compile Include="IconImpl.cs" /> <Compile Include="IconImpl.cs" />
<Compile Include="RenderLoop.cs" /> <Compile Include="WinFormsWin32Platform.cs" />
<Compile Include="SystemDialogImpl.cs" />
<Compile Include="CursorFactory.cs" />
<Compile Include="Input\KeyInterop.cs" />
<Compile Include="Input\WindowsKeyboardDevice.cs" />
<Compile Include="Input\WindowsMouseDevice.cs" />
<Compile Include="Interop\UnmanagedMethods.cs" />
<Compile Include="PlatformConstants.cs" />
<Compile Include="PopupImpl.cs" />
<Compile Include="WindowImpl.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Win32Platform.cs" />
<Compile Include="Embedding\EmbeddedWindowImpl.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\Avalonia.Animation\Avalonia.Animation.csproj"> <ProjectReference Include="..\..\Avalonia.Animation\Avalonia.Animation.csproj">
@ -125,8 +108,11 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="packages.config" /> <None Include="packages.config">
<SubType>Designer</SubType>
</None>
</ItemGroup> </ItemGroup>
<Import Project="Avalonia.Win32.Shared.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

23
src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs

@ -692,6 +692,9 @@ namespace Avalonia.Win32.Interop
[DllImport("kernel32.dll")] [DllImport("kernel32.dll")]
public static extern IntPtr GetModuleHandle(string lpModuleName); public static extern IntPtr GetModuleHandle(string lpModuleName);
[DllImport("kernel32.dll")]
public static extern uint GetCurrentThreadId();
[DllImport("user32.dll")] [DllImport("user32.dll")]
public static extern int GetSystemMetrics(SystemMetric smIndex); public static extern int GetSystemMetrics(SystemMetric smIndex);
@ -784,7 +787,7 @@ namespace Avalonia.Win32.Interop
[DllImport("user32.dll")] [DllImport("user32.dll")]
public static extern bool UnregisterClass(string lpClassName, IntPtr hInstance); public static extern bool UnregisterClass(string lpClassName, IntPtr hInstance);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "SetWindowTextW")]
public static extern bool SetWindowText(IntPtr hwnd, string lpString); public static extern bool SetWindowText(IntPtr hwnd, string lpString);
public enum ClassLongIndex : int public enum ClassLongIndex : int
@ -808,13 +811,14 @@ namespace Avalonia.Win32.Interop
return SetClassLong64(hWnd, nIndex, dwNewLong); return SetClassLong64(hWnd, nIndex, dwNewLong);
} }
#if !NETSTANDARD
[ComImport, ClassInterface(ClassInterfaceType.None), TypeLibType(TypeLibTypeFlags.FCanCreate), Guid("DC1C5A9C-E88A-4DDE-A5A1-60F82A20AEF7")] [ComImport, ClassInterface(ClassInterfaceType.None), TypeLibType(TypeLibTypeFlags.FCanCreate), Guid("DC1C5A9C-E88A-4DDE-A5A1-60F82A20AEF7")]
internal class FileOpenDialogRCW { } internal class FileOpenDialogRCW { }
[DllImport("shell32.dll", CharSet = CharSet.Unicode, SetLastError = true)] [DllImport("shell32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern int SHCreateItemFromParsingName([MarshalAs(UnmanagedType.LPWStr)] string pszPath, IntPtr pbc, ref Guid riid, [MarshalAs(UnmanagedType.Interface)] out IShellItem ppv); internal static extern int SHCreateItemFromParsingName([MarshalAs(UnmanagedType.LPWStr)] string pszPath, IntPtr pbc, ref Guid riid, [MarshalAs(UnmanagedType.Interface)] out IShellItem ppv);
#endif
[DllImport("user32.dll", SetLastError = true)] [DllImport("user32.dll", SetLastError = true)]
public static extern bool OpenClipboard(IntPtr hWndOwner); public static extern bool OpenClipboard(IntPtr hWndOwner);
@ -831,16 +835,16 @@ namespace Avalonia.Win32.Interop
[DllImport("user32.dll")] [DllImport("user32.dll")]
public static extern IntPtr SetClipboardData(ClipboardFormat uFormat, IntPtr hMem); public static extern IntPtr SetClipboardData(ClipboardFormat uFormat, IntPtr hMem);
[DllImport("kernel32.dll", CharSet = CharSet.Auto, ExactSpelling = true)] [DllImport("kernel32.dll", ExactSpelling = true)]
public static extern IntPtr GlobalLock(IntPtr handle); public static extern IntPtr GlobalLock(IntPtr handle);
[DllImport("kernel32.dll", CharSet = CharSet.Auto, ExactSpelling = true)] [DllImport("kernel32.dll", ExactSpelling = true)]
public static extern bool GlobalUnlock(IntPtr handle); public static extern bool GlobalUnlock(IntPtr handle);
[DllImport("kernel32.dll", CharSet = CharSet.Auto, ExactSpelling = true)] [DllImport("kernel32.dll", ExactSpelling = true)]
public static extern IntPtr GlobalAlloc(int uFlags, int dwBytes); public static extern IntPtr GlobalAlloc(int uFlags, int dwBytes);
[DllImport("kernel32.dll", CharSet = CharSet.Auto, ExactSpelling = true)] [DllImport("kernel32.dll", ExactSpelling = true)]
public static extern IntPtr GlobalFree(IntPtr hMem); public static extern IntPtr GlobalFree(IntPtr hMem);
[DllImport("kernel32.dll", SetLastError = true)] [DllImport("kernel32.dll", SetLastError = true)]
@ -877,7 +881,7 @@ namespace Avalonia.Win32.Interop
public static extern bool GetMonitorInfo([In] IntPtr hMonitor, [Out] MONITORINFO lpmi); public static extern bool GetMonitorInfo([In] IntPtr hMonitor, [Out] MONITORINFO lpmi);
[return: MarshalAs(UnmanagedType.Bool)] [return: MarshalAs(UnmanagedType.Bool)]
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "PostMessageW")]
public static extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam); public static extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
[DllImport("gdi32.dll")] [DllImport("gdi32.dll")]
@ -912,7 +916,7 @@ namespace Avalonia.Win32.Interop
MONITOR_DEFAULTTONEAREST = 0x00000002, MONITOR_DEFAULTTONEAREST = 0x00000002,
} }
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] [StructLayout(LayoutKind.Sequential)]
internal class MONITORINFO internal class MONITORINFO
{ {
public int cbSize = Marshal.SizeOf(typeof(MONITORINFO)); public int cbSize = Marshal.SizeOf(typeof(MONITORINFO));
@ -1146,7 +1150,7 @@ namespace Avalonia.Win32.Interop
public int flagsEx; public int flagsEx;
} }
} }
#if !NETSTANDARD
[ComImport(), Guid("42F85136-DB7E-439C-85F1-E4075D135FC8"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [ComImport(), Guid("42F85136-DB7E-439C-85F1-E4075D135FC8"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IFileDialog internal interface IFileDialog
{ {
@ -1246,4 +1250,5 @@ namespace Avalonia.Win32.Interop
uint Compare([In, MarshalAs(UnmanagedType.Interface)] IShellItem psi, [In] uint hint, out int piOrder); uint Compare([In, MarshalAs(UnmanagedType.Interface)] IShellItem psi, [In] uint hint, out int piOrder);
} }
#endif
} }

26
src/Windows/Avalonia.Win32/SystemDialogImpl.cs

@ -16,6 +16,16 @@ namespace Avalonia.Win32
class SystemDialogImpl : ISystemDialogImpl class SystemDialogImpl : ISystemDialogImpl
{ {
static char[] ToChars(string s)
{
if (s == null)
return null;
var chars = new char[s.Length];
for (int c = 0; c < s.Length; c++)
chars[c] = s[c];
return chars;
}
public unsafe Task<string[]> ShowFileDialogAsync(FileDialog dialog, IWindowImpl parent) public unsafe Task<string[]> ShowFileDialogAsync(FileDialog dialog, IWindowImpl parent)
{ {
var hWnd = parent?.Handle?.Handle ?? IntPtr.Zero; var hWnd = parent?.Handle?.Handle ?? IntPtr.Zero;
@ -40,14 +50,15 @@ namespace Avalonia.Win32
var filterBuffer = new char[filters.Length]; var filterBuffer = new char[filters.Length];
filters.CopyTo(0, filterBuffer, 0, filterBuffer.Length); filters.CopyTo(0, filterBuffer, 0, filterBuffer.Length);
var defExt = (dialog as SaveFileDialog)?.DefaultExtension?.ToArray(); var defExt = ToChars((dialog as SaveFileDialog)?.DefaultExtension);
var fileBuffer = new char[256]; var fileBuffer = new char[256];
dialog.InitialFileName?.CopyTo(0, fileBuffer, 0, dialog.InitialFileName.Length); dialog.InitialFileName?.CopyTo(0, fileBuffer, 0, dialog.InitialFileName.Length);
string userSelectedExt = null; string userSelectedExt = null;
var title = dialog.Title?.ToArray();
var initialDir = dialog.InitialDirectory?.ToArray(); var title = ToChars(dialog.Title);
var initialDir = ToChars(dialog.InitialDirectory);
fixed (char* pFileBuffer = fileBuffer) fixed (char* pFileBuffer = fileBuffer)
fixed (char* pFilterBuffer = filterBuffer) fixed (char* pFilterBuffer = filterBuffer)
@ -89,14 +100,17 @@ namespace Avalonia.Win32
var pofn = &ofn; var pofn = &ofn;
// We should save the current directory to restore it later. // We should save the current directory to restore it later.
#if !NETSTANDARD
var currentDirectory = Environment.CurrentDirectory; var currentDirectory = Environment.CurrentDirectory;
#endif
var res = dialog is OpenFileDialog var res = dialog is OpenFileDialog
? UnmanagedMethods.GetOpenFileName(new IntPtr(pofn)) ? UnmanagedMethods.GetOpenFileName(new IntPtr(pofn))
: UnmanagedMethods.GetSaveFileName(new IntPtr(pofn)); : UnmanagedMethods.GetSaveFileName(new IntPtr(pofn));
// Restore the old current directory, since GetOpenFileName and GetSaveFileName change it after they're called // Restore the old current directory, since GetOpenFileName and GetSaveFileName change it after they're called
#if !NETSTANDARD
Environment.CurrentDirectory = currentDirectory; Environment.CurrentDirectory = currentDirectory;
#endif
if (!res) if (!res)
return null; return null;
@ -141,6 +155,9 @@ namespace Avalonia.Win32
public Task<string> ShowFolderDialogAsync(OpenFolderDialog dialog, IWindowImpl parent) public Task<string> ShowFolderDialogAsync(OpenFolderDialog dialog, IWindowImpl parent)
{ {
#if NETSTANDARD
throw new NotImplementedException();
#else
return Task.Factory.StartNew(() => return Task.Factory.StartNew(() =>
{ {
string result = string.Empty; string result = string.Empty;
@ -197,6 +214,7 @@ namespace Avalonia.Win32
return result; return result;
}); });
#endif
} }
} }
} }

59
src/Windows/Avalonia.Win32/Win32Platform.cs

@ -4,9 +4,8 @@
using Avalonia.Input.Platform; using Avalonia.Input.Platform;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Reactive.Disposables; using System.Reactive.Disposables;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading; using System.Threading;
using Avalonia.Controls.Platform; using Avalonia.Controls.Platform;
@ -15,8 +14,12 @@ using Avalonia.Platform;
using Avalonia.Win32.Input; using Avalonia.Win32.Input;
using Avalonia.Win32.Interop; using Avalonia.Win32.Interop;
using Avalonia.Controls; using Avalonia.Controls;
using System.IO;
using Avalonia.Rendering; using Avalonia.Rendering;
#if NETSTANDARD
using Win32Exception = Avalonia.Win32.NetStandard.AvaloniaWin32Exception;
#else
using System.ComponentModel;
#endif
namespace Avalonia namespace Avalonia
{ {
@ -32,10 +35,10 @@ namespace Avalonia
namespace Avalonia.Win32 namespace Avalonia.Win32
{ {
class Win32Platform : IPlatformThreadingInterface, IPlatformSettings, IWindowingPlatform, IPlatformIconLoader partial class Win32Platform : IPlatformThreadingInterface, IPlatformSettings, IWindowingPlatform, IPlatformIconLoader
{ {
private static readonly Win32Platform s_instance = new Win32Platform(); private static readonly Win32Platform s_instance = new Win32Platform();
private static Thread _uiThread; private static uint _uiThread;
private UnmanagedMethods.WndProc _wndProcDelegate; private UnmanagedMethods.WndProc _wndProcDelegate;
private IntPtr _hwnd; private IntPtr _hwnd;
private readonly List<Delegate> _delegates = new List<Delegate>(); private readonly List<Delegate> _delegates = new List<Delegate>();
@ -71,7 +74,7 @@ namespace Avalonia.Win32
.Bind<IWindowingPlatform>().ToConstant(s_instance) .Bind<IWindowingPlatform>().ToConstant(s_instance)
.Bind<IPlatformIconLoader>().ToConstant(s_instance); .Bind<IPlatformIconLoader>().ToConstant(s_instance);
_uiThread = Thread.CurrentThread; _uiThread = UnmanagedMethods.GetCurrentThreadId();
} }
public bool HasMessages() public bool HasMessages()
@ -132,7 +135,7 @@ namespace Avalonia.Win32
new IntPtr(SignalL)); new IntPtr(SignalL));
} }
public bool CurrentThreadIsLoopThread => _uiThread == Thread.CurrentThread; public bool CurrentThreadIsLoopThread => _uiThread == UnmanagedMethods.GetCurrentThreadId();
public event Action Signaled; public event Action Signaled;
@ -155,8 +158,8 @@ namespace Avalonia.Win32
{ {
cbSize = Marshal.SizeOf(typeof(UnmanagedMethods.WNDCLASSEX)), cbSize = Marshal.SizeOf(typeof(UnmanagedMethods.WNDCLASSEX)),
lpfnWndProc = _wndProcDelegate, lpfnWndProc = _wndProcDelegate,
hInstance = Marshal.GetHINSTANCE(GetType().Module), hInstance = UnmanagedMethods.GetModuleHandle(null),
lpszClassName = "AvaloniaMessageWindow", lpszClassName = "AvaloniaMessageWindow " + Guid.NewGuid(),
}; };
ushort atom = UnmanagedMethods.RegisterClassEx(ref wndClassEx); ushort atom = UnmanagedMethods.RegisterClassEx(ref wndClassEx);
@ -181,46 +184,16 @@ namespace Avalonia.Win32
public IEmbeddableWindowImpl CreateEmbeddableWindow() public IEmbeddableWindowImpl CreateEmbeddableWindow()
{ {
#if NETSTANDARD
throw new NotSupportedException();
#else
return new EmbeddedWindowImpl(); return new EmbeddedWindowImpl();
#endif
} }
public IPopupImpl CreatePopup() public IPopupImpl CreatePopup()
{ {
return new PopupImpl(); return new PopupImpl();
} }
public IWindowIconImpl LoadIcon(string fileName)
{
using (var stream = File.OpenRead(fileName))
{
return CreateImpl(stream);
}
}
public IWindowIconImpl LoadIcon(Stream stream)
{
return CreateImpl(stream);
}
public IWindowIconImpl LoadIcon(IBitmapImpl bitmap)
{
using (var memoryStream = new MemoryStream())
{
bitmap.Save(memoryStream);
return new IconImpl(new System.Drawing.Bitmap(memoryStream));
}
}
private static IconImpl CreateImpl(Stream stream)
{
try
{
return new IconImpl(new System.Drawing.Icon(stream));
}
catch (ArgumentException)
{
return new IconImpl(new System.Drawing.Bitmap(stream));
}
}
} }
} }

47
src/Windows/Avalonia.Win32/WinFormsWin32Platform.cs

@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Avalonia.Platform;
namespace Avalonia.Win32
{
partial class Win32Platform
{
public IWindowIconImpl LoadIcon(string fileName)
{
using (var stream = File.OpenRead(fileName))
{
return CreateImpl(stream);
}
}
public IWindowIconImpl LoadIcon(Stream stream)
{
return CreateImpl(stream);
}
public IWindowIconImpl LoadIcon(IBitmapImpl bitmap)
{
using (var memoryStream = new MemoryStream())
{
bitmap.Save(memoryStream);
return new IconImpl(new System.Drawing.Bitmap(memoryStream));
}
}
private static IconImpl CreateImpl(Stream stream)
{
try
{
return new IconImpl(new System.Drawing.Icon(stream));
}
catch (ArgumentException)
{
return new IconImpl(new System.Drawing.Bitmap(stream));
}
}
}
}

8
src/Windows/Avalonia.Win32/WindowFramebuffer.cs

@ -1,13 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Interop;
using System.Windows.Media;
using Avalonia.Controls.Platform.Surfaces; using Avalonia.Controls.Platform.Surfaces;
using Avalonia.Win32.Interop; using Avalonia.Win32.Interop;
using PixelFormat = Avalonia.Controls.Platform.Surfaces.PixelFormat; using PixelFormat = Avalonia.Controls.Platform.Surfaces.PixelFormat;

11
src/Windows/Avalonia.Win32/WindowImpl.cs

@ -7,16 +7,17 @@ using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Controls.Platform.Surfaces; using System.Reactive.Disposables;
using Avalonia.Input.Raw; using Avalonia.Input.Raw;
using Avalonia.Platform; using Avalonia.Platform;
using Avalonia.Win32.Input; using Avalonia.Win32.Input;
using Avalonia.Win32.Interop; using Avalonia.Win32.Interop;
using static Avalonia.Win32.Interop.UnmanagedMethods; using static Avalonia.Win32.Interop.UnmanagedMethods;
#if NETSTANDARD
using Win32Exception = Avalonia.Win32.NetStandard.AvaloniaWin32Exception;
#endif
namespace Avalonia.Win32 namespace Avalonia.Win32
{ {
@ -419,7 +420,7 @@ namespace Avalonia.Win32
case UnmanagedMethods.WindowsMessage.WM_DESTROY: case UnmanagedMethods.WindowsMessage.WM_DESTROY:
if (Closed != null) if (Closed != null)
{ {
UnmanagedMethods.UnregisterClass(_className, Marshal.GetHINSTANCE(GetType().Module)); UnmanagedMethods.UnregisterClass(_className, UnmanagedMethods.GetModuleHandle(null));
Closed(); Closed();
} }
@ -624,7 +625,7 @@ namespace Avalonia.Win32
cbSize = Marshal.SizeOf(typeof(UnmanagedMethods.WNDCLASSEX)), cbSize = Marshal.SizeOf(typeof(UnmanagedMethods.WNDCLASSEX)),
style = 0, style = 0,
lpfnWndProc = _wndProcDelegate, lpfnWndProc = _wndProcDelegate,
hInstance = Marshal.GetHINSTANCE(GetType().Module), hInstance = UnmanagedMethods.GetModuleHandle(null),
hCursor = DefaultCursor, hCursor = DefaultCursor,
hbrBackground = IntPtr.Zero, hbrBackground = IntPtr.Zero,
lpszClassName = _className lpszClassName = _className

5
tests/Avalonia.Markup.Xaml.UnitTests/Avalonia.Markup.Xaml.UnitTests.csproj

@ -50,9 +50,8 @@
<HintPath>..\..\packages\Splat.1.6.2\lib\Net45\Splat.dll</HintPath> <HintPath>..\..\packages\Splat.1.6.2\lib\Net45\Splat.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Sprache, Version=2.0.0.51, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Sprache, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Sprache.2.0.0.51\lib\portable-net4+netcore45+win8+wp8+sl5+MonoAndroid+Xamarin.iOS10+MonoTouch\Sprache.dll</HintPath> <HintPath>..\..\packages\Sprache.2.1.0\lib\net40\Sprache.dll</HintPath>
<Private>True</Private>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Reactive.Core, Version=3.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL"> <Reference Include="System.Reactive.Core, Version=3.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">

2
tests/Avalonia.Markup.Xaml.UnitTests/packages.config

@ -2,7 +2,7 @@
<packages> <packages>
<package id="Moq" version="4.2.1510.2205" targetFramework="net451" /> <package id="Moq" version="4.2.1510.2205" targetFramework="net451" />
<package id="Splat" version="1.6.2" targetFramework="net451" /> <package id="Splat" version="1.6.2" targetFramework="net451" />
<package id="Sprache" version="2.0.0.51" targetFramework="net451" /> <package id="Sprache" version="2.1.0" targetFramework="net451" />
<package id="System.Reactive.Core" version="3.0.0" targetFramework="net451" /> <package id="System.Reactive.Core" version="3.0.0" targetFramework="net451" />
<package id="System.Reactive.Interfaces" version="3.0.0" targetFramework="net451" /> <package id="System.Reactive.Interfaces" version="3.0.0" targetFramework="net451" />
<package id="System.Reactive.Linq" version="3.0.0" targetFramework="net451" /> <package id="System.Reactive.Linq" version="3.0.0" targetFramework="net451" />

Loading…
Cancel
Save