Browse Source

Merge branch 'master' into fixes/825-layoutupdated

pull/840/head
Steven Kirk 9 years ago
committed by GitHub
parent
commit
daa500f6a1
  1. 3
      .gitignore
  2. 248
      Avalonia.sln
  3. 21
      Avalonia.sln.DotSettings
  4. 696
      build.cake
  5. 469
      packages.cake
  6. 143
      parameters.cake
  7. 11
      samples/ControlCatalog.Android/ControlCatalog.Android.csproj
  8. 24
      samples/ControlCatalog.Android/MainActivity.cs
  9. 7
      samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj
  10. 11
      samples/ControlCatalog.iOS/AppDelegate.cs
  11. 17
      samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj
  12. 6
      samples/ControlCatalog/Pages/ImagePage.xaml
  13. 23
      samples/ControlCatalog/Pages/ImagePage.xaml.cs
  14. 27
      samples/ControlCatalog/Pages/TreeViewPage.xaml.cs
  15. 47
      src/Android/Avalonia.Android/ActivityTracker.cs
  16. 29
      src/Android/Avalonia.Android/AndroidPlatform.cs
  17. 12
      src/Android/Avalonia.Android/AndroidThreadingInterface.cs
  18. 26
      src/Android/Avalonia.Android/AppBuilder.cs
  19. 12
      src/Android/Avalonia.Android/Avalonia.Android.csproj
  20. 51
      src/Android/Avalonia.Android/AvaloniaActivity.cs
  21. 69
      src/Android/Avalonia.Android/AvaloniaView.cs
  22. 105
      src/Android/Avalonia.Android/Platform/SkiaPlatform/AndroidFramebuffer.cs
  23. 30
      src/Android/Avalonia.Android/Platform/SkiaPlatform/InvalidationAwareSurfaceView.cs
  24. 44
      src/Android/Avalonia.Android/Platform/SkiaPlatform/MainWindowImpl.cs
  25. 91
      src/Android/Avalonia.Android/Platform/SkiaPlatform/PopupImpl.cs
  26. 225
      src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs
  27. 197
      src/Android/Avalonia.Android/Platform/SkiaPlatform/WindowImpl.cs
  28. 60
      src/Android/Avalonia.Android/Platform/Specific/AvaloniaActivity.cs
  29. 6
      src/Android/Avalonia.Android/Platform/Specific/Helpers/AndroidKeyboardEventsHelper.cs
  30. 10
      src/Android/Avalonia.Android/Platform/Specific/Helpers/AndroidTouchEventsHelper.cs
  31. 12
      src/Android/Avalonia.Android/Platform/Specific/IAndroidActivity.cs
  32. 6
      src/Android/Avalonia.Android/PlatformIconLoader.cs
  33. 21
      src/Android/Avalonia.AndroidTestApplication/Avalonia.AndroidTestApplication.csproj
  34. 32
      src/Android/Avalonia.AndroidTestApplication/MainActivity.cs
  35. 3
      src/Android/Avalonia.AndroidTestApplication/packages.config
  36. 4
      src/Avalonia.Animation/Avalonia.Animation.csproj
  37. 4
      src/Avalonia.Base/Avalonia.Base.csproj
  38. 4
      src/Avalonia.Controls/AppBuilderBase.cs
  39. 7
      src/Avalonia.Controls/Avalonia.Controls.csproj
  40. 17
      src/Avalonia.Controls/Control.cs
  41. 3
      src/Avalonia.Controls/Expander.cs
  42. 5
      src/Avalonia.Controls/IVirtualizingPanel.cs
  43. 5
      src/Avalonia.Controls/Platform/ExportWindowingSubsystemAttribute.cs
  44. 13
      src/Avalonia.Controls/Platform/ITopLevelImpl.cs
  45. 2
      src/Avalonia.Controls/Platform/IWindowIconImpl.cs
  46. 5
      src/Avalonia.Controls/Platform/IWindowImpl.cs
  47. 19
      src/Avalonia.Controls/Platform/Surfaces/IFramebufferPlatformSurface.cs
  48. 37
      src/Avalonia.Controls/Platform/Surfaces/ILockedFramebuffer.cs
  49. 15
      src/Avalonia.Controls/Platform/Surfaces/PixelFormat.cs
  50. 27
      src/Avalonia.Controls/Presenters/ItemVirtualizer.cs
  51. 11
      src/Avalonia.Controls/Presenters/TextPresenter.cs
  52. 4
      src/Avalonia.Controls/ScrollViewer.cs
  53. 6
      src/Avalonia.Controls/TopLevel.cs
  54. 27
      src/Avalonia.Controls/VirtualizingStackPanel.cs
  55. 20
      src/Avalonia.Controls/Window.cs
  56. 2
      src/Avalonia.Controls/WindowIcon.cs
  57. 4
      src/Avalonia.DesignerSupport/Avalonia.DesignerSupport.csproj
  58. 4
      src/Avalonia.Diagnostics/Avalonia.Diagnostics.csproj
  59. 56
      src/Avalonia.DotNetCoreRuntime/AppBuilder.cs
  60. 89
      src/Avalonia.DotNetCoreRuntime/Avalonia.DotNetCoreRuntime.csproj
  61. 47
      src/Avalonia.DotNetCoreRuntime/NetCoreRuntimePlatform.cs
  62. 41
      src/Avalonia.DotNetCoreRuntime/RuntimeInfo.cs
  63. 11
      src/Avalonia.DotNetCoreRuntime/project.json
  64. 21
      src/Avalonia.DotNetFrameworkRuntime/AppBuilder.cs
  65. 4
      src/Avalonia.DotNetFrameworkRuntime/Avalonia.DotNetFrameworkRuntime.csproj
  66. 4
      src/Avalonia.HtmlRenderer/Avalonia.HtmlRenderer.csproj
  67. 4
      src/Avalonia.Input/Avalonia.Input.csproj
  68. 4
      src/Avalonia.Interactivity/Avalonia.Interactivity.csproj
  69. 4
      src/Avalonia.Layout/Avalonia.Layout.csproj
  70. 4
      src/Avalonia.Logging.Serilog/Avalonia.Logging.Serilog.csproj
  71. 4
      src/Avalonia.ReactiveUI/Avalonia.ReactiveUI.csproj
  72. 4
      src/Avalonia.Styling/Avalonia.Styling.csproj
  73. 31
      src/Avalonia.Styling/Controls/NameScope.cs
  74. 4
      src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj
  75. 5
      src/Avalonia.Visuals/Avalonia.Visuals.csproj
  76. 9
      src/Avalonia.Visuals/Media/DrawingContext.cs
  77. 5
      src/Avalonia.Visuals/Platform/ExportRenderingSubsystemAttribute.cs
  78. 7
      src/Avalonia.Visuals/Platform/IModuleEnvironmentChecker.cs
  79. 7
      src/Avalonia.Visuals/Platform/IPlatformRenderInterface.cs
  80. 22
      src/Gtk/Avalonia.Cairo/CairoPlatform.cs
  81. 19
      src/Gtk/Avalonia.Cairo/RenderTarget.cs
  82. 5
      src/Gtk/Avalonia.Gtk/Avalonia.Gtk.csproj
  83. 39
      src/Gtk/Avalonia.Gtk/FramebufferManager.cs
  84. 5
      src/Gtk/Avalonia.Gtk/IconImpl.cs
  85. 209
      src/Gtk/Avalonia.Gtk/Input/GtkKeyboardDevice.cs
  86. 224
      src/Gtk/Avalonia.Gtk/KeyTransform.cs
  87. 55
      src/Gtk/Avalonia.Gtk/SurfaceFramebuffer.cs
  88. 4
      src/Gtk/Avalonia.Gtk/SystemDialogImpl.cs
  89. 2
      src/Gtk/Avalonia.Gtk/WindowImpl.cs
  90. 36
      src/Gtk/Avalonia.Gtk/WindowImplBase.cs
  91. 1
      src/Gtk/Avalonia.Gtk3/.gitignore
  92. 103
      src/Gtk/Avalonia.Gtk3/Avalonia.Gtk3.csproj
  93. 53
      src/Gtk/Avalonia.Gtk3/ClipboardImpl.cs
  94. 79
      src/Gtk/Avalonia.Gtk3/CursorFactory.cs
  95. 32
      src/Gtk/Avalonia.Gtk3/FramebufferManager.cs
  96. 91
      src/Gtk/Avalonia.Gtk3/GdkCursor.cs
  97. 1347
      src/Gtk/Avalonia.Gtk3/GdkKey.cs
  98. 116
      src/Gtk/Avalonia.Gtk3/Gtk3Platform.cs
  99. 69
      src/Gtk/Avalonia.Gtk3/ImageSurfaceFramebuffer.cs
  100. 20
      src/Gtk/Avalonia.Gtk3/Interop/CairoSurface.cs

3
.gitignore

@ -9,6 +9,7 @@
*.suo
*.user
*.sln.docstates
.vs/
# Build results
@ -160,3 +161,5 @@ tools/
.nuget
artifacts/
nuget
Avalonia.XBuild.sln
project.lock.json

248
Avalonia.sln

