diff --git a/Avalonia.sln b/Avalonia.sln
index 7b4a359f06..9cf93e8a84 100644
--- a/Avalonia.sln
+++ b/Avalonia.sln
@@ -1,4 +1,3 @@
-
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2027
@@ -15,8 +14,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Win32", "src\Windo
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Direct2D1", "src\Windows\Avalonia.Direct2D1\Avalonia.Direct2D1.csproj", "{3E908F67-5543-4879-A1DC-08EACE79B3CD}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Designer", "src\Windows\Avalonia.Designer\Avalonia.Designer.csproj", "{EC42600F-049B-43FF-AED1-8314D61B2749}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Input", "src\Avalonia.Input\Avalonia.Input.csproj", "{62024B2D-53EB-4638-B26B-85EEAA54866E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Interactivity", "src\Avalonia.Interactivity\Avalonia.Interactivity.csproj", "{6B0ED19D-A08B-461C-A9D9-A9EE40B0C06B}"
@@ -104,7 +101,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.DesignerSupport",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "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}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ControlCatalog.Desktop", "samples\ControlCatalog.Desktop\ControlCatalog.Desktop.csproj", "{2B888490-D14A-4BCA-AB4B-48676FA93C9B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ControlCatalog.iOS", "samples\ControlCatalog.iOS\ControlCatalog.iOS.csproj", "{57E0455D-D565-44BB-B069-EE1AA20F8337}"
EndProject
@@ -410,38 +407,6 @@ Global
{3E908F67-5543-4879-A1DC-08EACE79B3CD}.Release|NetCoreOnly.ActiveCfg = Release|Any CPU
{3E908F67-5543-4879-A1DC-08EACE79B3CD}.Release|x86.ActiveCfg = Release|Any CPU
{3E908F67-5543-4879-A1DC-08EACE79B3CD}.Release|x86.Build.0 = Release|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.Ad-Hoc|NetCoreOnly.ActiveCfg = Debug|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.AppStore|Any CPU.Build.0 = Release|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.AppStore|iPhone.ActiveCfg = Release|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.AppStore|iPhone.Build.0 = Release|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.AppStore|NetCoreOnly.ActiveCfg = Debug|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.AppStore|x86.ActiveCfg = Debug|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.Debug|iPhone.ActiveCfg = Debug|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.Debug|iPhone.Build.0 = Debug|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.Debug|NetCoreOnly.ActiveCfg = Debug|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.Debug|x86.ActiveCfg = Debug|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.Release|Any CPU.Build.0 = Release|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.Release|iPhone.ActiveCfg = Release|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.Release|iPhone.Build.0 = Release|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.Release|NetCoreOnly.ActiveCfg = Release|Any CPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}.Release|x86.ActiveCfg = Release|Any CPU
{62024B2D-53EB-4638-B26B-85EEAA54866E}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU
{62024B2D-53EB-4638-B26B-85EEAA54866E}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU
{62024B2D-53EB-4638-B26B-85EEAA54866E}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU
@@ -1699,6 +1664,7 @@ Global
{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|NetCoreOnly.ActiveCfg = Debug|Any CPU
+ {52F55355-D120-42AC-8116-8410A7D602FA}.Debug|NetCoreOnly.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
@@ -1708,6 +1674,7 @@ Global
{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|NetCoreOnly.ActiveCfg = Release|Any CPU
+ {52F55355-D120-42AC-8116-8410A7D602FA}.Release|NetCoreOnly.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
@@ -1735,6 +1702,7 @@ Global
{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|NetCoreOnly.ActiveCfg = Debug|Any CPU
+ {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Debug|NetCoreOnly.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
@@ -1744,6 +1712,7 @@ Global
{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|NetCoreOnly.ActiveCfg = Release|Any CPU
+ {F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Release|NetCoreOnly.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
{FBCAF3D0-2808-4934-8E96-3F607594517B}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU
@@ -2371,6 +2340,7 @@ Global
{050CC912-FF49-4A8B-B534-9544017446DD}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{050CC912-FF49-4A8B-B534-9544017446DD}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{050CC912-FF49-4A8B-B534-9544017446DD}.Debug|NetCoreOnly.ActiveCfg = Debug|Any CPU
+ {050CC912-FF49-4A8B-B534-9544017446DD}.Debug|NetCoreOnly.Build.0 = Debug|Any CPU
{050CC912-FF49-4A8B-B534-9544017446DD}.Debug|x86.ActiveCfg = Debug|Any CPU
{050CC912-FF49-4A8B-B534-9544017446DD}.Debug|x86.Build.0 = Debug|Any CPU
{050CC912-FF49-4A8B-B534-9544017446DD}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -2380,6 +2350,7 @@ Global
{050CC912-FF49-4A8B-B534-9544017446DD}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{050CC912-FF49-4A8B-B534-9544017446DD}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{050CC912-FF49-4A8B-B534-9544017446DD}.Release|NetCoreOnly.ActiveCfg = Release|Any CPU
+ {050CC912-FF49-4A8B-B534-9544017446DD}.Release|NetCoreOnly.Build.0 = Release|Any CPU
{050CC912-FF49-4A8B-B534-9544017446DD}.Release|x86.ActiveCfg = Release|Any CPU
{050CC912-FF49-4A8B-B534-9544017446DD}.Release|x86.Build.0 = Release|Any CPU
{F40FC0A2-1BC3-401C-BFC1-928EC4D4A9CE}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU
@@ -2505,7 +2476,6 @@ Global
GlobalSection(NestedProjects) = preSolution
{811A76CF-1CF6-440F-963B-BBE31BD72A82} = {B39A8919-9F95-48FE-AD7B-76E08B509888}
{3E908F67-5543-4879-A1DC-08EACE79B3CD} = {B39A8919-9F95-48FE-AD7B-76E08B509888}
- {EC42600F-049B-43FF-AED1-8314D61B2749} = {B39A8919-9F95-48FE-AD7B-76E08B509888}
{47ECDF59-DEF8-4C53-87B1-2098A3429059} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B}
{5CCB5571-7C30-4E7D-967D-0E2158EBD91F} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B}
{76716382-3159-460E-BDA6-C5715CF606D7} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B}
diff --git a/build.cake b/build.cake
index aa35d88aac..1c796e8594 100644
--- a/build.cake
+++ b/build.cake
@@ -93,7 +93,6 @@ Task("Clean")
CleanDirectory(parameters.NugetRoot);
CleanDirectory(parameters.ZipRoot);
CleanDirectory(parameters.BinRoot);
- CleanDirectory(parameters.DesignerTestsRoot);
});
Task("Restore-NuGet-Packages")
@@ -183,7 +182,7 @@ void RunCoreTest(string project, Parameters parameters, bool coreOnly = false)
Task("Run-Unit-Tests")
.IsDependentOn("Build")
- .IsDependentOn("Run-Designer-Unit-Tests")
+ .IsDependentOn("Run-Designer-Tests")
.IsDependentOn("Run-Render-Tests")
.WithCriteria(() => !parameters.SkipTests)
.Does(() => {
@@ -202,6 +201,13 @@ Task("Run-Unit-Tests")
}
});
+Task("Run-Designer-Tests")
+ .IsDependentOn("Build")
+ .WithCriteria(() => !parameters.SkipTests)
+ .Does(() => {
+ RunCoreTest("./tests/Avalonia.DesignerSupport.Tests", parameters, false);
+ });
+
Task("Run-Render-Tests")
.IsDependentOn("Build")
.WithCriteria(() => !parameters.SkipTests && parameters.IsRunningOnWindows)
@@ -210,25 +216,6 @@ Task("Run-Render-Tests")
RunCoreTest("./tests/Avalonia.Direct2D1.RenderTests/Avalonia.Direct2D1.RenderTests.csproj", parameters, true);
});
-Task("Run-Designer-Unit-Tests")
- .IsDependentOn("Build")
- .WithCriteria(() => !parameters.SkipTests && parameters.IsRunningOnWindows)
- .Does(() =>
-{
- var toolPath = (parameters.IsPlatformAnyCPU || parameters.IsPlatformX86) ?
- Context.Tools.Resolve("xunit.console.x86.exe") :
- Context.Tools.Resolve("xunit.console.exe");
-
- var xUnitSettings = new XUnit2Settings
- {
- ToolPath = toolPath,
- Parallelism = ParallelismOption.None,
- ShadowCopy = false,
- };
-
- XUnit2("./artifacts/designer-tests/Avalonia.DesignerSupport.Tests.dll", xUnitSettings);
-});
-
Task("Copy-Files")
.IsDependentOn("Run-Unit-Tests")
.Does(() =>
@@ -376,7 +363,6 @@ Task("Inspect")
{
var badIssues = new []{"PossibleNullReferenceException"};
var whitelist = new []{"tests", "src\\android", "src\\ios",
- "src\\windows\\avalonia.designer",
"src\\markup\\avalonia.markup.xaml\\portablexaml\\portable.xaml.github"};
Information("Running code inspections");
diff --git a/build/XUnit.props b/build/XUnit.props
index 1d7da7257d..15412d19e7 100644
--- a/build/XUnit.props
+++ b/build/XUnit.props
@@ -8,7 +8,7 @@
-
+
diff --git a/parameters.cake b/parameters.cake
index 9e6eaa9d27..759846c658 100644
--- a/parameters.cake
+++ b/parameters.cake
@@ -30,7 +30,6 @@ public class Parameters
public DirectoryPath NugetRoot { get; private set; }
public DirectoryPath ZipRoot { get; private set; }
public DirectoryPath BinRoot { get; private set; }
- public DirectoryPath DesignerTestsRoot { get; private set; }
public string DirSuffix { get; private set; }
public string DirSuffixIOS { get; private set; }
public DirectoryPathCollection BuildDirs { get; private set; }
@@ -106,7 +105,6 @@ public class Parameters
NugetRoot = ArtifactsDir.Combine("nuget");
ZipRoot = ArtifactsDir.Combine("zip");
BinRoot = ArtifactsDir.Combine("bin");
- DesignerTestsRoot = ArtifactsDir.Combine("designer-tests");
BuildDirs = context.GetDirectories("**/bin") + context.GetDirectories("**/obj");
diff --git a/src/Avalonia.DesignerSupport/DesignerApi.cs b/src/Avalonia.DesignerSupport/DesignerApi.cs
deleted file mode 100644
index cbbfbffec8..0000000000
--- a/src/Avalonia.DesignerSupport/DesignerApi.cs
+++ /dev/null
@@ -1,92 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Avalonia.DesignerSupport
-{
- class DesignerApiDictionary
- {
- public Dictionary Dictionary { get; set; }
-
- public DesignerApiDictionary(Dictionary dictionary)
- {
- Dictionary = dictionary;
- }
-
- protected object Get([CallerMemberName] string name = null)
- {
- object rv;
- Dictionary.TryGetValue(name, out rv);
- return rv;
- }
-
- protected void Set(object value, [CallerMemberName] string name = null)
- {
- Dictionary[name] = value;
- }
- }
-
- class DesignerApi : DesignerApiDictionary
- {
- public Action UpdateXaml
- {
- get { return (Action) Get(); }
- set {Set(value); }
- }
-
- public Action> UpdateXaml2
- {
- get { return (Action>)Get(); }
- set { Set(value); }
- }
-
- public Action OnResize
- {
- get { return (Action) Get(); }
- set { Set(value);}
- }
-
- public Action OnWindowCreated
- {
- set { Set(value); }
- get { return (Action) Get(); }
- }
-
- public Action SetScalingFactor
- {
- set { Set(value);}
- get { return (Action) Get(); }
- }
-
- public DesignerApi(Dictionary dictionary) : base(dictionary)
- {
- }
- }
-
- class DesignerApiXamlFileInfo : DesignerApiDictionary
- {
- public string Xaml
- {
- get { return (string)Get(); }
- set { Set(value); }
- }
-
- public string AssemblyPath
- {
- get { return (string) Get(); }
- set { Set(value); }
- }
-
- public DesignerApiXamlFileInfo(Dictionary dictionary) : base(dictionary)
- {
- }
-
- public DesignerApiXamlFileInfo(): base(new Dictionary())
- {
-
- }
- }
-}
diff --git a/src/Avalonia.DesignerSupport/DesignerAssist.cs b/src/Avalonia.DesignerSupport/DesignerAssist.cs
deleted file mode 100644
index f6f704b838..0000000000
--- a/src/Avalonia.DesignerSupport/DesignerAssist.cs
+++ /dev/null
@@ -1,100 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-using System.Linq;
-using System.Reflection;
-using System.Text;
-using Avalonia.Controls;
-using Avalonia.Controls.Platform;
-using Avalonia.Markup.Xaml;
-using Avalonia.Platform;
-using Avalonia.Styling;
-using Avalonia.Themes.Default;
-
-namespace Avalonia.DesignerSupport
-{
- class DesignerAssist
- {
- class DesignerApp : Application
- {
- public override void Initialize()
- {
- Styles.Add(new DefaultTheme());
-
- var loader = new AvaloniaXamlLoader();
- var baseLight = (IStyle)loader.Load(
- new Uri("resm:Avalonia.Themes.Default.Accents.BaseLight.xaml?assembly=Avalonia.Themes.Default"), null);
- Styles.Add(baseLight);
- }
- }
-
- public static DesignerApi Api { get; set; }
-
- public static void Init(Dictionary shared)
- {
- Design.IsDesignMode = true;
- Api = new DesignerApi(shared) {UpdateXaml = UpdateXaml, UpdateXaml2 = UpdateXaml2, SetScalingFactor = SetScalingFactor};
-
- var runtimeAssembly = Assembly.Load(new AssemblyName("Avalonia.DotNetFrameworkRuntime"));
-
- var plat = (IRuntimePlatform) Activator.CreateInstance(runtimeAssembly
- .DefinedTypes.First(typeof (IRuntimePlatform).GetTypeInfo().IsAssignableFrom).AsType());
-
- TypeInfo app = null;
- var asms = plat.GetLoadedAssemblies();
- foreach (var asm in asms)
- {
- 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
- }
- }
-
- var builderType = runtimeAssembly.GetType("Avalonia.AppBuilder");
-
- var builder = (dynamic)Activator.CreateInstance(builderType,
- app == null ? new DesignerApp() : (Application) Activator.CreateInstance(app.AsType()));
- builder
- .UseWindowingSubsystem("Avalonia.Win32")
- .UseRenderingSubsystem("Avalonia.Direct2D1")
- .SetupWithoutStarting();
- }
-
- private static void SetScalingFactor(double factor)
- {
- PlatformManager.SetDesignerScalingFactor(factor);
- s_currentWindow?.PlatformImpl?.Resize(s_currentWindow.ClientSize);
- }
-
- static Window s_currentWindow;
-
- private static void UpdateXaml(string xaml) => UpdateXaml2(new DesignerApiXamlFileInfo
- {
- Xaml = xaml
- }.Dictionary);
-
- private static void UpdateXaml2(Dictionary dic)
- {
- var xamlInfo = new DesignerApiXamlFileInfo(dic);
- Window window = DesignWindowLoader.LoadDesignerWindow(xamlInfo.Xaml, xamlInfo.AssemblyPath);
-
- s_currentWindow?.Close();
- s_currentWindow = window;
-
- // ReSharper disable once PossibleNullReferenceException
- // Always not null at this point
- Api.OnWindowCreated?.Invoke(window.PlatformImpl.Handle.Handle);
- Api.OnResize?.Invoke();
- }
- }
-}
diff --git a/src/Windows/Avalonia.Designer/App.config b/src/Windows/Avalonia.Designer/App.config
deleted file mode 100644
index d1428ad712..0000000000
--- a/src/Windows/Avalonia.Designer/App.config
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/src/Windows/Avalonia.Designer/App.xaml b/src/Windows/Avalonia.Designer/App.xaml
deleted file mode 100644
index 720e53c1c2..0000000000
--- a/src/Windows/Avalonia.Designer/App.xaml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
diff --git a/src/Windows/Avalonia.Designer/App.xaml.cs b/src/Windows/Avalonia.Designer/App.xaml.cs
deleted file mode 100644
index 20d836cda6..0000000000
--- a/src/Windows/Avalonia.Designer/App.xaml.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
-
-namespace Avalonia.Designer
-{
- ///
- /// Interaction logic for App.xaml
- ///
- internal partial class App
- {
- public App()
- {
- InitializeComponent();
- }
- }
-}
diff --git a/src/Windows/Avalonia.Designer/AppHost/AvaloniaAppHost.cs b/src/Windows/Avalonia.Designer/AppHost/AvaloniaAppHost.cs
deleted file mode 100644
index d06e4929fa..0000000000
--- a/src/Windows/Avalonia.Designer/AppHost/AvaloniaAppHost.cs
+++ /dev/null
@@ -1,225 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Reflection;
-using System.Text;
-using System.Threading;
-using System.Windows.Forms;
-using System.Windows.Forms.Integration;
-using System.Xml;
-using Avalonia.Designer.Comm;
-using Avalonia.Designer.InProcDesigner;
-using Timer = System.Windows.Forms.Timer;
-using Avalonia.DesignerSupport;
-
-namespace Avalonia.Designer.AppHost
-{
- class AvaloniaAppHost
- {
- private string _appDir;
- private readonly CommChannel _comm;
- private string _lastXaml;
- private string _currentXaml;
- private string _currentSourceAssembly;
- private bool _initSuccess;
- private readonly HostedAppModel _appModel;
- private Control _window;
-
- public AvaloniaAppHost(CommChannel channel)
- {
- _comm = channel;
- _appModel = new HostedAppModel(this);
- }
-
- public void Start()
- {
- AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
- _comm.OnMessage += Channel_OnMessage;
- _comm.Start();
- }
-
- private void Channel_OnMessage(object obj)
- {
- var init = obj as InitMessage;
- if (init != null)
- {
- Init(init.TargetExe);
- }
- var updateXaml = obj as UpdateXamlMessage;
- if (updateXaml != null)
- {
- _currentXaml = updateXaml.Xaml;
- _currentSourceAssembly = updateXaml.AssemblyPath;
- }
- }
-
- void UpdateState(string state)
- {
- _comm.SendMessage(new StateMessage(state));
- }
-
- Type LookupType(params string[] names)
- {
- var asms = AppDomain.CurrentDomain.GetAssemblies();
- foreach (var asm in asms)
- {
- foreach (var name in names)
- {
- var found = asm.GetType(name, false, true);
- if (found != null)
- return found;
- }
- }
- throw new TypeLoadException("Unable to find any of types: " + string.Join(",", names));
- }
-
- private MethodInfo LookupStaticMethod(string typeName, string method)
- {
- var type = LookupType(typeName);
- var methods = type.GetMethods();
- return methods.First(m => m.Name == method);
- }
-
- private void Init(string targetExe)
- {
- var log = new StringBuilder();
- try
- {
- DoInit(targetExe, log);
- }
- catch (Exception e)
- {
- UpdateState("Unable to load Avalonia:\n\n" + e + "\n\n" + log);
- }
- }
-
-
-
- private void DoInit(string targetExe, StringBuilder logger)
- {
- _appDir = Path.GetFullPath(Path.GetDirectoryName(targetExe));
- Directory.SetCurrentDirectory(_appDir);
- Action log = s =>
- {
- UpdateState(s);
- logger.AppendLine(s);
- };
- log("Loading assemblies from " + _appDir);
- var asms = new List();
- foreach(var asm in Directory.GetFiles(_appDir).Where(f=>f.ToLower().EndsWith(".dll")||f.ToLower().EndsWith(".exe")))
- try
- {
- log("Trying to load " + asm);
- asms.Add(Assembly.LoadFrom(asm));
- }
- catch (Exception e)
- {
- logger.AppendLine(e.ToString());
- }
-
- log("Initializing built-in designer");
- var dic = new Dictionary();
- Api = new DesignerApi(dic) {OnResize = OnResize, OnWindowCreated = OnWindowCreated};
- LookupStaticMethod("Avalonia.DesignerSupport.DesignerAssist", "Init").Invoke(null, new object[] {dic});
-
- _window = new Control
- {
- Controls =
- {
- new ElementHost()
- {
- Child = new InProcDesignerView(_appModel),
- Dock = DockStyle.Fill
- }
- }
- };
- _window.CreateControl();
-
- new Timer {Interval = 200, Enabled = true}.Tick += delegate { XamlUpdater(); };
- _comm.SendMessage(new WindowCreatedMessage(_window.Handle));
- _initSuccess = true;
- }
-
- private void OnWindowCreated(IntPtr hWnd)
- {
- _appModel.NativeWindowHandle = hWnd;
- }
-
-
- public DesignerApi Api { get; set; }
-
-
- bool ValidateXml(string xml)
- {
- try
- {
- var rdr = new XmlTextReader(new StringReader(xml));
- while (rdr.Read())
- {
-
- }
- }
- catch
- {
- return false;
- }
- return true;
- }
-
- private void OnResize()
- {
-
- }
-
- void XamlUpdater()
- {
- if (!_initSuccess)
- return;
- if(_lastXaml == _currentXaml)
- return;
- _lastXaml = _currentXaml;
-
- if (!ValidateXml(_currentXaml))
- {
- _appModel.SetError("Invalid markup");
- return;
- }
- try
- {
- if (Api.UpdateXaml2 != null)
- {
- Api.UpdateXaml2(new DesignerApiXamlFileInfo
- {
- AssemblyPath = _currentSourceAssembly,
- Xaml = _currentXaml
- }.Dictionary);
- }
- else
- Api.UpdateXaml(_currentXaml);
-
- _appModel.SetError(null);
- }
- catch (Exception e)
- {
- _appModel.SetError("XAML load error", e.ToString());
- }
- }
-
-
-
- private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
- {
- string assemblyPath = Path.Combine(_appDir, new AssemblyName(args.Name).Name + ".dll");
- if (File.Exists(assemblyPath) == false) return null;
- Assembly assembly = Assembly.LoadFrom(assemblyPath);
- return assembly;
- }
- }
-
- static class Helper
- {
- public static object Prop(this object obj, string name) => obj.GetType().GetProperty(name).GetValue(obj);
-
- }
-}
diff --git a/src/Windows/Avalonia.Designer/AppHost/HostedAppModel.cs b/src/Windows/Avalonia.Designer/AppHost/HostedAppModel.cs
deleted file mode 100644
index b5d0687baa..0000000000
--- a/src/Windows/Avalonia.Designer/AppHost/HostedAppModel.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Media;
-using JetBrains.Annotations;
-
-namespace Avalonia.Designer.AppHost
-{
- public class HostedAppModel : INotifyPropertyChanged
- {
- private readonly AvaloniaAppHost _host;
- private IntPtr _nativeWindowHandle;
- private string _error;
- private string _errorDetails;
-
- internal HostedAppModel(AvaloniaAppHost host)
- {
- _host = host;
- Background = Settings.Background;
- }
-
- public IntPtr NativeWindowHandle
- {
- get { return _nativeWindowHandle; }
- set
- {
- if (value.Equals(_nativeWindowHandle)) return;
- _nativeWindowHandle = value;
- OnPropertyChanged();
- }
- }
-
- public string Error
- {
- get { return _error; }
- private set
- {
- if (value == _error) return;
- _error = value;
- OnPropertyChanged();
- }
- }
-
- public string ErrorDetails
- {
- get { return _errorDetails; }
- private set
- {
- if (value == _errorDetails) return;
- _errorDetails = value;
- OnPropertyChanged();
- }
- }
-
- public string Background
- {
- get { return _background; }
- set
- {
- if (value == _background) return;
- _background = value;
- OnPropertyChanged();
- }
- }
-
- public IReadOnlyList AvailableScalingFactors => new List() {1, 2, 4, 8};
-
- public double CurrentScalingFactor
- {
- get { return _currentScalingFactor; }
- set
- {
- _currentScalingFactor = value;
- _host.Api.SetScalingFactor(value);
- }
- }
-
- public void SetError(string error, string details = null)
- {
- Error = error;
- ErrorDetails = details;
- }
-
- double _currentScalingFactor = 1;
- private string _background;
-
- public event PropertyChangedEventHandler PropertyChanged;
-
- [NotifyPropertyChangedInvocator]
- protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
- {
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
- }
- }
-}
diff --git a/src/Windows/Avalonia.Designer/AppHost/WindowHost.cs b/src/Windows/Avalonia.Designer/AppHost/WindowHost.cs
deleted file mode 100644
index 998df93949..0000000000
--- a/src/Windows/Avalonia.Designer/AppHost/WindowHost.cs
+++ /dev/null
@@ -1,143 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Linq;
-using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-namespace Avalonia.Designer.AppHost
-{
- class WindowHost : UserControl
- {
- private readonly bool _supportScroll;
-
- public WindowHost(bool supportScroll)
- {
- _supportScroll = supportScroll;
- if (_supportScroll)
- {
- AutoScroll = true;
- VerticalScroll.Enabled = true;
- HorizontalScroll.Enabled = true;
- }
- SetStyle(ControlStyles.AllPaintingInWmPaint, true);
- Controls.Add(_windowHost);
- _windowHost.Anchor = AnchorStyles.None;
- if (!supportScroll)
- _windowHost.Visible = false;
- _timer.Tick += delegate
- {
- ReloadSettings();
- FixWindow();
- };
- }
-
- private void ReloadSettings()
- {
- var bkg = Settings.Background;
- var color = System.Drawing.ColorTranslator.FromHtml(bkg);
- if (BackColor != color)
- BackColor = color;
- }
-
- private readonly Control _windowHost = new Control() {Text = "WindowWrapper"};
- private readonly Timer _timer = new Timer {Enabled = true, Interval = 50};
- private IntPtr _hWnd;
- private int _desiredWidth;
- private int _desiredHeight;
-
- private const int WM_HSCROLL = 0x114;
- private const int WM_VSCROLL = 0x115;
-
- protected override void WndProc(ref Message m)
- {
- if ((m.Msg == WM_HSCROLL || m.Msg == WM_VSCROLL)
- && (((int) m.WParam & 0xFFFF) == 5))
- {
- // Change SB_THUMBTRACK to SB_THUMBPOSITION
- m.WParam = (IntPtr) (((int) m.WParam & ~0xFFFF) | 4);
- }
- base.WndProc(ref m);
- }
-
- protected override void OnPaint(PaintEventArgs e)
- {
- using (var b = new SolidBrush(BackColor))
- e.Graphics.FillRectangle(b, e.ClipRectangle);
- }
-
- void FixPosition()
- {
- var newScrollSize = new Size(_desiredWidth, _desiredHeight);
- if (AutoScrollMinSize != newScrollSize)
- AutoScrollMinSize = newScrollSize;
-
- var width = Width - AutoScrollMargin.Width;
- var height = Height - AutoScrollMargin.Height;
- var x = Math.Max(0, (width - _windowHost.Width)/2);
- var y = Math.Max(0, (height - _windowHost.Height)/2);
-
- var newLoc = new Point(x - HorizontalScroll.Value, y - VerticalScroll.Value);
- if(_windowHost.Location != newLoc)
- _windowHost.Location = newLoc;
- }
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- _timer.Dispose();
- }
- base.Dispose(disposing);
- }
-
- public void SetWindow(IntPtr hWnd)
- {
- if (_hWnd != IntPtr.Zero)
- WinApi.SendMessage(_hWnd, WinApi.WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
- _hWnd = hWnd;
- if (_hWnd != IntPtr.Zero)
- {
- WinApi.SetParent(hWnd, _supportScroll ? _windowHost.Handle : Handle);
- FixWindow();
- }
- }
-
- void FixWindow()
- {
- if (_hWnd != IntPtr.Zero)
- {
- if (_supportScroll)
- {
- WinApi.RECT rc;
- WinApi.GetWindowRect(_hWnd, out rc);
- _desiredWidth = rc.Right - rc.Left;
- _desiredHeight = rc.Bottom - rc.Top;
- var pt = _windowHost.PointToClient(new Point(rc.Left, rc.Top));
-
- if (
- !(pt.Y == 0 && pt.X == 0 && _desiredWidth == _windowHost.Width &&
- _desiredHeight == _windowHost.Height))
- {
- _windowHost.Width = _desiredWidth;
- _windowHost.Height = _desiredHeight;
- WinApi.MoveWindow(_hWnd, 0, 0, _desiredWidth, _desiredHeight, true);
- }
- FixPosition();
- }
- else
- {
- WinApi.MoveWindow(_hWnd, 0, 0, Width, Height, true);
- }
- }
- }
-
- protected override void OnResize(EventArgs e)
- {
- FixWindow();
- base.OnResize(e);
- }
- }
-}
diff --git a/src/Windows/Avalonia.Designer/Avalonia.Designer.csproj b/src/Windows/Avalonia.Designer/Avalonia.Designer.csproj
deleted file mode 100644
index 4fdd06c9ce..0000000000
--- a/src/Windows/Avalonia.Designer/Avalonia.Designer.csproj
+++ /dev/null
@@ -1,126 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {EC42600F-049B-43FF-AED1-8314D61B2749}
- WinExe
- Properties
- Avalonia.Designer
- Avalonia.Designer
- v4.5
- 512
- true
- PackageReference
-
-
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
- true
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
- true
-
-
- avalonia.designer.snk
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- DesignerApi.cs
-
-
- App.xaml
-
-
-
-
- UserControl
-
-
-
-
-
-
-
-
- DemoWindow.xaml
-
-
- InProcDesignerView.xaml
-
-
- AvaloniaDesigner.xaml
-
-
-
-
-
-
-
-
-
-
-
-
- Designer
- MSBuild:Compile
-
-
- Designer
- MSBuild:Compile
-
-
- Designer
- MSBuild:Compile
-
-
- Designer
- MSBuild:Compile
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Windows/Avalonia.Designer/AvaloniaDesigner.xaml b/src/Windows/Avalonia.Designer/AvaloniaDesigner.xaml
deleted file mode 100644
index 7ed9223a22..0000000000
--- a/src/Windows/Avalonia.Designer/AvaloniaDesigner.xaml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Windows/Avalonia.Designer/AvaloniaDesigner.xaml.cs b/src/Windows/Avalonia.Designer/AvaloniaDesigner.xaml.cs
deleted file mode 100644
index e61ba01a96..0000000000
--- a/src/Windows/Avalonia.Designer/AvaloniaDesigner.xaml.cs
+++ /dev/null
@@ -1,142 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Forms.Integration;
-using System.Windows.Input;
-using System.Windows.Interop;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
-using Avalonia.Designer.AppHost;
-using Avalonia.Designer.Comm;
-
-namespace Avalonia.Designer
-{
- ///
- /// Interaction logic for PerpexDesigner.xaml
- ///
- public partial class AvaloniaDesigner
- {
- public static readonly DependencyProperty TargetExeProperty = DependencyProperty.Register(
- "TargetExe", typeof (string), typeof (AvaloniaDesigner), new FrameworkPropertyMetadata(TargetExeChanged));
-
- private static void TargetExeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- ((AvaloniaDesigner) d).RestartProcess();
- }
- public string TargetExe
- {
- get { return (string) GetValue(TargetExeProperty); }
- set { SetValue(TargetExeProperty, value); }
- }
-
- public static readonly DependencyProperty XamlProperty = DependencyProperty.Register(
- "Xaml", typeof (string), typeof (AvaloniaDesigner), new FrameworkPropertyMetadata(XamlChanged));
-
- private static void XamlChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- ((AvaloniaDesigner) d).OnXamlChanged();
- }
-
- public string Xaml
- {
- get { return (string) GetValue(XamlProperty); }
- set { SetValue(XamlProperty, value); }
- }
-
- public static readonly DependencyProperty SourceAssemblyProperty = DependencyProperty.Register(
- "SourceAssembly", typeof (string), typeof (AvaloniaDesigner), new FrameworkPropertyMetadata(XamlChanged));
-
- public string SourceAssembly
- {
- get { return (string) GetValue(SourceAssemblyProperty); }
- set { SetValue(SourceAssemblyProperty, value); }
- }
-
- private readonly ProcessHost _host = new ProcessHost();
-
-
- public AvaloniaDesigner()
- {
- InitializeComponent();
- BindingOperations.SetBinding(State, TextBox.TextProperty,
- new Binding(nameof(ProcessHost.State)) {Source = _host, Mode = BindingMode.OneWay});
-
- _host.PropertyChanged += _host_PropertyChanged;
- }
-
- private void _host_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
- {
- if (e.PropertyName == nameof(ProcessHost.WindowHandle))
- {
- ResetNativeContainer();
- if(_host.WindowHandle == IntPtr.Zero)
- return;
- NativeContainer.Child = new WindowHost(false);
- var wndHost = ((WindowHost) NativeContainer.Child);
- wndHost.SetWindow(_host.WindowHandle);
- }
- }
-
- void ResetNativeContainer()
- {
- if (NativeContainer.Child != null)
- {
- var child = NativeContainer.Child;
- NativeContainer.Child = null;
- child.Dispose();
- }
- }
-
-
- public void KillProcess()
- {
- _host.Kill();
- ResetNativeContainer();
- }
-
- bool CheckTargetExeOrSetError()
- {
- if (string.IsNullOrEmpty(TargetExe))
- {
- _host.State = "No target exe found";
- return false;
- }
-
- if (File.Exists(TargetExe ?? ""))
- return true;
- _host.State = "No target binary found, build your project";
- return false;
- }
-
- public void RestartProcess()
- {
- KillProcess();
- if(!CheckTargetExeOrSetError())
- return;
- if(string.IsNullOrEmpty(Xaml))
- return;
- _host.Start(TargetExe, Xaml, SourceAssembly);
- }
-
- private void OnXamlChanged()
- {
- if (!CheckTargetExeOrSetError())
- return;
- if (!_host.IsAlive)
- _host.Start(TargetExe, Xaml, SourceAssembly);
- else
- _host.UpdateXaml(Xaml ?? "", SourceAssembly);
- }
-
- }
-}
diff --git a/src/Windows/Avalonia.Designer/Comm/CommChannel.cs b/src/Windows/Avalonia.Designer/Comm/CommChannel.cs
deleted file mode 100644
index 5851ad79c8..0000000000
--- a/src/Windows/Avalonia.Designer/Comm/CommChannel.cs
+++ /dev/null
@@ -1,137 +0,0 @@
-using System;
-using System.Collections.Concurrent;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Runtime.Serialization;
-using System.Runtime.Serialization.Formatters.Binary;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-using System.Windows.Threading;
-
-namespace Avalonia.Designer.Comm
-{
- class CommChannel : IDisposable
- {
- private readonly BinaryReader _input;
- private readonly BinaryWriter _output;
- private readonly SynchronizationContext _dispatcher;
- readonly TaskCompletionSource _terminating = new TaskCompletionSource();
- private readonly BlockingCollection _outputQueue = new BlockingCollection();
- public event Action