From d79fc6bbd8bf6d61753b6aeca3f25b04e538ea7f Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Fri, 13 May 2016 19:58:55 +0200 Subject: [PATCH 1/5] Added AppBuilder Use AppBuilder to configure the Application and make sure that everything is set up in the correct order. --- samples/BindingTest/App.xaml.cs | 13 +-- samples/BindingTest/MainWindow.xaml.cs | 2 +- .../ControlCatalog.Desktop.csproj | 20 +++++ samples/ControlCatalog.Desktop/Program.cs | 39 +++++---- samples/ControlCatalog.iOS/AppDelegate.cs | 8 +- samples/ControlCatalog/App.xaml.cs | 10 ++- samples/ControlCatalog/MainWindow.xaml.cs | 4 +- samples/TestApplication/Program.cs | 23 +----- samples/XamlTestApplication/Program.cs | 10 +-- samples/XamlTestApplicationPcl/XamlTestApp.cs | 5 ++ src/Avalonia.Controls/AppBuilder.cs | 80 +++++++++++++++++++ src/Avalonia.Controls/Application.cs | 14 ++-- .../Avalonia.Controls.csproj | 1 + src/Gtk/Avalonia.Cairo/CairoPlatform.cs | 7 +- src/Gtk/Avalonia.Gtk/GtkPlatform.cs | 7 +- .../AvaloniaXamlLoader.cs | 12 --- src/Skia/Avalonia.Skia/SkiaPlatform.cs | 7 +- .../Avalonia.Direct2D1/Direct2D1Platform.cs | 7 +- src/Windows/Avalonia.Win32/Win32Platform.cs | 7 +- src/iOS/Avalonia.iOS/iOSPlatform.cs | 19 ++--- .../AppDelegate.cs | 9 ++- .../Avalonia.UnitTests/UnitTestApplication.cs | 1 + 22 files changed, 195 insertions(+), 110 deletions(-) create mode 100644 src/Avalonia.Controls/AppBuilder.cs diff --git a/samples/BindingTest/App.xaml.cs b/samples/BindingTest/App.xaml.cs index 26df631523..07fa406c1c 100644 --- a/samples/BindingTest/App.xaml.cs +++ b/samples/BindingTest/App.xaml.cs @@ -1,7 +1,6 @@ using System; using Avalonia; using Avalonia.Controls; -using Avalonia.Diagnostics; using Avalonia.Logging.Serilog; using Avalonia.Markup.Xaml; using Serilog; @@ -15,15 +14,19 @@ namespace BindingTest RegisterServices(); } + public override void Initialize() + { + AvaloniaXamlLoader.Load(this); + } + private static void Main() { InitializeLogging(); - new App() + AppBuilder.Configure() .UseWin32() - .UseDirect2D() - .LoadFromXaml() - .RunWithMainWindow(); + .UseDirect2D1() + .Start(); } private static void InitializeLogging() diff --git a/samples/BindingTest/MainWindow.xaml.cs b/samples/BindingTest/MainWindow.xaml.cs index 8b07c6b482..c1c3c09406 100644 --- a/samples/BindingTest/MainWindow.xaml.cs +++ b/samples/BindingTest/MainWindow.xaml.cs @@ -16,7 +16,7 @@ namespace BindingTest private void InitializeComponent() { - this.LoadFromXaml(); + AvaloniaXamlLoader.Load(this); } } } diff --git a/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj b/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj index 79f5f1d259..c56b61fc50 100644 --- a/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj +++ b/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj @@ -75,6 +75,10 @@ {6417E941-21BC-467B-A771-0DE389353CE6} Avalonia.Markup + + {d211e587-d8bc-45b9-95a4-f297c8fa5200} + Avalonia.Animation + {B09B78D8-9B26-48B0-9149-D64A2F120F3F} Avalonia.Base @@ -83,10 +87,26 @@ {D2221C82-4A25-4583-9B43-D791E3F6820C} Avalonia.Controls + + {62024b2d-53eb-4638-b26b-85eeaa54866e} + Avalonia.Input + + + {6b0ed19d-a08b-461c-a9d9-a9ee40b0c06b} + Avalonia.Interactivity + + + {42472427-4774-4c81-8aff-9f27b8e31721} + Avalonia.Layout + {B61B66A3-B82D-4875-8001-89D3394FE0C9} Avalonia.Logging.Serilog + + {eb582467-6abb-43a1-b052-e981ba910e3a} + Avalonia.SceneGraph + {F1BAA01A-F176-4C6A-B39D-5B40BB1B148F} Avalonia.Styling diff --git a/samples/ControlCatalog.Desktop/Program.cs b/samples/ControlCatalog.Desktop/Program.cs index 4257587b21..ae8c9f5d8f 100644 --- a/samples/ControlCatalog.Desktop/Program.cs +++ b/samples/ControlCatalog.Desktop/Program.cs @@ -1,10 +1,10 @@ -using Avalonia.Logging.Serilog; -using Serilog; using System; using System.Linq; using Avalonia; -using System.Reflection; +using Avalonia.Controls; +using Avalonia.Logging.Serilog; using Avalonia.Platform; +using Serilog; namespace ControlCatalog { @@ -14,10 +14,12 @@ namespace ControlCatalog { InitializeLogging(); - new App() - .ConfigureRenderSystem(args) - .LoadFromXaml() - .RunWithMainWindow(); + // TODO: Make this work with GTK/Skia/Cairo depending on command-line args + // again. + AppBuilder.Configure() + .UseWin32() + .UseDirect2D1() + .Start(); } // This will be made into a runtime configuration extension soon! @@ -31,6 +33,12 @@ namespace ControlCatalog #endif } + private static void ConfigureAssetAssembly(AppBuilder builder) + { + AvaloniaLocator.CurrentMutable + .GetService() + .SetDefaultAssembly(typeof(App).Assembly); + } } ///////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -96,33 +104,32 @@ namespace ControlCatalog /// /// Selects the optimal render system for desktop platforms. Supports cmd line overrides /// - /// + /// /// - public static TApp ConfigureRenderSystem(this TApp app, string[] args) where TApp : Application + public static AppBuilder ConfigureRenderSystem(this AppBuilder builder, string[] args) { // So this all works great under Windows where it can support // ALL configurations. But on OSX/Unix we cannot use Direct2D - // if (args.Contains("--gtk") || DefaultRenderSystem() == RenderSystem.GTK) { - app.UseGtk(); - app.UseCairo(); + builder.UseGtk(); + builder.UseCairo(); } else { - app.UseWin32(); + builder.UseWin32(); if (args.Contains("--skia") || DefaultRenderSystem() == RenderSystem.Skia) { - app.UseSkia(); + builder.UseSkia(); } else { - app.UseDirect2D(); + builder.UseDirect2D1(); } } - return app; + return builder; } } } diff --git a/samples/ControlCatalog.iOS/AppDelegate.cs b/samples/ControlCatalog.iOS/AppDelegate.cs index 94c79cd60b..e352b39200 100644 --- a/samples/ControlCatalog.iOS/AppDelegate.cs +++ b/samples/ControlCatalog.iOS/AppDelegate.cs @@ -19,17 +19,13 @@ namespace ControlCatalog // public override bool FinishedLaunching(UIApplication uiapp, NSDictionary options) { - new App() + AppBuilder.Configure() .UseiOS() .UseSkiaViewHost() .UseSkia() - .UseAssetAssembly(typeof(App).Assembly) - .LoadFromXaml() - .RunWithMainWindow(); + .Start(); return true; } } - - } \ No newline at end of file diff --git a/samples/ControlCatalog/App.xaml.cs b/samples/ControlCatalog/App.xaml.cs index 66bf8e6b8d..fe2ccdb218 100644 --- a/samples/ControlCatalog/App.xaml.cs +++ b/samples/ControlCatalog/App.xaml.cs @@ -1,16 +1,18 @@ using Avalonia; - +using Avalonia.Markup.Xaml; namespace ControlCatalog { - // Eventually we should move this into a PCL library so we can access - // from mobile platforms - // public class App : Application { public App() { RegisterServices(); } + + public override void Initialize() + { + AvaloniaXamlLoader.Load(this); + } } } diff --git a/samples/ControlCatalog/MainWindow.xaml.cs b/samples/ControlCatalog/MainWindow.xaml.cs index 2dea549160..c7c61e2b4e 100644 --- a/samples/ControlCatalog/MainWindow.xaml.cs +++ b/samples/ControlCatalog/MainWindow.xaml.cs @@ -19,9 +19,7 @@ namespace ControlCatalog // now I am doing that here. But we need a better solution!! var theme = new Avalonia.Themes.Default.DefaultTheme(); theme.FindResource("Button"); - - - this.LoadFromXaml(); + AvaloniaXamlLoader.Load(this); } } } diff --git a/samples/TestApplication/Program.cs b/samples/TestApplication/Program.cs index 3cee513c17..5e79916a8d 100644 --- a/samples/TestApplication/Program.cs +++ b/samples/TestApplication/Program.cs @@ -34,25 +34,10 @@ namespace TestApplication var app = new App(); - if (args.Contains("--gtk")) - { - app.UseGtk(); - app.UseCairo(); - } - else - { - app.UseWin32(); - - // not available until we do the SkiaSharp merge - //if (args.Contains("--skia")) - //{ - // app.UseSkia(); - //} - //else - { - app.UseDirect2D(); - } - } + AppBuilder.Configure(app) + .UseWin32() + .UseDirect2D1() + .SetupWithoutStarting(); app.Run(); } diff --git a/samples/XamlTestApplication/Program.cs b/samples/XamlTestApplication/Program.cs index 020c353677..50b3c364d4 100644 --- a/samples/XamlTestApplication/Program.cs +++ b/samples/XamlTestApplication/Program.cs @@ -7,6 +7,7 @@ using System.Windows.Threading; using Avalonia; using Serilog; using Avalonia.Logging.Serilog; +using Avalonia.Controls; namespace XamlTestApplication { @@ -19,11 +20,10 @@ namespace XamlTestApplication InitializeLogging(); - new XamlTestApp() - .UseWin32() - .UseDirect2D() - .LoadFromXaml() - .RunWithMainWindow(); + AppBuilder.Configure() + .UseWin32() + .UseDirect2D1() + .Start(); } private static void InitializeLogging() diff --git a/samples/XamlTestApplicationPcl/XamlTestApp.cs b/samples/XamlTestApplicationPcl/XamlTestApp.cs index efc744dcb0..7518346e91 100644 --- a/samples/XamlTestApplicationPcl/XamlTestApp.cs +++ b/samples/XamlTestApplicationPcl/XamlTestApp.cs @@ -10,5 +10,10 @@ namespace XamlTestApplication { RegisterServices(); } + + public override void Initialize() + { + AvaloniaXamlLoader.Load(this); + } } } diff --git a/src/Avalonia.Controls/AppBuilder.cs b/src/Avalonia.Controls/AppBuilder.cs new file mode 100644 index 0000000000..628fac3cc1 --- /dev/null +++ b/src/Avalonia.Controls/AppBuilder.cs @@ -0,0 +1,80 @@ +// 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 Avalonia.Input; +using System; + +namespace Avalonia.Controls +{ + public class AppBuilder + { + public Application Instance { get; set; } + + public Action WindowingSubsystem { get; set; } + + public Action RenderingSubsystem { get; set; } + + public Action BeforeStartCallback { get; set; } + + public static AppBuilder Configure() + where TApp : Application, new() + { + return Configure(new TApp()); + } + + public static AppBuilder Configure(Application app) + { + AvaloniaLocator.CurrentMutable.BindToSelf(app); + + return new AppBuilder() + { + Instance = app, + }; + } + + public AppBuilder BeforeStarting(Action callback) + { + BeforeStartCallback = callback; + return this; + } + + public void Start() + where TMainWindow : Window, new() + { + Setup(); + BeforeStartCallback?.Invoke(this); + + var window = new TMainWindow(); + window.Show(); + Instance.Run(window); + } + + public AppBuilder SetupWithoutStarting() + { + Setup(); + return this; + } + + public void Setup() + { + if (Instance == null) + { + throw new InvalidOperationException("No App instance configured."); + } + + if (WindowingSubsystem == null) + { + throw new InvalidOperationException("No windowing system configured."); + } + + if (RenderingSubsystem == null) + { + throw new InvalidOperationException("No rendering system configured."); + } + + WindowingSubsystem(); + RenderingSubsystem(); + Instance.Initialize(); + } + } +} diff --git a/src/Avalonia.Controls/Application.cs b/src/Avalonia.Controls/Application.cs index a24f481fe5..aedf3370a3 100644 --- a/src/Avalonia.Controls/Application.cs +++ b/src/Avalonia.Controls/Application.cs @@ -50,12 +50,6 @@ namespace Avalonia /// public Application() { - if (Current != null) - { - throw new InvalidOperationException("Cannot create more than one Application instance."); - } - - AvaloniaLocator.CurrentMutable.BindToSelf(this); OnExit += OnExiting; } @@ -132,6 +126,13 @@ namespace Avalonia _platformInitializationCallback = cb; } + /// + /// Initializes the application by loading XAML etc. + /// + public virtual void Initialize() + { + } + /// /// Runs the application's main loop until the is closed. /// @@ -165,7 +166,6 @@ namespace Avalonia /// protected virtual void OnExiting(object sender, EventArgs e) { - } /// diff --git a/src/Avalonia.Controls/Avalonia.Controls.csproj b/src/Avalonia.Controls/Avalonia.Controls.csproj index 2a0040d863..6f7dd4bcf8 100644 --- a/src/Avalonia.Controls/Avalonia.Controls.csproj +++ b/src/Avalonia.Controls/Avalonia.Controls.csproj @@ -43,6 +43,7 @@ Properties\SharedAssemblyInfo.cs + diff --git a/src/Gtk/Avalonia.Cairo/CairoPlatform.cs b/src/Gtk/Avalonia.Cairo/CairoPlatform.cs index 0dd708d9d3..8092764c1b 100644 --- a/src/Gtk/Avalonia.Cairo/CairoPlatform.cs +++ b/src/Gtk/Avalonia.Cairo/CairoPlatform.cs @@ -6,15 +6,16 @@ using Avalonia.Cairo.Media; using Avalonia.Cairo.Media.Imaging; using Avalonia.Media; using Avalonia.Platform; +using Avalonia.Controls; namespace Avalonia { public static class GtkApplicationExtensions { - public static TApp UseCairo(this TApp app) where TApp : Application + public static AppBuilder UseCairo(this AppBuilder builder) { - Avalonia.Cairo.CairoPlatform.Initialize(); - return app; + builder.RenderingSubsystem = Avalonia.Cairo.CairoPlatform.Initialize; + return builder; } } } diff --git a/src/Gtk/Avalonia.Gtk/GtkPlatform.cs b/src/Gtk/Avalonia.Gtk/GtkPlatform.cs index cc19110e86..b09f1c9ea6 100644 --- a/src/Gtk/Avalonia.Gtk/GtkPlatform.cs +++ b/src/Gtk/Avalonia.Gtk/GtkPlatform.cs @@ -9,15 +9,16 @@ using Avalonia.Input.Platform; using Avalonia.Input; using Avalonia.Platform; using Avalonia.Shared.PlatformSupport; +using Avalonia.Controls; namespace Avalonia { public static class GtkApplicationExtensions { - public static TApp UseGtk(this TApp app) where TApp : Application + public static AppBuilder UseGtk(this AppBuilder builder) { - Avalonia.Gtk.GtkPlatform.Initialize(); - return app; + builder.WindowingSubsystem = Avalonia.Gtk.GtkPlatform.Initialize; + return builder; } } } diff --git a/src/Markup/Avalonia.Markup.Xaml/AvaloniaXamlLoader.cs b/src/Markup/Avalonia.Markup.Xaml/AvaloniaXamlLoader.cs index c36a58cf0b..437e6e849f 100644 --- a/src/Markup/Avalonia.Markup.Xaml/AvaloniaXamlLoader.cs +++ b/src/Markup/Avalonia.Markup.Xaml/AvaloniaXamlLoader.cs @@ -223,15 +223,3 @@ namespace Avalonia.Markup.Xaml } } } - -namespace Avalonia -{ - public static class XamlObjectExtensions - { - public static TObject LoadFromXaml(this TObject obj) - { - Markup.Xaml.AvaloniaXamlLoader.Load(obj); - return obj; - } - } -} diff --git a/src/Skia/Avalonia.Skia/SkiaPlatform.cs b/src/Skia/Avalonia.Skia/SkiaPlatform.cs index 31781ad0bd..1d93089e45 100644 --- a/src/Skia/Avalonia.Skia/SkiaPlatform.cs +++ b/src/Skia/Avalonia.Skia/SkiaPlatform.cs @@ -1,16 +1,17 @@ using System; using System.Collections.Generic; using System.Text; +using Avalonia.Controls; using Avalonia.Platform; namespace Avalonia { public static class SkiaApplicationExtensions { - public static TApp UseSkia(this TApp app) where TApp : Application + public static AppBuilder UseSkia(this AppBuilder builder) { - Avalonia.Skia.SkiaPlatform.Initialize(); - return app; + builder.RenderingSubsystem = Avalonia.Skia.SkiaPlatform.Initialize; + return builder; } } } diff --git a/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs b/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs index 03230a3e60..ae2b5d314d 100644 --- a/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs +++ b/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs @@ -6,15 +6,16 @@ using System.IO; using Avalonia.Direct2D1.Media; using Avalonia.Media; using Avalonia.Platform; +using Avalonia.Controls; namespace Avalonia { public static class Direct2DApplicationExtensions { - public static TApp UseDirect2D(this TApp app) where TApp : Application + public static AppBuilder UseDirect2D1(this AppBuilder builder) { - Avalonia.Direct2D1.Direct2D1Platform.Initialize(); - return app; + builder.RenderingSubsystem = Avalonia.Direct2D1.Direct2D1Platform.Initialize; + return builder; } } } diff --git a/src/Windows/Avalonia.Win32/Win32Platform.cs b/src/Windows/Avalonia.Win32/Win32Platform.cs index 71e18bcffe..c1e0260596 100644 --- a/src/Windows/Avalonia.Win32/Win32Platform.cs +++ b/src/Windows/Avalonia.Win32/Win32Platform.cs @@ -15,15 +15,16 @@ using Avalonia.Platform; using Avalonia.Shared.PlatformSupport; using Avalonia.Win32.Input; using Avalonia.Win32.Interop; +using Avalonia.Controls; namespace Avalonia { public static class Win32ApplicationExtensions { - public static TApp UseWin32(this TApp app) where TApp : Application + public static AppBuilder UseWin32(this AppBuilder builder) { - Avalonia.Win32.Win32Platform.Initialize(); - return app; + builder.WindowingSubsystem = Avalonia.Win32.Win32Platform.Initialize; + return builder; } } } diff --git a/src/iOS/Avalonia.iOS/iOSPlatform.cs b/src/iOS/Avalonia.iOS/iOSPlatform.cs index c78d1eaa82..e28aadf034 100644 --- a/src/iOS/Avalonia.iOS/iOSPlatform.cs +++ b/src/iOS/Avalonia.iOS/iOSPlatform.cs @@ -7,19 +7,20 @@ using Avalonia.Platform; using Avalonia.Shared.PlatformSupport; using Avalonia.Skia; using UIKit; +using Avalonia.Controls; namespace Avalonia { public static class iOSApplicationExtensions { - public static AppT UseiOS(this AppT app) where AppT : Application + public static AppBuilder UseiOS(this AppBuilder builder) { - Avalonia.iOS.iOSPlatform.Initialize(); - return app; + builder.WindowingSubsystem = Avalonia.iOS.iOSPlatform.Initialize; + return builder; } // TODO: Can we merge this with UseSkia somehow once HW/platform cleanup is done? - public static AppT UseSkiaViewHost(this AppT app) where AppT : Application + public static AppBuilder UseSkiaViewHost(this AppBuilder builder) { var window = new UIWindow(UIScreen.MainScreen.Bounds); var controller = new AvaloniaViewController(window); @@ -31,15 +32,7 @@ namespace Avalonia SkiaPlatform.Initialize(); - return app; - } - - public static AppT UseAssetAssembly(this AppT app, Assembly assembly) where AppT : Application - { - // Asset loading searches our own assembly? - var loader = new AssetLoader(assembly); - AvaloniaLocator.CurrentMutable.Bind().ToConstant(loader); - return app; + return builder; } } } diff --git a/src/iOS/Avalonia.iOSTestApplication/AppDelegate.cs b/src/iOS/Avalonia.iOSTestApplication/AppDelegate.cs index e4ef8b8afe..211b7d5daa 100644 --- a/src/iOS/Avalonia.iOSTestApplication/AppDelegate.cs +++ b/src/iOS/Avalonia.iOSTestApplication/AppDelegate.cs @@ -27,13 +27,14 @@ namespace Avalonia.iOSTestApplication // public override bool FinishedLaunching(UIApplication uiapp, NSDictionary options) { - var app = new App() + var app = new App(); + + AppBuilder.Configure(app) .UseiOS() .UseSkiaViewHost() - .UseSkia(); + .UseSkia() + .SetupWithoutStarting(); - var asm = typeof(App).Assembly; - app.UseAssetAssembly(asm); app.Run(); return true; diff --git a/tests/Avalonia.UnitTests/UnitTestApplication.cs b/tests/Avalonia.UnitTests/UnitTestApplication.cs index 9c7eb427ed..01151b4952 100644 --- a/tests/Avalonia.UnitTests/UnitTestApplication.cs +++ b/tests/Avalonia.UnitTests/UnitTestApplication.cs @@ -33,6 +33,7 @@ namespace Avalonia.UnitTests { var scope = AvaloniaLocator.EnterScope(); var app = new UnitTestApplication(services); + AvaloniaLocator.CurrentMutable.BindToSelf(app); return scope; } From 40b9447bb39c5963708961d1b2cb4450237b1388 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Sat, 14 May 2016 00:45:17 +0300 Subject: [PATCH 2/5] Fixed DesignerAssist and added test for it --- Avalonia.sln | 95 +++++++++-- .../ControlCatalog.Desktop.csproj | 6 +- src/Avalonia.Controls/AppBuilder.cs | 12 ++ .../DesignerAssist.cs | 23 ++- .../App.config | 6 + .../Avalonia.DesignerSupport.TestApp/App.xaml | 6 + .../App.xaml.cs | 23 +++ .../Avalonia.DesignerSupport.TestApp.csproj | 153 ++++++++++++++++++ .../MainWindow.xaml | 5 + .../MainWindow.xaml.cs | 13 ++ .../Program.cs | 21 +++ .../Properties/AssemblyInfo.cs | 36 +++++ .../Properties/Resources.Designer.cs | 71 ++++++++ .../Properties/Resources.resx | 117 ++++++++++++++ .../Properties/Settings.Designer.cs | 30 ++++ .../Properties/Settings.settings | 7 + .../Avalonia.DesignerSupport.Tests.csproj | 80 +++++++++ .../Avalonia.DesignerSupport.Tests/Checker.cs | 85 ++++++++++ .../DesignerSupportTests.cs | 33 ++++ .../Properties/AssemblyInfo.cs | 36 +++++ .../packages.config | 9 ++ 21 files changed, 838 insertions(+), 29 deletions(-) create mode 100644 tests/Avalonia.DesignerSupport.TestApp/App.config create mode 100644 tests/Avalonia.DesignerSupport.TestApp/App.xaml create mode 100644 tests/Avalonia.DesignerSupport.TestApp/App.xaml.cs create mode 100644 tests/Avalonia.DesignerSupport.TestApp/Avalonia.DesignerSupport.TestApp.csproj create mode 100644 tests/Avalonia.DesignerSupport.TestApp/MainWindow.xaml create mode 100644 tests/Avalonia.DesignerSupport.TestApp/MainWindow.xaml.cs create mode 100644 tests/Avalonia.DesignerSupport.TestApp/Program.cs create mode 100644 tests/Avalonia.DesignerSupport.TestApp/Properties/AssemblyInfo.cs create mode 100644 tests/Avalonia.DesignerSupport.TestApp/Properties/Resources.Designer.cs create mode 100644 tests/Avalonia.DesignerSupport.TestApp/Properties/Resources.resx create mode 100644 tests/Avalonia.DesignerSupport.TestApp/Properties/Settings.Designer.cs create mode 100644 tests/Avalonia.DesignerSupport.TestApp/Properties/Settings.settings create mode 100644 tests/Avalonia.DesignerSupport.Tests/Avalonia.DesignerSupport.Tests.csproj create mode 100644 tests/Avalonia.DesignerSupport.Tests/Checker.cs create mode 100644 tests/Avalonia.DesignerSupport.Tests/DesignerSupportTests.cs create mode 100644 tests/Avalonia.DesignerSupport.Tests/Properties/AssemblyInfo.cs create mode 100644 tests/Avalonia.DesignerSupport.Tests/packages.config diff --git a/Avalonia.sln b/Avalonia.sln index 3b885312df..d9ef7a7137 100644 --- a/Avalonia.sln +++ b/Avalonia.sln @@ -1,7 +1,6 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.25123.0 +VisualStudioVersion = 14.0.24720.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Base", "src\Avalonia.Base\Avalonia.Base.csproj", "{B09B78D8-9B26-48B0-9149-D64A2F120F3F}" EndProject @@ -153,11 +152,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ControlCatalog.iOS", "sampl EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Skia.RenderTests", "tests\Avalonia.RenderTests\Avalonia.Skia.RenderTests.csproj", "{D35A9F3D-8BB0-496E-BF72-444038A7DEBB}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.DesignerSupport.Tests", "tests\Avalonia.DesignerSupport.Tests\Avalonia.DesignerSupport.Tests.csproj", "{52F55355-D120-42AC-8116-8410A7D602FA}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.DesignerSupport.TestApp", "tests\Avalonia.DesignerSupport.TestApp\Avalonia.DesignerSupport.TestApp.csproj", "{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution src\Shared\RenderHelpers\RenderHelpers.projitems*{fb05ac90-89ba-4f2f-a924-f37875fb547c}*SharedItemsImports = 4 - src\Shared\PlatformSupport\PlatformSupport.projitems*{4488ad85-1495-4809-9aa4-ddfe0a48527e}*SharedItemsImports = 4 - src\Shared\PlatformSupport\PlatformSupport.projitems*{7b92af71-6287-4693-9dcb-bd5b6e927e23}*SharedItemsImports = 4 src\Shared\PlatformSupport\PlatformSupport.projitems*{e4d9629c-f168-4224-3f51-a5e482ffbc42}*SharedItemsImports = 13 src\Skia\Avalonia.Skia\Avalonia.Skia.projitems*{2f59f3d0-748d-4652-b01e-e0d954756308}*SharedItemsImports = 13 src\Shared\PlatformSupport\PlatformSupport.projitems*{db070a10-bf39-4752-8456-86e9d5928478}*SharedItemsImports = 4 @@ -165,16 +166,12 @@ Global src\Skia\Avalonia.Skia\Avalonia.Skia.projitems*{925dd807-b651-475f-9f7c-cbeb974ce43d}*SharedItemsImports = 4 samples\TestApplicationShared\TestApplicationShared.projitems*{78345174-5b52-4a14-b9fd-d5f2428137f0}*SharedItemsImports = 13 src\Shared\PlatformSupport\PlatformSupport.projitems*{54f237d5-a70a-4752-9656-0c70b1a7b047}*SharedItemsImports = 4 - samples\TestApplicationShared\TestApplicationShared.projitems*{ff69b927-c545-49ae-8e16-3d14d621aa12}*SharedItemsImports = 4 src\Shared\RenderHelpers\RenderHelpers.projitems*{3c4c0cb4-0c0f-4450-a37b-148c84ff905f}*SharedItemsImports = 13 src\Shared\PlatformSupport\PlatformSupport.projitems*{811a76cf-1cf6-440f-963b-bbe31bd72a82}*SharedItemsImports = 4 src\Shared\PlatformSupport\PlatformSupport.projitems*{88060192-33d5-4932-b0f9-8bd2763e857d}*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 - samples\TestApplicationShared\TestApplicationShared.projitems*{8c923867-8a8f-4f6b-8b80-47d9e8436166}*SharedItemsImports = 4 samples\TestApplicationShared\TestApplicationShared.projitems*{e3a1060b-50d0-44e8-88b6-f44ef2e5bd72}*SharedItemsImports = 4 - src\Shared\RenderHelpers\RenderHelpers.projitems*{bd43f7c0-396b-4aa1-bad9-dfde54d51298}*SharedItemsImports = 4 - src\Skia\Avalonia.Skia\Avalonia.Skia.projitems*{bd43f7c0-396b-4aa1-bad9-dfde54d51298}*SharedItemsImports = 4 src\Shared\RenderHelpers\RenderHelpers.projitems*{3e908f67-5543-4879-a1dc-08eace79b3cd}*SharedItemsImports = 4 src\Shared\PlatformSupport\PlatformSupport.projitems*{e1aa3dbf-9056-4530-9376-18119a7a3ffe}*SharedItemsImports = 4 EndGlobalSection @@ -1432,16 +1429,16 @@ Global {47BE08A7-5985-410B-9FFC-2264B8EA595F}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU {47BE08A7-5985-410B-9FFC-2264B8EA595F}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU {47BE08A7-5985-410B-9FFC-2264B8EA595F}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU - {47BE08A7-5985-410B-9FFC-2264B8EA595F}.Ad-Hoc|x86.ActiveCfg = AppStore|Any CPU - {47BE08A7-5985-410B-9FFC-2264B8EA595F}.Ad-Hoc|x86.Build.0 = AppStore|Any CPU + {47BE08A7-5985-410B-9FFC-2264B8EA595F}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU + {47BE08A7-5985-410B-9FFC-2264B8EA595F}.Ad-Hoc|x86.Build.0 = Debug|Any CPU {47BE08A7-5985-410B-9FFC-2264B8EA595F}.AppStore|Any CPU.ActiveCfg = Release|Any CPU {47BE08A7-5985-410B-9FFC-2264B8EA595F}.AppStore|Any CPU.Build.0 = Release|Any CPU {47BE08A7-5985-410B-9FFC-2264B8EA595F}.AppStore|iPhone.ActiveCfg = Release|Any CPU {47BE08A7-5985-410B-9FFC-2264B8EA595F}.AppStore|iPhone.Build.0 = Release|Any CPU {47BE08A7-5985-410B-9FFC-2264B8EA595F}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU {47BE08A7-5985-410B-9FFC-2264B8EA595F}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU - {47BE08A7-5985-410B-9FFC-2264B8EA595F}.AppStore|x86.ActiveCfg = AppStore|Any CPU - {47BE08A7-5985-410B-9FFC-2264B8EA595F}.AppStore|x86.Build.0 = AppStore|Any CPU + {47BE08A7-5985-410B-9FFC-2264B8EA595F}.AppStore|x86.ActiveCfg = Debug|Any CPU + {47BE08A7-5985-410B-9FFC-2264B8EA595F}.AppStore|x86.Build.0 = Debug|Any CPU {47BE08A7-5985-410B-9FFC-2264B8EA595F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {47BE08A7-5985-410B-9FFC-2264B8EA595F}.Debug|Any CPU.Build.0 = Debug|Any CPU {47BE08A7-5985-410B-9FFC-2264B8EA595F}.Debug|iPhone.ActiveCfg = Debug|Any CPU @@ -1506,16 +1503,16 @@ Global {4488AD85-1495-4809-9AA4-DDFE0A48527E}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU {4488AD85-1495-4809-9AA4-DDFE0A48527E}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU {4488AD85-1495-4809-9AA4-DDFE0A48527E}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU - {4488AD85-1495-4809-9AA4-DDFE0A48527E}.Ad-Hoc|x86.ActiveCfg = AppStore|Any CPU - {4488AD85-1495-4809-9AA4-DDFE0A48527E}.Ad-Hoc|x86.Build.0 = AppStore|Any CPU + {4488AD85-1495-4809-9AA4-DDFE0A48527E}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU + {4488AD85-1495-4809-9AA4-DDFE0A48527E}.Ad-Hoc|x86.Build.0 = Debug|Any CPU {4488AD85-1495-4809-9AA4-DDFE0A48527E}.AppStore|Any CPU.ActiveCfg = Release|Any CPU {4488AD85-1495-4809-9AA4-DDFE0A48527E}.AppStore|Any CPU.Build.0 = Release|Any CPU {4488AD85-1495-4809-9AA4-DDFE0A48527E}.AppStore|iPhone.ActiveCfg = Release|Any CPU {4488AD85-1495-4809-9AA4-DDFE0A48527E}.AppStore|iPhone.Build.0 = Release|Any CPU {4488AD85-1495-4809-9AA4-DDFE0A48527E}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU {4488AD85-1495-4809-9AA4-DDFE0A48527E}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU - {4488AD85-1495-4809-9AA4-DDFE0A48527E}.AppStore|x86.ActiveCfg = AppStore|Any CPU - {4488AD85-1495-4809-9AA4-DDFE0A48527E}.AppStore|x86.Build.0 = AppStore|Any CPU + {4488AD85-1495-4809-9AA4-DDFE0A48527E}.AppStore|x86.ActiveCfg = Debug|Any CPU + {4488AD85-1495-4809-9AA4-DDFE0A48527E}.AppStore|x86.Build.0 = Debug|Any CPU {4488AD85-1495-4809-9AA4-DDFE0A48527E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4488AD85-1495-4809-9AA4-DDFE0A48527E}.Debug|Any CPU.Build.0 = Debug|Any CPU {4488AD85-1495-4809-9AA4-DDFE0A48527E}.Debug|iPhone.ActiveCfg = Debug|Any CPU @@ -1836,6 +1833,70 @@ Global {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Release|iPhoneSimulator.Build.0 = Release|Any CPU {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Release|x86.ActiveCfg = Release|Any CPU {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Release|x86.Build.0 = Release|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.Ad-Hoc|x86.ActiveCfg = Release|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.Ad-Hoc|x86.Build.0 = Release|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.AppStore|Any CPU.ActiveCfg = Release|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.AppStore|Any CPU.Build.0 = Release|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.AppStore|iPhone.ActiveCfg = Release|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.AppStore|iPhone.Build.0 = Release|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.AppStore|x86.ActiveCfg = Release|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.AppStore|x86.Build.0 = Release|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.Debug|iPhone.Build.0 = Debug|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.Debug|x86.ActiveCfg = Debug|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.Debug|x86.Build.0 = Debug|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.Release|Any CPU.Build.0 = Release|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.Release|iPhone.ActiveCfg = Release|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.Release|iPhone.Build.0 = Release|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.Release|x86.ActiveCfg = Release|Any CPU + {52F55355-D120-42AC-8116-8410A7D602FA}.Release|x86.Build.0 = Release|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Ad-Hoc|x86.ActiveCfg = Release|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Ad-Hoc|x86.Build.0 = Release|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.AppStore|Any CPU.ActiveCfg = Release|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.AppStore|Any CPU.Build.0 = Release|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.AppStore|iPhone.ActiveCfg = Release|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.AppStore|iPhone.Build.0 = Release|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.AppStore|x86.ActiveCfg = Release|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.AppStore|x86.Build.0 = Release|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Debug|iPhone.Build.0 = Debug|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Debug|x86.ActiveCfg = Debug|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Debug|x86.Build.0 = Debug|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Release|Any CPU.Build.0 = Release|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Release|iPhone.ActiveCfg = Release|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Release|iPhone.Build.0 = Release|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Release|x86.ActiveCfg = Release|Any CPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1884,5 +1945,7 @@ Global {2B888490-D14A-4BCA-AB4B-48676FA93C9B} = {9B9E3891-2366-4253-A952-D08BCEB71098} {57E0455D-D565-44BB-B069-EE1AA20F8337} = {9B9E3891-2366-4253-A952-D08BCEB71098} {D35A9F3D-8BB0-496E-BF72-444038A7DEBB} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B} + {52F55355-D120-42AC-8116-8410A7D602FA} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B} + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B} EndGlobalSection EndGlobal diff --git a/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj b/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj index c56b61fc50..6f02024d86 100644 --- a/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj +++ b/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj @@ -1,4 +1,4 @@ - + @@ -59,6 +59,10 @@ + + {799a7bb5-3c2c-48b6-85a7-406a12c420da} + Avalonia.DesignerSupport + {FB05AC90-89BA-4F2F-A924-F37875FB547C} Avalonia.Cairo diff --git a/src/Avalonia.Controls/AppBuilder.cs b/src/Avalonia.Controls/AppBuilder.cs index 628fac3cc1..428b823dac 100644 --- a/src/Avalonia.Controls/AppBuilder.cs +++ b/src/Avalonia.Controls/AppBuilder.cs @@ -55,6 +55,18 @@ namespace Avalonia.Controls return this; } + public AppBuilder WithWindowingSubsystem(Action initializer) + { + WindowingSubsystem = initializer; + return this; + } + + public AppBuilder WithRenderingSubsystem(Action initializer) + { + RenderingSubsystem = initializer; + return this; + } + public void Setup() { if (Instance == null) diff --git a/src/Avalonia.DesignerSupport/DesignerAssist.cs b/src/Avalonia.DesignerSupport/DesignerAssist.cs index f7db384dec..d0b50802b5 100644 --- a/src/Avalonia.DesignerSupport/DesignerAssist.cs +++ b/src/Avalonia.DesignerSupport/DesignerAssist.cs @@ -20,11 +20,8 @@ namespace Avalonia.DesignerSupport { class DesignerApp : Application { - public DesignerApp() + public override void Initialize() { - RegisterServices(); - //For now we only support windows - InitializeSubsystems(2); Styles.Add(new DefaultTheme()); var loader = new AvaloniaXamlLoader(); @@ -40,30 +37,32 @@ namespace Avalonia.DesignerSupport { Design.IsDesignMode = true; Api = new DesignerApi(shared) {UpdateXaml = UpdateXaml, SetScalingFactor = SetScalingFactor}; - Application.RegisterPlatformCallback(Application.InitializeWin32Subsystem); - var plat = (IPclPlatformWrapper) Activator.CreateInstance(Assembly.Load(new AssemblyName("Avalonia.Win32")) .DefinedTypes.First(typeof (IPclPlatformWrapper).GetTypeInfo().IsAssignableFrom).AsType()); + TypeInfo app = null; - foreach (var asm in plat.GetLoadedAssemblies()) + var asms = plat.GetLoadedAssemblies(); + foreach (var asm in asms) { - if(Equals(asm, typeof(Application).GetTypeInfo().Assembly)) + if(Equals(asm, typeof(Application).GetTypeInfo().Assembly) || Equals(asm, typeof(DesignerApp).GetTypeInfo().Assembly)) continue; try { app = asm.DefinedTypes.Where(typeof (Application).GetTypeInfo().IsAssignableFrom).FirstOrDefault(); if (app != null) break; + } catch { //Ignore, Assembly.DefinedTypes threw an exception, we can't do anything about that } } - if (app == null) - new DesignerApp(); - else - Activator.CreateInstance(app.AsType()); + + AppBuilder.Configure(app == null ? new DesignerApp() : (Application) Activator.CreateInstance(app.AsType())) + .WithWindowingSubsystem(Application.InitializeWin32Subsystem) + .WithRenderingSubsystem(() => { }) + .Setup(); } private static void SetScalingFactor(double factor) diff --git a/tests/Avalonia.DesignerSupport.TestApp/App.config b/tests/Avalonia.DesignerSupport.TestApp/App.config new file mode 100644 index 0000000000..8324aa6ff1 --- /dev/null +++ b/tests/Avalonia.DesignerSupport.TestApp/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/tests/Avalonia.DesignerSupport.TestApp/App.xaml b/tests/Avalonia.DesignerSupport.TestApp/App.xaml new file mode 100644 index 0000000000..214bcd8797 --- /dev/null +++ b/tests/Avalonia.DesignerSupport.TestApp/App.xaml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/tests/Avalonia.DesignerSupport.TestApp/App.xaml.cs b/tests/Avalonia.DesignerSupport.TestApp/App.xaml.cs new file mode 100644 index 0000000000..f9407a4708 --- /dev/null +++ b/tests/Avalonia.DesignerSupport.TestApp/App.xaml.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Avalonia.Markup.Xaml; + +namespace Avalonia.DesignerSupport.TestApp +{ + public class App : Application + { + + public App() + { + RegisterServices(); + } + + public override void Initialize() + { + AvaloniaXamlLoader.Load(this); + } + } +} diff --git a/tests/Avalonia.DesignerSupport.TestApp/Avalonia.DesignerSupport.TestApp.csproj b/tests/Avalonia.DesignerSupport.TestApp/Avalonia.DesignerSupport.TestApp.csproj new file mode 100644 index 0000000000..7f318da083 --- /dev/null +++ b/tests/Avalonia.DesignerSupport.TestApp/Avalonia.DesignerSupport.TestApp.csproj @@ -0,0 +1,153 @@ + + + + + Debug + AnyCPU + {F1381F98-4D24-409A-A6C5-1C5B1E08BB08} + WinExe + Properties + Avalonia.DesignerSupport.TestApp + Avalonia.DesignerSupport.TestApp + v4.6 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + App.xaml + + + MainWindow.xaml + + + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + Designer + MSBuild:Compile + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + Designer + MSBuild:Compile + + + + + + + + {d211e587-d8bc-45b9-95a4-f297c8fa5200} + Avalonia.Animation + + + {b09b78d8-9b26-48b0-9149-d64a2f120f3f} + Avalonia.Base + + + {d2221c82-4a25-4583-9b43-d791e3f6820c} + Avalonia.Controls + + + {799a7bb5-3c2c-48b6-85a7-406a12c420da} + Avalonia.DesignerSupport + + + {62024b2d-53eb-4638-b26b-85eeaa54866e} + Avalonia.Input + + + {6b0ed19d-a08b-461c-a9d9-a9ee40b0c06b} + Avalonia.Interactivity + + + {42472427-4774-4c81-8aff-9f27b8e31721} + Avalonia.Layout + + + {eb582467-6abb-43a1-b052-e981ba910e3a} + Avalonia.SceneGraph + + + {f1baa01a-f176-4c6a-b39d-5b40bb1b148f} + Avalonia.Styling + + + {3e10a5fa-e8da-48b1-ad44-6a5b6cb7750f} + Avalonia.Themes.Default + + + {3e53a01a-b331-47f3-b828-4a5717e77a24} + Avalonia.Markup.Xaml + + + {6417e941-21bc-467b-a771-0de389353ce6} + Avalonia.Markup + + + {3e908f67-5543-4879-a1dc-08eace79b3cd} + Avalonia.Direct2D1 + + + {811a76cf-1cf6-440f-963b-bbe31bd72a82} + Avalonia.Win32 + + + + + \ No newline at end of file diff --git a/tests/Avalonia.DesignerSupport.TestApp/MainWindow.xaml b/tests/Avalonia.DesignerSupport.TestApp/MainWindow.xaml new file mode 100644 index 0000000000..6938bd8c49 --- /dev/null +++ b/tests/Avalonia.DesignerSupport.TestApp/MainWindow.xaml @@ -0,0 +1,5 @@ + +