@ -99,10 +99,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Skia.Desktop", "sr
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Skia.Android", "src\Skia\Avalonia.Skia.Android\Avalonia.Skia.Android.csproj", "{BD43F7C0-396B-4AA1-BAD9-DFDE54D51298}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Skia.Android.TestApp", "src\Skia\Avalonia.Skia.Android.TestApp\Avalonia.Skia.Android.TestApp.csproj", "{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Skia.iOS.TestApp", "src\Skia\Avalonia.Skia.iOS.TestApp\Avalonia.Skia.iOS.TestApp.csproj", "{DA49C5F3-BE95-461C-B999-072128CCF59E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Skia.iOS", "src\Skia\Avalonia.Skia.iOS\Avalonia.Skia.iOS.csproj", "{47BE08A7-5985-410B-9FFC-2264B8EA595F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Android", "Android", "{7CF9789C-F1D3-4D0E-90E5-F1DF67A2753F}"
@ -130,6 +126,9 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ControlCatalog", "samples\ControlCatalog\ControlCatalog.csproj", "{D0A739B9-3C68-4BA6-A328-41606954B6BD}"
EndProject
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
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ControlCatalog.iOS", "samples\ControlCatalog.iOS\ControlCatalog.iOS.csproj", "{57E0455D-D565-44BB-B069-EE1AA20F8337}"
EndProject
@ -155,19 +154,34 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RenderTest", "samples\Rende
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ControlCatalog.Android", "samples\ControlCatalog.Android\ControlCatalog.Android.csproj", "{29132311-1848-4FD6-AE0C-4FF841151BD3}"
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
GlobalSection(SharedMSBuildProjectFiles) = preSolution
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*{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\RenderHelpers\RenderHelpers.projitems*{47be08a7-5985-410b-9ffc-2264b8ea595f}*SharedItemsImports = 4
src\Skia\Avalonia.Skia\Avalonia.Skia.projitems*{47be08a7-5985-410b-9ffc-2264b8ea595f}*SharedItemsImports = 4
tests\Avalonia.RenderTests\Avalonia.RenderTests.projitems*{48840edd-24bf-495d-911e-2eb12ae75d3b}*SharedItemsImports = 13
src\Shared\PlatformSupport\PlatformSupport.projitems*{4a1abb09-9047-4bd5-a4ad-a055e52c5ee0}*SharedItemsImports = 4
src\Shared\PlatformSupport\PlatformSupport.projitems*{7b92af71-6287-4693-9dcb-bd5b6e927e23}*SharedItemsImports = 4
src\Shared\PlatformSupport\PlatformSupport.projitems*{7863ea94-f0fb-4386-bf8c-e5bfa761560a}*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\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\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
@ -1469,66 +1483,6 @@ Global
{BD43F7C0-396B-4AA1-BAD9-DFDE54D51298}.Release|Mono.ActiveCfg = Release|Any CPU
{BD43F7C0-396B-4AA1-BAD9-DFDE54D51298}.Release|x86.ActiveCfg = Release|Any CPU
{BD43F7C0-396B-4AA1-BAD9-DFDE54D51298}.Release|x86.Build.0 = Release|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.Ad-Hoc|Mono.ActiveCfg = Debug|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.Ad-Hoc|x86.Deploy.0 = Debug|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.AppStore|iPhone.ActiveCfg = Release|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.AppStore|Mono.ActiveCfg = Debug|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.AppStore|x86.ActiveCfg = Debug|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.AppStore|x86.Build.0 = Debug|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.AppStore|x86.Deploy.0 = Debug|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.Debug|Mono.ActiveCfg = Debug|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.Debug|x86.ActiveCfg = Debug|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.Debug|x86.Build.0 = Debug|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.Debug|x86.Deploy.0 = Debug|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.Release|Any CPU.Build.0 = Release|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.Release|Any CPU.Deploy.0 = Release|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.Release|iPhone.ActiveCfg = Release|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.Release|Mono.ActiveCfg = Release|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.Release|x86.ActiveCfg = Release|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.Release|x86.Build.0 = Release|Any CPU
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31}.Release|x86.Deploy.0 = Release|Any CPU
{DA49C5F3-BE95-461C-B999-072128CCF59E}.Ad-Hoc|Any CPU.ActiveCfg = Ad-Hoc|iPhone
{DA49C5F3-BE95-461C-B999-072128CCF59E}.Ad-Hoc|iPhone.ActiveCfg = Ad-Hoc|iPhone
{DA49C5F3-BE95-461C-B999-072128CCF59E}.Ad-Hoc|iPhone.Build.0 = Ad-Hoc|iPhone
{DA49C5F3-BE95-461C-B999-072128CCF59E}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Ad-Hoc|iPhoneSimulator
{DA49C5F3-BE95-461C-B999-072128CCF59E}.Ad-Hoc|iPhoneSimulator.Build.0 = Ad-Hoc|iPhoneSimulator
{DA49C5F3-BE95-461C-B999-072128CCF59E}.Ad-Hoc|Mono.ActiveCfg = Ad-Hoc|iPhoneSimulator
{DA49C5F3-BE95-461C-B999-072128CCF59E}.Ad-Hoc|x86.ActiveCfg = Ad-Hoc|iPhoneSimulator
{DA49C5F3-BE95-461C-B999-072128CCF59E}.AppStore|Any CPU.ActiveCfg = AppStore|iPhone
{DA49C5F3-BE95-461C-B999-072128CCF59E}.AppStore|iPhone.ActiveCfg = AppStore|iPhone
{DA49C5F3-BE95-461C-B999-072128CCF59E}.AppStore|iPhone.Build.0 = AppStore|iPhone
{DA49C5F3-BE95-461C-B999-072128CCF59E}.AppStore|iPhoneSimulator.ActiveCfg = AppStore|iPhoneSimulator
{DA49C5F3-BE95-461C-B999-072128CCF59E}.AppStore|iPhoneSimulator.Build.0 = AppStore|iPhoneSimulator
{DA49C5F3-BE95-461C-B999-072128CCF59E}.AppStore|Mono.ActiveCfg = AppStore|iPhoneSimulator
{DA49C5F3-BE95-461C-B999-072128CCF59E}.AppStore|x86.ActiveCfg = AppStore|iPhoneSimulator
{DA49C5F3-BE95-461C-B999-072128CCF59E}.Debug|Any CPU.ActiveCfg = Debug|iPhone
{DA49C5F3-BE95-461C-B999-072128CCF59E}.Debug|iPhone.ActiveCfg = Debug|iPhone
{DA49C5F3-BE95-461C-B999-072128CCF59E}.Debug|iPhone.Build.0 = Debug|iPhone
{DA49C5F3-BE95-461C-B999-072128CCF59E}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
{DA49C5F3-BE95-461C-B999-072128CCF59E}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
{DA49C5F3-BE95-461C-B999-072128CCF59E}.Debug|Mono.ActiveCfg = Debug|iPhoneSimulator
{DA49C5F3-BE95-461C-B999-072128CCF59E}.Debug|x86.ActiveCfg = Debug|iPhoneSimulator
{DA49C5F3-BE95-461C-B999-072128CCF59E}.Release|Any CPU.ActiveCfg = Release|iPhone
{DA49C5F3-BE95-461C-B999-072128CCF59E}.Release|iPhone.ActiveCfg = Release|iPhone
{DA49C5F3-BE95-461C-B999-072128CCF59E}.Release|iPhone.Build.0 = Release|iPhone
{DA49C5F3-BE95-461C-B999-072128CCF59E}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
{DA49C5F3-BE95-461C-B999-072128CCF59E}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
{DA49C5F3-BE95-461C-B999-072128CCF59E}.Release|Mono.ActiveCfg = Release|iPhoneSimulator
{DA49C5F3-BE95-461C-B999-072128CCF59E}.Release|x86.ActiveCfg = Release|iPhoneSimulator
{47BE08A7-5985-410B-9FFC-2264B8EA595F}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU
{47BE08A7-5985-410B-9FFC-2264B8EA595F}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU
{47BE08A7-5985-410B-9FFC-2264B8EA595F}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU
@ -2329,6 +2283,164 @@ Global
{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.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
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -2359,8 +2471,6 @@ Global
{2F59F3D0-748D-4652-B01E-E0D954756308} = {3743B0F2-CC41-4F14-A8C8-267F579BF91E}
{925DD807-B651-475F-9F7C-CBEB974CE43D} = {3743B0F2-CC41-4F14-A8C8-267F579BF91E}
{BD43F7C0-396B-4AA1-BAD9-DFDE54D51298} = {3743B0F2-CC41-4F14-A8C8-267F579BF91E}
{F92E55A5-ED73-4CCB-AB4B-0541B6757F31} = {3743B0F2-CC41-4F14-A8C8-267F579BF91E}
{DA49C5F3-BE95-461C-B999-072128CCF59E} = {3743B0F2-CC41-4F14-A8C8-267F579BF91E}
{47BE08A7-5985-410B-9FFC-2264B8EA595F} = {3743B0F2-CC41-4F14-A8C8-267F579BF91E}
{7B92AF71-6287-4693-9DCB-BD5B6E927E23} = {7CF9789C-F1D3-4D0E-90E5-F1DF67A2753F}
{FF69B927-C545-49AE-8E16-3D14D621AA12} = {7CF9789C-F1D3-4D0E-90E5-F1DF67A2753F}
@ -2382,5 +2492,9 @@ Global
{BD7F352C-6DC1-4740-BAF2-2D34A038728C} = {A0CC0258-D18C-4AB3-854F-7101680FC3F9}
{F1FDC5B0-4654-416F-AE69-E3E9BBD87801} = {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
EndGlobal

21
Avalonia.sln.DotSettings

@ -2,6 +2,24 @@
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=6417B24E_002D49C2_002D4985_002D8DB2_002D3AB9D898EC91/@EntryIndexedValue">ExplicitlyExcluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=E3A1060B_002D50D0_002D44E8_002D88B6_002DF44EF2E5BD72_002Ff_003Ahtml_002Ehtm/@EntryIndexedValue">ExplicitlyExcluded</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantUsingDirective/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/UserRules/=DECLSPEC_005FPROPERTY/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/UserRules/=ENUM/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/UserRules/=ENUMERATOR/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/UserRules/=GETTER/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/UserRules/=GLOBAL_005FFUNCTION/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/UserRules/=GLOBAL_005FVARIABLE/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/UserRules/=LOCAL_005FTYPEDEF/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/UserRules/=LOCAL_005FVARIABLE/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/UserRules/=NAMESPACE/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/UserRules/=PARAMETER/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/UserRules/=SETTER/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="set_" Suffix="" Style="aa_bb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/UserRules/=STRUCT/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/UserRules/=STRUCT_005FFIELD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="_" Style="aa_bb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/UserRules/=STRUCT_005FMETHODS/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/UserRules/=TEMPLATE_005FPARAMETER/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/UserRules/=TYPEDEF/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/UserRules/=UNION/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/UserRules/=UNION_005FMEMBER/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Constants/@EntryIndexedValue">&lt;Policy Inspect="False" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=EnumMember/@EntryIndexedValue">&lt;Policy Inspect="False" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Interfaces/@EntryIndexedValue">&lt;Policy Inspect="False" Prefix="I" Suffix="" Style="AaBb" /&gt;</s:String>
@ -10,8 +28,9 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Other/@EntryIndexedValue">&lt;Policy Inspect="False" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Parameters/@EntryIndexedValue">&lt;Policy Inspect="False" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateConstants/@EntryIndexedValue">&lt;Policy Inspect="False" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="s_" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb"&gt;&lt;ExtraRule Prefix="s_" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="s_" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=StaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=TypeParameters/@EntryIndexedValue">&lt;Policy Inspect="False" Prefix="T" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=TypesAndNamespaces/@EntryIndexedValue">&lt;Policy Inspect="False" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String></wpf:ResourceDictionary>

696
build.cake

@ -24,574 +24,118 @@ using Polly;
using NuGet;
///////////////////////////////////////////////////////////////////////////////
// ARGUMENTS
// SCRIPTS
///////////////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var platform = Argument("platform", "Any CPU");
var configuration = Argument("configuration", "Release");
var skipTests = HasArgument("skip-tests");
#load "./parameters.cake"
#load "./packages.cake"
///////////////////////////////////////////////////////////////////////////////
// CONFIGURATION
///////////////////////////////////////////////////////////////////////////////
var MainRepo = "AvaloniaUI/Avalonia";
var MasterBranch = "master";
var AssemblyInfoPath = File("./src/Shared/SharedAssemblyInfo.cs");
var ReleasePlatform = "Any CPU";
var ReleaseConfiguration = "Release";
var MSBuildSolution = "./Avalonia.sln";
var XBuildSolution = "./Avalonia.sln";
///////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
// PARAMETERS
///////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
var isPlatformAnyCPU = StringComparer.OrdinalIgnoreCase.Equals(platform, "Any CPU");
var isPlatformX86 = StringComparer.OrdinalIgnoreCase.Equals(platform, "x86");
var isPlatformX64 = StringComparer.OrdinalIgnoreCase.Equals(platform, "x64");
var isLocalBuild = BuildSystem.IsLocalBuild;
var isRunningOnUnix = IsRunningOnUnix();
var isRunningOnWindows = IsRunningOnWindows();
var isRunningOnAppVeyor = BuildSystem.AppVeyor.IsRunningOnAppVeyor;
var isPullRequest = BuildSystem.AppVeyor.Environment.PullRequest.IsPullRequest;
var isMainRepo = StringComparer.OrdinalIgnoreCase.Equals(MainRepo, BuildSystem.AppVeyor.Environment.Repository.Name);
var isMasterBranch = StringComparer.OrdinalIgnoreCase.Equals(MasterBranch, BuildSystem.AppVeyor.Environment.Repository.Branch);
var isTagged = BuildSystem.AppVeyor.Environment.Repository.Tag.IsTag
&& !string.IsNullOrWhiteSpace(BuildSystem.AppVeyor.Environment.Repository.Tag.Name);
var isReleasable = StringComparer.OrdinalIgnoreCase.Equals(ReleasePlatform, platform)
&& StringComparer.OrdinalIgnoreCase.Equals(ReleaseConfiguration, configuration);
var isMyGetRelease = !isTagged && isReleasable;
var isNuGetRelease = isTagged && isReleasable;
Parameters parameters = new Parameters(Context);
Packages packages = new Packages(Context, parameters);
///////////////////////////////////////////////////////////////////////////////
// VERSION
// SETUP
///////////////////////////////////////////////////////////////////////////////
var version = ParseAssemblyInfo(AssemblyInfoPath).AssemblyVersion;
if (isRunningOnAppVeyor)
Setup(context =>
{
if (isTagged)
{
// Use Tag Name as version
version = BuildSystem.AppVeyor.Environment.Repository.Tag.Name;
}
else
Information("Building version {0} of Avalonia ({1}, {2}, {3}) using version {4} of Cake.",
parameters.Version,
parameters.Platform,
parameters.Configuration,
parameters.Target,
typeof(ICakeContext).Assembly.GetName().Version.ToString());
if (parameters.IsRunningOnAppVeyor)
{
// Use AssemblyVersion with Build as version
version += "-build" + EnvironmentVariable("APPVEYOR_BUILD_NUMBER") + "-alpha";
Information("Repository Name: " + BuildSystem.AppVeyor.Environment.Repository.Name);
Information("Repository Branch: " + BuildSystem.AppVeyor.Environment.Repository.Branch);
}
}
///////////////////////////////////////////////////////////////////////////////
// DIRECTORIES
///////////////////////////////////////////////////////////////////////////////
var artifactsDir = (DirectoryPath)Directory("./artifacts");
var nugetRoot = artifactsDir.Combine("nuget");
var zipRoot = artifactsDir.Combine("zip");
var binRoot = artifactsDir.Combine("bin");
var testsRoot = artifactsDir.Combine("tests");
var dirSuffix = configuration;
var dirSuffixSkia = (isPlatformAnyCPU ? "x86" : platform) + "/" + configuration;
var dirSuffixIOS = "iPhone" + "/" + configuration;
var buildDirs =
GetDirectories("./src/**/bin/" + dirSuffix) +
GetDirectories("./src/**/obj/" + dirSuffix) +
GetDirectories("./src/Markup/**/bin/" + dirSuffix) +
GetDirectories("./src/Markup/**/obj/" + dirSuffix) +
GetDirectories("./src/Android/**/bin/" + dirSuffix) +
GetDirectories("./src/Android/**/obj/" + dirSuffix) +
GetDirectories("./src/Gtk/**/bin/" + dirSuffix) +
GetDirectories("./src/Gtk/**/obj/" + dirSuffix) +
GetDirectories("./src/iOS/**/bin/" + dirSuffixIOS) +
GetDirectories("./src/iOS/**/obj/" + dirSuffixIOS) +
(DirectoryPath)Directory("./src/Skia/Avalonia.Skia.Android/bin/" + dirSuffix) +
(DirectoryPath)Directory("./src/Skia/Avalonia.Skia.Android/obj/" + 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.Desktop/bin/" + dirSuffixSkia) +
(DirectoryPath)Directory("./src/Skia/Avalonia.Skia.Desktop/obj/" + dirSuffixSkia) +
(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.TestApp/bin/" + dirSuffixIOS) +
(DirectoryPath)Directory("./src/Skia/Avalonia.Skia.iOS.TestApp/obj/" + dirSuffixIOS) +
GetDirectories("./src/Windows/**/bin/" + dirSuffix) +
GetDirectories("./src/Windows/**/obj/" + dirSuffix) +
GetDirectories("./tests/**/bin/" + dirSuffix) +
GetDirectories("./tests/**/obj/" + dirSuffix) +
GetDirectories("./Samples/**/bin/" + dirSuffix) +
GetDirectories("./Samples/**/obj/" + dirSuffix);
var fileZipSuffix = version + ".zip";
var zipCoreArtifacts = zipRoot.CombineWithFilePath("Avalonia-" + fileZipSuffix);
var zipSourceControlCatalogDesktopDirs = (DirectoryPath)Directory("./samples/ControlCatalog.Desktop/bin/" + dirSuffix);
var zipTargetControlCatalogDesktopDirs = zipRoot.CombineWithFilePath("ControlCatalog.Desktop-" + fileZipSuffix);
Information("Target: " + parameters.Target);
Information("Platform: " + parameters.Platform);
Information("Configuration: " + parameters.Configuration);
Information("IsLocalBuild: " + parameters.IsLocalBuild);
Information("IsRunningOnUnix: " + parameters.IsRunningOnUnix);
Information("IsRunningOnWindows: " + parameters.IsRunningOnWindows);
Information("IsRunningOnAppVeyor: " + parameters.IsRunningOnAppVeyor);
Information("IsPullRequest: " + parameters.IsPullRequest);
Information("IsMainRepo: " + parameters.IsMainRepo);
Information("IsMasterBranch: " + parameters.IsMasterBranch);
Information("IsTagged: " + parameters.IsTagged);
Information("IsReleasable: " + parameters.IsReleasable);
Information("IsMyGetRelease: " + parameters.IsMyGetRelease);
Information("IsNuGetRelease: " + parameters.IsNuGetRelease);
});
///////////////////////////////////////////////////////////////////////////////
// NUGET NUSPECS
// TEARDOWN
///////////////////////////////////////////////////////////////////////////////
Information("Getting git modules:");
var ignoredSubModulesPaths = System.IO.File.ReadAllLines(".git/config").Where(m=>m.StartsWith("[submodule ")).Select(m =>
Teardown(context =>
{
var path = m.Split(' ')[1].Trim("\"[] \t".ToArray());
Information(path);
return ((DirectoryPath)Directory(path)).FullPath;
}).ToList();
var normalizePath = new Func<string, string>(
path => path.Replace(System.IO.Path.DirectorySeparatorChar, System.IO.Path.AltDirectorySeparatorChar).ToUpperInvariant());
// Key: Package Id
// Value is Tuple where Item1: Package Version, Item2: The packages.config file path.
var packageVersions = new Dictionary<string, IList<Tuple<string,string>>>();
System.IO.Directory.EnumerateFiles(((DirectoryPath)Directory("./src")).FullPath, "packages.config", SearchOption.AllDirectories).ToList().ForEach(fileName =>
{
if (!ignoredSubModulesPaths.Any(i => normalizePath(fileName).Contains(normalizePath(i))))
{
var file = new PackageReferenceFile(fileName);
foreach (PackageReference packageReference in file.GetPackageReferences())
{
IList<Tuple<string, string>> versions;
packageVersions.TryGetValue(packageReference.Id, out versions);
if (versions == null)
{
versions = new List<Tuple<string, string>>();
packageVersions[packageReference.Id] = versions;
}
versions.Add(Tuple.Create(packageReference.Version.ToString(), fileName));
}
}
Information("Finished running tasks.");
});
Information("Checking installed NuGet package dependencies versions:");
///////////////////////////////////////////////////////////////////////////////
// TASKS
///////////////////////////////////////////////////////////////////////////////
packageVersions.ToList().ForEach(package =>
Task("Clean")
.Does(() =>
{
var packageVersion = package.Value.First().Item1;
bool isValidVersion = package.Value.All(x => x.Item1 == packageVersion);
if (!isValidVersion)
{
Information("Error: package {0} has multiple versions installed:", package.Key);
foreach (var v in package.Value)
{
Information("{0}, file: {1}", v.Item1, v.Item2);
}
throw new Exception("Detected multiple NuGet package version installed for different projects.");
}
});
Information("Setting NuGet package dependencies versions:");
var SerilogVersion = packageVersions["Serilog"].FirstOrDefault().Item1;
var SplatVersion = packageVersions["Splat"].FirstOrDefault().Item1;
var SpracheVersion = packageVersions["Sprache"].FirstOrDefault().Item1;
var SystemReactiveVersion = packageVersions["System.Reactive"].FirstOrDefault().Item1;
var SkiaSharpVersion = packageVersions["SkiaSharp"].FirstOrDefault().Item1;
var SharpDXVersion = packageVersions["SharpDX"].FirstOrDefault().Item1;
var SharpDXDirect2D1Version = packageVersions["SharpDX.Direct2D1"].FirstOrDefault().Item1;
var SharpDXDXGIVersion = packageVersions["SharpDX.DXGI"].FirstOrDefault().Item1;
Information("Package: Serilog, version: {0}", SerilogVersion);
Information("Package: Splat, version: {0}", SplatVersion);
Information("Package: Sprache, version: {0}", SpracheVersion);
Information("Package: System.Reactive, version: {0}", SystemReactiveVersion);
Information("Package: SkiaSharp, version: {0}", SkiaSharpVersion);
Information("Package: SharpDX, version: {0}", SharpDXVersion);
Information("Package: SharpDX.Direct2D1, version: {0}", SharpDXDirect2D1Version);
Information("Package: SharpDX.DXGI, version: {0}", SharpDXDXGIVersion);
var SetNuGetNuspecCommonProperties = new Action<NuGetPackSettings> ((nuspec) => {
nuspec.Version = version;
nuspec.Authors = new [] { "Avalonia Team" };
nuspec.Owners = new [] { "stevenk" };
nuspec.LicenseUrl = new Uri("http://opensource.org/licenses/MIT");
nuspec.ProjectUrl = new Uri("https://github.com/AvaloniaUI/Avalonia/");
nuspec.RequireLicenseAcceptance = false;
nuspec.Symbols = false;
nuspec.NoPackageAnalysis = true;
nuspec.Description = "The Avalonia UI framework";
nuspec.Copyright = "Copyright 2015";
nuspec.Tags = new [] { "Avalonia" };
CleanDirectories(parameters.BuildDirs);
CleanDirectory(parameters.ArtifactsDir);
CleanDirectory(parameters.NugetRoot);
CleanDirectory(parameters.ZipRoot);
CleanDirectory(parameters.BinRoot);
CleanDirectory(parameters.TestsRoot);
});
var coreLibraries = new string[][]
Task("Prepare-XBuild-Solution")
.Does(() =>
{
new [] { "./src/", "Avalonia.Animation", ".dll" },
new [] { "./src/", "Avalonia.Animation", ".xml" },
new [] { "./src/", "Avalonia.Base", ".dll" },
new [] { "./src/", "Avalonia.Base", ".xml" },
new [] { "./src/", "Avalonia.Controls", ".dll" },
new [] { "./src/", "Avalonia.Controls", ".xml" },
new [] { "./src/", "Avalonia.DesignerSupport", ".dll" },
new [] { "./src/", "Avalonia.DesignerSupport", ".xml" },
new [] { "./src/", "Avalonia.Diagnostics", ".dll" },
new [] { "./src/", "Avalonia.Diagnostics", ".xml" },
new [] { "./src/", "Avalonia.Input", ".dll" },
new [] { "./src/", "Avalonia.Input", ".xml" },
new [] { "./src/", "Avalonia.Interactivity", ".dll" },
new [] { "./src/", "Avalonia.Interactivity", ".xml" },
new [] { "./src/", "Avalonia.Layout", ".dll" },
new [] { "./src/", "Avalonia.Layout", ".xml" },
new [] { "./src/", "Avalonia.Logging.Serilog", ".dll" },
new [] { "./src/", "Avalonia.Logging.Serilog", ".xml" },
new [] { "./src/", "Avalonia.Visuals", ".dll" },
new [] { "./src/", "Avalonia.Visuals", ".xml" },
new [] { "./src/", "Avalonia.Styling", ".dll" },
new [] { "./src/", "Avalonia.Styling", ".xml" },
new [] { "./src/", "Avalonia.ReactiveUI", ".dll" },
new [] { "./src/", "Avalonia.Themes.Default", ".dll" },
new [] { "./src/", "Avalonia.Themes.Default", ".xml" },
new [] { "./src/Markup/", "Avalonia.Markup", ".dll" },
new [] { "./src/Markup/", "Avalonia.Markup", ".xml" },
new [] { "./src/Markup/", "Avalonia.Markup.Xaml", ".dll" },
new [] { "./src/Markup/", "Avalonia.Markup.Xaml", ".xml" }
};
var coreLibrariesFiles = coreLibraries.Select((lib) => {
return (FilePath)File(lib[0] + lib[1] + "/bin/" + dirSuffix + "/" + lib[1] + lib[2]);
}).ToList();
var coreLibrariesNuSpecContent = coreLibrariesFiles.Select((file) => {
return new NuSpecContent {
Source = file.FullPath, Target = "lib/portable-windows8+net45"
};
});
var win32CoreLibrariesNuSpecContent = coreLibrariesFiles.Select((file) => {
return new NuSpecContent {
Source = file.FullPath, Target = "lib/net45"
};
});
var net45RuntimePlatformExtensions = new [] {".xml", ".dll"};
var net45RuntimePlatform = net45RuntimePlatformExtensions.Select(libSuffix => {
return new NuSpecContent {
Source = ((FilePath)File("./src/Avalonia.DotNetFrameworkRuntime/bin/" + dirSuffix + "/Avalonia.DotNetFrameworkRuntime" + libSuffix)).FullPath,
Target = "lib/net45"
var blacklistedProjects = new[]
{
"Avalonia.Win32.NetStandard",
"Avalonia.DotNetCoreRuntime",
"Avalonia.Skia.Desktop.NetStandard",
"Avalonia.Gtk3"
};
});
var blacklistedGuids = System.IO.File.ReadAllLines(parameters.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();
var nuspecNuGetSettingsCore = new []
{
///////////////////////////////////////////////////////////////////////////////
// Avalonia
///////////////////////////////////////////////////////////////////////////////
new NuGetPackSettings()
{
Id = "Avalonia",
Dependencies = new []
{
new NuSpecDependency() { Id = "Serilog", Version = SerilogVersion },
new NuSpecDependency() { Id = "Splat", Version = SplatVersion },
new NuSpecDependency() { Id = "Sprache", Version = SpracheVersion },
new NuSpecDependency() { Id = "System.Reactive", Version = SystemReactiveVersion }
},
Files = coreLibrariesNuSpecContent.Concat(win32CoreLibrariesNuSpecContent).Concat(net45RuntimePlatform).ToList(),
BasePath = Directory("./"),
OutputDirectory = nugetRoot
},
///////////////////////////////////////////////////////////////////////////////
// Avalonia.HtmlRenderer
///////////////////////////////////////////////////////////////////////////////
new NuGetPackSettings()
{
Id = "Avalonia.HtmlRenderer",
Dependencies = new []
{
new NuSpecDependency() { Id = "Avalonia", Version = version }
},
Files = new []
{
new NuSpecContent { Source = "Avalonia.HtmlRenderer.dll", Target = "lib/portable-windows8+net45" }
},
BasePath = Directory("./src/Avalonia.HtmlRenderer/bin/" + dirSuffix),
OutputDirectory = nugetRoot
}
};
Console.WriteLine("Blacklisted guids are: " + string.Join(",", blacklistedGuids));
var removeUntilEndProject = false;
var nuspecNuGetSettingsMobile = new []
{
///////////////////////////////////////////////////////////////////////////////
// Avalonia.Android
///////////////////////////////////////////////////////////////////////////////
new NuGetPackSettings()
{
Id = "Avalonia.Android",
Dependencies = new []
{
new NuSpecDependency() { Id = "Avalonia", Version = version },
new NuSpecDependency() { Id = "Avalonia.Skia.Android", Version = version }
},
Files = new []
System.IO.File.WriteAllLines(parameters.XBuildSolution, System.IO.File.ReadAllLines(parameters.MSBuildSolution)
.Where(l =>
{
new NuSpecContent { Source = "Avalonia.Android.dll", Target = "lib/MonoAndroid10" }
},
BasePath = Directory("./src/Android/Avalonia.Android/bin/" + dirSuffix),
OutputDirectory = nugetRoot
},
///////////////////////////////////////////////////////////////////////////////
// Avalonia.Skia.Android
///////////////////////////////////////////////////////////////////////////////
new NuGetPackSettings()
{
Id = "Avalonia.Skia.Android",
Dependencies = new []
{
new NuSpecDependency() { Id = "Avalonia", Version = version },
new NuSpecDependency() { Id = "SkiaSharp", Version = SkiaSharpVersion }
},
Files = new []
{
new NuSpecContent { Source = "Avalonia.Skia.Android.dll", Target = "lib/MonoAndroid10" }
},
BasePath = Directory("./src/Skia/Avalonia.Skia.Android/bin/" + dirSuffix),
OutputDirectory = nugetRoot
},
///////////////////////////////////////////////////////////////////////////////
// Avalonia.iOS
///////////////////////////////////////////////////////////////////////////////
new NuGetPackSettings()
{
Id = "Avalonia.iOS",
Dependencies = new []
{
new NuSpecDependency() { Id = "Avalonia", Version = version },
new NuSpecDependency() { Id = "Avalonia.Skia.iOS", Version = version }
},
Files = new []
{
new NuSpecContent { Source = "Avalonia.iOS.dll", Target = "lib/Xamarin.iOS10" }
},
BasePath = Directory("./src/iOS/Avalonia.iOS/bin/" + dirSuffixIOS),
OutputDirectory = nugetRoot
},
///////////////////////////////////////////////////////////////////////////////
// Avalonia.Skia.iOS
///////////////////////////////////////////////////////////////////////////////
new NuGetPackSettings()
{
Id = "Avalonia.Skia.iOS",
Dependencies = new []
{
new NuSpecDependency() { Id = "Avalonia", Version = version },
new NuSpecDependency() { Id = "SkiaSharp", Version = SkiaSharpVersion }
},
Files = new []
{
new NuSpecContent { Source = "Avalonia.Skia.iOS.dll", Target = "lib/Xamarin.iOS10" }
},
BasePath = Directory("./src/Skia/Avalonia.Skia.iOS/bin/" + dirSuffixIOS),
OutputDirectory = nugetRoot
},
///////////////////////////////////////////////////////////////////////////////
// Avalonia.Mobile
///////////////////////////////////////////////////////////////////////////////
new NuGetPackSettings()
{
Id = "Avalonia.Mobile",
Dependencies = new []
{
new NuSpecDependency() { Id = "Avalonia.Android", Version = version },
new NuSpecDependency() { Id = "Avalonia.iOS", Version = version }
},
Files = new NuSpecContent[]
{
new NuSpecContent { Source = "licence.md", Target = "" }
},
BasePath = Directory("./"),
OutputDirectory = nugetRoot
}
};
var nuspecNuGetSettingsDesktop = new []
{
///////////////////////////////////////////////////////////////////////////////
// Avalonia.Win32
///////////////////////////////////////////////////////////////////////////////
new NuGetPackSettings()
{
Id = "Avalonia.Win32",
Dependencies = new []
{
new NuSpecDependency() { Id = "Avalonia", Version = version }
},
Files = new []
{
new NuSpecContent { Source = "Avalonia.Win32.dll", Target = "lib/net45" }
},
BasePath = Directory("./src/Windows/Avalonia.Win32/bin/" + dirSuffix),
OutputDirectory = nugetRoot
},
///////////////////////////////////////////////////////////////////////////////
// Avalonia.Direct2D1
///////////////////////////////////////////////////////////////////////////////
new NuGetPackSettings()
{
Id = "Avalonia.Direct2D1",
Dependencies = new []
{
new NuSpecDependency() { Id = "Avalonia", Version = version },
new NuSpecDependency() { Id = "SharpDX", Version = SharpDXVersion },
new NuSpecDependency() { Id = "SharpDX.Direct2D1", Version = SharpDXDirect2D1Version },
new NuSpecDependency() { Id = "SharpDX.DXGI", Version = SharpDXDXGIVersion }
},
Files = new []
{
new NuSpecContent { Source = "Avalonia.Direct2D1.dll", Target = "lib/net45" }
},
BasePath = Directory("./src/Windows/Avalonia.Direct2D1/bin/" + dirSuffix),
OutputDirectory = nugetRoot
},
///////////////////////////////////////////////////////////////////////////////
// Avalonia.Gtk
///////////////////////////////////////////////////////////////////////////////
new NuGetPackSettings()
{
Id = "Avalonia.Gtk",
Dependencies = new []
{
new NuSpecDependency() { Id = "Avalonia", Version = version }
},
Files = new []
{
new NuSpecContent { Source = "Avalonia.Gtk.dll", Target = "lib/net45" }
},
BasePath = Directory("./src/Gtk/Avalonia.Gtk/bin/" + dirSuffix),
OutputDirectory = nugetRoot
},
///////////////////////////////////////////////////////////////////////////////
// Avalonia.Cairo
///////////////////////////////////////////////////////////////////////////////
new NuGetPackSettings()
{
Id = "Avalonia.Cairo",
Dependencies = new []
{
new NuSpecDependency() { Id = "Avalonia", Version = version }
},
Files = new []
{
new NuSpecContent { Source = "Avalonia.Cairo.dll", Target = "lib/net45" }
},
BasePath = Directory("./src/Gtk/Avalonia.Cairo/bin/" + dirSuffix),
OutputDirectory = nugetRoot
},
///////////////////////////////////////////////////////////////////////////////
// Avalonia.Skia.Desktop
///////////////////////////////////////////////////////////////////////////////
new NuGetPackSettings()
{
Id = "Avalonia.Skia.Desktop",
Dependencies = new []
{
new NuSpecDependency() { Id = "Avalonia", Version = version },
new NuSpecDependency() { Id = "SkiaSharp", Version = SkiaSharpVersion }
},
Files = new []
{
new NuSpecContent { Source = "Avalonia.Skia.Desktop.dll", Target = "lib/net45" }
},
BasePath = Directory("./src/Skia/Avalonia.Skia.Desktop/bin/" + dirSuffixSkia),
OutputDirectory = nugetRoot
},
///////////////////////////////////////////////////////////////////////////////
// Avalonia.Desktop
///////////////////////////////////////////////////////////////////////////////
new NuGetPackSettings()
{
Id = "Avalonia.Desktop",
Dependencies = new []
{
new NuSpecDependency() { Id = "Avalonia.Win32", Version = version },
new NuSpecDependency() { Id = "Avalonia.Direct2D1", Version = version },
new NuSpecDependency() { Id = "Avalonia.Gtk", Version = version },
new NuSpecDependency() { Id = "Avalonia.Cairo", Version = version },
new NuSpecDependency() { Id = "Avalonia.Skia.Desktop", Version = version }
},
Files = new NuSpecContent[]
{
new NuSpecContent { Source = "licence.md", Target = "" }
},
BasePath = Directory("./"),
OutputDirectory = nugetRoot
}
};
var nuspecNuGetSettings = new List<NuGetPackSettings>();
nuspecNuGetSettings.AddRange(nuspecNuGetSettingsCore);
nuspecNuGetSettings.AddRange(nuspecNuGetSettingsDesktop);
nuspecNuGetSettings.AddRange(nuspecNuGetSettingsMobile);
nuspecNuGetSettings.ForEach((nuspec) => SetNuGetNuspecCommonProperties(nuspec));
var nugetPackages = nuspecNuGetSettings.Select(nuspec => {
return nuspec.OutputDirectory.CombineWithFilePath(string.Concat(nuspec.Id, ".", nuspec.Version, ".nupkg"));
}).ToArray();
var binFiles = nuspecNuGetSettings.SelectMany(nuspec => {
return nuspec.Files.Select(file => {
return ((DirectoryPath)nuspec.BasePath).CombineWithFilePath(file.Source);
});
}).GroupBy(f => f.FullPath).Select(g => g.First());
///////////////////////////////////////////////////////////////////////////////
// INFORMATION
///////////////////////////////////////////////////////////////////////////////
Information("Building version {0} of Avalonia ({1}, {2}, {3}) using version {4} of Cake.",
version,
platform,
configuration,
target,
typeof(ICakeContext).Assembly.GetName().Version.ToString());
if (isRunningOnAppVeyor)
{
Information("Repository Name: " + BuildSystem.AppVeyor.Environment.Repository.Name);
Information("Repository Branch: " + BuildSystem.AppVeyor.Environment.Repository.Branch);
}
Information("Target: " + target);
Information("Platform: " + platform);
Information("Configuration: " + configuration);
Information("IsLocalBuild: " + isLocalBuild);
Information("IsRunningOnUnix: " + isRunningOnUnix);
Information("IsRunningOnWindows: " + isRunningOnWindows);
Information("IsRunningOnAppVeyor: " + isRunningOnAppVeyor);
Information("IsPullRequest: " + isPullRequest);
Information("IsMainRepo: " + isMainRepo);
Information("IsMasterBranch: " + isMasterBranch);
Information("IsTagged: " + isTagged);
Information("IsReleasable: " + isReleasable);
Information("IsMyGetRelease: " + isMyGetRelease);
Information("IsNuGetRelease: " + isNuGetRelease);
///////////////////////////////////////////////////////////////////////////////
// TASKS
///////////////////////////////////////////////////////////////////////////////
Task("Clean")
.Does(() =>
{
CleanDirectories(buildDirs);
CleanDirectory(artifactsDir);
CleanDirectory(nugetRoot);
CleanDirectory(zipRoot);
CleanDirectory(binRoot);
CleanDirectory(testsRoot);
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")
.IsDependentOn("Clean")
.IsDependentOn("Prepare-XBuild-Solution")
.Does(() =>
{
var maxRetryCount = 5;
@ -609,15 +153,15 @@ Task("Restore-NuGet-Packages")
toolTimeout+=0.5;
}})
.Execute(()=> {
if(isRunningOnWindows)
if(parameters.IsRunningOnWindows)
{
NuGetRestore(MSBuildSolution, new NuGetRestoreSettings {
NuGetRestore(parameters.MSBuildSolution, new NuGetRestoreSettings {
ToolTimeout = TimeSpan.FromMinutes(toolTimeout)
});
}
else
{
NuGetRestore(XBuildSolution, new NuGetRestoreSettings {
NuGetRestore(parameters.XBuildSolution, new NuGetRestoreSettings {
ToolTimeout = TimeSpan.FromMinutes(toolTimeout)
});
}
@ -628,11 +172,11 @@ Task("Build")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
if(isRunningOnWindows)
if(parameters.IsRunningOnWindows)
{
MSBuild(MSBuildSolution, settings => {
settings.SetConfiguration(configuration);
settings.WithProperty("Platform", "\"" + platform + "\"");
MSBuild(parameters.MSBuildSolution, settings => {
settings.SetConfiguration(parameters.Configuration);
settings.WithProperty("Platform", "\"" + parameters.Platform + "\"");
settings.SetVerbosity(Verbosity.Minimal);
settings.WithProperty("Windows", "True");
settings.UseToolVersion(MSBuildToolVersion.VS2015);
@ -641,9 +185,9 @@ Task("Build")
}
else
{
XBuild(XBuildSolution, settings => {
settings.SetConfiguration(configuration);
settings.WithProperty("Platform", "\"" + platform + "\"");
XBuild(parameters.XBuildSolution, settings => {
settings.SetConfiguration(parameters.Configuration);
settings.WithProperty("Platform", "\"" + parameters.Platform + "\"");
settings.SetVerbosity(Verbosity.Minimal);
});
}
@ -651,23 +195,23 @@ Task("Build")
Task("Run-Unit-Tests")
.IsDependentOn("Build")
.WithCriteria(() => !skipTests)
.WithCriteria(() => !parameters.SkipTests)
.Does(() =>
{
var unitTests = GetDirectories("./tests/Avalonia.*.UnitTests")
.Select(dir => System.IO.Path.GetFileName(dir.FullPath))
.Where(name => isRunningOnWindows ? true : !(name.IndexOf("Direct2D", StringComparison.OrdinalIgnoreCase) >= 0))
.Select(name => MakeAbsolute(File("./tests/" + name + "/bin/" + dirSuffix + "/" + name + ".dll")))
.Where(name => parameters.IsRunningOnWindows ? true : !(name.IndexOf("Direct2D", StringComparison.OrdinalIgnoreCase) >= 0))
.Select(name => MakeAbsolute(File("./tests/" + name + "/bin/" + parameters.DirSuffix + "/" + name + ".dll")))
.ToList();
if (isRunningOnWindows)
if (parameters.IsRunningOnWindows)
{
var leakTests = GetFiles("./tests/Avalonia.LeakTests/bin/" + dirSuffix + "/*.LeakTests.dll");
var leakTests = GetFiles("./tests/Avalonia.LeakTests/bin/" + parameters.DirSuffix + "/*.LeakTests.dll");
unitTests.AddRange(leakTests);
}
var toolPath = (isPlatformAnyCPU || isPlatformX86) ?
var toolPath = (parameters.IsPlatformAnyCPU || parameters.IsPlatformX86) ?
"./tools/xunit.runner.console/tools/xunit.console.x86.exe" :
"./tools/xunit.runner.console/tools/xunit.console.exe";
@ -678,9 +222,9 @@ Task("Run-Unit-Tests")
ShadowCopy = false
};
xUnitSettings.NoAppDomain = !isRunningOnWindows;
xUnitSettings.NoAppDomain = !parameters.IsRunningOnWindows;
var openCoverOutput = artifactsDir.GetFilePath(new FilePath("./coverage.xml"));
var openCoverOutput = parameters.ArtifactsDir.GetFilePath(new FilePath("./coverage.xml"));
var openCoverSettings = new OpenCoverSettings()
.WithFilter("+[Avalonia.*]* -[*Test*]* -[ControlCatalog*]*")
.WithFilter("-[Avalonia.*]OmniXaml.* -[Avalonia.*]Glass.*")
@ -690,11 +234,11 @@ Task("Run-Unit-Tests")
foreach(var test in unitTests.Where(testFile => FileExists(testFile)))
{
CopyDirectory(test.GetDirectory(), testsRoot);
CopyDirectory(test.GetDirectory(), parameters.TestsRoot);
}
var testsInDirectoryToRun = new List<FilePath>();
if(isRunningOnWindows)
if(parameters.IsRunningOnWindows)
{
testsInDirectoryToRun.AddRange(GetFiles("./artifacts/tests/*Tests.dll"));
}
@ -703,7 +247,7 @@ Task("Run-Unit-Tests")
testsInDirectoryToRun.AddRange(GetFiles("./artifacts/tests/*.UnitTests.dll"));
}
if(isRunningOnWindows)
if(parameters.IsRunningOnWindows)
{
OpenCover(context => {
context.XUnit2(testsInDirectoryToRun, xUnitSettings);
@ -719,26 +263,26 @@ Task("Copy-Files")
.IsDependentOn("Run-Unit-Tests")
.Does(() =>
{
CopyFiles(binFiles, binRoot);
CopyFiles(packages.BinFiles, parameters.BinRoot);
});
Task("Zip-Files")
.IsDependentOn("Copy-Files")
.Does(() =>
{
Zip(binRoot, zipCoreArtifacts);
Zip(parameters.BinRoot, parameters.ZipCoreArtifacts);
Zip(zipSourceControlCatalogDesktopDirs,
zipTargetControlCatalogDesktopDirs,
GetFiles(zipSourceControlCatalogDesktopDirs.FullPath + "/*.dll") +
GetFiles(zipSourceControlCatalogDesktopDirs.FullPath + "/*.exe"));
Zip(parameters.ZipSourceControlCatalogDesktopDirs,
parameters.ZipTargetControlCatalogDesktopDirs,
GetFiles(parameters.ZipSourceControlCatalogDesktopDirs.FullPath + "/*.dll") +
GetFiles(parameters.ZipSourceControlCatalogDesktopDirs.FullPath + "/*.exe"));
});
Task("Create-NuGet-Packages")
.IsDependentOn("Run-Unit-Tests")
.Does(() =>
{
foreach(var nuspec in nuspecNuGetSettings)
foreach(var nuspec in packages.NuspecNuGetSettings)
{
NuGetPack(nuspec);
}
@ -746,11 +290,11 @@ Task("Create-NuGet-Packages")
Task("Publish-MyGet")
.IsDependentOn("Create-NuGet-Packages")
.WithCriteria(() => !isLocalBuild)
.WithCriteria(() => !isPullRequest)
.WithCriteria(() => isMainRepo)
.WithCriteria(() => isMasterBranch)
.WithCriteria(() => isMyGetRelease)
.WithCriteria(() => !parameters.IsLocalBuild)
.WithCriteria(() => !parameters.IsPullRequest)
.WithCriteria(() => parameters.IsMainRepo)
.WithCriteria(() => parameters.IsMasterBranch)
.WithCriteria(() => parameters.IsMyGetRelease)
.Does(() =>
{
var apiKey = EnvironmentVariable("MYGET_API_KEY");
@ -765,7 +309,7 @@ Task("Publish-MyGet")
throw new InvalidOperationException("Could not resolve MyGet API url.");
}
foreach(var nupkg in nugetPackages)
foreach(var nupkg in packages.NugetPackages)
{
NuGetPush(nupkg, new NuGetPushSettings {
Source = apiUrl,
@ -780,11 +324,11 @@ Task("Publish-MyGet")
Task("Publish-NuGet")
.IsDependentOn("Create-NuGet-Packages")
.WithCriteria(() => !isLocalBuild)
.WithCriteria(() => !isPullRequest)
.WithCriteria(() => isMainRepo)
.WithCriteria(() => isMasterBranch)
.WithCriteria(() => isNuGetRelease)
.WithCriteria(() => !parameters.IsLocalBuild)
.WithCriteria(() => !parameters.IsPullRequest)
.WithCriteria(() => parameters.IsMainRepo)
.WithCriteria(() => parameters.IsMasterBranch)
.WithCriteria(() => parameters.IsNuGetRelease)
.Does(() =>
{
var apiKey = EnvironmentVariable("NUGET_API_KEY");
@ -799,7 +343,7 @@ Task("Publish-NuGet")
throw new InvalidOperationException("Could not resolve NuGet API url.");
}
foreach(var nupkg in nugetPackages)
foreach(var nupkg in packages.NugetPackages)
{
NuGetPush(nupkg, new NuGetPushSettings {
ApiKey = apiKey,
@ -834,4 +378,4 @@ Task("Travis")
// EXECUTE
///////////////////////////////////////////////////////////////////////////////
RunTarget(target);
RunTarget(parameters.Target);

469
packages.cake

@ -0,0 +1,469 @@
public class Packages
{
public List<NuGetPackSettings> NuspecNuGetSettings { get; private set; }
public FilePath[] NugetPackages { get; private set; }
public FilePath[] BinFiles { get; private set; }
public Packages(ICakeContext context, Parameters parameters)
{
// NUGET NUSPECS
context.Information("Getting git modules:");
var ignoredSubModulesPaths = System.IO.File.ReadAllLines(".git/config").Where(m=>m.StartsWith("[submodule ")).Select(m =>
{
var path = m.Split(' ')[1].Trim("\"[] \t".ToArray());
context.Information(path);
return ((DirectoryPath)context.Directory(path)).FullPath;
}).ToList();
var normalizePath = new Func<string, string>(
path => path.Replace(System.IO.Path.DirectorySeparatorChar, System.IO.Path.AltDirectorySeparatorChar).ToUpperInvariant());
// Key: Package Id
// Value is Tuple where Item1: Package Version, Item2: The packages.config file path.
var packageVersions = new Dictionary<string, IList<Tuple<string,string>>>();
System.IO.Directory.EnumerateFiles(((DirectoryPath)context.Directory("./src")).FullPath, "packages.config", SearchOption.AllDirectories).ToList().ForEach(fileName =>
{
if (!ignoredSubModulesPaths.Any(i => normalizePath(fileName).Contains(normalizePath(i))))
{
var file = new PackageReferenceFile(fileName);
foreach (PackageReference packageReference in file.GetPackageReferences())
{
IList<Tuple<string, string>> versions;
packageVersions.TryGetValue(packageReference.Id, out versions);
if (versions == null)
{
versions = new List<Tuple<string, string>>();
packageVersions[packageReference.Id] = versions;
}
versions.Add(Tuple.Create(packageReference.Version.ToString(), fileName));
}
}
});
context.Information("Checking installed NuGet package dependencies versions:");
packageVersions.ToList().ForEach(package =>
{
var packageVersion = package.Value.First().Item1;
bool isValidVersion = package.Value.All(x => x.Item1 == packageVersion);
if (!isValidVersion)
{
context.Information("Error: package {0} has multiple versions installed:", package.Key);
foreach (var v in package.Value)
{
context.Information("{0}, file: {1}", v.Item1, v.Item2);
}
throw new Exception("Detected multiple NuGet package version installed for different projects.");
}
});
context.Information("Setting NuGet package dependencies versions:");
var SerilogVersion = packageVersions["Serilog"].FirstOrDefault().Item1;
var SplatVersion = packageVersions["Splat"].FirstOrDefault().Item1;
var SpracheVersion = packageVersions["Sprache"].FirstOrDefault().Item1;
var SystemReactiveVersion = packageVersions["System.Reactive"].FirstOrDefault().Item1;
var SkiaSharpVersion = packageVersions["SkiaSharp"].FirstOrDefault().Item1;
var SharpDXVersion = packageVersions["SharpDX"].FirstOrDefault().Item1;
var SharpDXDirect2D1Version = packageVersions["SharpDX.Direct2D1"].FirstOrDefault().Item1;
var SharpDXDirect3D11Version = packageVersions["SharpDX.Direct3D11"].FirstOrDefault().Item1;
var SharpDXDXGIVersion = packageVersions["SharpDX.DXGI"].FirstOrDefault().Item1;
context.Information("Package: Serilog, version: {0}", SerilogVersion);
context.Information("Package: Splat, version: {0}", SplatVersion);
context.Information("Package: Sprache, version: {0}", SpracheVersion);
context.Information("Package: System.Reactive, version: {0}", SystemReactiveVersion);
context.Information("Package: SkiaSharp, version: {0}", SkiaSharpVersion);
context.Information("Package: SharpDX, version: {0}", SharpDXVersion);
context.Information("Package: SharpDX.Direct2D1, version: {0}", SharpDXDirect2D1Version);
context.Information("Package: SharpDX.Direct3D11, version: {0}", SharpDXDirect3D11Version);
context.Information("Package: SharpDX.DXGI, version: {0}", SharpDXDXGIVersion);
var SetNuGetNuspecCommonProperties = new Action<NuGetPackSettings> ((nuspec) => {
nuspec.Version = parameters.Version;
nuspec.Authors = new [] { "Avalonia Team" };
nuspec.Owners = new [] { "stevenk" };
nuspec.LicenseUrl = new Uri("http://opensource.org/licenses/MIT");
nuspec.ProjectUrl = new Uri("https://github.com/AvaloniaUI/Avalonia/");
nuspec.RequireLicenseAcceptance = false;
nuspec.Symbols = false;
nuspec.NoPackageAnalysis = true;
nuspec.Description = "The Avalonia UI framework";
nuspec.Copyright = "Copyright 2015";
nuspec.Tags = new [] { "Avalonia" };
});
var coreLibraries = new string[][]
{
new [] { "./src/", "Avalonia.Animation", ".dll" },
new [] { "./src/", "Avalonia.Animation", ".xml" },
new [] { "./src/", "Avalonia.Base", ".dll" },
new [] { "./src/", "Avalonia.Base", ".xml" },
new [] { "./src/", "Avalonia.Controls", ".dll" },
new [] { "./src/", "Avalonia.Controls", ".xml" },
new [] { "./src/", "Avalonia.DesignerSupport", ".dll" },
new [] { "./src/", "Avalonia.DesignerSupport", ".xml" },
new [] { "./src/", "Avalonia.Diagnostics", ".dll" },
new [] { "./src/", "Avalonia.Diagnostics", ".xml" },
new [] { "./src/", "Avalonia.Input", ".dll" },
new [] { "./src/", "Avalonia.Input", ".xml" },
new [] { "./src/", "Avalonia.Interactivity", ".dll" },
new [] { "./src/", "Avalonia.Interactivity", ".xml" },
new [] { "./src/", "Avalonia.Layout", ".dll" },
new [] { "./src/", "Avalonia.Layout", ".xml" },
new [] { "./src/", "Avalonia.Logging.Serilog", ".dll" },
new [] { "./src/", "Avalonia.Logging.Serilog", ".xml" },
new [] { "./src/", "Avalonia.Visuals", ".dll" },
new [] { "./src/", "Avalonia.Visuals", ".xml" },
new [] { "./src/", "Avalonia.Styling", ".dll" },
new [] { "./src/", "Avalonia.Styling", ".xml" },
new [] { "./src/", "Avalonia.ReactiveUI", ".dll" },
new [] { "./src/", "Avalonia.Themes.Default", ".dll" },
new [] { "./src/", "Avalonia.Themes.Default", ".xml" },
new [] { "./src/Markup/", "Avalonia.Markup", ".dll" },
new [] { "./src/Markup/", "Avalonia.Markup", ".xml" },
new [] { "./src/Markup/", "Avalonia.Markup.Xaml", ".dll" },
new [] { "./src/Markup/", "Avalonia.Markup.Xaml", ".xml" }
};
var coreLibrariesFiles = coreLibraries.Select((lib) => {
return (FilePath)context.File(lib[0] + lib[1] + "/bin/" + parameters.DirSuffix + "/" + lib[1] + lib[2]);
}).ToList();
var coreLibrariesNuSpecContent = coreLibrariesFiles.Select((file) => {
return new NuSpecContent {
Source = file.FullPath, Target = "lib/portable-windows8+net45"
};
});
var win32CoreLibrariesNuSpecContent = coreLibrariesFiles.Select((file) => {
return new NuSpecContent {
Source = file.FullPath, Target = "lib/net45"
};
});
var netcoreappCoreLibrariesNuSpecContent = coreLibrariesFiles.Select((file) => {
return new NuSpecContent {
Source = file.FullPath, Target = "lib/netcoreapp1.0"
};
});
var net45RuntimePlatformExtensions = new [] {".xml", ".dll"};
var net45RuntimePlatform = net45RuntimePlatformExtensions.Select(libSuffix => {
return new NuSpecContent {
Source = ((FilePath)context.File("./src/Avalonia.DotNetFrameworkRuntime/bin/" + parameters.DirSuffix + "/Avalonia.DotNetFrameworkRuntime" + libSuffix)).FullPath,
Target = "lib/net45"
};
});
var netCoreRuntimePlatformExtensions = new [] {".xml", ".dll"};
var netCoreRuntimePlatform = netCoreRuntimePlatformExtensions.Select(libSuffix => {
return new NuSpecContent {
Source = ((FilePath)context.File("./src/Avalonia.DotNetCoreRuntime/bin/" + parameters.DirSuffix + "/Avalonia.DotNetCoreRuntime" + libSuffix)).FullPath,
Target = "lib/netcoreapp1.0"
};
});
var nuspecNuGetSettingsCore = new []
{
///////////////////////////////////////////////////////////////////////////////
// Avalonia
///////////////////////////////////////////////////////////////////////////////
new NuGetPackSettings()
{
Id = "Avalonia",
Dependencies = new []
{
new NuSpecDependency() { Id = "Serilog", Version = SerilogVersion },
new NuSpecDependency() { Id = "Splat", Version = SplatVersion },
new NuSpecDependency() { Id = "Sprache", Version = SpracheVersion },
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)
.Concat(netcoreappCoreLibrariesNuSpecContent).Concat(netCoreRuntimePlatform)
.ToList(),
BasePath = context.Directory("./"),
OutputDirectory = parameters.NugetRoot
},
///////////////////////////////////////////////////////////////////////////////
// Avalonia.HtmlRenderer
///////////////////////////////////////////////////////////////////////////////
new NuGetPackSettings()
{
Id = "Avalonia.HtmlRenderer",
Dependencies = new []
{
new NuSpecDependency() { Id = "Avalonia", Version = parameters.Version }
},
Files = new []
{
new NuSpecContent { Source = "Avalonia.HtmlRenderer.dll", Target = "lib/portable-windows8+net45" }
},
BasePath = context.Directory("./src/Avalonia.HtmlRenderer/bin/" + parameters.DirSuffix),
OutputDirectory = parameters.NugetRoot
}
};
var nuspecNuGetSettingsMobile = new []
{
///////////////////////////////////////////////////////////////////////////////
// Avalonia.Android
///////////////////////////////////////////////////////////////////////////////
new NuGetPackSettings()
{
Id = "Avalonia.Android",
Dependencies = new []
{
new NuSpecDependency() { Id = "Avalonia", Version = parameters.Version },
new NuSpecDependency() { Id = "Avalonia.Skia.Android", Version = parameters.Version }
},
Files = new []
{
new NuSpecContent { Source = "Avalonia.Android.dll", Target = "lib/MonoAndroid10" }
},
BasePath = context.Directory("./src/Android/Avalonia.Android/bin/" + parameters.DirSuffix),
OutputDirectory = parameters.NugetRoot
},
///////////////////////////////////////////////////////////////////////////////
// Avalonia.Skia.Android
///////////////////////////////////////////////////////////////////////////////
new NuGetPackSettings()
{
Id = "Avalonia.Skia.Android",
Dependencies = new []
{
new NuSpecDependency() { Id = "Avalonia", Version = parameters.Version },
new NuSpecDependency() { Id = "SkiaSharp", Version = SkiaSharpVersion }
},
Files = new []
{
new NuSpecContent { Source = "Avalonia.Skia.Android.dll", Target = "lib/MonoAndroid10" }
},
BasePath = context.Directory("./src/Skia/Avalonia.Skia.Android/bin/" + parameters.DirSuffix),
OutputDirectory = parameters.NugetRoot
},
///////////////////////////////////////////////////////////////////////////////
// Avalonia.iOS
///////////////////////////////////////////////////////////////////////////////
new NuGetPackSettings()
{
Id = "Avalonia.iOS",
Dependencies = new []
{
new NuSpecDependency() { Id = "Avalonia", Version = parameters.Version },
new NuSpecDependency() { Id = "Avalonia.Skia.iOS", Version = parameters.Version }
},
Files = new []
{
new NuSpecContent { Source = "Avalonia.iOS.dll", Target = "lib/Xamarin.iOS10" }
},
BasePath = context.Directory("./src/iOS/Avalonia.iOS/bin/" + parameters.DirSuffixIOS),
OutputDirectory = parameters.NugetRoot
},
///////////////////////////////////////////////////////////////////////////////
// Avalonia.Skia.iOS
///////////////////////////////////////////////////////////////////////////////
new NuGetPackSettings()
{
Id = "Avalonia.Skia.iOS",
Dependencies = new []
{
new NuSpecDependency() { Id = "Avalonia", Version = parameters.Version },
new NuSpecDependency() { Id = "SkiaSharp", Version = SkiaSharpVersion }
},
Files = new []
{
new NuSpecContent { Source = "Avalonia.Skia.iOS.dll", Target = "lib/Xamarin.iOS10" }
},
BasePath = context.Directory("./src/Skia/Avalonia.Skia.iOS/bin/" + parameters.DirSuffixIOS),
OutputDirectory = parameters.NugetRoot
},
///////////////////////////////////////////////////////////////////////////////
// Avalonia.Mobile
///////////////////////////////////////////////////////////////////////////////
new NuGetPackSettings()
{
Id = "Avalonia.Mobile",
Dependencies = new []
{
new NuSpecDependency() { Id = "Avalonia.Android", Version = parameters.Version },
new NuSpecDependency() { Id = "Avalonia.iOS", Version = parameters.Version }
},
Files = new NuSpecContent[]
{
new NuSpecContent { Source = "licence.md", Target = "" }
},
BasePath = context.Directory("./"),
OutputDirectory = parameters.NugetRoot
}
};
var nuspecNuGetSettingsDesktop = new []
{
///////////////////////////////////////////////////////////////////////////////
// Avalonia.Win32
///////////////////////////////////////////////////////////////////////////////
new NuGetPackSettings()
{
Id = "Avalonia.Win32",
Dependencies = new []
{
new NuSpecDependency() { Id = "Avalonia", Version = parameters.Version }
},
Files = new []
{
new NuSpecContent { Source = "Avalonia.Win32/bin/" + parameters.DirSuffix + "/Avalonia.Win32.dll", Target = "lib/net45" },
new NuSpecContent { Source = "Avalonia.Win32.NetStandard/bin/" + parameters.DirSuffix + "/Avalonia.Win32.dll", Target = "lib/netstandard1.1" }
},
BasePath = context.Directory("./src/Windows"),
OutputDirectory = parameters.NugetRoot
},
///////////////////////////////////////////////////////////////////////////////
// Avalonia.Direct2D1
///////////////////////////////////////////////////////////////////////////////
new NuGetPackSettings()
{
Id = "Avalonia.Direct2D1",
Dependencies = new []
{
new NuSpecDependency() { Id = "Avalonia", Version = parameters.Version },
new NuSpecDependency() { Id = "SharpDX", Version = SharpDXVersion },
new NuSpecDependency() { Id = "SharpDX.Direct2D1", Version = SharpDXDirect2D1Version },
new NuSpecDependency() { Id = "SharpDX.Direct3D11", Version = SharpDXDirect3D11Version },
new NuSpecDependency() { Id = "SharpDX.DXGI", Version = SharpDXDXGIVersion }
},
Files = new []
{
new NuSpecContent { Source = "Avalonia.Direct2D1.dll", Target = "lib/net45" }
},
BasePath = context.Directory("./src/Windows/Avalonia.Direct2D1/bin/" + parameters.DirSuffix),
OutputDirectory = parameters.NugetRoot
},
///////////////////////////////////////////////////////////////////////////////
// Avalonia.Gtk
///////////////////////////////////////////////////////////////////////////////
new NuGetPackSettings()
{
Id = "Avalonia.Gtk",
Dependencies = new []
{
new NuSpecDependency() { Id = "Avalonia", Version = parameters.Version }
},
Files = new []
{
new NuSpecContent { Source = "Avalonia.Gtk.dll", Target = "lib/net45" }
},
BasePath = context.Directory("./src/Gtk/Avalonia.Gtk/bin/" + parameters.DirSuffix),
OutputDirectory = parameters.NugetRoot
},
///////////////////////////////////////////////////////////////////////////////
// Avalonia.Gtk3
///////////////////////////////////////////////////////////////////////////////
new NuGetPackSettings()
{
Id = "Avalonia.Gtk3",
Dependencies = new []
{
new NuSpecDependency() { Id = "Avalonia", Version = parameters.Version }
},
Files = new []
{
new NuSpecContent { Source = "Avalonia.Gtk3.dll", Target = "lib/netstandard1.1" }
},
BasePath = context.Directory("./src/Gtk/Avalonia.Gtk3/bin/" + parameters.DirSuffix),
OutputDirectory = parameters.NugetRoot
},
///////////////////////////////////////////////////////////////////////////////
// Avalonia.Cairo
///////////////////////////////////////////////////////////////////////////////
new NuGetPackSettings()
{
Id = "Avalonia.Cairo",
Dependencies = new []
{
new NuSpecDependency() { Id = "Avalonia", Version = parameters.Version }
},
Files = new []
{
new NuSpecContent { Source = "Avalonia.Cairo.dll", Target = "lib/net45" }
},
BasePath = context.Directory("./src/Gtk/Avalonia.Cairo/bin/" + parameters.DirSuffix),
OutputDirectory = parameters.NugetRoot
},
///////////////////////////////////////////////////////////////////////////////
// Avalonia.Skia.Desktop
///////////////////////////////////////////////////////////////////////////////
new NuGetPackSettings()
{
Id = "Avalonia.Skia.Desktop",
Dependencies = new []
{
new NuSpecDependency() { Id = "Avalonia", Version = parameters.Version },
new NuSpecDependency() { Id = "SkiaSharp", Version = SkiaSharpVersion },
//.NET Core
new NuSpecDependency() { Id = "Avalonia", TargetFramework = "netcoreapp1.0", Version = parameters.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 []
{
new NuSpecContent { Source = "Avalonia.Skia.Desktop/bin/" + parameters.DirSuffixSkia + "/Avalonia.Skia.Desktop.dll", Target = "lib/net45" },
new NuSpecContent { Source = "Avalonia.Skia.Desktop.NetStandard/bin/" + parameters.DirSuffix + "/Avalonia.Skia.Desktop.dll", Target = "lib/netcoreapp1.0" }
},
BasePath = context.Directory("./src/Skia/"),
OutputDirectory = parameters.NugetRoot
},
///////////////////////////////////////////////////////////////////////////////
// Avalonia.Desktop
///////////////////////////////////////////////////////////////////////////////
new NuGetPackSettings()
{
Id = "Avalonia.Desktop",
Dependencies = new []
{
new NuSpecDependency() { Id = "Avalonia.Win32", Version = parameters.Version },
new NuSpecDependency() { Id = "Avalonia.Direct2D1", Version = parameters.Version },
new NuSpecDependency() { Id = "Avalonia.Gtk", Version = parameters.Version },
new NuSpecDependency() { Id = "Avalonia.Cairo", Version = parameters.Version },
new NuSpecDependency() { Id = "Avalonia.Skia.Desktop", Version = parameters.Version }
},
Files = new NuSpecContent[]
{
new NuSpecContent { Source = "licence.md", Target = "" }
},
BasePath = context.Directory("./"),
OutputDirectory = parameters.NugetRoot
}
};
NuspecNuGetSettings = new List<NuGetPackSettings>();
NuspecNuGetSettings.AddRange(nuspecNuGetSettingsCore);
NuspecNuGetSettings.AddRange(nuspecNuGetSettingsDesktop);
NuspecNuGetSettings.AddRange(nuspecNuGetSettingsMobile);
NuspecNuGetSettings.ForEach((nuspec) => SetNuGetNuspecCommonProperties(nuspec));
NugetPackages = NuspecNuGetSettings.Select(nuspec => {
return nuspec.OutputDirectory.CombineWithFilePath(string.Concat(nuspec.Id, ".", nuspec.Version, ".nupkg"));
}).ToArray();
BinFiles = NuspecNuGetSettings.SelectMany(nuspec => {
return nuspec.Files.Select(file => {
return ((DirectoryPath)nuspec.BasePath).CombineWithFilePath(file.Source);
});
}).GroupBy(f => f.FullPath).Select(g => g.First()).ToArray();
}
}

143
parameters.cake

@ -0,0 +1,143 @@
public class Parameters
{
public string Target { get; private set; }
public string Platform { get; private set; }
public string Configuration { get; private set; }
public bool SkipTests { get; private set; }
public string MainRepo { get; private set; }
public string MasterBranch { get; private set; }
public string AssemblyInfoPath { get; private set; }
public string ReleasePlatform { get; private set; }
public string ReleaseConfiguration { get; private set; }
public string MSBuildSolution { get; private set; }
public string XBuildSolution { get; private set; }
public bool IsPlatformAnyCPU { get; private set; }
public bool IsPlatformX86 { get; private set; }
public bool IsPlatformX64 { get; private set; }
public bool IsLocalBuild { get; private set; }
public bool IsRunningOnUnix { get; private set; }
public bool IsRunningOnWindows { get; private set; }
public bool IsRunningOnAppVeyor { get; private set; }
public bool IsPullRequest { get; private set; }
public bool IsMainRepo { get; private set; }
public bool IsMasterBranch { get; private set; }
public bool IsTagged { get; private set; }
public bool IsReleasable { get; private set; }
public bool IsMyGetRelease { get; private set; }
public bool IsNuGetRelease { get; private set; }
public string Version { get; private set; }
public DirectoryPath ArtifactsDir { get; private set; }
public DirectoryPath NugetRoot { get; private set; }
public DirectoryPath ZipRoot { get; private set; }
public DirectoryPath BinRoot { get; private set; }
public DirectoryPath TestsRoot { get; private set; }
public string DirSuffix { get; private set; }
public string DirSuffixSkia { get; private set; }
public string DirSuffixIOS { get; private set; }
public DirectoryPathCollection BuildDirs { get; private set; }
public string FileZipSuffix { get; private set; }
public FilePath ZipCoreArtifacts { get; private set; }
public DirectoryPath ZipSourceControlCatalogDesktopDirs { get; private set; }
public FilePath ZipTargetControlCatalogDesktopDirs { get; private set; }
public Parameters(ICakeContext context)
{
var buildSystem = context.BuildSystem();
// ARGUMENTS
Target = context.Argument("target", "Default");
Platform = context.Argument("platform", "Any CPU");
Configuration = context.Argument("configuration", "Release");
SkipTests = context.HasArgument("skip-tests");
// CONFIGURATION
MainRepo = "AvaloniaUI/Avalonia";
MasterBranch = "master";
AssemblyInfoPath = context.File("./src/Shared/SharedAssemblyInfo.cs");
ReleasePlatform = "Any CPU";
ReleaseConfiguration = "Release";
MSBuildSolution = "./Avalonia.sln";
XBuildSolution = "./Avalonia.XBuild.sln";
// PARAMETERS
IsPlatformAnyCPU = StringComparer.OrdinalIgnoreCase.Equals(Platform, "Any CPU");
IsPlatformX86 = StringComparer.OrdinalIgnoreCase.Equals(Platform, "x86");
IsPlatformX64 = StringComparer.OrdinalIgnoreCase.Equals(Platform, "x64");
IsLocalBuild = buildSystem.IsLocalBuild;
IsRunningOnUnix = context.IsRunningOnUnix();
IsRunningOnWindows = context.IsRunningOnWindows();
IsRunningOnAppVeyor = buildSystem.AppVeyor.IsRunningOnAppVeyor;
IsPullRequest = buildSystem.AppVeyor.Environment.PullRequest.IsPullRequest;
IsMainRepo = StringComparer.OrdinalIgnoreCase.Equals(MainRepo, buildSystem.AppVeyor.Environment.Repository.Name);
IsMasterBranch = StringComparer.OrdinalIgnoreCase.Equals(MasterBranch, buildSystem.AppVeyor.Environment.Repository.Branch);
IsTagged = buildSystem.AppVeyor.Environment.Repository.Tag.IsTag
&& !string.IsNullOrWhiteSpace(buildSystem.AppVeyor.Environment.Repository.Tag.Name);
IsReleasable = StringComparer.OrdinalIgnoreCase.Equals(ReleasePlatform, Platform)
&& StringComparer.OrdinalIgnoreCase.Equals(ReleaseConfiguration, Configuration);
IsMyGetRelease = !IsTagged && IsReleasable;
IsNuGetRelease = IsTagged && IsReleasable;
// VERSION
Version = context.Argument("force-nuget-version", context.ParseAssemblyInfo(AssemblyInfoPath).AssemblyVersion);
if (IsRunningOnAppVeyor)
{
if (IsTagged)
{
// Use Tag Name as version
Version = buildSystem.AppVeyor.Environment.Repository.Tag.Name;
}
else
{
// Use AssemblyVersion with Build as version
Version += "-build" + context.EnvironmentVariable("APPVEYOR_BUILD_NUMBER") + "-alpha";
}
}
// DIRECTORIES
ArtifactsDir = (DirectoryPath)context.Directory("./artifacts");
NugetRoot = ArtifactsDir.Combine("nuget");
ZipRoot = ArtifactsDir.Combine("zip");
BinRoot = ArtifactsDir.Combine("bin");
TestsRoot = ArtifactsDir.Combine("tests");
DirSuffix = Configuration;
DirSuffixSkia = (IsPlatformAnyCPU ? "x86" : Platform) + "/" + Configuration;
DirSuffixIOS = "iPhone" + "/" + Configuration;
BuildDirs =
context.GetDirectories("./src/**/bin/" + DirSuffix) +
context.GetDirectories("./src/**/obj/" + DirSuffix) +
context.GetDirectories("./src/Markup/**/bin/" + DirSuffix) +
context.GetDirectories("./src/Markup/**/obj/" + DirSuffix) +
context.GetDirectories("./src/Android/**/bin/" + DirSuffix) +
context.GetDirectories("./src/Android/**/obj/" + DirSuffix) +
context.GetDirectories("./src/Gtk/**/bin/" + DirSuffix) +
context.GetDirectories("./src/Gtk/**/obj/" + DirSuffix) +
context.GetDirectories("./src/iOS/**/bin/" + DirSuffixIOS) +
context.GetDirectories("./src/iOS/**/obj/" + DirSuffixIOS) +
(DirectoryPath)context.Directory("./src/Skia/Avalonia.Skia.Android/bin/" + DirSuffix) +
(DirectoryPath)context.Directory("./src/Skia/Avalonia.Skia.Android/obj/" + DirSuffix) +
(DirectoryPath)context.Directory("./src/Skia/Avalonia.Skia.Android.TestApp/bin/" + DirSuffix) +
(DirectoryPath)context.Directory("./src/Skia/Avalonia.Skia.Android.TestApp/obj/" + DirSuffix) +
(DirectoryPath)context.Directory("./src/Skia/Avalonia.Skia.Desktop/bin/" + DirSuffixSkia) +
(DirectoryPath)context.Directory("./src/Skia/Avalonia.Skia.Desktop/obj/" + DirSuffixSkia) +
(DirectoryPath)context.Directory("./src/Skia/Avalonia.Skia.Desktop.NetStandard/bin/" + DirSuffix) +
(DirectoryPath)context.Directory("./src/Skia/Avalonia.Skia.Desktop.NetStandard/obj/" + DirSuffix) +
(DirectoryPath)context.Directory("./src/Skia/Avalonia.Skia.iOS/bin/" + DirSuffixIOS) +
(DirectoryPath)context.Directory("./src/Skia/Avalonia.Skia.iOS/obj/" + DirSuffixIOS) +
(DirectoryPath)context.Directory("./src/Skia/Avalonia.Skia.iOS.TestApp/bin/" + DirSuffixIOS) +
(DirectoryPath)context.Directory("./src/Skia/Avalonia.Skia.iOS.TestApp/obj/" + DirSuffixIOS) +
context.GetDirectories("./src/Windows/**/bin/" + DirSuffix) +
context.GetDirectories("./src/Windows/**/obj/" + DirSuffix) +
context.GetDirectories("./tests/**/bin/" + DirSuffix) +
context.GetDirectories("./tests/**/obj/" + DirSuffix) +
context.GetDirectories("./Samples/**/bin/" + DirSuffix) +
context.GetDirectories("./Samples/**/obj/" + DirSuffix);
FileZipSuffix = Version + ".zip";
ZipCoreArtifacts = ZipRoot.CombineWithFilePath("Avalonia-" + FileZipSuffix);
ZipSourceControlCatalogDesktopDirs = (DirectoryPath)context.Directory("./samples/ControlCatalog.Desktop/bin/" + DirSuffix);
ZipTargetControlCatalogDesktopDirs = ZipRoot.CombineWithFilePath("ControlCatalog.Desktop-" + FileZipSuffix);
}
}

11
samples/ControlCatalog.Android/ControlCatalog.Android.csproj

@ -29,12 +29,15 @@
<WarningLevel>4</WarningLevel>
<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>
<AndroidLinkMode>None</AndroidLinkMode>
<EmbedAssembliesIntoApk>False</EmbedAssembliesIntoApk>
<EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk>
<BundleAssemblies>False</BundleAssemblies>
<AndroidCreatePackagePerAbi>False</AndroidCreatePackagePerAbi>
<AndroidSupportedAbis>armeabi,armeabi-v7a,x86</AndroidSupportedAbis>
<AndroidSupportedAbis>armeabi;armeabi-v7a;x86</AndroidSupportedAbis>
<Debugger>Xamarin</Debugger>
<AndroidEnableMultiDex>False</AndroidEnableMultiDex>
<AotAssemblies>False</AotAssemblies>
<EnableLLVM>False</EnableLLVM>
<EnableProguard>False</EnableProguard>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@ -109,10 +112,6 @@
<Project>{7062ae20-5dcc-4442-9645-8195bdece63e}</Project>
<Name>Avalonia.Diagnostics</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Avalonia.DotNetFrameworkRuntime\Avalonia.DotNetFrameworkRuntime.csproj">
<Project>{4a1abb09-9047-4bd5-a4ad-a055e52c5ee0}</Project>
<Name>Avalonia.DotNetFrameworkRuntime</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Avalonia.HtmlRenderer\Avalonia.HtmlRenderer.csproj">
<Project>{5fb2b005-0a7f-4dad-add4-3ed01444e63d}</Project>
<Name>Avalonia.HtmlRenderer</Name>

24
samples/ControlCatalog.Android/MainActivity.cs

@ -1,9 +1,8 @@
using System;
using Android.App;
using Android.OS;
using Android.Content.PM;
using Avalonia.Android.Platform.Specific;
using Avalonia.Android;
using Avalonia.Controls;
using Avalonia.Controls.Templates;
using Avalonia.Markup.Xaml;
@ -17,29 +16,16 @@ namespace ControlCatalog.Android
[Activity(Label = "ControlCatalog.Android", MainLauncher = true, Icon = "@drawable/icon", LaunchMode = LaunchMode.SingleInstance)]
public class MainActivity : AvaloniaActivity
{
public MainActivity() : base(typeof (App))
{
}
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
App app;
if (Avalonia.Application.Current != null)
app = (App)Avalonia.Application.Current;
else
if (Avalonia.Application.Current == null)
{
app = new App();
AppBuilder.Configure(app)
AppBuilder.Configure(new App())
.UseAndroid()
.UseSkia()
.SetupWithoutStarting();
Content = new MainView();
}
var mainWindow = new MainWindow();
app.Run(mainWindow);
base.OnCreate(savedInstanceState);
}
}
}

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

@ -33,6 +33,9 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<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>
@ -72,6 +75,10 @@
<Project>{FB05AC90-89BA-4F2F-A924-F37875FB547C}</Project>
<Name>Avalonia.Cairo</Name>
</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">
<Project>{54F237D5-A70A-4752-9656-0C70B1A7B047}</Project>
<Name>Avalonia.Gtk</Name>

11
samples/ControlCatalog.iOS/AppDelegate.cs

@ -2,6 +2,8 @@ using Foundation;
using UIKit;
using Avalonia;
using Avalonia.Controls;
using Avalonia.iOS;
using Avalonia.Media;
namespace ControlCatalog
{
@ -11,6 +13,8 @@ namespace ControlCatalog
[Register("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{
public override UIWindow Window { get; set; }
//
// This method is invoked when the application has loaded and is ready to run. In this
// method you should instantiate the window, load the UI into it and then make the window
@ -22,10 +26,9 @@ namespace ControlCatalog
{
AppBuilder.Configure<App>()
.UseiOS()
.UseSkiaViewHost()
.UseSkia()
.Start<MainWindow>();
.UseSkia().SetupWithoutStarting();
Window = new AvaloniaWindow() {Content = new MainView(), StatusBarColor = Colors.LightSteelBlue};
Window.MakeKeyAndVisible();
return true;
}
}

17
samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj

@ -20,8 +20,21 @@
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<MtouchArch>i386</MtouchArch>
<MtouchLink>None</MtouchLink>
<MtouchDebug>true</MtouchDebug>
<MtouchLink>SdkOnly</MtouchLink>
<MtouchDebug>True</MtouchDebug>
<MtouchSdkVersion>9.1</MtouchSdkVersion>
<MtouchProfiling>False</MtouchProfiling>
<MtouchFastDev>False</MtouchFastDev>
<MtouchNoSymbolStrip>False</MtouchNoSymbolStrip>
<MtouchUseLlvm>False</MtouchUseLlvm>
<MtouchUseThumb>False</MtouchUseThumb>
<MtouchEnableBitcode>False</MtouchEnableBitcode>
<MtouchUseSGen>False</MtouchUseSGen>
<MtouchUseRefCounting>False</MtouchUseRefCounting>
<OptimizePNGs>True</OptimizePNGs>
<MtouchTlsProvider>Default</MtouchTlsProvider>
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
<MtouchFloat32>False</MtouchFloat32>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
<DebugType>none</DebugType>

6
samples/ControlCatalog/Pages/ImagePage.xaml

@ -34,6 +34,10 @@
Width="100" Height="200"
Stretch="UniformToFill"/>
</StackPanel>
</StackPanel>
</StackPanel>
<StackPanel Orientation="Vertical">
<TextBlock>Window Icon as an Image</TextBlock>
<Image Name="Icon" Width="100" Height="200" Stretch="None" />
</StackPanel>
</StackPanel>
</UserControl>

23
samples/ControlCatalog/Pages/ImagePage.xaml.cs

@ -1,10 +1,14 @@
using System.IO;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Media.Imaging;
namespace ControlCatalog.Pages
{
public class ImagePage : UserControl
{
private Image iconImage;
public ImagePage()
{
this.InitializeComponent();
@ -13,6 +17,25 @@ namespace ControlCatalog.Pages
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
iconImage = this.Get<Image>("Icon");
}
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
{
base.OnAttachedToVisualTree(e);
if (iconImage.Source == null)
{
var windowRoot = e.Root as Window;
if (windowRoot != null)
{
using (var stream = new MemoryStream())
{
windowRoot.Icon.Save(stream);
stream.Seek(0, SeekOrigin.Begin);
iconImage.Source = new Bitmap(stream);
}
}
}
}
}
}

27
samples/ControlCatalog/Pages/TreeViewPage.xaml.cs

@ -11,7 +11,7 @@ namespace ControlCatalog.Pages
public TreeViewPage()
{
this.InitializeComponent();
DataContext = CreateNodes(0);
DataContext = new Node().Children;
}
private void InitializeComponent()
@ -19,19 +19,22 @@ namespace ControlCatalog.Pages
AvaloniaXamlLoader.Load(this);
}
private IList<Node> CreateNodes(int level)
public class Node
{
return Enumerable.Range(0, 10).Select(x => new Node
private IList<Node> _children;
public string Header { get; private set; }
public IList<Node> Children
{
Header = $"Item {x}",
Children = level < 5 ? CreateNodes(level + 1) : null,
}).ToList();
}
private class Node
{
public string Header { get; set; }
public IList<Node> Children { get; set; }
get
{
if (_children == null)
{
_children = Enumerable.Range(1, 10).Select(i => new Node() {Header = $"Item {i}"})
.ToArray();
}
return _children;
}
}
}
}
}

47
src/Android/Avalonia.Android/ActivityTracker.cs

@ -0,0 +1,47 @@
using Android.App;
using Android.OS;
namespace Avalonia.Android
{
internal class ActivityTracker : Java.Lang.Object, global::Android.App.Application.IActivityLifecycleCallbacks
{
public static Activity Current { get; private set; }
public void OnActivityCreated(Activity activity, Bundle savedInstanceState)
{
Current = activity;
}
public void OnActivityDestroyed(Activity activity)
{
if (Current == activity)
Current = null;
}
public void OnActivityPaused(Activity activity)
{
if (Current == activity)
Current = null;
}
public void OnActivityResumed(Activity activity)
{
Current = activity;
}
public void OnActivitySaveInstanceState(Activity activity, Bundle outState)
{
Current = activity;
}
public void OnActivityStarted(Activity activity)
{
Current = activity;
}
public void OnActivityStopped(Activity activity)
{
if (Current == activity)
Current = null;
}
}
}

29
src/Android/Avalonia.Android/AndroidPlatform.cs

@ -1,5 +1,8 @@
using System;
using System.IO;
using System.Linq;
using Android.Content;
using Android.Views;
using Avalonia.Android.Platform;
using Avalonia.Android.Platform.Input;
using Avalonia.Android.Platform.SkiaPlatform;
@ -8,6 +11,7 @@ using Avalonia.Controls.Platform;
using Avalonia.Input;
using Avalonia.Input.Platform;
using Avalonia.Platform;
using Avalonia.Rendering;
using Avalonia.Shared.PlatformSupport;
using Avalonia.Skia;
@ -17,7 +21,8 @@ namespace Avalonia
{
public static T UseAndroid<T>(this T builder) where T : AppBuilderBase<T>, new()
{
builder.UseWindowingSubsystem(Android.AndroidPlatform.Initialize, "Android");
builder.UseWindowingSubsystem(() => Android.AndroidPlatform.Initialize(builder.Instance), "Android");
builder.UseSkia();
return builder;
}
}
@ -25,7 +30,7 @@ namespace Avalonia
namespace Avalonia.Android
{
public class AndroidPlatform : IPlatformSettings, IWindowingPlatform
class AndroidPlatform : IPlatformSettings, IWindowingPlatform
{
public static readonly AndroidPlatform Instance = new AndroidPlatform();
public Size DoubleClickSize => new Size(4, 4);
@ -40,7 +45,7 @@ namespace Avalonia.Android
_scalingFactor = global::Android.App.Application.Context.Resources.DisplayMetrics.ScaledDensity;
}
public static void Initialize()
public static void Initialize(Avalonia.Application app)
{
AvaloniaLocator.CurrentMutable
.Bind<IClipboard>().ToTransient<ClipboardImpl>()
@ -51,29 +56,29 @@ namespace Avalonia.Android
.Bind<IPlatformThreadingInterface>().ToConstant(new AndroidThreadingInterface())
.Bind<ISystemDialogImpl>().ToTransient<SystemDialogImpl>()
.Bind<IWindowingPlatform>().ToConstant(Instance)
.Bind<IPlatformIconLoader>().ToSingleton<PlatformIconLoader>();
.Bind<IPlatformIconLoader>().ToSingleton<PlatformIconLoader>()
.Bind<IRenderLoop>().ToConstant(new DefaultRenderLoop(60))
SkiaPlatform.Initialize();
}
.Bind<IAssetLoader>().ToConstant(new AssetLoader(app.GetType().Assembly));
public void Init(Type applicationType)
{
StandardRuntimePlatformServices.Register(applicationType.Assembly);
SkiaPlatform.Initialize();
((global::Android.App.Application) global::Android.App.Application.Context.ApplicationContext)
.RegisterActivityLifecycleCallbacks(new ActivityTracker());
}
public IWindowImpl CreateWindow()
{
return new WindowImpl();
throw new NotSupportedException();
}
public IEmbeddableWindowImpl CreateEmbeddableWindow()
{
throw new NotImplementedException();
throw new NotSupportedException();
}
public IPopupImpl CreatePopup()
{
throw new NotImplementedException();
return new PopupImpl();
}
}
}

12
src/Android/Avalonia.Android/AndroidThreadingInterface.cs

@ -51,10 +51,16 @@ namespace Avalonia.Android
scheduled = true;
EnsureInvokeOnMainThread(() =>
{
tick();
lock (l)
try
{
scheduled = false;
tick();
}
finally
{
lock (l)
{
scheduled = false;
}
}
});
}

26
src/Android/Avalonia.Android/AppBuilder.cs

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Avalonia.Controls;
using Avalonia.Platform;
using Avalonia.Shared.PlatformSupport;
namespace Avalonia
{
public sealed class AppBuilder : AppBuilderBase<AppBuilder>
{
public AppBuilder() : base(new StandardRuntimePlatform(),
builder => StandardRuntimePlatformServices.Register(builder.Instance?.GetType()?.Assembly))
{
}
}
}

12
src/Android/Avalonia.Android/Avalonia.Android.csproj

@ -61,18 +61,22 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ActivityTracker.cs" />
<Compile Include="AndroidPlatform.cs" />
<Compile Include="AndroidThreadingInterface.cs" />
<Compile Include="AppBuilder.cs" />
<Compile Include="AvaloniaActivity.cs" />
<Compile Include="AvaloniaView.cs" />
<Compile Include="PlatformIconLoader.cs" />
<Compile Include="Platform\ClipboardImpl.cs" />
<Compile Include="CursorFactory.cs" />
<Compile Include="Platform\Input\AndroidKeyboardDevice.cs" />
<Compile Include="Platform\Input\AndroidMouseDevice.cs" />
<Compile Include="Platform\SkiaPlatform\MainWindowImpl.cs" />
<Compile Include="Platform\SkiaPlatform\WindowImpl.cs" />
<Compile Include="Platform\SkiaPlatform\AndroidFramebuffer.cs" />
<Compile Include="Platform\SkiaPlatform\InvalidationAwareSurfaceView.cs" />
<Compile Include="Platform\SkiaPlatform\PopupImpl.cs" />
<Compile Include="Platform\SkiaPlatform\TopLevelImpl.cs" />
<Compile Include="Platform\Specific\IAndroidView.cs" />
<Compile Include="Platform\Specific\IAndroidActivity.cs" />
<Compile Include="Platform\Specific\AvaloniaActivity.cs" />
<Compile Include="Platform\Specific\Helpers\AndroidTouchEventsHelper.cs" />
<Compile Include="Platform\Specific\Helpers\AndroidKeyboardEventsHelper.cs" />
<Compile Include="Resources\Resource.Designer.cs" />

51
src/Android/Avalonia.Android/AvaloniaActivity.cs

@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
namespace Avalonia.Android
{
public abstract class AvaloniaActivity : Activity
{
internal AvaloniaView View;
object _content;
protected override void OnCreate(Bundle savedInstanceState)
{
RequestWindowFeature(WindowFeatures.NoTitle);
View = new AvaloniaView(this);
if(_content != null)
View.Content = _content;
SetContentView(View);
TakeKeyEvents(true);
base.OnCreate(savedInstanceState);
}
public object Content
{
get
{
return _content;
}
set
{
_content = value;
if (View != null)
View.Content = value;
}
}
public override bool DispatchKeyEvent(KeyEvent e)
{
return View.DispatchKeyEvent(e);
}
}
}

69
src/Android/Avalonia.Android/AvaloniaView.cs

@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Avalonia.Android.Platform.SkiaPlatform;
using Avalonia.Controls;
using Avalonia.Controls.Embedding;
using Avalonia.Platform;
namespace Avalonia.Android
{
public class AvaloniaView : FrameLayout
{
private readonly EmbeddableControlRoot _root;
private readonly ViewImpl _view;
public AvaloniaView(Context context) : base(context)
{
_view = new ViewImpl(context);
AddView(_view.View);
_root = new EmbeddableControlRoot(_view);
_root.Prepare();
}
public object Content
{
get { return _root.Content; }
set { _root.Content = value; }
}
public override bool DispatchKeyEvent(KeyEvent e)
{
return _view.View.DispatchKeyEvent(e);
}
class ViewImpl : TopLevelImpl, IEmbeddableWindowImpl
{
public event Action LostFocus;
public ViewImpl(Context context) : base(context)
{
View.Focusable = true;
View.FocusChange += ViewImpl_FocusChange;
}
private void ViewImpl_FocusChange(object sender, FocusChangeEventArgs e)
{
if(!e.HasFocus)
LostFocus?.Invoke();
}
protected override void OnResized(Size size)
{
MaxClientSize = size;
base.OnResized(size);
}
public WindowState WindowState { get; set; }
public IDisposable ShowDialog() => null;
}
}
}

105
src/Android/Avalonia.Android/Platform/SkiaPlatform/AndroidFramebuffer.cs

@ -0,0 +1,105 @@
using System;
using System.Runtime.InteropServices;
using Android.Runtime;
using Android.Views;
using Avalonia.Controls.Platform.Surfaces;
namespace Avalonia.Android.Platform.SkiaPlatform
{
class AndroidFramebuffer : ILockedFramebuffer
{
private IntPtr _window;
public AndroidFramebuffer(Surface surface)
{
if(surface == null)
throw new ArgumentNullException(nameof(surface));
_window = ANativeWindow_fromSurface(JNIEnv.Handle, surface.Handle);
if (_window == IntPtr.Zero)
throw new Exception("Unable to obtain ANativeWindow");
ANativeWindow_Buffer buffer;
var rc = new ARect()
{
right = Width = ANativeWindow_getWidth(_window),
bottom = Height = ANativeWindow_getHeight(_window)
};
ANativeWindow_lock(_window, out buffer, ref rc);
Format = buffer.format == AndroidPixelFormat.WINDOW_FORMAT_RGB_565
? PixelFormat.Rgb565 : PixelFormat.Rgba8888;
RowBytes = buffer.stride * (Format == PixelFormat.Rgb565 ? 2 : 4);
Address = buffer.bits;
}
public void Dispose()
{
ANativeWindow_unlockAndPost(_window);
ANativeWindow_release(_window);
_window = IntPtr.Zero;
Address = IntPtr.Zero;
}
public IntPtr Address { get; set; }
public int Width { get; }
public int Height { get; }
public int RowBytes { get; }
public Size Dpi { get; } = new Size(96, 96);
public PixelFormat Format { get; }
[DllImport("android")]
internal static extern IntPtr ANativeWindow_fromSurface(IntPtr jniEnv, IntPtr handle);
[DllImport("android")]
internal static extern int ANativeWindow_getWidth(IntPtr window);
[DllImport("android")]
internal static extern int ANativeWindow_getHeight(IntPtr window);
[DllImport("android")]
internal static extern void ANativeWindow_release(IntPtr window);
[DllImport("android")]
internal static extern void ANativeWindow_unlockAndPost(IntPtr window);
[DllImport("android")]
internal static extern int ANativeWindow_lock(IntPtr window, out ANativeWindow_Buffer outBuffer, ref ARect inOutDirtyBounds);
public enum AndroidPixelFormat
{
WINDOW_FORMAT_RGBA_8888 = 1,
WINDOW_FORMAT_RGBX_8888 = 2,
WINDOW_FORMAT_RGB_565 = 4,
}
internal struct ARect
{
public int left;
public int top;
public int right;
public int bottom;
}
internal struct ANativeWindow_Buffer
{
// The number of pixels that are show horizontally.
public int width;
// The number of pixels that are shown vertically.
public int height;
// The number of *pixels* that a line in the buffer takes in
// memory. This may be >= width.
public int stride;
// The format of the buffer. One of WINDOW_FORMAT_*
public AndroidPixelFormat format;
// The actual bits.
public IntPtr bits;
// Do not touch.
uint reserved1;
uint reserved2;
uint reserved3;
uint reserved4;
uint reserved5;
uint reserved6;
}
}
}

30
src/Skia/Avalonia.Skia.Android/SkiaView.cs → src/Android/Avalonia.Android/Platform/SkiaPlatform/InvalidationAwareSurfaceView.cs

@ -14,18 +14,17 @@ using Android.Widget;
using Avalonia.Media;
using Avalonia.Platform;
namespace Avalonia.Skia.Android
namespace Avalonia.Android
{
public abstract class SkiaView : SurfaceView, ISurfaceHolderCallback, IPlatformHandle
public abstract class InvalidationAwareSurfaceView : SurfaceView, ISurfaceHolderCallback, IPlatformHandle
{
private readonly Activity _context;
bool _invalidateQueued;
readonly object _lock = new object();
private readonly Handler _handler;
public SkiaView(Activity context) : base(context)
public InvalidationAwareSurfaceView(Context context) : base(context)
{
_context = context;
Holder.AddCallback(this);
_handler = new Handler(context.MainLooper);
}
@ -38,13 +37,11 @@ namespace Avalonia.Skia.Android
return;
_handler.Post(() =>
{
lock (_lock)
{
_invalidateQueued = false;
}
if (Holder.Surface?.IsValid != true)
return;
try
{
Draw();
DoDraw();
}
catch (Exception e)
{
@ -67,20 +64,29 @@ namespace Avalonia.Skia.Android
public void SurfaceChanged(ISurfaceHolder holder, Format format, int width, int height)
{
Log.Info("AVALONIA", "Surface Changed");
Draw();
DoDraw();
}
public void SurfaceCreated(ISurfaceHolder holder)
{
Log.Info("AVALONIA", "Surface Created");
Draw();
DoDraw();
}
public void SurfaceDestroyed(ISurfaceHolder holder)
{
Log.Info("AVALONIA", "Surface Destroyed");
}
protected void DoDraw()
{
lock (_lock)
{
_invalidateQueued = false;
}
Draw();
}
protected abstract void Draw();
public string HandleDescriptor => "SurfaceView";
}

44
src/Android/Avalonia.Android/Platform/SkiaPlatform/MainWindowImpl.cs

@ -1,44 +0,0 @@
using Android.Views;
using Avalonia.Android.Platform.Specific;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Platform;
namespace Avalonia.Android.Platform.SkiaPlatform
{
public class MainWindowImpl :
WindowImpl
, IWindowImpl
{
public MainWindowImpl()
{
}
public new WindowState WindowState
{
get { return WindowState.Normal; }
set { }
}
protected override void Init()
{
base.Init();
HandleEvents = true;
_keyboardHelper.ActivateAutoShowKeybord();
}
void ITopLevelImpl.Show()
{
(Parent as ViewGroup)?.RemoveAllViews();
AvaloniaLocator.Current.GetService<IAndroidActivity>().ContentView = this;
//this.Visibility = ViewStates.Visible;
}
void ITopLevelImpl.SetInputRoot(IInputRoot inputRoot)
{
base.SetInputRoot(inputRoot);
_keyboardHelper.UpdateKeyboardState(inputRoot);
}
}
}

91
src/Android/Avalonia.Android/Platform/SkiaPlatform/PopupImpl.cs

@ -0,0 +1,91 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.Graphics;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Avalonia.Platform;
namespace Avalonia.Android.Platform.SkiaPlatform
{
class PopupImpl : TopLevelImpl, IPopupImpl
{
private Point _position;
private bool _isAdded;
public PopupImpl() : base(ActivityTracker.Current, true)
{
}
private Size _clientSize = new Size(1, 1);
public override Size ClientSize
{
get { return base.ClientSize; }
set
{
if(View == null)
return;
_clientSize = value;
UpdateParams();
}
}
public override Point Position
{
get { return _position; }
set
{
_position = value;
PositionChanged?.Invoke(_position);
UpdateParams();
}
}
WindowManagerLayoutParams CreateParams() => new WindowManagerLayoutParams(0,
WindowManagerFlags.NotTouchModal, Format.Translucent)
{
Gravity = GravityFlags.Left | GravityFlags.Top,
WindowAnimations = 0,
X = (int) _position.X,
Y = (int) _position.Y,
Width = Math.Max(1, (int) _clientSize.Width),
Height = Math.Max(1, (int) _clientSize.Height)
};
void UpdateParams()
{
if (_isAdded)
ActivityTracker.Current?.WindowManager?.UpdateViewLayout(View, CreateParams());
}
public override void Show()
{
if (_isAdded)
return;
ActivityTracker.Current.WindowManager.AddView(View, CreateParams());
_isAdded = true;
}
public override void Hide()
{
if (_isAdded)
{
var wm = View.Context.ApplicationContext.GetSystemService(Context.WindowService)
.JavaCast<IWindowManager>();
wm.RemoveView(View);
_isAdded = false;
}
}
public override void Dispose()
{
Hide();
base.Dispose();
}
}
}

225
src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs

@ -0,0 +1,225 @@
using Android.App;
using Android.Content;
using Android.Graphics;
using Android.Views;
using Avalonia.Android.Platform.Specific;
using Avalonia.Android.Platform.Specific.Helpers;
using Avalonia.Input;
using Avalonia.Input.Raw;
using Avalonia.Platform;
using System;
using System.Collections.Generic;
using System.Reactive.Disposables;
using Avalonia.Controls;
using Avalonia.Controls.Platform.Surfaces;
namespace Avalonia.Android.Platform.SkiaPlatform
{
class TopLevelImpl : IAndroidView, ITopLevelImpl, IFramebufferPlatformSurface
{
private readonly AndroidKeyboardEventsHelper<TopLevelImpl> _keyboardHelper;
private readonly AndroidTouchEventsHelper<TopLevelImpl> _touchHelper;
private ViewImpl _view;
public TopLevelImpl(Context context, bool placeOnTop = false)
{
_view = new ViewImpl(context, this, placeOnTop);
_keyboardHelper = new AndroidKeyboardEventsHelper<TopLevelImpl>(this);
_touchHelper = new AndroidTouchEventsHelper<TopLevelImpl>(this, () => InputRoot,
p => GetAvaloniaPointFromEvent(p));
MaxClientSize = new Size(_view.Resources.DisplayMetrics.WidthPixels,
_view.Resources.DisplayMetrics.HeightPixels);
}
private bool _handleEvents;
public bool HandleEvents
{
get { return _handleEvents; }
set
{
_handleEvents = value;
_keyboardHelper.HandleEvents = _handleEvents;
}
}
public virtual Point GetAvaloniaPointFromEvent(MotionEvent e) => new Point(e.GetX(), e.GetY());
public IInputRoot InputRoot { get; private set; }
public virtual Size ClientSize
{
get
{
if (_view == null)
return new Size(0, 0);
return new Size(_view.Width, _view.Height);
}
set
{
}
}
public Action Closed { get; set; }
public Action Deactivated { get; set; }
public Action<RawInputEventArgs> Input { get; set; }
public Size MaxClientSize { get; protected set; }
public Action<Rect> Paint { get; set; }
public Action<Size> Resized { get; set; }
public Action<double> ScalingChanged { get; set; }
public Action<Point> PositionChanged { get; set; }
public View View => _view;
Action ITopLevelImpl.Activated { get; set; }
IPlatformHandle ITopLevelImpl.Handle => _view;
public IEnumerable<object> Surfaces => new object[] {this};
public void Activate()
{
}
public virtual void Hide()
{
_view.Visibility = ViewStates.Invisible;
}
public void SetSystemDecorations(bool enabled)
{
}
public void Invalidate(Rect rect)
{
if (_view.Holder?.Surface?.IsValid == true) _view.Invalidate();
}
public Point PointToClient(Point point)
{
return point;
}
public Point PointToScreen(Point point)
{
return point;
}
public void SetCursor(IPlatformHandle cursor)
{
//still not implemented
}
public void SetInputRoot(IInputRoot inputRoot)
{
InputRoot = inputRoot;
}
public void SetTitle(string title)
{
}
public virtual void Show()
{
_view.Visibility = ViewStates.Visible;
}
public void BeginMoveDrag()
{
//Not supported
}
public void BeginResizeDrag(WindowEdge edge)
{
//Not supported
}
public virtual Point Position { get; set; }
public double Scaling => 1;
void Draw()
{
Paint?.Invoke(new Rect(new Point(0, 0), ClientSize));
}
public void SetIcon(IWindowIconImpl icon)
{
// No window icons for mobile platforms
}
public virtual void Dispose()
{
_view.Dispose();
_view = null;
}
protected virtual void OnResized(Size size)
{
Resized?.Invoke(size);
}
class ViewImpl : InvalidationAwareSurfaceView, ISurfaceHolderCallback
{
private readonly TopLevelImpl _tl;
private Size _oldSize;
public ViewImpl(Context context, TopLevelImpl tl, bool placeOnTop) : base(context)
{
_tl = tl;
if (placeOnTop)
SetZOrderOnTop(true);
}
protected override void Draw()
{
_tl.Draw();
}
public override bool DispatchTouchEvent(MotionEvent e)
{
bool callBase;
bool? result = _tl._touchHelper.DispatchTouchEvent(e, out callBase);
bool baseResult = callBase ? base.DispatchTouchEvent(e) : false;
return result != null ? result.Value : baseResult;
}
public override bool DispatchKeyEvent(KeyEvent e)
{
bool callBase;
bool? res = _tl._keyboardHelper.DispatchKeyEvent(e, out callBase);
bool baseResult = callBase ? base.DispatchKeyEvent(e) : false;
return res != null ? res.Value : baseResult;
}
void ISurfaceHolderCallback.SurfaceChanged(ISurfaceHolder holder, Format format, int width, int height)
{
var newSize = new Size(width, height);
if (newSize != _oldSize)
{
_oldSize = newSize;
_tl.OnResized(newSize);
}
base.SurfaceChanged(holder, format, width, height);
}
}
ILockedFramebuffer IFramebufferPlatformSurface.Lock()=>new AndroidFramebuffer(_view.Holder.Surface);
}
}

197
src/Android/Avalonia.Android/Platform/SkiaPlatform/WindowImpl.cs

@ -1,197 +0,0 @@
using Android.App;
using Android.Content;
using Android.Graphics;
using Android.Views;
using Avalonia.Android.Platform.Specific;
using Avalonia.Android.Platform.Specific.Helpers;
using Avalonia.Input;
using Avalonia.Input.Raw;
using Avalonia.Platform;
using Avalonia.Skia.Android;
using System;
using Avalonia.Controls;
namespace Avalonia.Android.Platform.SkiaPlatform
{
public class WindowImpl : SkiaView, IAndroidView, IWindowImpl, ISurfaceHolderCallback
{
protected AndroidKeyboardEventsHelper<WindowImpl> _keyboardHelper;
private AndroidTouchEventsHelper<WindowImpl> _touchHelper;
public WindowImpl(Context context) : base((Activity)context)
{
_keyboardHelper = new AndroidKeyboardEventsHelper<WindowImpl>(this);
_touchHelper = new AndroidTouchEventsHelper<WindowImpl>(this, () => InputRoot, p => GetAvaloniaPointFromEvent(p));
MaxClientSize = new Size(Resources.DisplayMetrics.WidthPixels, Resources.DisplayMetrics.HeightPixels);
ClientSize = MaxClientSize;
Init();
}
public WindowImpl() : this(AvaloniaLocator.Current.GetService<IAndroidActivity>().Activity)
{
}
void ISurfaceHolderCallback.SurfaceChanged(ISurfaceHolder holder, Format format, int width, int height)
{
var newSize = new Size(width, height);
if (newSize != ClientSize)
{
MaxClientSize = newSize;
ClientSize = newSize;
Resized?.Invoke(ClientSize);
}
base.SurfaceChanged(holder, format, width, height);
}
protected virtual void Init()
{
}
private bool _handleEvents;
public bool HandleEvents
{
get { return _handleEvents; }
set
{
_handleEvents = value;
_keyboardHelper.HandleEvents = _handleEvents;
}
}
public WindowState WindowState
{
get { return WindowState.Normal; }
set { }
}
public virtual Point GetAvaloniaPointFromEvent(MotionEvent e) => new Point(e.GetX(), e.GetY());
public IInputRoot InputRoot { get; private set; }
public Size ClientSize { get; set; }
public Action Closed { get; set; }
public Action Deactivated { get; set; }
public Action<RawInputEventArgs> Input { get; set; }
public Size MaxClientSize { get; private set; }
public Action<Rect> Paint { get; set; }
public Action<Size> Resized { get; set; }
public Action<double> ScalingChanged { get; set; }
public Action<Point> PositionChanged { get; set; }
public View View => this;
Action ITopLevelImpl.Activated { get; set; }
IPlatformHandle ITopLevelImpl.Handle => this;
public void Activate()
{
}
public void Hide()
{
this.Visibility = ViewStates.Invisible;
}
public void SetSystemDecorations(bool enabled)
{
}
public void SetCoverTaskbarWhenMaximized(bool enable)
{
//Not supported
}
public void Invalidate(Rect rect)
{
if (Holder?.Surface?.IsValid == true) base.Invalidate();
}
public Point PointToClient(Point point)
{
return point;
}
public Point PointToScreen(Point point)
{
return point;
}
public void SetCursor(IPlatformHandle cursor)
{
//still not implemented
}
public void SetInputRoot(IInputRoot inputRoot)
{
InputRoot = inputRoot;
}
public void SetTitle(string title)
{
}
public void Show()
{
this.Visibility = ViewStates.Visible;
}
public void BeginMoveDrag()
{
//Not supported
}
public void BeginResizeDrag(WindowEdge edge)
{
//Not supported
}
public Point Position { get; set; }
public double Scaling => 1;
public IDisposable ShowDialog()
{
throw new NotImplementedException();
}
public override bool DispatchTouchEvent(MotionEvent e)
{
bool callBase;
bool? result = _touchHelper.DispatchTouchEvent(e, out callBase);
bool baseResult = callBase ? base.DispatchTouchEvent(e) : false;
return result != null ? result.Value : baseResult;
}
public override bool DispatchKeyEvent(KeyEvent e)
{
bool callBase;
bool? res = _keyboardHelper.DispatchKeyEvent(e, out callBase);
bool baseResult = callBase ? base.DispatchKeyEvent(e) : false;
return res != null ? res.Value : baseResult;
}
protected override void Draw()
{
Paint?.Invoke(new Rect(new Point(0, 0), ClientSize));
}
public void SetIcon(IWindowIconImpl icon)
{
// No window icons for mobile platforms
}
}
}

60
src/Android/Avalonia.Android/Platform/Specific/AvaloniaActivity.cs

@ -1,60 +0,0 @@
using System;
using Android.App;
using Android.OS;
using Android.Views;
using Android.Widget;
namespace Avalonia.Android.Platform.Specific
{
public class AvaloniaActivity : Activity, IAndroidActivity
{
private IAndroidView _contentView;
public AvaloniaActivity(Type applicationType)
{
AndroidPlatform.Instance.Init(applicationType);
}
public Activity Activity => this;
public IAndroidView ContentView
{
get
{
return this._contentView;
}
set
{
this._contentView = value;
var fl = new FrameLayout(this);
fl.AddView(this._contentView.View);
//this.SetContentView(value.View);
this.SetContentView(fl);
}
}
protected override void OnCreate(Bundle savedInstanceState)
{
AvaloniaLocator.CurrentMutable.Bind<IAndroidActivity>().ToConstant(this);
RequestWindowFeature(WindowFeatures.NoTitle);
base.OnCreate(savedInstanceState);
}
public override void SetContentView(View view)
{
base.SetContentView(view);
TakeKeyEvents(true);
}
public override bool DispatchKeyEvent(KeyEvent e)
{
if (_contentView != null)
{
_contentView.View.DispatchKeyEvent(e);
}
return base.DispatchKeyEvent(e);
}
}
}

6
src/Android/Avalonia.Android/Platform/Specific/Helpers/AndroidKeyboardEventsHelper.cs

@ -12,7 +12,7 @@ using System.ComponentModel;
namespace Avalonia.Android.Platform.Specific.Helpers
{
public class AndroidKeyboardEventsHelper<TView> : IDisposable where TView : View, IWindowImpl, IAndroidView
public class AndroidKeyboardEventsHelper<TView> : IDisposable where TView :ITopLevelImpl, IAndroidView
{
private TView _view;
private IInputElement _lastFocusedElement;
@ -90,7 +90,7 @@ namespace Avalonia.Android.Platform.Specific.Helpers
private void TryShowHideKeyboard(IInputElement element, bool value)
{
var input = _view.Context.GetSystemService(Context.InputMethodService).JavaCast<InputMethodManager>();
var input = _view.View.Context.GetSystemService(Context.InputMethodService).JavaCast<InputMethodManager>();
if (value)
{
@ -102,7 +102,7 @@ namespace Avalonia.Android.Platform.Specific.Helpers
else
{
//hide keyboard
input.HideSoftInputFromWindow(_view.WindowToken, HideSoftInputFlags.None);
input.HideSoftInputFromWindow(_view.View.WindowToken, HideSoftInputFlags.None);
}
}

10
src/Android/Avalonia.Android/Platform/Specific/Helpers/AndroidTouchEventsHelper.cs

@ -8,7 +8,7 @@ using System;
namespace Avalonia.Android.Platform.Specific.Helpers
{
public class AndroidTouchEventsHelper<TView> : IDisposable where TView : View, IWindowImpl, IAndroidView
public class AndroidTouchEventsHelper<TView> : IDisposable where TView : ITopLevelImpl, IAndroidView
{
private TView _view;
public bool HandleEvents { get; set; }
@ -63,10 +63,10 @@ namespace Avalonia.Android.Platform.Specific.Helpers
//if point is in view otherwise it's possible avalonia not to find the proper window to dispatch the event
_point = _getPointFunc(e);
double x = _view.GetX();
double y = _view.GetY();
double r = x + _view.Width;
double b = y + _view.Height;
double x = _view.View.GetX();
double y = _view.View.GetY();
double r = x + _view.View.Width;
double b = y + _view.View.Height;
if (x <= _point.X && r >= _point.X && y <= _point.Y && b >= _point.Y)
{

12
src/Android/Avalonia.Android/Platform/Specific/IAndroidActivity.cs

@ -1,12 +0,0 @@
using Android.App;
using Android.Views;
namespace Avalonia.Android.Platform.Specific
{
public interface IAndroidActivity
{
Activity Activity { get; }
IAndroidView ContentView { get; set; }
}
}

6
src/Android/Avalonia.Android/PlatformIconLoader.cs

@ -49,11 +49,9 @@ namespace Avalonia.Android
stream.CopyTo(this.stream);
}
public Stream Save()
public void Save(Stream outputStream)
{
var returnStream = new MemoryStream();
stream.CopyTo(returnStream);
return returnStream;
stream.CopyTo(outputStream);
}
}
}

21
src/Android/Avalonia.AndroidTestApplication/Avalonia.AndroidTestApplication.csproj

@ -20,7 +20,7 @@
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugSymbols>True</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
@ -29,16 +29,16 @@
<WarningLevel>4</WarningLevel>
<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>
<AndroidLinkMode>None</AndroidLinkMode>
<AndroidLinkSkip />
<EmbedAssembliesIntoApk>False</EmbedAssembliesIntoApk>
<EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk>
<BundleAssemblies>False</BundleAssemblies>
<AndroidCreatePackagePerAbi>False</AndroidCreatePackagePerAbi>
<AndroidSupportedAbis>armeabi,armeabi-v7a,x86</AndroidSupportedAbis>
<AndroidStoreUncompressedFileExtensions />
<MandroidI18n />
<AndroidSupportedAbis>armeabi;armeabi-v7a;x86</AndroidSupportedAbis>
<Debugger>Xamarin</Debugger>
<AndroidEnableMultiDex>False</AndroidEnableMultiDex>
<DevInstrumentationEnabled>True</DevInstrumentationEnabled>
<AotAssemblies>False</AotAssemblies>
<EnableLLVM>False</EnableLLVM>
<EnableProguard>False</EnableProguard>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@ -72,9 +72,8 @@
<HintPath>..\..\..\packages\Splat.1.6.2\lib\monoandroid\Splat.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Sprache, Version=2.0.0.51, 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>
<Private>True</Private>
<Reference Include="Sprache, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Sprache.2.1.0\lib\netstandard1.0\Sprache.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
@ -172,10 +171,6 @@
<Project>{3e10a5fa-e8da-48b1-ad44-6a5b6cb7750f}</Project>
<Name>Avalonia.Themes.Default</Name>
</ProjectReference>
<ProjectReference Include="..\..\Avalonia.DotNetFrameworkRuntime\Avalonia.DotNetFrameworkRuntime.csproj">
<Project>{4a1abb09-9047-4bd5-a4ad-a055e52c5ee0}</Project>
<Name>Avalonia.DotNetFrameworkRuntime</Name>
</ProjectReference>
<ProjectReference Include="..\..\Avalonia.HtmlRenderer\Avalonia.HtmlRenderer.csproj">
<Project>{5fb2b005-0a7f-4dad-add4-3ed01444e63d}</Project>
<Name>Avalonia.HtmlRenderer</Name>

32
src/Android/Avalonia.AndroidTestApplication/MainActivity.cs

@ -2,7 +2,7 @@ using System;
using Android.App;
using Android.Content.PM;
using Android.OS;
using Avalonia.Android.Platform.Specific;
using Avalonia.Android;
using Avalonia.Controls;
using Avalonia.Controls.Templates;
using Avalonia.Markup.Xaml;
@ -17,36 +17,24 @@ namespace Avalonia.AndroidTestApplication
Icon = "@drawable/icon",
LaunchMode = LaunchMode.SingleInstance/*,
ScreenOrientation = ScreenOrientation.Landscape*/)]
public class MainBaseActivity : AvaloniaActivity
public class MainBaseActivity : Activity
{
public MainBaseActivity() : base(typeof (App))
{
}
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
App app;
if (Avalonia.Application.Current != null)
app = (App)Avalonia.Application.Current;
else
if (Avalonia.Application.Current == null)
{
app = new App();
AppBuilder.Configure(app)
AppBuilder.Configure<App>()
.UseAndroid()
.UseSkia()
.SetupWithoutStarting();
}
app.Run();
SetContentView(new AvaloniaView(this) { Content = App.CreateSimpleWindow() });
}
}
public class App : Application
{
public void Run()
public override void Initialize()
{
Styles.Add(new DefaultTheme());
@ -55,18 +43,14 @@ namespace Avalonia.AndroidTestApplication
new Uri("resm:Avalonia.Themes.Default.Accents.BaseLight.xaml?assembly=Avalonia.Themes.Default"));
Styles.Add(baseLight);
var wnd = App.CreateSimpleWindow();
wnd.AttachDevTools();
Run(wnd);
}
// This provides a simple UI tree for testing input handling, drawing, etc
public static Window CreateSimpleWindow()
public static ContentControl CreateSimpleWindow()
{
Window window = new Window
ContentControl window = new ContentControl()
{
Title = "Avalonia Test Application",
Background = Brushes.Red,
Content = new StackPanel
{

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

@ -2,7 +2,7 @@
<packages>
<package id="Serilog" version="1.5.14" targetFramework="monoandroid44" />
<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.Concurrent" version="4.0.12" 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.Runtime" 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.Tasks" version="4.0.11" targetFramework="monoandroid44" />
</packages>

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

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

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

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

4
src/Avalonia.Controls/AppBuilderBase.cs

@ -60,10 +60,10 @@ namespace Avalonia.Controls
/// </summary>
public Action<TAppBuilder> BeforeStartCallback { get; private set; } = builder => { };
protected AppBuilderBase(IRuntimePlatform platform, Action platformSevices)
protected AppBuilderBase(IRuntimePlatform platform, Action<TAppBuilder> platformSevices)
{
RuntimePlatform = platform;
RuntimePlatformServicesInitializer = platformSevices;
RuntimePlatformServicesInitializer = () => platformSevices((TAppBuilder)this);
}
/// <summary>

7
src/Avalonia.Controls/Avalonia.Controls.csproj

@ -18,7 +18,7 @@
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
@ -29,7 +29,7 @@
<DocumentationFile>bin\Debug\Avalonia.Controls.XML</DocumentationFile>
<NoWarn>CS1591</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
@ -57,6 +57,9 @@
<Compile Include="HotkeyManager.cs" />
<Compile Include="IApplicationLifecycle.cs" />
<Compile Include="IScrollable.cs" />
<Compile Include="Platform\Surfaces\IFramebufferPlatformSurface.cs" />
<Compile Include="Platform\Surfaces\ILockedFramebuffer.cs" />
<Compile Include="Platform\Surfaces\PixelFormat.cs" />
<Compile Include="PointEventArgs.cs" />
<Compile Include="Embedding\EmbeddableControlRoot.cs" />
<Compile Include="Platform\IEmbeddableWindowImpl.cs" />

17
src/Avalonia.Controls/Control.cs

@ -671,6 +671,23 @@ namespace Avalonia.Controls
if (Name != null)
{
_nameScope?.Register(Name, this);
var visualParent = Parent as Visual;
if (this is INameScope && visualParent != null)
{
// If we have e.g. a named UserControl in a window then we want that control
// to be findable by name from the Window, so register with both name scopes.
// This differs from WPF's behavior in that XAML manually registers controls
// with name scopes based on the XAML file in which the name attribute appears,
// but we're trying to avoid XAML magic in Avalonia in order to made code-
// created UIs easy. This will cause problems if a UserControl declares a name
// in its XAML and that control is included multiple times in a parent control
// (as the name will be duplicated), however at the moment I'm fine with saying
// "don't do that".
var parentNameScope = NameScope.FindNameScope(visualParent);
parentNameScope?.Register(Name, this);
}
}
}

3
src/Avalonia.Controls/Expander.cs

@ -31,7 +31,8 @@ namespace Avalonia.Controls
AvaloniaProperty.RegisterDirect<Expander, bool>(
nameof(IsExpanded),
o => o.IsExpanded,
(o, v) => o.IsExpanded = v);
(o, v) => o.IsExpanded = v,
defaultBindingMode: Data.BindingMode.TwoWay);
static Expander()
{

5
src/Avalonia.Controls/IVirtualizingPanel.cs

@ -66,6 +66,11 @@ namespace Avalonia.Controls
/// </summary>
double PixelOffset { get; set; }
/// <summary>
/// Gets or sets the current scroll offset in the cross axis.
/// </summary>
double CrossAxisOffset { get; set; }
/// <summary>
/// Invalidates the measure of the control and forces a call to
/// <see cref="IVirtualizingController.UpdateControls"/> on the next measure.

5
src/Avalonia.Controls/Platform/ExportWindowingSubsystemAttribute.cs

@ -9,16 +9,19 @@ namespace Avalonia.Platform
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public class ExportWindowingSubsystemAttribute : Attribute
{
public ExportWindowingSubsystemAttribute(OperatingSystemType requiredRuntimePlatform, int priority, string name, Type initializationType, string initializationMethod)
public ExportWindowingSubsystemAttribute(OperatingSystemType requiredRuntimePlatform, int priority, string name, Type initializationType,
string initializationMethod, Type environmentChecker = null)
{
Name = name;
InitializationType = initializationType;
InitializationMethod = initializationMethod;
EnvironmentChecker = environmentChecker;
RequiredOS = requiredRuntimePlatform;
Priority = priority;
}
public string InitializationMethod { get; private set; }
public Type EnvironmentChecker { get; }
public Type InitializationType { get; private set; }
public string Name { get; private set; }
public int Priority { get; private set; }

13
src/Avalonia.Controls/Platform/ITopLevelImpl.cs

@ -2,6 +2,7 @@
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Collections.Generic;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Input.Raw;
@ -37,6 +38,18 @@ namespace Avalonia.Platform
/// </summary>
IPlatformHandle Handle { get; }
/// <summary>
/// The list of native platform's surfaces that can be consumed by rendering subsystems.
/// </summary>
/// <remarks>
/// Rendering platform will check that list and see if it can utilize one of them to output.
/// It should be enough to expose a native window handle via IPlatformHandle
/// and add support for framebuffer (even if it's emulated one) via IFramebufferPlatformSurface.
/// If you have some rendering platform that's tied to your particular windowing platform,
/// just expose some toolkit-specific object (e. g. Func&lt;Gdk.Drawable&gt; in case of GTK#+Cairo)
/// </remarks>
IEnumerable<object> Surfaces { get; }
/// <summary>
/// Gets or sets a method called when the window is activated (receives focus).
/// </summary>

2
src/Avalonia.Controls/Platform/IWindowIconImpl.cs

@ -7,6 +7,6 @@ namespace Avalonia.Platform
{
public interface IWindowIconImpl
{
Stream Save();
void Save(Stream outputStream);
}
}

5
src/Avalonia.Controls/Platform/IWindowImpl.cs

@ -35,11 +35,6 @@ namespace Avalonia.Platform
/// </summary>
void SetSystemDecorations(bool enabled);
/// <summary>
/// When system decorations are disabled sets if the maximized state covers the entire screen or just the working area.
/// </summary>
void SetCoverTaskbarWhenMaximized(bool enable);
/// <summary>
/// Sets the icon of this window.
/// </summary>

19
src/Avalonia.Controls/Platform/Surfaces/IFramebufferPlatformSurface.cs

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Avalonia.Controls.Platform.Surfaces
{
public interface IFramebufferPlatformSurface
{
/// <summary>
/// Provides a framebuffer descriptor for drawing.
/// </summary>
/// <remarks>
/// Contents should be drawn on actual window after disposing
/// </remarks>
ILockedFramebuffer Lock();
}
}

37
src/Avalonia.Controls/Platform/Surfaces/ILockedFramebuffer.cs

@ -0,0 +1,37 @@
using System;
namespace Avalonia.Controls.Platform.Surfaces
{
public interface ILockedFramebuffer : IDisposable
{
/// <summary>
/// Address of the first pixel
/// </summary>
IntPtr Address { get; }
/// <summary>
/// Framebuffer width
/// </summary>
int Width { get; }
/// <summary>
/// Framebuffer height
/// </summary>
int Height { get; }
/// <summary>
/// Number of bytes per row
/// </summary>
int RowBytes { get; }
/// <summary>
/// DPI of underling screen
/// </summary>
Size Dpi { get; }
/// <summary>
/// Pixel format
/// </summary>
PixelFormat Format { get; }
}
}

15
src/Avalonia.Controls/Platform/Surfaces/PixelFormat.cs

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Avalonia.Controls.Platform.Surfaces
{
public enum PixelFormat
{
Rgb565,
Rgba8888,
Bgra8888
}
}

27
src/Avalonia.Controls/Presenters/ItemVirtualizer.cs

@ -4,6 +4,7 @@
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Reactive.Linq;
using Avalonia.Controls.Primitives;
using Avalonia.Controls.Utils;
using Avalonia.Input;
@ -17,6 +18,7 @@ namespace Avalonia.Controls.Presenters
internal abstract class ItemVirtualizer : IVirtualizingController, IDisposable
{
private double _crossAxisOffset;
private IDisposable _subscriptions;
/// <summary>
/// Initializes a new instance of the <see cref="ItemVirtualizer"/> class.
@ -27,6 +29,15 @@ namespace Avalonia.Controls.Presenters
Owner = owner;
Items = owner.Items;
ItemCount = owner.Items.Count();
var panel = VirtualizingPanel;
if (panel != null)
{
_subscriptions = panel.GetObservable(Panel.BoundsProperty)
.Skip(1)
.Subscribe(_ => InvalidateScroll());
}
}
/// <summary>
@ -195,8 +206,17 @@ namespace Avalonia.Controls.Presenters
/// <returns>The actual size used.</returns>
public virtual Size ArrangeOverride(Size finalSize)
{
var origin = Vertical ? new Point(-_crossAxisOffset, 0) : new Point(0, _crossAxisOffset);
Owner.Panel.Arrange(new Rect(origin, finalSize));
if (VirtualizingPanel != null)
{
VirtualizingPanel.CrossAxisOffset = _crossAxisOffset;
Owner.Panel.Arrange(new Rect(finalSize));
}
else
{
var origin = Vertical ? new Point(-_crossAxisOffset, 0) : new Point(0, _crossAxisOffset);
Owner.Panel.Arrange(new Rect(origin, finalSize));
}
return finalSize;
}
@ -240,6 +260,9 @@ namespace Avalonia.Controls.Presenters
/// <inheritdoc/>
public virtual void Dispose()
{
_subscriptions?.Dispose();
_subscriptions = null;
if (VirtualizingPanel != null)
{
VirtualizingPanel.Controller = null;

11
src/Avalonia.Controls/Presenters/TextPresenter.cs

@ -173,10 +173,13 @@ namespace Avalonia.Controls.Presenters
{
if (this.GetVisualParent() != null)
{
_caretBlink = true;
_caretTimer.Stop();
_caretTimer.Start();
InvalidateVisual();
if (_caretTimer.IsEnabled)
{
_caretBlink = true;
_caretTimer.Stop();
_caretTimer.Start();
InvalidateVisual();
}
if (IsMeasureValid)
{

4
src/Avalonia.Controls/ScrollViewer.cs

@ -157,10 +157,6 @@ namespace Avalonia.Controls
/// </summary>
public ScrollViewer()
{
Observable.CombineLatest(
this.GetObservable(ExtentProperty),
this.GetObservable(ViewportProperty))
.Select(x => new { Extent = x[0], Viewport = x[1] });
}
/// <summary>

6
src/Avalonia.Controls/TopLevel.cs

@ -184,7 +184,7 @@ namespace Avalonia.Controls
/// <summary>
/// Gets the renderer for the window.
/// </summary>
public IRenderer Renderer { get; }
public IRenderer Renderer { get; private set; }
/// <summary>
/// Gets the access key handler for the window.
@ -237,7 +237,7 @@ namespace Avalonia.Controls
/// <inheritdoc/>
IRenderTarget IRenderRoot.CreateRenderTarget()
{
return _renderInterface.CreateRenderTarget(PlatformImpl.Handle);
return _renderInterface.CreateRenderTarget(PlatformImpl.Surfaces);
}
/// <inheritdoc/>
@ -381,6 +381,8 @@ namespace Avalonia.Controls
private void HandleClosed()
{
Closed?.Invoke(this, EventArgs.Empty);
Renderer?.Dispose();
Renderer = null;
_applicationLifecycle.OnExit -= OnApplicationExiting;
}

27
src/Avalonia.Controls/VirtualizingStackPanel.cs

@ -19,6 +19,7 @@ namespace Avalonia.Controls
private double _averageItemSize;
private int _averageCount;
private double _pixelOffset;
private double _crossAxisOffset;
private bool _forceRemeasure;
bool IVirtualizingPanel.IsFull
@ -60,6 +61,20 @@ namespace Avalonia.Controls
}
}
double IVirtualizingPanel.CrossAxisOffset
{
get { return _crossAxisOffset; }
set
{
if (_crossAxisOffset != value)
{
_crossAxisOffset = value;
InvalidateArrange();
}
}
}
private IVirtualizingController Controller => ((IVirtualizingPanel)this).Controller;
void IVirtualizingPanel.ForceInvalidateMeasure()
@ -140,7 +155,11 @@ namespace Avalonia.Controls
{
if (orientation == Orientation.Vertical)
{
rect = new Rect(rect.X, rect.Y - _pixelOffset, rect.Width, rect.Height);
rect = new Rect(
rect.X - _crossAxisOffset,
rect.Y - _pixelOffset,
rect.Width,
rect.Height);
child.Arrange(rect);
if (rect.Y >= _availableSpace.Height)
@ -157,7 +176,11 @@ namespace Avalonia.Controls
}
else
{
rect = new Rect(rect.X - _pixelOffset, rect.Y, rect.Width, rect.Height);
rect = new Rect(
rect.X - _pixelOffset,
rect.Y - _crossAxisOffset,
rect.Width,
rect.Height);
child.Arrange(rect);
if (rect.X >= _availableSpace.Width)

20
src/Avalonia.Controls/Window.cs

@ -64,13 +64,6 @@ namespace Avalonia.Controls
public static readonly StyledProperty<bool> HasSystemDecorationsProperty =
AvaloniaProperty.Register<Window, bool>(nameof(HasSystemDecorations), true);
/// <summary>
/// Sets if the window should cover the taskbar when maximized. Only applies to Windows
/// with HasSystemDecorations = false.
/// </summary>
public static readonly StyledProperty<bool> CoverTaskbarOnMaximizeProperty =
AvaloniaProperty.Register<Window, bool>(nameof(CoverTaskbarOnMaximize), true);
/// <summary>
/// Defines the <see cref="Title"/> property.
/// </summary>
@ -97,9 +90,6 @@ namespace Avalonia.Controls
HasSystemDecorationsProperty.Changed.AddClassHandler<Window>(
(s, e) => s.PlatformImpl.SetSystemDecorations((bool) e.NewValue));
CoverTaskbarOnMaximizeProperty.Changed.AddClassHandler<Window>(
(s, e) => s.PlatformImpl.SetCoverTaskbarWhenMaximized((bool)e.NewValue));
IconProperty.Changed.AddClassHandler<Window>((s, e) => s.PlatformImpl.SetIcon(((WindowIcon)e.NewValue).PlatformImpl));
}
@ -168,16 +158,6 @@ namespace Avalonia.Controls
set { SetValue(HasSystemDecorationsProperty, value); }
}
/// <summary>
/// Sets if the window should cover the taskbar when maximized. Only applies to Windows
/// with HasSystemDecorations = false.
/// </summary>
public bool CoverTaskbarOnMaximize
{
get { return GetValue(CoverTaskbarOnMaximizeProperty); }
set { SetValue(CoverTaskbarOnMaximizeProperty, value); }
}
/// <summary>
/// Gets or sets the minimized/maximized state of the window.
/// </summary>

2
src/Avalonia.Controls/WindowIcon.cs

@ -31,6 +31,6 @@ namespace Avalonia.Controls
public IWindowIconImpl PlatformImpl { get; }
public Stream Save() => PlatformImpl.Save();
public void Save(Stream stream) => PlatformImpl.Save(stream);
}
}

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

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

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

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

56
src/Avalonia.DotNetCoreRuntime/AppBuilder.cs

@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
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(),
builder => StandardRuntimePlatformServices.Register(builder.Instance?.GetType()
?.GetTypeInfo().Assembly))
{
}
/// <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": {}
}
}

21
src/Avalonia.DotNetFrameworkRuntime/AppBuilder.cs

@ -17,7 +17,8 @@ namespace Avalonia
/// Initializes a new instance of the <see cref="AppBuilder"/> class.
/// </summary>
public AppBuilder()
: base(new StandardRuntimePlatform(), () => StandardRuntimePlatformServices.Register())
: base(new StandardRuntimePlatform(),
builder => StandardRuntimePlatformServices.Register(builder.Instance?.GetType()?.Assembly))
{
}
@ -30,6 +31,20 @@ namespace Avalonia
Instance = app;
}
bool CheckEnvironment(Type checkerType)
{
if (checkerType == null)
return true;
try
{
return ((IModuleEnvironmentChecker) Activator.CreateInstance(checkerType)).IsCompatible;
}
catch
{
return false;
}
}
/// <summary>
/// Instructs the <see cref="AppBuilder"/> to use the best settings for the platform.
/// </summary>
@ -42,13 +57,13 @@ namespace Avalonia
var windowingSubsystemAttribute = (from assembly in RuntimePlatform.GetLoadedAssemblies()
from attribute in assembly.GetCustomAttributes<ExportWindowingSubsystemAttribute>()
where attribute.RequiredOS == os
where attribute.RequiredOS == os && CheckEnvironment(attribute.EnvironmentChecker)
orderby attribute.Priority ascending
select attribute).First();
var renderingSubsystemAttribute = (from assembly in RuntimePlatform.GetLoadedAssemblies()
from attribute in assembly.GetCustomAttributes<ExportRenderingSubsystemAttribute>()
where attribute.RequiredOS == os
where attribute.RequiredOS == os && CheckEnvironment(attribute.EnvironmentChecker)
where attribute.RequiresWindowingSubsystem == null
|| attribute.RequiresWindowingSubsystem == windowingSubsystemAttribute.Name
orderby attribute.Priority ascending

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

31
src/Avalonia.Styling/Controls/NameScope.cs

@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using Avalonia.LogicalTree;
namespace Avalonia.Controls
{
@ -29,6 +30,32 @@ namespace Avalonia.Controls
/// </summary>
public event EventHandler<NameScopeEventArgs> Unregistered;
/// <summary>
/// Finds the containing name scope for a visual.
/// </summary>
/// <param name="visual">The visual.</param>
/// <returns>The containing name scope.</returns>
public static INameScope FindNameScope(Visual visual)
{
Contract.Requires<ArgumentNullException>(visual != null);
INameScope result;
while (visual != null)
{
result = visual as INameScope ?? GetNameScope(visual);
if (result != null)
{
return result;
}
visual = (visual as ILogical).LogicalParent as Visual;
}
return null;
}
/// <summary>
/// Gets the value of the attached <see cref="NameScopeProperty"/> on a visual.
/// </summary>
@ -36,6 +63,8 @@ namespace Avalonia.Controls
/// <returns>The value of the NameScope attached property.</returns>
public static INameScope GetNameScope(Visual visual)
{
Contract.Requires<ArgumentNullException>(visual != null);
return visual.GetValue(NameScopeProperty);
}
@ -46,6 +75,8 @@ namespace Avalonia.Controls
/// <param name="value">The value to set.</param>
public static void SetNameScope(Visual visual, INameScope value)
{
Contract.Requires<ArgumentNullException>(visual != null);
visual.SetValue(NameScopeProperty, value);
}

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

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

5
src/Avalonia.Visuals/Avalonia.Visuals.csproj

@ -18,7 +18,7 @@
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
@ -29,7 +29,7 @@
<DocumentationFile>bin\Debug\Avalonia.Visuals.xml</DocumentationFile>
<NoWarn>CS1591</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
@ -102,6 +102,7 @@
<Compile Include="Media\Geometry.cs" />
<Compile Include="Media\IDrawingContext.cs" />
<Compile Include="Platform\ExportRenderingSubsystemAttribute.cs" />
<Compile Include="Platform\IModuleEnvironmentChecker.cs" />
<Compile Include="Rendering\IRenderer.cs" />
<Compile Include="Rendering\IRendererFactory.cs" />
<Compile Include="Rendering\IRenderLoop.cs" />

9
src/Avalonia.Visuals/Media/DrawingContext.cs

@ -12,10 +12,6 @@ namespace Avalonia.Media
{
private readonly IDrawingContextImpl _impl;
private int _currentLevel;
//Internal tranformation that is applied but not exposed anywhere
//To be used for DPI scaling, etc
private Matrix? _hiddenPostTransform = Matrix.Identity;
static readonly Stack<Stack<PushedState>> StateStackPool = new Stack<Stack<PushedState>>();
@ -39,10 +35,9 @@ namespace Avalonia.Media
}
}
public DrawingContext(IDrawingContextImpl impl, Matrix? hiddenPostTransform = null)
public DrawingContext(IDrawingContextImpl impl)
{
_impl = impl;
_hiddenPostTransform = hiddenPostTransform;
}
@ -60,8 +55,6 @@ namespace Avalonia.Media
{
_currentTransform = value;
var transform = _currentTransform*_currentContainerTransform;
if (_hiddenPostTransform.HasValue)
transform = transform*_hiddenPostTransform.Value;
_impl.Transform = transform;
}
}

5
src/Avalonia.Visuals/Platform/ExportRenderingSubsystemAttribute.cs

@ -9,16 +9,19 @@ namespace Avalonia.Platform
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public class ExportRenderingSubsystemAttribute : Attribute
{
public ExportRenderingSubsystemAttribute(OperatingSystemType requiredOS, int priority, string name, Type initializationType, string initializationMethod)
public ExportRenderingSubsystemAttribute(OperatingSystemType requiredOS, int priority, string name, Type initializationType, string initializationMethod,
Type environmentChecker = null)
{
Name = name;
InitializationType = initializationType;
InitializationMethod = initializationMethod;
EnvironmentChecker = environmentChecker;
RequiredOS = requiredOS;
Priority = priority;
}
public string InitializationMethod { get; private set; }
public Type EnvironmentChecker { get; }
public Type InitializationType { get; private set; }
public string Name { get; private set; }
public int Priority { get; private set; }

7
src/Avalonia.Visuals/Platform/IModuleEnvironmentChecker.cs

@ -0,0 +1,7 @@
namespace Avalonia.Platform
{
public interface IModuleEnvironmentChecker
{
bool IsCompatible { get; }
}
}

7
src/Avalonia.Visuals/Platform/IPlatformRenderInterface.cs

@ -1,6 +1,7 @@
// Copyright (c) The Avalonia Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Collections.Generic;
using System.IO;
using Avalonia.Media;
@ -40,9 +41,11 @@ namespace Avalonia.Platform
/// <summary>
/// Creates a renderer.
/// </summary>
/// <param name="handle">The platform handle for the renderer.</param>
/// <param name="surfaces">
/// The list of native platform surfaces that can be used for output.
/// </param>
/// <returns>An <see cref="IRenderTarget"/>.</returns>
IRenderTarget CreateRenderTarget(IPlatformHandle handle);
IRenderTarget CreateRenderTarget(IEnumerable<object> surfaces);
/// <summary>
/// Creates a render target bitmap implementation.

22
src/Gtk/Avalonia.Cairo/CairoPlatform.cs

@ -2,6 +2,8 @@
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Collections.Generic;
using System.Linq;
using Avalonia.Cairo.Media;
using Avalonia.Cairo.Media.Imaging;
using Avalonia.Media;
@ -50,24 +52,14 @@ namespace Avalonia.Cairo
return new FormattedTextImpl(s_pangoContext, text, fontFamily, fontSize, fontStyle, textAlignment, fontWeight);
}
public IRenderTarget CreateRenderTarget(IPlatformHandle handle)
public IRenderTarget CreateRenderTarget(IEnumerable<object> surfaces)
{
var window = handle as Gtk.Window;
if (window != null)
{
window.DoubleBuffered = true;
return new RenderTarget(window);
}
var area = handle as Gtk.DrawingArea;
if (area != null)
{
area.DoubleBuffered = true;
return new RenderTarget(area);
}
var accessor = surfaces?.OfType<Func<Gdk.Drawable>>().FirstOrDefault();
if(accessor!=null)
return new RenderTarget(accessor);
throw new NotSupportedException(string.Format(
"Don't know how to create a Cairo renderer from a '{0}' handle which isn't Gtk.Window or Gtk.DrawingArea",
handle.HandleDescriptor));
"Don't know how to create a Cairo renderer from any of the provided surfaces."));
}
public IRenderTargetBitmapImpl CreateRenderTargetBitmap(int width, int height)

19
src/Gtk/Avalonia.Cairo/RenderTarget.cs

@ -20,8 +20,8 @@ namespace Avalonia.Cairo
public class RenderTarget : IRenderTarget
{
private readonly Surface _surface;
private readonly Gtk.Window _window;
private readonly Gtk.DrawingArea _area;
private readonly Func<Gdk.Drawable> _drawableAccessor;
/// <summary>
/// Initializes a new instance of the <see cref="RenderTarget"/> class.
@ -29,9 +29,9 @@ namespace Avalonia.Cairo
/// <param name="window">The window.</param>
/// <param name="width">The width of the window.</param>
/// <param name="height">The height of the window.</param>
public RenderTarget(Gtk.Window window)
public RenderTarget(Func<Gdk.Drawable> drawable)
{
_window = window;
_drawableAccessor = drawable;
}
public RenderTarget(ImageSurface surface)
@ -39,11 +39,6 @@ namespace Avalonia.Cairo
_surface = surface;
}
public RenderTarget(DrawingArea area)
{
_area = area;
}
/// <summary>
/// Creates a cairo surface that targets a platform-specific resource.
/// </summary>
@ -52,12 +47,10 @@ namespace Avalonia.Cairo
public IDrawingContextImpl CreateMediaDrawingContext()
{
if (_window != null)
return new Media.DrawingContext(_window.GdkWindow);
if (_drawableAccessor != null)
return new Media.DrawingContext(_drawableAccessor());
if (_surface != null)
return new Media.DrawingContext(_surface);
if (_area != null)
return new Media.DrawingContext(_area.GdkWindow);
throw new InvalidOperationException("Unspecified render target");
}

5
src/Gtk/Avalonia.Gtk/Avalonia.Gtk.csproj

@ -30,6 +30,8 @@
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="Mono.Cairo, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
</Reference>
<Reference Include="System" />
<Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
@ -48,7 +50,10 @@
<Compile Include="ClipboardImpl.cs" />
<Compile Include="EmbeddableImpl.cs" />
<Compile Include="Embedding\GtkAvaloniaControlHost.cs" />
<Compile Include="FramebufferManager.cs" />
<Compile Include="IconImpl.cs" />
<Compile Include="KeyTransform.cs" />
<Compile Include="SurfaceFramebuffer.cs" />
<Compile Include="SystemDialogImpl.cs" />
<Compile Include="CursorFactory.cs" />
<Compile Include="GtkExtensions.cs" />

39
src/Gtk/Avalonia.Gtk/FramebufferManager.cs

@ -0,0 +1,39 @@
using System;
using Avalonia.Controls.Platform.Surfaces;
namespace Avalonia.Gtk
{
class FramebufferManager : IFramebufferPlatformSurface, IDisposable
{
private readonly WindowImplBase _window;
private SurfaceFramebuffer _fb;
public FramebufferManager(WindowImplBase window)
{
_window = window;
}
public void Dispose()
{
_fb?.Deallocate();
}
public ILockedFramebuffer Lock()
{
if(_window.CurrentDrawable == null)
throw new InvalidOperationException("Window is not in drawing state");
var drawable = _window.CurrentDrawable;
var width = (int) _window.ClientSize.Width;
var height = (int) _window.ClientSize.Height;
if (_fb == null || _fb.Width != width ||
_fb.Height != height)
{
_fb?.Deallocate();
_fb = new SurfaceFramebuffer(width, height);
}
_fb.SetDrawable(drawable);
return _fb;
}
}
}

5
src/Gtk/Avalonia.Gtk/IconImpl.cs

@ -18,9 +18,10 @@ namespace Avalonia.Gtk
public Pixbuf Pixbuf { get; }
public Stream Save()
public void Save(Stream stream)
{
return new MemoryStream(Pixbuf.SaveToBuffer("png"));
var buffer = Pixbuf.SaveToBuffer("png");
stream.Write(buffer, 0, buffer.Length);
}
}
}

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

@ -8,218 +8,11 @@ using System.Reflection;
using System.Text;
using Avalonia.Input;
namespace Avalonia.Gtk
{
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 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;
}
}
}

55
src/Gtk/Avalonia.Gtk/SurfaceFramebuffer.cs

@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Avalonia.Controls.Platform.Surfaces;
using Avalonia.Platform;
using Cairo;
using Gdk;
namespace Avalonia.Gtk
{
class SurfaceFramebuffer : ILockedFramebuffer
{
private Drawable _drawable;
private ImageSurface _surface;
public SurfaceFramebuffer(int width, int height)
{
_surface = new ImageSurface(Cairo.Format.RGB24, width, height);
}
public void SetDrawable(Drawable drawable)
{
_drawable = drawable;
_surface.Flush();
}
public void Deallocate()
{
_surface.Dispose();
_surface = null;
}
public void Dispose()
{
using (var ctx = CairoHelper.Create(_drawable))
{
_surface.MarkDirty();
ctx.SetSourceSurface(_surface, 0, 0);
ctx.Paint();
}
_drawable = null;
}
public IntPtr Address => _surface.DataPtr;
public int Width => _surface.Width;
public int Height => _surface.Height;
public int RowBytes => _surface.Stride;
//TODO: Proper DPI detect
public Size Dpi => new Size(96, 96);
public PixelFormat Format => PixelFormat.Bgra8888;
}
}

4
src/Gtk/Avalonia.Gtk/SystemDialogImpl.cs

@ -15,7 +15,7 @@ namespace Avalonia.Gtk
public Task<string[]> ShowFileDialogAsync(FileDialog dialog, IWindowImpl parent)
{
var tcs = new TaskCompletionSource<string[]>();
var dlg = new global::Gtk.FileChooserDialog(dialog.Title, ((WindowImplBase)parent).Widget.Toplevel as Window,
var dlg = new global::Gtk.FileChooserDialog(dialog.Title, ((WindowImplBase)parent)?.Widget.Toplevel as Window,
dialog is OpenFileDialog
? FileChooserAction.Open
: FileChooserAction.Save,
@ -57,7 +57,7 @@ namespace Avalonia.Gtk
public Task<string> ShowFolderDialogAsync(OpenFolderDialog dialog, IWindowImpl parent)
{
var tcs = new TaskCompletionSource<string>();
var dlg = new global::Gtk.FileChooserDialog(dialog.Title, ((WindowImplBase)parent).Widget.Toplevel as Window,
var dlg = new global::Gtk.FileChooserDialog(dialog.Title, ((WindowImplBase)parent)?.Widget.Toplevel as Window,
FileChooserAction.SelectFolder,
"Cancel", ResponseType.Cancel,
"Select Folder", ResponseType.Accept)

2
src/Gtk/Avalonia.Gtk/WindowImpl.cs

@ -10,7 +10,7 @@ namespace Avalonia.Gtk
{
private Gtk.Window _window;
private Gtk.Window Window => _window ?? (_window = (Gtk.Window) Widget);
public WindowImpl(Gtk.WindowType type) : base(new PlatformHandleAwareWindow(type))
{
Init();

36
src/Gtk/Avalonia.Gtk/WindowImplBase.cs

@ -2,16 +2,14 @@
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Reactive.Disposables;
using System.Runtime.InteropServices;
using Gdk;
using Avalonia.Controls;
using System.Collections.Generic;
using Avalonia.Input;
using Avalonia.Input.Raw;
using Avalonia.Platform;
using Avalonia.Input;
using Avalonia.Threading;
using Gdk;
using Action = System.Action;
using WindowEdge = Avalonia.Controls.WindowEdge;
using GLib;
namespace Avalonia.Gtk
{
@ -21,8 +19,7 @@ namespace Avalonia.Gtk
{
private IInputRoot _inputRoot;
protected Gtk.Widget _window;
public Gtk.Widget Widget => _window;
private FramebufferManager _framebuffer;
private Gtk.IMContext _imContext;
@ -33,6 +30,7 @@ namespace Avalonia.Gtk
protected WindowImplBase(Gtk.Widget window)
{
_window = window;
_framebuffer = new FramebufferManager(this);
Init();
}
@ -43,7 +41,6 @@ namespace Avalonia.Gtk
_imContext = new Gtk.IMMulticontext();
_imContext.Commit += ImContext_Commit;
_window.Realized += OnRealized;
_window.DoubleBuffered = false;
_window.Realize();
_window.ButtonPressEvent += OnButtonPressEvent;
_window.ButtonReleaseEvent += OnButtonReleaseEvent;
@ -53,10 +50,13 @@ namespace Avalonia.Gtk
_window.KeyReleaseEvent += OnKeyReleaseEvent;
_window.ExposeEvent += OnExposeEvent;
_window.MotionNotifyEvent += OnMotionNotifyEvent;
}
public IPlatformHandle Handle { get; private set; }
public Gtk.Widget Widget => _window;
public Gdk.Drawable CurrentDrawable { get; private set; }
void OnRealized (object sender, EventArgs eventArgs)
{
@ -127,6 +127,13 @@ namespace Avalonia.Gtk
public Action<double> ScalingChanged { get; set; }
public IEnumerable<object> Surfaces => new object[]
{
Handle,
new Func<Gdk.Drawable>(() => CurrentDrawable),
_framebuffer
};
public IPopupImpl CreatePopup()
{
return new PopupImpl();
@ -260,10 +267,11 @@ namespace Avalonia.Gtk
GtkKeyboardDevice.Instance,
evnt.Time,
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);
}
[ConnectBefore]
void OnKeyPressEvent(object o, Gtk.KeyPressEventArgs args)
{
args.RetVal = true;
@ -283,7 +291,9 @@ namespace Avalonia.Gtk
void OnExposeEvent(object o, Gtk.ExposeEventArgs args)
{
CurrentDrawable = args.Event.Window;
Paint(args.Event.Area.ToAvalonia());
CurrentDrawable = null;
args.RetVal = true;
}
@ -304,13 +314,9 @@ namespace Avalonia.Gtk
args.RetVal = true;
}
public void SetCoverTaskbarWhenMaximized(bool enable)
{
// No action neccesary on Gtk.
}
public void Dispose()
{
_framebuffer.Dispose();
_window.Hide();
_window.Dispose();
_window = null;

1
src/Gtk/Avalonia.Gtk3/.gitignore

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

103
src/Gtk/Avalonia.Gtk3/Avalonia.Gtk3.csproj

@ -0,0 +1,103 @@
<?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="Interop\CairoSurface.cs" />
<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;
}
}
}

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

@ -0,0 +1,32 @@
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;
public FramebufferManager(TopLevelImpl window)
{
_window = window;
}
public void Dispose()
{
//
}
public ILockedFramebuffer Lock()
{
if(_window.CurrentCairoContext == IntPtr.Zero)
throw new InvalidOperationException("Window is not in drawing state");
var width = (int) _window.ClientSize.Width;
var height = (int) _window.ClientSize.Height;
return new ImageSurfaceFramebuffer(_window.CurrentCairoContext, _window.GtkWidget, width, height);
}
}
}

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");
}
}
}

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

@ -0,0 +1,69 @@
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 readonly GtkWidget _widget;
private CairoSurface _surface;
private int _factor;
public ImageSurfaceFramebuffer(IntPtr context, GtkWidget widget, int width, int height)
{
_context = context;
_widget = widget;
_factor = (int)(Native.GtkWidgetGetScaleFactor?.Invoke(_widget) ?? 1u);
width *= _factor;
height *= _factor;
_surface = Native.CairoImageSurfaceCreate(1, width, height);
Width = width;
Height = height;
Address = Native.CairoImageSurfaceGetData(_surface);
RowBytes = Native.CairoImageSurfaceGetStride(_surface);
Native.CairoSurfaceFlush(_surface);
}
public void Dispose()
{
if(_context == IntPtr.Zero || _surface == null)
return;
Native.CairoSurfaceMarkDirty(_surface);
Native.CairoScale(_context, 1d / _factor, 1d / _factor);
Native.CairoSetSourceSurface(_context, _surface, 0, 0);
Native.CairoPaint(_context);
_context = IntPtr.Zero;
_surface.Dispose();
_surface = null;
}
public IntPtr Address { get; }
public int Width { get; }
public int Height { get; }
public int RowBytes { get; }
public Size Dpi
{
get
{
return new Size(96, 96) * _factor;
}
}
public PixelFormat Format => PixelFormat.Bgra8888;
}
}

20
src/Gtk/Avalonia.Gtk3/Interop/CairoSurface.cs

@ -0,0 +1,20 @@
using System;
using System.Runtime.InteropServices;
namespace Avalonia.Gtk3.Interop
{
class CairoSurface : SafeHandle
{
public CairoSurface() : base(IntPtr.Zero, true)
{
}
protected override bool ReleaseHandle()
{
Native.CairoSurfaceDestroy(handle);
return true;
}
public override bool IsInvalid => handle == IntPtr.Zero;
}
}

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save