From b792b6cd5f8e477f8dbe93a99eb09af59532628b Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Mon, 26 Oct 2020 15:05:55 -0400 Subject: [PATCH 01/68] Add initail build using new solution --- .vscode/launch.json | 53 ++++++++++++++++++++++++++++++++++ .vscode/tasks.json | 42 +++++++++++++++++++++++++++ MinoriEditorShell-Avalonia.sln | 39 +++++++++++++++++++++++++ 3 files changed, 134 insertions(+) create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json create mode 100644 MinoriEditorShell-Avalonia.sln diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..ac118859 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,53 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceFolder}/bin/Debug//", + "args": [], + "cwd": "${workspaceFolder}", + "stopAtEntry": false, + "console": "internalConsole" + }, + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "WARNING01": "*********************************************************************************", + "WARNING02": "The C# extension was unable to automatically decode projects in the current", + "WARNING03": "workspace to create a runnable launch.json file. A template launch.json file has", + "WARNING04": "been created as a placeholder.", + "WARNING05": "", + "WARNING06": "If OmniSharp is currently unable to load your project, you can attempt to resolve", + "WARNING07": "this by restoring any missing project dependencies (example: run 'dotnet restore')", + "WARNING08": "and by fixing any reported errors from building the projects in your workspace.", + "WARNING09": "If this allows OmniSharp to now load your project then --", + "WARNING10": " * Delete this file", + "WARNING11": " * Open the Visual Studio Code command palette (View->Command Palette)", + "WARNING12": " * run the command: '.NET: Generate Assets for Build and Debug'.", + "WARNING13": "", + "WARNING14": "If your project requires a more complex launch configuration, you may wish to delete", + "WARNING15": "this configuration and pick a different template using the 'Add Configuration...'", + "WARNING16": "button at the bottom of this file.", + "WARNING17": "*********************************************************************************", + "preLaunchTask": "build", + "program": "${workspaceFolder}/bin/Debug//.dll", + "args": [], + "cwd": "${workspaceFolder}", + "console": "internalConsole", + "stopAtEntry": false + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000..5f7c8584 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,42 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "shell", + "args": [ + "build", + "MinoriEditorShell-Avalonia.sln", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "group": "build", + "presentation": { + "reveal": "silent" + }, + "problemMatcher": "$msCompile" + }, + { + "label": "test", + "command": "dotnet", + "type": "shell", + "args": [ + "test", + "MinoriEditorShell-Avalonia.sln", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "group": { + "kind": "test", + "isDefault": true + }, + "presentation": { + "reveal": "silent" + }, + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/MinoriEditorShell-Avalonia.sln b/MinoriEditorShell-Avalonia.sln new file mode 100644 index 00000000..853e78d2 --- /dev/null +++ b/MinoriEditorShell-Avalonia.sln @@ -0,0 +1,39 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26124.0 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Modules", "Modules", "{D9E73129-B533-484C-AEFC-7DA139610289}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MinoriEditorShell", "Modules\MinoriEditorShell\MinoriEditorShell.csproj", "{C7863C93-477E-445B-98A1-F09454583537}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C7863C93-477E-445B-98A1-F09454583537}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C7863C93-477E-445B-98A1-F09454583537}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C7863C93-477E-445B-98A1-F09454583537}.Debug|x64.ActiveCfg = Debug|Any CPU + {C7863C93-477E-445B-98A1-F09454583537}.Debug|x64.Build.0 = Debug|Any CPU + {C7863C93-477E-445B-98A1-F09454583537}.Debug|x86.ActiveCfg = Debug|Any CPU + {C7863C93-477E-445B-98A1-F09454583537}.Debug|x86.Build.0 = Debug|Any CPU + {C7863C93-477E-445B-98A1-F09454583537}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C7863C93-477E-445B-98A1-F09454583537}.Release|Any CPU.Build.0 = Release|Any CPU + {C7863C93-477E-445B-98A1-F09454583537}.Release|x64.ActiveCfg = Release|Any CPU + {C7863C93-477E-445B-98A1-F09454583537}.Release|x64.Build.0 = Release|Any CPU + {C7863C93-477E-445B-98A1-F09454583537}.Release|x86.ActiveCfg = Release|Any CPU + {C7863C93-477E-445B-98A1-F09454583537}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {C7863C93-477E-445B-98A1-F09454583537} = {D9E73129-B533-484C-AEFC-7DA139610289} + EndGlobalSection +EndGlobal From 23cd6058399066aa60fc5a4fd5df1a715943ded4 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Mon, 26 Oct 2020 18:02:21 -0400 Subject: [PATCH 02/68] Try add new simple application with launch/build settings --- .vscode/launch.json | 4 +- Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml | 10 ++++ .../SimpleDemo.Avalonia/App.xaml.cs | 24 +++++++++ .../SimpleDemo.Avalonia/MainWindow.xaml | 9 ++++ .../SimpleDemo.Avalonia/MainWindow.xaml.cs | 19 +++++++ .../SimpleDemo/SimpleDemo.Avalonia/Program.cs | 23 +++++++++ .../SimpleDemo/SimpleDemo.Avalonia/Readme.md | 18 +++++++ .../SimpleDemo.Avalonia.csproj | 21 ++++++++ .../SimpleDemo.Avalonia/nuget.config | 6 +++ MinoriEditorShell-Avalonia.sln | 50 +++++++++++++++++++ 10 files changed, 182 insertions(+), 2 deletions(-) create mode 100644 Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml create mode 100644 Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml.cs create mode 100644 Demos/SimpleDemo/SimpleDemo.Avalonia/MainWindow.xaml create mode 100644 Demos/SimpleDemo/SimpleDemo.Avalonia/MainWindow.xaml.cs create mode 100644 Demos/SimpleDemo/SimpleDemo.Avalonia/Program.cs create mode 100644 Demos/SimpleDemo/SimpleDemo.Avalonia/Readme.md create mode 100644 Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj create mode 100644 Demos/SimpleDemo/SimpleDemo.Avalonia/nuget.config diff --git a/.vscode/launch.json b/.vscode/launch.json index ac118859..2399bc69 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,11 +5,11 @@ "version": "0.2.0", "configurations": [ { - "name": ".NET Core Launch (console)", + "name": ".NET Core Launch (SimpleDemo.Avalonia)", "type": "coreclr", "request": "launch", "preLaunchTask": "build", - "program": "${workspaceFolder}/bin/Debug//", + "program": "${workspaceFolder}/Demos/SimpleDemo/SimpleDemo.Avalonia/bin/Debug/netcoreapp3.1/SimpleDemo.Avalonia.dll", "args": [], "cwd": "${workspaceFolder}", "stopAtEntry": false, diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml new file mode 100644 index 00000000..56667383 --- /dev/null +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml @@ -0,0 +1,10 @@ + + + + + + diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml.cs b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml.cs new file mode 100644 index 00000000..c0c9fe5c --- /dev/null +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml.cs @@ -0,0 +1,24 @@ +using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Markup.Xaml; + +namespace SimpleDemo.Avalonia +{ + public class App : Application + { + public override void Initialize() + { + AvaloniaXamlLoader.Load(this); + } + + public override void OnFrameworkInitializationCompleted() + { + if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + { + desktop.MainWindow = new MainWindow(); + } + + base.OnFrameworkInitializationCompleted(); + } + } +} \ No newline at end of file diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/MainWindow.xaml b/Demos/SimpleDemo/SimpleDemo.Avalonia/MainWindow.xaml new file mode 100644 index 00000000..27908b12 --- /dev/null +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/MainWindow.xaml @@ -0,0 +1,9 @@ + + Welcome to Avalonia! + diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/MainWindow.xaml.cs b/Demos/SimpleDemo/SimpleDemo.Avalonia/MainWindow.xaml.cs new file mode 100644 index 00000000..7ecff1a6 --- /dev/null +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/MainWindow.xaml.cs @@ -0,0 +1,19 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace SimpleDemo.Avalonia +{ + public class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); + } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } + } +} \ No newline at end of file diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/Program.cs b/Demos/SimpleDemo/SimpleDemo.Avalonia/Program.cs new file mode 100644 index 00000000..b541cf40 --- /dev/null +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/Program.cs @@ -0,0 +1,23 @@ +using System; +using Avalonia; +using Avalonia.Controls; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Logging.Serilog; + +namespace SimpleDemo.Avalonia +{ + class Program + { + // Initialization code. Don't use any Avalonia, third-party APIs or any + // SynchronizationContext-reliant code before AppMain is called: things aren't initialized + // yet and stuff might break. + public static void Main(string[] args) => BuildAvaloniaApp() + .StartWithClassicDesktopLifetime(args); + + // Avalonia configuration, don't remove; also used by visual designer. + public static AppBuilder BuildAvaloniaApp() + => AppBuilder.Configure() + .UsePlatformDetect() + .LogToDebug(); + } +} diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/Readme.md b/Demos/SimpleDemo/SimpleDemo.Avalonia/Readme.md new file mode 100644 index 00000000..afbc5686 --- /dev/null +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/Readme.md @@ -0,0 +1,18 @@ +# Introduction + +This is an attempt to get MvvmCross and Avalonia to play nice togeather. + +## Creation steps +Since we need to create our own MvvmCross.Platforms.Wpf +to Avalonui bridge, we will prefix the bridge with ava. +This is not using the ReactUI helper since we are using +MvvmCross. + +1. `dotnet new avalonia.app -o SimpleDemo.Avalonia` +1. Change the `App` class to use MesApplication from + `MinoriEditorShell.Platforms.Avalonuia` + 1. Add `xmlns:mes="clr-namespace:MinoriEditorShell.Platforms.Avalonia;assembly=MinoriEditorShell.Platforms.Avalonia"` + 2. Change `Application` to `mes:MesApplication` + 3. update `App.xmal.cs` + + \ No newline at end of file diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj b/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj new file mode 100644 index 00000000..c2129b01 --- /dev/null +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj @@ -0,0 +1,21 @@ + + + WinExe + netcoreapp3.1 + + + + %(Filename) + + + Designer + + + + + + + + + + diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/nuget.config b/Demos/SimpleDemo/SimpleDemo.Avalonia/nuget.config new file mode 100644 index 00000000..7c07e225 --- /dev/null +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/nuget.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/MinoriEditorShell-Avalonia.sln b/MinoriEditorShell-Avalonia.sln index 853e78d2..2720fa9f 100644 --- a/MinoriEditorShell-Avalonia.sln +++ b/MinoriEditorShell-Avalonia.sln @@ -7,6 +7,16 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Modules", "Modules", "{D9E7 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MinoriEditorShell", "Modules\MinoriEditorShell\MinoriEditorShell.csproj", "{C7863C93-477E-445B-98A1-F09454583537}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Demos", "Demos", "{3787F54F-76A2-47AE-AA26-79065C6CE52F}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SimpleDemo", "SimpleDemo", "{40760750-D249-419D-B947-BB18B5A7FC4B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleDemo.Core", "Demos\SimpleDemo\SimpleDemo.Core\SimpleDemo.Core.csproj", "{5D755878-EA31-4D57-B5D9-D36EA9275DA9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MinoriEditorShell.Platforms.Avolonia", "Modules\MinoriEditorShell.Platforms.Avalonia\MinoriEditorShell.Platforms.Avolonia.csproj", "{761A0C29-1CBC-4AB0-AB90-5899136CAEB6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleDemo.Avalonia", "Demos\SimpleDemo\SimpleDemo.Avalonia\SimpleDemo.Avalonia.csproj", "{4AEE5668-722A-4799-9399-DBF9023D14F5}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -32,8 +42,48 @@ Global {C7863C93-477E-445B-98A1-F09454583537}.Release|x64.Build.0 = Release|Any CPU {C7863C93-477E-445B-98A1-F09454583537}.Release|x86.ActiveCfg = Release|Any CPU {C7863C93-477E-445B-98A1-F09454583537}.Release|x86.Build.0 = Release|Any CPU + {5D755878-EA31-4D57-B5D9-D36EA9275DA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5D755878-EA31-4D57-B5D9-D36EA9275DA9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5D755878-EA31-4D57-B5D9-D36EA9275DA9}.Debug|x64.ActiveCfg = Debug|Any CPU + {5D755878-EA31-4D57-B5D9-D36EA9275DA9}.Debug|x64.Build.0 = Debug|Any CPU + {5D755878-EA31-4D57-B5D9-D36EA9275DA9}.Debug|x86.ActiveCfg = Debug|Any CPU + {5D755878-EA31-4D57-B5D9-D36EA9275DA9}.Debug|x86.Build.0 = Debug|Any CPU + {5D755878-EA31-4D57-B5D9-D36EA9275DA9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5D755878-EA31-4D57-B5D9-D36EA9275DA9}.Release|Any CPU.Build.0 = Release|Any CPU + {5D755878-EA31-4D57-B5D9-D36EA9275DA9}.Release|x64.ActiveCfg = Release|Any CPU + {5D755878-EA31-4D57-B5D9-D36EA9275DA9}.Release|x64.Build.0 = Release|Any CPU + {5D755878-EA31-4D57-B5D9-D36EA9275DA9}.Release|x86.ActiveCfg = Release|Any CPU + {5D755878-EA31-4D57-B5D9-D36EA9275DA9}.Release|x86.Build.0 = Release|Any CPU + {761A0C29-1CBC-4AB0-AB90-5899136CAEB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {761A0C29-1CBC-4AB0-AB90-5899136CAEB6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {761A0C29-1CBC-4AB0-AB90-5899136CAEB6}.Debug|x64.ActiveCfg = Debug|Any CPU + {761A0C29-1CBC-4AB0-AB90-5899136CAEB6}.Debug|x64.Build.0 = Debug|Any CPU + {761A0C29-1CBC-4AB0-AB90-5899136CAEB6}.Debug|x86.ActiveCfg = Debug|Any CPU + {761A0C29-1CBC-4AB0-AB90-5899136CAEB6}.Debug|x86.Build.0 = Debug|Any CPU + {761A0C29-1CBC-4AB0-AB90-5899136CAEB6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {761A0C29-1CBC-4AB0-AB90-5899136CAEB6}.Release|Any CPU.Build.0 = Release|Any CPU + {761A0C29-1CBC-4AB0-AB90-5899136CAEB6}.Release|x64.ActiveCfg = Release|Any CPU + {761A0C29-1CBC-4AB0-AB90-5899136CAEB6}.Release|x64.Build.0 = Release|Any CPU + {761A0C29-1CBC-4AB0-AB90-5899136CAEB6}.Release|x86.ActiveCfg = Release|Any CPU + {761A0C29-1CBC-4AB0-AB90-5899136CAEB6}.Release|x86.Build.0 = Release|Any CPU + {4AEE5668-722A-4799-9399-DBF9023D14F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4AEE5668-722A-4799-9399-DBF9023D14F5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4AEE5668-722A-4799-9399-DBF9023D14F5}.Debug|x64.ActiveCfg = Debug|Any CPU + {4AEE5668-722A-4799-9399-DBF9023D14F5}.Debug|x64.Build.0 = Debug|Any CPU + {4AEE5668-722A-4799-9399-DBF9023D14F5}.Debug|x86.ActiveCfg = Debug|Any CPU + {4AEE5668-722A-4799-9399-DBF9023D14F5}.Debug|x86.Build.0 = Debug|Any CPU + {4AEE5668-722A-4799-9399-DBF9023D14F5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4AEE5668-722A-4799-9399-DBF9023D14F5}.Release|Any CPU.Build.0 = Release|Any CPU + {4AEE5668-722A-4799-9399-DBF9023D14F5}.Release|x64.ActiveCfg = Release|Any CPU + {4AEE5668-722A-4799-9399-DBF9023D14F5}.Release|x64.Build.0 = Release|Any CPU + {4AEE5668-722A-4799-9399-DBF9023D14F5}.Release|x86.ActiveCfg = Release|Any CPU + {4AEE5668-722A-4799-9399-DBF9023D14F5}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {C7863C93-477E-445B-98A1-F09454583537} = {D9E73129-B533-484C-AEFC-7DA139610289} + {40760750-D249-419D-B947-BB18B5A7FC4B} = {3787F54F-76A2-47AE-AA26-79065C6CE52F} + {5D755878-EA31-4D57-B5D9-D36EA9275DA9} = {40760750-D249-419D-B947-BB18B5A7FC4B} + {761A0C29-1CBC-4AB0-AB90-5899136CAEB6} = {D9E73129-B533-484C-AEFC-7DA139610289} + {4AEE5668-722A-4799-9399-DBF9023D14F5} = {40760750-D249-419D-B947-BB18B5A7FC4B} EndGlobalSection EndGlobal From b120d194ddb933127103046c2a1d4d8bfa68b60a Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Mon, 26 Oct 2020 18:31:35 -0400 Subject: [PATCH 03/68] use mvx application bridge --- Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml | 5 +- .../SimpleDemo.Avalonia/App.xaml.cs | 3 +- ...inoriEditorShell.Platforms.Avolonia.csproj | 53 ++++++++ .../ViewModels/MesApplicatioin.cs | 115 ++++++++++++++++++ 4 files changed, 173 insertions(+), 3 deletions(-) create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avolonia.csproj create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesApplicatioin.cs diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml index 56667383..8c7b8bbd 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml @@ -1,10 +1,11 @@ - - + diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml.cs b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml.cs index c0c9fe5c..47fc0fe9 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml.cs +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml.cs @@ -1,10 +1,11 @@ using Avalonia; using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Markup.Xaml; +using MinoriEditorShell.Platforms.Avalonia.ViewModels; namespace SimpleDemo.Avalonia { - public class App : Application + public class App : MesApplication { public override void Initialize() { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avolonia.csproj b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avolonia.csproj new file mode 100644 index 00000000..6ae8d0d4 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avolonia.csproj @@ -0,0 +1,53 @@ + + + + netstandard2.0 + MinoriEditorStudio is an application shell similar in concept to the Visual Studio Shell. +This uses AvalonDock and has an MVVM architecture based on MvvmCross. + Copyright 2019 + https://github.com/TorisanKitsune/MinoriEditorShell + https://github.com/TorisanKitsune/MinoriEditorShell + + git + .net40 netcoreapp WPF MvvmCross AvalonDock Visual Studio IDE Shell + true + Mark Kromis + Mark Kromis + Library + bin\MinoriEditorShell.Platforms.Avalonia.xml + ..\..\.sonarlint\minorieditorshellcsharp.ruleset + + + + + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesApplicatioin.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesApplicatioin.cs new file mode 100644 index 00000000..26c3be3a --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesApplicatioin.cs @@ -0,0 +1,115 @@ +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Markup.Xaml; +using MvvmCross; +using MvvmCross.IoC; +using MvvmCross.Logging; +using MvvmCross.Plugin; +using MvvmCross.ViewModels; +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Threading.Tasks; + +namespace MinoriEditorShell.Platforms.Avalonia.ViewModels +{ + ///This is a bridge between MvvmCross and Avalonia project + public abstract class MesApplication : global::Avalonia.Application, IMvxApplication + { + private IMvxViewModelLocator _defaultLocator; + + private IMvxViewModelLocator DefaultLocator + { + get + { + _defaultLocator = _defaultLocator ?? CreateDefaultViewModelLocator(); + return _defaultLocator; + } + } + + protected virtual IMvxViewModelLocator CreateDefaultViewModelLocator() + { + return new MvxDefaultViewModelLocator(); + } + + public virtual void LoadPlugins(IMvxPluginManager pluginManager) + { + // do nothing + } + + /// + /// Any initialization steps that can be done in the background + /// + // public virtual override void Initialize() + // { + // base.Initialize(); + // // do nothing + // } + + /// + /// Any initialization steps that need to be done on the UI thread + /// + public virtual Task Startup() + { + IMvxLog log = Mvx.IoCProvider.Resolve().GetLogFor(); + log.Trace("AppStart: Application Startup - On UI thread"); + return Task.CompletedTask; + } + + /// + /// If the application is restarted (eg primary activity on Android + /// can be restarted) this method will be called before Startup + /// is called again + /// + public virtual void Reset() + { + // do nothing + } + + public IMvxViewModelLocator FindViewModelLocator(MvxViewModelRequest request) + { + return DefaultLocator; + } + + protected void RegisterCustomAppStart() + where TMvxAppStart : class, IMvxAppStart + { + Mvx.IoCProvider.ConstructAndRegisterSingleton(); + } + + protected void RegisterAppStart() + where TViewModel : IMvxViewModel + { + Mvx.IoCProvider.ConstructAndRegisterSingleton>(); + } + + protected void RegisterAppStart(IMvxAppStart appStart) + { + Mvx.IoCProvider.RegisterSingleton(appStart); + } + + protected virtual void RegisterAppStart() + where TViewModel : IMvxViewModel where TParameter : class + { + Mvx.IoCProvider.ConstructAndRegisterSingleton>(); + } + + protected IEnumerable CreatableTypes() + { + return CreatableTypes(GetType().GetTypeInfo().Assembly); + } + + protected IEnumerable CreatableTypes(Assembly assembly) + { + return assembly.CreatableTypes(); + } + } + + public class MvxApplication : MvxApplication, IMvxApplication + { + public virtual TParameter Startup(TParameter parameter) + { + // do nothing, so just return the original hint + return parameter; + } + } +} \ No newline at end of file From 60d9fe17b2f6d2255e385b0c1db16b823212acc3 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Mon, 26 Oct 2020 18:55:19 -0400 Subject: [PATCH 04/68] Fix application --- Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml | 2 +- .../SimpleDemo.Avalonia/App.xaml.cs | 4 +- .../ViewModels/MesApplicatioin.cs | 115 ------------------ .../Views/MesApplicatioin.cs | 60 +++++++++ 4 files changed, 64 insertions(+), 117 deletions(-) delete mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesApplicatioin.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesApplicatioin.cs diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml index 8c7b8bbd..2d9d3162 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml @@ -1,7 +1,7 @@ diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml.cs b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml.cs index 47fc0fe9..abd980e1 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml.cs +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml.cs @@ -1,7 +1,7 @@ using Avalonia; using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Markup.Xaml; -using MinoriEditorShell.Platforms.Avalonia.ViewModels; +using MinoriEditorShell.Platforms.Avalonia.Views; namespace SimpleDemo.Avalonia { @@ -11,6 +11,8 @@ public override void Initialize() { AvaloniaXamlLoader.Load(this); } + + protected override void RegisterSetup() { } //this.RegisterSetupType>(); public override void OnFrameworkInitializationCompleted() { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesApplicatioin.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesApplicatioin.cs deleted file mode 100644 index 26c3be3a..00000000 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesApplicatioin.cs +++ /dev/null @@ -1,115 +0,0 @@ -using Avalonia.Controls.ApplicationLifetimes; -using Avalonia.Markup.Xaml; -using MvvmCross; -using MvvmCross.IoC; -using MvvmCross.Logging; -using MvvmCross.Plugin; -using MvvmCross.ViewModels; -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Threading.Tasks; - -namespace MinoriEditorShell.Platforms.Avalonia.ViewModels -{ - ///This is a bridge between MvvmCross and Avalonia project - public abstract class MesApplication : global::Avalonia.Application, IMvxApplication - { - private IMvxViewModelLocator _defaultLocator; - - private IMvxViewModelLocator DefaultLocator - { - get - { - _defaultLocator = _defaultLocator ?? CreateDefaultViewModelLocator(); - return _defaultLocator; - } - } - - protected virtual IMvxViewModelLocator CreateDefaultViewModelLocator() - { - return new MvxDefaultViewModelLocator(); - } - - public virtual void LoadPlugins(IMvxPluginManager pluginManager) - { - // do nothing - } - - /// - /// Any initialization steps that can be done in the background - /// - // public virtual override void Initialize() - // { - // base.Initialize(); - // // do nothing - // } - - /// - /// Any initialization steps that need to be done on the UI thread - /// - public virtual Task Startup() - { - IMvxLog log = Mvx.IoCProvider.Resolve().GetLogFor(); - log.Trace("AppStart: Application Startup - On UI thread"); - return Task.CompletedTask; - } - - /// - /// If the application is restarted (eg primary activity on Android - /// can be restarted) this method will be called before Startup - /// is called again - /// - public virtual void Reset() - { - // do nothing - } - - public IMvxViewModelLocator FindViewModelLocator(MvxViewModelRequest request) - { - return DefaultLocator; - } - - protected void RegisterCustomAppStart() - where TMvxAppStart : class, IMvxAppStart - { - Mvx.IoCProvider.ConstructAndRegisterSingleton(); - } - - protected void RegisterAppStart() - where TViewModel : IMvxViewModel - { - Mvx.IoCProvider.ConstructAndRegisterSingleton>(); - } - - protected void RegisterAppStart(IMvxAppStart appStart) - { - Mvx.IoCProvider.RegisterSingleton(appStart); - } - - protected virtual void RegisterAppStart() - where TViewModel : IMvxViewModel where TParameter : class - { - Mvx.IoCProvider.ConstructAndRegisterSingleton>(); - } - - protected IEnumerable CreatableTypes() - { - return CreatableTypes(GetType().GetTypeInfo().Assembly); - } - - protected IEnumerable CreatableTypes(Assembly assembly) - { - return assembly.CreatableTypes(); - } - } - - public class MvxApplication : MvxApplication, IMvxApplication - { - public virtual TParameter Startup(TParameter parameter) - { - // do nothing, so just return the original hint - return parameter; - } - } -} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesApplicatioin.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesApplicatioin.cs new file mode 100644 index 00000000..f0bb6948 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesApplicatioin.cs @@ -0,0 +1,60 @@ +using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Markup.Xaml; +using MvvmCross; +using MvvmCross.IoC; +using MvvmCross.Logging; +using MvvmCross.Plugin; +using MvvmCross.ViewModels; +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Threading.Tasks; + +namespace MinoriEditorShell.Platforms.Avalonia.Views +{ + ///This is a bridge between MvvmCross and Avalonia project + public abstract class MesApplication : Application + { + public MesApplication() : base() + { + RegisterSetup(); + } + + public virtual void ApplicationInitialized() + { + // if (MainWindow == null) return; + + // MvxWpfSetupSingleton.EnsureSingletonAvailable(Dispatcher, MainWindow).EnsureInitialized(); + + // RunAppStart(); + } + + protected virtual void RunAppStart(object hint = null) + { + if (Mvx.IoCProvider.TryResolve(out IMvxAppStart startup) && !startup.IsStarted) + { + startup.Start(GetAppStartHint(hint)); + } + } + + protected virtual object GetAppStartHint(object hint = null) + { + return hint; + } + + protected virtual void RegisterSetup() + { + } + } + + // public class MvxApplication : MvxApplication + // where TMvxWpfSetup : MvxWpfSetup, new() + // where TApplication : class, IMvxApplication, new() + // { + // protected override void RegisterSetup() + // { + // this.RegisterSetupType(); + // } + // } +} \ No newline at end of file From 0b5aeb8c375b68a8cf82a422f5a9ed6f7c5c8e3e Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Mon, 26 Oct 2020 18:55:37 -0400 Subject: [PATCH 05/68] Remove extra launch task --- .vscode/launch.json | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 2399bc69..ec435ed0 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -14,40 +14,6 @@ "cwd": "${workspaceFolder}", "stopAtEntry": false, "console": "internalConsole" - }, - { - "name": ".NET Core Launch (console)", - "type": "coreclr", - "request": "launch", - "WARNING01": "*********************************************************************************", - "WARNING02": "The C# extension was unable to automatically decode projects in the current", - "WARNING03": "workspace to create a runnable launch.json file. A template launch.json file has", - "WARNING04": "been created as a placeholder.", - "WARNING05": "", - "WARNING06": "If OmniSharp is currently unable to load your project, you can attempt to resolve", - "WARNING07": "this by restoring any missing project dependencies (example: run 'dotnet restore')", - "WARNING08": "and by fixing any reported errors from building the projects in your workspace.", - "WARNING09": "If this allows OmniSharp to now load your project then --", - "WARNING10": " * Delete this file", - "WARNING11": " * Open the Visual Studio Code command palette (View->Command Palette)", - "WARNING12": " * run the command: '.NET: Generate Assets for Build and Debug'.", - "WARNING13": "", - "WARNING14": "If your project requires a more complex launch configuration, you may wish to delete", - "WARNING15": "this configuration and pick a different template using the 'Add Configuration...'", - "WARNING16": "button at the bottom of this file.", - "WARNING17": "*********************************************************************************", - "preLaunchTask": "build", - "program": "${workspaceFolder}/bin/Debug//.dll", - "args": [], - "cwd": "${workspaceFolder}", - "console": "internalConsole", - "stopAtEntry": false - }, - { - "name": ".NET Core Attach", - "type": "coreclr", - "request": "attach", - "processId": "${command:pickProcess}" } ] } \ No newline at end of file From 306bb0903db182f77a9382452322802071bdde73 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sun, 24 Jan 2021 15:22:20 -0500 Subject: [PATCH 06/68] Skeleton Copy --- .../Behaviors/CustomGlowWindowBehavior.cs | 111 +++ ...MesBindableTreeViewSelectedItemBehavior.cs | 194 ++++++ .../Behaviors/MesKeyboardFocusBehavior.cs | 17 + .../Behaviors/MesWindowOptionsBehavior.cs | 101 +++ .../Controls/MesClippingHwndHost.cs | 90 +++ .../Controls/MesCustomToggleButton.cs | 12 + .../Controls/MesDynamicStyle.cs | 97 +++ .../Controls/MesExpanderEx.cs | 14 + .../Controls/MesHwndMouse.cs | 22 + .../Controls/MesHwndMouseEventArgs.cs | 110 +++ .../Controls/MesHwndMouseState.cs | 48 ++ .../Controls/MesHwndWrapper.cs | 631 ++++++++++++++++++ .../Controls/MesLayoutInitializer.cs | 118 ++++ .../Controls/MesPanesStyleSelector.cs | 28 + .../Controls/MesPanesTemplateSelector.cs | 27 + .../Controls/MesSliderEx.cs | 33 + .../Controls/MesVisualTreeUtility.cs | 23 + .../Converters/BoolToInsertModeConverter.cs | 39 ++ .../DrawingColorToMediaBrushConverter.cs | 25 + .../DrawingColorToMediaColorConverter.cs | 24 + .../Converters/NativeConverters.cs | 8 + .../NullObjectToVisibiltyConverter.cs | 28 + .../Converters/NullableValueConverter.cs | 17 + .../Converters/TreeViewIndentConverter.cs | 43 ++ .../Core/IMesAvaSetup.cs | 13 + .../Core/MesAvaSetup.cs | 211 ++++++ .../Extensions/ConsoleModifiersExtension.cs | 26 + .../MesPersistedDocument.cs | 84 +++ .../MesContentPresentationAttributes.cs | 10 + .../MesWindowPresentationAttribute.cs | 11 + .../Presenters/IMesAvaViewPresenter.cs | 6 + .../Presenters/MesAvaViewPresenter.cs | 134 ++++ .../Services/IMesInputManager.cs | 12 + .../Services/IMesMainWindow.cs | 18 + .../Services/IMesResourceManager.cs | 14 + .../Services/MesInputBindingTrigger.cs | 42 ++ .../Services/MesInputManager.cs | 52 ++ .../Services/MesMessageBox.cs | 13 + .../Services/MesResourceManager.cs | 49 ++ .../Services/MesThemeManager.cs | 100 +++ .../ShaderEffects/MesGrayscaleEffect.cs | 21 + .../ShaderEffects/MesGrayscaleEffect.ps | Bin 0 -> 236 bytes .../ShaderEffects/MesShaderEffectBase.cs | 18 + .../ShaderEffects/MesShaderEffectUtility.cs | 13 + .../Themes/BlueTheme.xaml | 448 +++++++++++++ .../Themes/Controls/Button.xaml | 43 ++ .../Themes/Controls/CheckBox.xaml | 70 ++ .../Themes/Controls/ColorCanvas.xaml | 196 ++++++ .../Themes/Controls/ColorPicker.xaml | 309 +++++++++ .../Themes/Controls/ComboBox.xaml | 193 ++++++ .../Themes/Controls/Focus.xaml | 16 + .../Themes/Controls/Generic.xaml | 84 +++ .../Themes/Controls/Label.xaml | 24 + .../Themes/Controls/Menu.xaml | 371 ++++++++++ .../Themes/Controls/Merged.xaml | 25 + .../Themes/Controls/ScrollBar.xaml | 289 ++++++++ .../Themes/Controls/Slider.xaml | 258 +++++++ .../Themes/Controls/Styles.xaml | 21 + .../Themes/Controls/TextBox.xaml | 46 ++ .../Themes/Controls/ToolBarStyles.xaml | 41 ++ .../Themes/Controls/Toolbar.xaml | 362 ++++++++++ .../Themes/Controls/Tooltip.xaml | 34 + .../Themes/Controls/TreeView.xaml | 166 +++++ .../Themes/Controls/Window.xaml | 33 + .../Themes/Controls/WindowCommands.xaml | 95 +++ .../Themes/DarkTheme.xaml | 449 +++++++++++++ .../Themes/LightTheme.xaml | 449 +++++++++++++ .../Themes/MesBlueTheme.cs | 20 + .../Themes/MesDarkTheme.cs | 20 + .../Themes/MesLightTheme.cs | 20 + .../Themes/MesThemeBase.cs | 45 ++ .../ViewModels/MesStatusBarItemViewModel.cs | 32 + .../Views/MesApplicatioin.cs | 4 +- .../Views/MesDocumentManagerView.xaml | 95 +++ .../Views/MesDocumentManagerView.xaml.cs | 54 ++ .../Views/MesGeneralSettingsView.xaml | 41 ++ .../Views/MesGeneralSettingsView.xaml.cs | 13 + .../Views/MesLayoutUtility.cs | 71 ++ .../Views/MesMainWindowView.xaml | 34 + .../Views/MesMainWindowView.xaml.cs | 10 + .../Views/MesSettingsView.xaml | 84 +++ .../Views/MesSettingsView.xaml.cs | 18 + .../Views/MesStatusBarView.xaml | 118 ++++ .../Views/MesStatusBarView.xaml.cs | 25 + .../Views/MesWindow.cs | 129 ++++ .../Win32/NativeMethods.cs | 208 ++++++ 86 files changed, 7768 insertions(+), 2 deletions(-) create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/CustomGlowWindowBehavior.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesBindableTreeViewSelectedItemBehavior.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesKeyboardFocusBehavior.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesWindowOptionsBehavior.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesClippingHwndHost.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesCustomToggleButton.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesDynamicStyle.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesExpanderEx.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouse.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouseEventArgs.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouseState.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndWrapper.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesLayoutInitializer.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesPanesStyleSelector.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesPanesTemplateSelector.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesSliderEx.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesVisualTreeUtility.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Converters/BoolToInsertModeConverter.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Converters/DrawingColorToMediaBrushConverter.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Converters/DrawingColorToMediaColorConverter.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Converters/NativeConverters.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Converters/NullObjectToVisibiltyConverter.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Converters/NullableValueConverter.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Converters/TreeViewIndentConverter.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Core/IMesAvaSetup.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvaSetup.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Extensions/ConsoleModifiersExtension.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/MesPersistedDocument.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/Attributes/MesContentPresentationAttributes.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/Attributes/MesWindowPresentationAttribute.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/IMesAvaViewPresenter.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvaViewPresenter.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Services/IMesInputManager.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Services/IMesMainWindow.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Services/IMesResourceManager.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesInputBindingTrigger.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesInputManager.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesMessageBox.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesResourceManager.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesThemeManager.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesGrayscaleEffect.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesGrayscaleEffect.ps create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesShaderEffectBase.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesShaderEffectUtility.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Themes/BlueTheme.xaml create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Button.xaml create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/CheckBox.xaml create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/ColorCanvas.xaml create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/ColorPicker.xaml create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/ComboBox.xaml create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Focus.xaml create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Generic.xaml create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Label.xaml create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Menu.xaml create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Merged.xaml create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/ScrollBar.xaml create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Slider.xaml create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Styles.xaml create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/TextBox.xaml create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/ToolBarStyles.xaml create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Toolbar.xaml create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Tooltip.xaml create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/TreeView.xaml create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Window.xaml create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/WindowCommands.xaml create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Themes/DarkTheme.xaml create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Themes/LightTheme.xaml create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesBlueTheme.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesDarkTheme.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesLightTheme.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesThemeBase.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesStatusBarItemViewModel.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.xaml create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.xaml.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesGeneralSettingsView.xaml create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesGeneralSettingsView.xaml.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesLayoutUtility.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesMainWindowView.xaml create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesMainWindowView.xaml.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesSettingsView.xaml create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesSettingsView.xaml.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesStatusBarView.xaml create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesStatusBarView.xaml.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesWindow.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Win32/NativeMethods.cs diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/CustomGlowWindowBehavior.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/CustomGlowWindowBehavior.cs new file mode 100644 index 00000000..c41d1fae --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/CustomGlowWindowBehavior.cs @@ -0,0 +1,111 @@ +//namespace MinoriEditorShell.Platforms.Wpf.Behaviors +//{ +// Copied from MahApp's GlowWindowBehavior, because that one has a bug if GlowBrush is set in a style, rather than directly. +//public class CustomGlowWindowBehavior : Behavior +//{ +// //private GlowWindow left; +// //private GlowWindow right; +// //private GlowWindow top; +// //private GlowWindow bottom; + +// //protected override void OnAttached() +// //{ +// // base.OnAttached(); +// // this.AssociatedObject.Loaded += new RoutedEventHandler(this.AssociatedObjectOnLoaded); +// //} + +// //private void AssociatedObjectOnLoaded(object sender, RoutedEventArgs routedEventArgs) +// //{ +// // MetroWindow metroWindow = this.AssociatedObject as MetroWindow; +// // if (metroWindow != null && (metroWindow.UseNoneWindowStyle/* || metroWindow.GlowBrush == null*/)) +// // return; +// // this.left = new GlowWindow(this.AssociatedObject, GlowDirection.Left); +// // this.right = new GlowWindow(this.AssociatedObject, GlowDirection.Right); +// // this.top = new GlowWindow(this.AssociatedObject, GlowDirection.Top); +// // this.bottom = new GlowWindow(this.AssociatedObject, GlowDirection.Bottom); +// // this.Show(); +// // this.Update(); + +// // metroWindow.LocationChanged += (s, e) => this.Update(); +// // metroWindow.SizeChanged += (s, e) => this.Update(); + +// // if (metroWindow == null || !metroWindow.WindowTransitionsEnabled) +// // { +// // this.SetOpacityTo(1.0); +// // } +// // else +// // { +// // this.StartOpacityStoryboard(); +// // this.AssociatedObject.IsVisibleChanged += new DependencyPropertyChangedEventHandler(this.AssociatedObjectIsVisibleChanged); +// // this.AssociatedObject.Closing += (CancelEventHandler) ((o, args) => +// // { +// // if (args.Cancel) +// // return; +// // this.AssociatedObject.IsVisibleChanged -= new DependencyPropertyChangedEventHandler(this.AssociatedObjectIsVisibleChanged); +// // }); +// // } +// //} + +// //private void AssociatedObjectIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) +// //{ +// // if (!this.AssociatedObject.IsVisible) +// // this.SetOpacityTo(0.0); +// // else +// // this.StartOpacityStoryboard(); +// //} + +// ///// +// ///// Updates all glow windows (visible, hidden, collapsed) +// ///// +// ///// +// //private void Update() +// //{ +// // if (this.left == null || this.right == null || (this.top == null || this.bottom == null)) +// // return; +// // this.left.Update(); +// // this.right.Update(); +// // this.top.Update(); +// // this.bottom.Update(); +// //} + +// ///// +// ///// Sets the opacity to all glow windows +// ///// +// ///// +// //private void SetOpacityTo(double newOpacity) +// //{ +// // if (this.left == null || this.right == null || (this.top == null || this.bottom == null)) +// // return; +// // this.left.Opacity = newOpacity; +// // this.right.Opacity = newOpacity; +// // this.top.Opacity = newOpacity; +// // this.bottom.Opacity = newOpacity; +// //} + +// ///// +// ///// Starts the opacity storyboard 0 -> 1 +// ///// +// ///// +// //private void StartOpacityStoryboard() +// //{ +// // if (this.left == null || this.left.OpacityStoryboard == null || (this.right == null || this.right.OpacityStoryboard == null) || (this.top == null || this.top.OpacityStoryboard == null || (this.bottom == null || this.bottom.OpacityStoryboard == null))) +// // return; +// // this.left.BeginStoryboard(this.left.OpacityStoryboard); +// // this.right.BeginStoryboard(this.right.OpacityStoryboard); +// // this.top.BeginStoryboard(this.top.OpacityStoryboard); +// // this.bottom.BeginStoryboard(this.bottom.OpacityStoryboard); +// //} + +// ///// +// ///// Shows all glow windows +// ///// +// ///// +// //private void Show() +// //{ +// // this.left.Show(); +// // this.right.Show(); +// // this.top.Show(); +// // this.bottom.Show(); +// //} +//} +//} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesBindableTreeViewSelectedItemBehavior.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesBindableTreeViewSelectedItemBehavior.cs new file mode 100644 index 00000000..b57be102 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesBindableTreeViewSelectedItemBehavior.cs @@ -0,0 +1,194 @@ +namespace MinoriEditorShell.Platforms.Wpf.Behaviors +{ + // From http://stackoverflow.com/a/20636049/208817 + // public class MesBindableTreeViewSelectedItemBehavior : Behavior + // { + // #region SelectedItem Property + + // public object SelectedItem + // { + // get { return GetValue(SelectedItemProperty); } + // set { SetValue(SelectedItemProperty, value); } + // } + + // public static readonly DependencyProperty SelectedItemProperty = DependencyProperty.Register( + // "SelectedItem", typeof(object), typeof(MesBindableTreeViewSelectedItemBehavior), + // new UIPropertyMetadata(null, OnSelectedItemChanged)); + + // private static void OnSelectedItemChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) + // { + // Action selectTreeViewItem = tvi2 => + // { + // if (tvi2 != null) + // { + // tvi2.IsSelected = true; + // tvi2.Focus(); + // } + // }; + + // var tvi = e.NewValue as TreeViewItem; + + // if (tvi == null) + // { + // var tree = ((MesBindableTreeViewSelectedItemBehavior) sender).AssociatedObject; + // if (tree == null) + // return; + + // if (!tree.IsLoaded) + // { + // RoutedEventHandler handler = null; + // handler = (sender2, e2) => + // { + // tvi = GetTreeViewItem(tree, e.NewValue); + // selectTreeViewItem(tvi); + // tree.Loaded -= handler; + // }; + // tree.Loaded += handler; + + // return; + // } + // tvi = GetTreeViewItem(tree, e.NewValue); + // } + + // selectTreeViewItem(tvi); + // } + + // #endregion + + // #region Private + + // private void OnTreeViewSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs e) + // { + // SelectedItem = e.NewValue; + // } + + // private static TreeViewItem GetTreeViewItem(ItemsControl container, object item) + // { + // if (container != null) + // { + // if (container.DataContext == item) + // { + // return container as TreeViewItem; + // } + + // // Expand the current container + // if (container is TreeViewItem && !((TreeViewItem) container).IsExpanded) + // { + // container.SetValue(TreeViewItem.IsExpandedProperty, true); + // } + + // // Try to generate the ItemsPresenter and the ItemsPanel. + // // by calling ApplyTemplate. Note that in the + // // virtualizing case even if the item is marked + // // expanded we still need to do this step in order to + // // regenerate the visuals because they may have been virtualized away. + + // container.ApplyTemplate(); + // var itemsPresenter = + // (ItemsPresenter) container.Template.FindName("ItemsHost", container); + // if (itemsPresenter != null) + // { + // itemsPresenter.ApplyTemplate(); + // } + // else + // { + // // The Tree template has not named the ItemsPresenter, + // // so walk the descendents and find the child. + // itemsPresenter = FindVisualChild(container); + // if (itemsPresenter == null) + // { + // container.UpdateLayout(); + // itemsPresenter = FindVisualChild(container); + // } + // } + + // var itemsHostPanel = (Panel) VisualTreeHelper.GetChild(itemsPresenter, 0); + + // // Ensure that the generator for this panel has been created. + //#pragma warning disable 168 + // var children = itemsHostPanel.Children; + //#pragma warning restore 168 + + // for (int i = 0, count = container.Items.Count; i < count; i++) + // { + // var subContainer = (TreeViewItem) container.ItemContainerGenerator. + // ContainerFromIndex(i); + // if (subContainer == null) + // { + // continue; + // } + + // subContainer.BringIntoView(); + + // // Search the next level for the object. + // var resultContainer = GetTreeViewItem(subContainer, item); + // if (resultContainer != null) + // { + // return resultContainer; + // } + // else + // { + // // The object is not under this TreeViewItem + // // so collapse it. + // //subContainer.IsExpanded = false; + // } + // } + // } + + // return null; + // } + + // /// + // /// Search for an element of a certain type in the visual tree. + // /// + // /// The type of element to find. + // /// The parent element. + // /// + // private static T FindVisualChild(Visual visual) where T : Visual + // { + // for (int i = 0; i < VisualTreeHelper.GetChildrenCount(visual); i++) + // { + // Visual child = (Visual) VisualTreeHelper.GetChild(visual, i); + // if (child != null) + // { + // T correctlyTyped = child as T; + // if (correctlyTyped != null) + // { + // return correctlyTyped; + // } + + // T descendent = FindVisualChild(child); + // if (descendent != null) + // { + // return descendent; + // } + // } + // } + + // return null; + // } + + // #endregion + + // #region Protected + + // protected override void OnAttached() + // { + // base.OnAttached(); + + // AssociatedObject.SelectedItemChanged += OnTreeViewSelectedItemChanged; + // } + + // protected override void OnDetaching() + // { + // base.OnDetaching(); + + // if (AssociatedObject != null) + // { + // AssociatedObject.SelectedItemChanged -= OnTreeViewSelectedItemChanged; + // } + // } + + // #endregion + // } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesKeyboardFocusBehavior.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesKeyboardFocusBehavior.cs new file mode 100644 index 00000000..c6eebe76 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesKeyboardFocusBehavior.cs @@ -0,0 +1,17 @@ +//using System.Windows.Interactivity; + +namespace MinoriEditorShell.Platforms.Wpf.Behaviors +{ + //public class MesKeyboardFocusBehavior : Behavior + //{ + // protected override void OnAttached() + // { + // if (!AssociatedObject.IsLoaded) + // AssociatedObject.Loaded += (sender, e) => { Keyboard.Focus(AssociatedObject); }; + // else + // Keyboard.Focus(AssociatedObject); + + // base.OnAttached(); + // } + //} +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesWindowOptionsBehavior.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesWindowOptionsBehavior.cs new file mode 100644 index 00000000..02df7cb9 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesWindowOptionsBehavior.cs @@ -0,0 +1,101 @@ +//using System.Windows.Interactivity; + +namespace MinoriEditorShell.Platforms.Wpf.Behaviors +{ + //public class MesWindowOptionsBehavior : Behavior + //{ + // public static readonly DependencyProperty ShowIconProperty = DependencyProperty.Register( + // "ShowIcon", typeof(Boolean), typeof(MesWindowOptionsBehavior), + // new PropertyMetadata(true, OnWindowOptionChanged)); + + // public Boolean ShowIcon + // { + // get => (Boolean)GetValue(ShowIconProperty); + // set => SetValue(ShowIconProperty, value); + // } + + // public static readonly DependencyProperty ShowMinimizeBoxProperty = DependencyProperty.Register( + // "ShowMinimizeBox", typeof(Boolean), typeof(MesWindowOptionsBehavior), + // new PropertyMetadata(true, OnWindowOptionChanged)); + + // public Boolean ShowMinimizeBox + // { + // get => (Boolean)GetValue(ShowMinimizeBoxProperty); + // set => SetValue(ShowMinimizeBoxProperty, value); + // } + + // public static readonly DependencyProperty ShowMaximizeBoxProperty = DependencyProperty.Register( + // "ShowMaximizeBox", typeof(Boolean), typeof(MesWindowOptionsBehavior), + // new PropertyMetadata(true, OnWindowOptionChanged)); + + // public Boolean ShowMaximizeBox + // { + // get => (Boolean)GetValue(ShowMaximizeBoxProperty); + // set => SetValue(ShowMaximizeBoxProperty, value); + // } + + // private static void OnWindowOptionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => ((MesWindowOptionsBehavior)d).UpdateWindowStyle(); + + // private void UpdateWindowStyle() + // { + // if (AssociatedObject == null) + // { + // return; + // } + + // IntPtr handle = new WindowInteropHelper(AssociatedObject).Handle; + + // Int32 windowStyle = NativeMethods.GetWindowLong(handle, NativeMethods.GWL_STYLE); + + // if (ShowMinimizeBox) + // { + // windowStyle |= NativeMethods.WS_MINIMIZEBOX; + // } + // else + // { + // windowStyle &= ~NativeMethods.WS_MINIMIZEBOX; + // } + + // if (ShowMaximizeBox) + // { + // windowStyle |= NativeMethods.WS_MAXIMIZEBOX; + // } + // else + // { + // windowStyle &= ~NativeMethods.WS_MAXIMIZEBOX; + // } + + // NativeMethods.SetWindowLong(handle, NativeMethods.GWL_STYLE, windowStyle); + + // if (ShowIcon) + // { + // // TODO + // } + // else + // { + // Int32 exWindowStyle = NativeMethods.GetWindowLong(handle, NativeMethods.GWL_EXSTYLE); + // NativeMethods.SetWindowLong(handle, NativeMethods.GWL_EXSTYLE, + // exWindowStyle | NativeMethods.WS_EX_DLGMODALFRAME); + + // NativeMethods.SetWindowPos(handle, IntPtr.Zero, 0, 0, 0, 0, + // NativeMethods.SWP_NOMOVE | NativeMethods.SWP_NOSIZE | NativeMethods.SWP_NOZORDER | NativeMethods.SWP_FRAMECHANGED); + + // NativeMethods.SendMessage(handle, NativeMethods.WM_SETICON, IntPtr.Zero, IntPtr.Zero); + // } + // } + + // protected override void OnAttached() + // { + // AssociatedObject.SourceInitialized += OnSourceInitialized; + // base.OnAttached(); + // } + + // protected override void OnDetaching() + // { + // AssociatedObject.SourceInitialized -= OnSourceInitialized; + // base.OnDetaching(); + // } + + // private void OnSourceInitialized(Object sender, EventArgs e) => UpdateWindowStyle(); + //} +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesClippingHwndHost.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesClippingHwndHost.cs new file mode 100644 index 00000000..f80f261a --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesClippingHwndHost.cs @@ -0,0 +1,90 @@ +using MinoriEditorShell.Platforms.Wpf.Win32; +using System; +using System.Collections; +using System.Runtime.InteropServices; +using System.Windows; +// using System.Windows.Interop; +// using System.Windows.Media; + +namespace MinoriEditorShell.Platforms.Wpf.Controls +{ + // public class MesClippingHwndHost : HwndHost + // { + // private HwndSource _source; + + // public static readonly DependencyProperty ContentProperty = DependencyProperty.Register( + // "Content", typeof(Visual), typeof(MesClippingHwndHost), + // new PropertyMetadata(OnContentChanged)); + + // private static void OnContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + // { + // MesClippingHwndHost hwndHost = (MesClippingHwndHost)d; + + // if (e.OldValue != null) + // { + // if (hwndHost._source != null) + // { + // hwndHost._source.RootVisual = null; + // } + + // hwndHost.RemoveLogicalChild(e.OldValue); + // } + + // if (e.NewValue != null) + // { + // hwndHost.AddLogicalChild(e.NewValue); + // if (hwndHost._source != null) + // { + // hwndHost._source.RootVisual = (Visual)e.NewValue; + // } + // } + // } + + // public Visual Content + // { + // get => (Visual)GetValue(ContentProperty); + // set => SetValue(ContentProperty, value); + // } + + // protected override IEnumerator LogicalChildren + // { + // get + // { + // if (Content != null) + // { + // yield return Content; + // } + // } + // } + + // protected override HandleRef BuildWindowCore(HandleRef hwndParent) + // { + // HwndSourceParameters param = new HwndSourceParameters("MinoriEditorStudioClippingHwndHost", (Int32)Width, (Int32)Height) + // { + // ParentWindow = hwndParent.Handle, + // WindowStyle = NativeMethods.WS_VISIBLE | NativeMethods.WS_CHILD, + // }; + + // _source = new HwndSource(param) + // { + // RootVisual = Content + // }; + + // return new HandleRef(null, _source.Handle); + // } + + // protected override void DestroyWindowCore(HandleRef hwnd) + // { + // _source.Dispose(); + // _source = null; + // } + + // protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) + // { + // // If we don't do this, HwndHost doesn't seem to pick up on all size changes. + // UpdateWindowPos(); + + // base.OnRenderSizeChanged(sizeInfo); + // } + //} +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesCustomToggleButton.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesCustomToggleButton.cs new file mode 100644 index 00000000..89b5804c --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesCustomToggleButton.cs @@ -0,0 +1,12 @@ +//using System.Windows.Controls.Primitives; + +namespace MinoriEditorShell.Platforms.Wpf.Controls +{ + // public class MesCustomToggleButton : ToggleButton + // { + // protected override void OnToggle() + // { + // // Don't update IsChecked - we'll do that with a binding. + // } + // } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesDynamicStyle.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesDynamicStyle.cs new file mode 100644 index 00000000..8f4b5cc8 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesDynamicStyle.cs @@ -0,0 +1,97 @@ +using System; +using System.Windows; +//using System.Windows.Controls; + +namespace MinoriEditorShell.Platforms.Wpf.Controls +{ + // Based on http://stackoverflow.com/questions/9490264/dynamicresource-for-style-basedon + // public class MesDynamicStyle + // { + // public static readonly DependencyProperty BaseStyleProperty = DependencyProperty.RegisterAttached( + // "BaseStyle", typeof(Style), typeof(MesDynamicStyle), + // new PropertyMetadata(OnStylesChanged)); + + // public static Style GetBaseStyle(DependencyObject obj) + // { + // return (Style)obj.GetValue(BaseStyleProperty); + // } + + // public static void SetBaseStyle(DependencyObject obj, Style value) + // { + // obj.SetValue(BaseStyleProperty, value); + // } + + // public static readonly DependencyProperty DerivedStyleProperty = DependencyProperty.RegisterAttached( + // "DerivedStyle", typeof(Style), typeof(MesDynamicStyle), + // new PropertyMetadata(OnStylesChanged)); + + // public static Style GetDerivedStyle(DependencyObject obj) + // { + // return (Style)obj.GetValue(DerivedStyleProperty); + // } + + // public static void SetDerivedStyle(DependencyObject obj, Style value) + // { + // obj.SetValue(DerivedStyleProperty, value); + // } + + // private static void OnStylesChanged(DependencyObject target, DependencyPropertyChangedEventArgs e) + // { + // var mergedStyles = GetMergedStyles(target, GetBaseStyle(target), GetDerivedStyle(target)); + // var element = (FrameworkElement)target; + // element.Style = mergedStyles; + // } + + // public static readonly DependencyProperty ItemContainerBaseStyleProperty = DependencyProperty.RegisterAttached( + // "ItemContainerBaseStyle", typeof(Style), typeof(MesDynamicStyle), + // new PropertyMetadata(OnItemContainerStylesChanged)); + + // public static Style GetItemContainerBaseStyle(DependencyObject obj) + // { + // return (Style)obj.GetValue(ItemContainerBaseStyleProperty); + // } + + // public static void SetItemContainerBaseStyle(DependencyObject obj, Style value) + // { + // obj.SetValue(ItemContainerBaseStyleProperty, value); + // } + + // public static readonly DependencyProperty ItemContainerDerivedStyleProperty = DependencyProperty.RegisterAttached( + // "ItemContainerDerivedStyle", typeof(Style), typeof(MesDynamicStyle), + // new PropertyMetadata(OnItemContainerStylesChanged)); + + // public static Style GetItemContainerDerivedStyle(DependencyObject obj) + // { + // return (Style)obj.GetValue(ItemContainerDerivedStyleProperty); + // } + + // public static void SetItemContainerDerivedStyle(DependencyObject obj, Style value) + // { + // obj.SetValue(ItemContainerDerivedStyleProperty, value); + // } + + // private static void OnItemContainerStylesChanged(DependencyObject target, DependencyPropertyChangedEventArgs e) + // { + // var mergedStyles = GetMergedStyles(target, + // GetItemContainerBaseStyle(target), + // GetItemContainerDerivedStyle(target)); + // var element = (ItemsControl)target; + // element.ItemContainerStyle = mergedStyles; + // } + + // public static Style GetMergedStyles(DependencyObject target, Style baseStyle, Style derivedStyle) + // where T : DependencyObject + // { + // if (!(target is T)) + // throw new InvalidCastException("Target must be " + typeof(T)); + + // if (derivedStyle == null) return baseStyle; + // if (baseStyle == null) return derivedStyle; + + // var newStyle = new Style { BasedOn = baseStyle, TargetType = derivedStyle.TargetType }; + // foreach (var setter in derivedStyle.Setters) newStyle.Setters.Add(setter); + // foreach (var trigger in derivedStyle.Triggers) newStyle.Triggers.Add(trigger); + // return newStyle; + // } + // } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesExpanderEx.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesExpanderEx.cs new file mode 100644 index 00000000..bbbb200a --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesExpanderEx.cs @@ -0,0 +1,14 @@ +using System.Windows; +//using System.Windows.Controls; + +namespace MinoriEditorShell.Platforms.Wpf.Controls +{ + // public class MesExpanderEx : Expander + // { + // static MesExpanderEx() + // { + // DefaultStyleKeyProperty.OverrideMetadata(typeof(MesExpanderEx), + // new FrameworkPropertyMetadata(typeof(MesExpanderEx))); + // } + // } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouse.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouse.cs new file mode 100644 index 00000000..cb3b1162 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouse.cs @@ -0,0 +1,22 @@ +using MinoriEditorShell.Platforms.Wpf.Win32; +using System; +using System.Windows; + +namespace MinoriEditorShell.Platforms.Wpf.Controls +{ + public static class MesHwndMouse + { + // public static Point GetCursorPosition() + // { + // NativeMethods.NativePoint point = new NativeMethods.NativePoint(); + // NativeMethods.GetCursorPos(ref point); + // return new Point(point.X, point.Y); + // } + + // public static void SetCursorPosition(Point point) => NativeMethods.SetCursorPos((Int32)point.X, (Int32)point.Y); + + // public static void ShowCursor() => NativeMethods.ShowCursor(true); + + // public static void HideCursor() => NativeMethods.ShowCursor(false); + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouseEventArgs.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouseEventArgs.cs new file mode 100644 index 00000000..340fa78e --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouseEventArgs.cs @@ -0,0 +1,110 @@ +#region File Description + +//----------------------------------------------------------------------------- +// Copyright 2011, Nick Gravelyn. +// Licensed under the terms of the Ms-PL: +// http://www.microsoft.com/opensource/licenses.mspx#Ms-PL +//----------------------------------------------------------------------------- + +#endregion File Description + +using System; +using System.Windows; +using System.Windows.Input; + +namespace MinoriEditorShell.Platforms.Wpf.Controls +{ + // public class MesHwndMouseEventArgs : EventArgs + // { + // /// + // /// Gets the state of the left mouse button. + // /// + // public MouseButtonState LeftButton { get; private set; } + + // /// + // /// Gets the state of the right mouse button. + // /// + // public MouseButtonState RightButton { get; private set; } + + // /// + // /// Gets the state of the middle mouse button. + // /// + // public MouseButtonState MiddleButton { get; private set; } + + // /// + // /// Gets the state of the first extra mouse button. + // /// + // public MouseButtonState X1Button { get; private set; } + + // /// + // /// Gets the state of the second extra mouse button. + // /// + // public MouseButtonState X2Button { get; private set; } + + // /// + // /// Gets the button that was double clicked. + // /// + // public MouseButton? DoubleClickButton { get; private set; } + + // /// + // /// Gets the mouse wheel delta. + // /// + // public int WheelDelta { get; private set; } + + // /// + // /// Gets the horizontal mouse wheel delta. + // /// + // public int HorizontalWheelDelta { get; private set; } + + // /// + // /// Gets the position of the mouse in screen coordinates. + // /// + // public Point ScreenPosition { get; private set; } + + // /// + // /// Calculates the position of the mouse relative to a particular element. + // /// + // public Point GetPosition(UIElement relativeTo) + // { + // return relativeTo.PointFromScreen(ScreenPosition); + // } + + // /// + // /// Initializes a new HwndMouseEventArgs. + // /// + // /// The state from which to initialize the properties. + // public MesHwndMouseEventArgs(MesHwndMouseState state) + // { + // LeftButton = state.LeftButton; + // RightButton = state.RightButton; + // MiddleButton = state.MiddleButton; + // X1Button = state.X1Button; + // X2Button = state.X2Button; + // ScreenPosition = state.ScreenPosition; + // } + + // /// + // /// Initializes a new HwndMouseEventArgs. + // /// + // /// The state from which to initialize the properties. + // /// The mouse wheel rotation delta. + // /// The horizontal mouse wheel delta. + // public MesHwndMouseEventArgs(MesHwndMouseState state, int mouseWheelDelta, int mouseHWheelDelta) + // : this(state) + // { + // WheelDelta = mouseWheelDelta; + // HorizontalWheelDelta = mouseHWheelDelta; + // } + + // /// + // /// Initializes a new HwndMouseEventArgs. + // /// + // /// The state from which to initialize the properties. + // /// The button that was double clicked. + // public MesHwndMouseEventArgs(MesHwndMouseState state, MouseButton doubleClickButton) + // : this(state) + // { + // DoubleClickButton = doubleClickButton; + // } + // } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouseState.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouseState.cs new file mode 100644 index 00000000..8a979ef7 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouseState.cs @@ -0,0 +1,48 @@ +#region File Description + +//----------------------------------------------------------------------------- +// Copyright 2011, Nick Gravelyn. +// Licensed under the terms of the Ms-PL: +// http://www.microsoft.com/opensource/licenses.mspx#Ms-PL +//----------------------------------------------------------------------------- + +#endregion File Description + +using System.Windows; +using System.Windows.Input; + +namespace MinoriEditorShell.Platforms.Wpf.Controls +{ + public class MesHwndMouseState + { + // /// + // /// The current state of the left mouse button. + // /// + // public MouseButtonState LeftButton; + + // /// + // /// The current state of the right mouse button. + // /// + // public MouseButtonState RightButton; + + // /// + // /// The current state of the middle mouse button. + // /// + // public MouseButtonState MiddleButton; + + // /// + // /// The current state of the first extra mouse button. + // /// + // public MouseButtonState X1Button; + + // /// + // /// The current state of the second extra mouse button. + // /// + // public MouseButtonState X2Button; + + // /// + // /// The current position of the mouse in screen coordinates. + // /// + // public Point ScreenPosition; + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndWrapper.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndWrapper.cs new file mode 100644 index 00000000..4b2dc7c4 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndWrapper.cs @@ -0,0 +1,631 @@ +#region File Description + +//----------------------------------------------------------------------------- +// Copyright 2011, Nick Gravelyn. +// Licensed under the terms of the Ms-PL: +// http://www.microsoft.com/opensource/licenses.mspx#Ms-PL +//----------------------------------------------------------------------------- + +#endregion File Description + +using MinoriEditorShell.Platforms.Wpf.Win32; +using System; +using System.Linq; +using System.Runtime.InteropServices; +using System.Windows; +using System.Windows.Input; +//using System.Windows.Interop; +//using System.Windows.Media; + +namespace MinoriEditorShell.Platforms.Wpf.Controls +{ + /// + /// A control that enables graphics rendering inside a WPF control through + /// the use of a hosted child Hwnd. + /// + // public abstract class MesHwndWrapper : HwndHost + // { + // #region Fields + + // // The name of our window class + // private const string WindowClass = "GraphicsDeviceControlHostWindowClass"; + + // // The HWND we present to when rendering + // private IntPtr _hWnd; + + // // For holding previous hWnd focus + // private IntPtr _hWndPrev; + + // // Track if the application has focus + // private bool _applicationHasFocus; + + // // Track if the mouse is in the window + // private bool _mouseInWindow; + + // // Track the previous mouse position + // private Point _previousPosition; + + // // Track the mouse state + // private readonly MesHwndMouseState _mouseState = new MesHwndMouseState(); + + // // Tracking whether we've "capture" the mouse + // private bool _isMouseCaptured; + + // #endregion Fields + + // #region Events + + // /// + // /// Invoked when the control receives a left mouse down message. + // /// + // public event EventHandler HwndLButtonDown; + + // /// + // /// Invoked when the control receives a left mouse up message. + // /// + // public event EventHandler HwndLButtonUp; + + // /// + // /// Invoked when the control receives a left mouse double click message. + // /// + // public event EventHandler HwndLButtonDblClick; + + // /// + // /// Invoked when the control receives a right mouse down message. + // /// + // public event EventHandler HwndRButtonDown; + + // /// + // /// Invoked when the control receives a right mouse up message. + // /// + // public event EventHandler HwndRButtonUp; + + // /// + // /// Invoked when the control receives a rigt mouse double click message. + // /// + // public event EventHandler HwndRButtonDblClick; + + // /// + // /// Invoked when the control receives a middle mouse down message. + // /// + // public event EventHandler HwndMButtonDown; + + // /// + // /// Invoked when the control receives a middle mouse up message. + // /// + // public event EventHandler HwndMButtonUp; + + // /// + // /// Invoked when the control receives a middle mouse double click message. + // /// + // public event EventHandler HwndMButtonDblClick; + + // /// + // /// Invoked when the control receives a mouse down message for the first extra button. + // /// + // public event EventHandler HwndX1ButtonDown; + + // /// + // /// Invoked when the control receives a mouse up message for the first extra button. + // /// + // public event EventHandler HwndX1ButtonUp; + + // /// + // /// Invoked when the control receives a double click message for the first extra mouse button. + // /// + // public event EventHandler HwndX1ButtonDblClick; + + // /// + // /// Invoked when the control receives a mouse down message for the second extra button. + // /// + // public event EventHandler HwndX2ButtonDown; + + // /// + // /// Invoked when the control receives a mouse up message for the second extra button. + // /// + // public event EventHandler HwndX2ButtonUp; + + // /// + // /// Invoked when the control receives a double click message for the first extra mouse button. + // /// + // public event EventHandler HwndX2ButtonDblClick; + + // /// + // /// Invoked when the control receives a mouse move message. + // /// + // public event EventHandler HwndMouseMove; + + // /// + // /// Invoked when the control first gets a mouse move message. + // /// + // public event EventHandler HwndMouseEnter; + + // /// + // /// Invoked when the control gets a mouse leave message. + // /// + // public event EventHandler HwndMouseLeave; + + // /// + // /// Invoked when the control recieves a mouse wheel delta. + // /// + // public event EventHandler HwndMouseWheel; + + // #endregion Events + + // #region Properties + + // public new bool IsMouseCaptured + // { + // get { return _isMouseCaptured; } + // } + + // #endregion Properties + + // #region Construction and Disposal + + // protected MesHwndWrapper() + // { + // // We must be notified of the application foreground status for our mouse input events + // Application.Current.Activated += OnApplicationActivated; + // Application.Current.Deactivated += OnApplicationDeactivated; + + // // We use the CompositionTarget.Rendering event to trigger the control to draw itself + // CompositionTarget.Rendering += OnCompositionTargetRendering; + + // // Check whether the application is active (it almost certainly is, at this point). + // if (Application.Current.Windows.Cast().Any(x => x.IsActive)) + // _applicationHasFocus = true; + // } + + // protected override void Dispose(bool disposing) + // { + // // Unhook all events. + // CompositionTarget.Rendering -= OnCompositionTargetRendering; + // if (Application.Current != null) + // { + // Application.Current.Activated -= OnApplicationActivated; + // Application.Current.Deactivated -= OnApplicationDeactivated; + // } + + // base.Dispose(disposing); + // } + + // #endregion Construction and Disposal + + // #region Public Methods + + // /// + // /// Captures the mouse, hiding it and trapping it inside the window bounds. + // /// + // /// + // /// This method is useful for tooling scenarios where you only care about the mouse deltas + // /// and want the user to be able to continue interacting with the window while they move + // /// the mouse. A good example of this is rotating an object based on the mouse deltas where + // /// through capturing you can spin and spin without having the cursor leave the window. + // /// + // public new void CaptureMouse() + // { + // // Don't do anything if the mouse is already captured + // if (_isMouseCaptured) + // return; + + // NativeMethods.SetCapture(_hWnd); + // _isMouseCaptured = true; + // } + + // /// + // /// Releases the capture of the mouse which makes it visible and allows it to leave the window bounds. + // /// + // public new void ReleaseMouseCapture() + // { + // // Don't do anything if the mouse is not captured + // if (!_isMouseCaptured) + // return; + + // NativeMethods.ReleaseCapture(); + // _isMouseCaptured = false; + // } + + // #endregion Public Methods + + // #region Graphics Device Control Implementation + + // private void OnCompositionTargetRendering(object sender, EventArgs e) + // { + // // Get the current width and height of the control + // var width = (int)ActualWidth; + // var height = (int)ActualHeight; + + // // If the control has no width or no height, skip drawing since it's not visible + // if (width < 1 || height < 1) + // return; + + // Render(_hWnd); + // } + + // protected abstract void Render(IntPtr windowHandle); + + // private void OnApplicationActivated(object sender, EventArgs e) + // { + // _applicationHasFocus = true; + // } + + // private void OnApplicationDeactivated(object sender, EventArgs e) + // { + // _applicationHasFocus = false; + // ResetMouseState(); + + // if (_mouseInWindow) + // { + // _mouseInWindow = false; + // RaiseHwndMouseLeave(new MesHwndMouseEventArgs(_mouseState)); + // } + + // ReleaseMouseCapture(); + // } + + // private void ResetMouseState() + // { + // // We need to invoke events for any buttons that were pressed + // bool fireL = _mouseState.LeftButton == MouseButtonState.Pressed; + // bool fireM = _mouseState.MiddleButton == MouseButtonState.Pressed; + // bool fireR = _mouseState.RightButton == MouseButtonState.Pressed; + // bool fireX1 = _mouseState.X1Button == MouseButtonState.Pressed; + // bool fireX2 = _mouseState.X2Button == MouseButtonState.Pressed; + + // // Update the state of all of the buttons + // _mouseState.LeftButton = MouseButtonState.Released; + // _mouseState.MiddleButton = MouseButtonState.Released; + // _mouseState.RightButton = MouseButtonState.Released; + // _mouseState.X1Button = MouseButtonState.Released; + // _mouseState.X2Button = MouseButtonState.Released; + + // // Fire any events + // var args = new MesHwndMouseEventArgs(_mouseState); + // if (fireL) + // RaiseHwndLButtonUp(args); + // if (fireM) + // RaiseHwndMButtonUp(args); + // if (fireR) + // RaiseHwndRButtonUp(args); + // if (fireX1) + // RaiseHwndX1ButtonUp(args); + // if (fireX2) + // RaiseHwndX2ButtonUp(args); + + // // The mouse is no longer considered to be in our window + // _mouseInWindow = false; + // } + + // #endregion Graphics Device Control Implementation + + // #region HWND Management + + // protected override HandleRef BuildWindowCore(HandleRef hwndParent) + // { + // // Create the host window as a child of the parent + // _hWnd = CreateHostWindow(hwndParent.Handle); + // return new HandleRef(this, _hWnd); + // } + + // protected override void DestroyWindowCore(HandleRef hwnd) + // { + // // Destroy the window and reset our hWnd value + // NativeMethods.DestroyWindow(hwnd.Handle); + // _hWnd = IntPtr.Zero; + // } + + // /// + // /// Creates the host window as a child of the parent window. + // /// + // private IntPtr CreateHostWindow(IntPtr hWndParent) + // { + // // Register our window class + // RegisterWindowClass(); + + // // Create the window + // return NativeMethods.CreateWindowEx(0, WindowClass, "", + // NativeMethods.WS_CHILD | NativeMethods.WS_VISIBLE, + // 0, 0, (int)Width, (int)Height, hWndParent, IntPtr.Zero, IntPtr.Zero, 0); + // } + + // /// + // /// Registers the window class. + // /// + // private void RegisterWindowClass() + // { + // var wndClass = new NativeMethods.WNDCLASSEX(); + // wndClass.cbSize = (uint)Marshal.SizeOf(wndClass); + // wndClass.hInstance = NativeMethods.GetModuleHandle(null); + // wndClass.lpfnWndProc = NativeMethods.DefaultWindowProc; + // wndClass.lpszClassName = WindowClass; + // wndClass.hCursor = NativeMethods.LoadCursor(IntPtr.Zero, NativeMethods.IDC_ARROW); + + // NativeMethods.RegisterClassEx(ref wndClass); + // } + + // #endregion HWND Management + + // #region WndProc Implementation + + // protected override IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) + // { + // switch (msg) + // { + // case NativeMethods.WM_MOUSEWHEEL: + // if (_mouseInWindow) + // { + // int delta = NativeMethods.GetWheelDeltaWParam(wParam.ToInt32()); + // RaiseHwndMouseWheel(new MesHwndMouseEventArgs(_mouseState, delta, 0)); + // } + // break; + + // case NativeMethods.WM_LBUTTONDOWN: + // _mouseState.LeftButton = MouseButtonState.Pressed; + // RaiseHwndLButtonDown(new MesHwndMouseEventArgs(_mouseState)); + // break; + + // case NativeMethods.WM_LBUTTONUP: + // _mouseState.LeftButton = MouseButtonState.Released; + // RaiseHwndLButtonUp(new MesHwndMouseEventArgs(_mouseState)); + // break; + + // case NativeMethods.WM_LBUTTONDBLCLK: + // RaiseHwndLButtonDblClick(new MesHwndMouseEventArgs(_mouseState, MouseButton.Left)); + // break; + + // case NativeMethods.WM_RBUTTONDOWN: + // _mouseState.RightButton = MouseButtonState.Pressed; + // RaiseHwndRButtonDown(new MesHwndMouseEventArgs(_mouseState)); + // break; + + // case NativeMethods.WM_RBUTTONUP: + // _mouseState.RightButton = MouseButtonState.Released; + // RaiseHwndRButtonUp(new MesHwndMouseEventArgs(_mouseState)); + // break; + + // case NativeMethods.WM_RBUTTONDBLCLK: + // RaiseHwndRButtonDblClick(new MesHwndMouseEventArgs(_mouseState, MouseButton.Right)); + // break; + + // case NativeMethods.WM_MBUTTONDOWN: + // _mouseState.MiddleButton = MouseButtonState.Pressed; + // RaiseHwndMButtonDown(new MesHwndMouseEventArgs(_mouseState)); + // break; + + // case NativeMethods.WM_MBUTTONUP: + // _mouseState.MiddleButton = MouseButtonState.Released; + // RaiseHwndMButtonUp(new MesHwndMouseEventArgs(_mouseState)); + // break; + + // case NativeMethods.WM_MBUTTONDBLCLK: + // RaiseHwndMButtonDblClick(new MesHwndMouseEventArgs(_mouseState, MouseButton.Middle)); + // break; + + // case NativeMethods.WM_XBUTTONDOWN: + // if (((int)wParam & NativeMethods.MK_XBUTTON1) != 0) + // { + // _mouseState.X1Button = MouseButtonState.Pressed; + // RaiseHwndX1ButtonDown(new MesHwndMouseEventArgs(_mouseState)); + // } + // else if (((int)wParam & NativeMethods.MK_XBUTTON2) != 0) + // { + // _mouseState.X2Button = MouseButtonState.Pressed; + // RaiseHwndX2ButtonDown(new MesHwndMouseEventArgs(_mouseState)); + // } + // break; + + // case NativeMethods.WM_XBUTTONUP: + // if (((int)wParam & NativeMethods.MK_XBUTTON1) != 0) + // { + // _mouseState.X1Button = MouseButtonState.Released; + // RaiseHwndX1ButtonUp(new MesHwndMouseEventArgs(_mouseState)); + // } + // else if (((int)wParam & NativeMethods.MK_XBUTTON2) != 0) + // { + // _mouseState.X2Button = MouseButtonState.Released; + // RaiseHwndX2ButtonUp(new MesHwndMouseEventArgs(_mouseState)); + // } + // break; + + // case NativeMethods.WM_XBUTTONDBLCLK: + // if (((int)wParam & NativeMethods.MK_XBUTTON1) != 0) + // RaiseHwndX1ButtonDblClick(new MesHwndMouseEventArgs(_mouseState, MouseButton.XButton1)); + // else if (((int)wParam & NativeMethods.MK_XBUTTON2) != 0) + // RaiseHwndX2ButtonDblClick(new MesHwndMouseEventArgs(_mouseState, MouseButton.XButton2)); + // break; + + // case NativeMethods.WM_MOUSEMOVE: + // // If the application isn't in focus, we don't handle this message + // if (!_applicationHasFocus) + // break; + + // // record the prevous and new position of the mouse + // _mouseState.ScreenPosition = PointToScreen(new Point( + // NativeMethods.GetXLParam((int)lParam), + // NativeMethods.GetYLParam((int)lParam))); + + // if (!_mouseInWindow) + // { + // _mouseInWindow = true; + + // RaiseHwndMouseEnter(new MesHwndMouseEventArgs(_mouseState)); + + // // Track the previously focused window, and set focus to this window. + // _hWndPrev = NativeMethods.GetFocus(); + // NativeMethods.SetFocus(_hWnd); + + // // send the track mouse event so that we get the WM_MOUSELEAVE message + // var tme = new NativeMethods.TRACKMOUSEEVENT + // { + // cbSize = Marshal.SizeOf(typeof(NativeMethods.TRACKMOUSEEVENT)), + // dwFlags = NativeMethods.TME_LEAVE, + // hWnd = hwnd + // }; + // NativeMethods.TrackMouseEvent(ref tme); + // } + + // if (_mouseState.ScreenPosition != _previousPosition) + // RaiseHwndMouseMove(new MesHwndMouseEventArgs(_mouseState)); + + // _previousPosition = _mouseState.ScreenPosition; + + // break; + + // case NativeMethods.WM_MOUSELEAVE: + + // // If we have capture, we ignore this message because we're just + // // going to reset the cursor position back into the window + // if (_isMouseCaptured) + // break; + + // // Reset the state which releases all buttons and + // // marks the mouse as not being in the window. + // ResetMouseState(); + + // RaiseHwndMouseLeave(new MesHwndMouseEventArgs(_mouseState)); + + // NativeMethods.SetFocus(_hWndPrev); + + // break; + // } + + // return base.WndProc(hwnd, msg, wParam, lParam, ref handled); + // } + + // protected virtual void RaiseHwndLButtonDown(MesHwndMouseEventArgs args) + // { + // var handler = HwndLButtonDown; + // if (handler != null) + // handler(this, args); + // } + + // protected virtual void RaiseHwndLButtonUp(MesHwndMouseEventArgs args) + // { + // var handler = HwndLButtonUp; + // if (handler != null) + // handler(this, args); + // } + + // protected virtual void RaiseHwndRButtonDown(MesHwndMouseEventArgs args) + // { + // var handler = HwndRButtonDown; + // if (handler != null) + // handler(this, args); + // } + + // protected virtual void RaiseHwndRButtonUp(MesHwndMouseEventArgs args) + // { + // var handler = HwndRButtonUp; + // if (handler != null) + // handler(this, args); + // } + + // protected virtual void RaiseHwndMButtonDown(MesHwndMouseEventArgs args) + // { + // var handler = HwndMButtonDown; + // if (handler != null) + // handler(this, args); + // } + + // protected virtual void RaiseHwndMButtonUp(MesHwndMouseEventArgs args) + // { + // var handler = HwndMButtonUp; + // if (handler != null) + // handler(this, args); + // } + + // protected virtual void RaiseHwndLButtonDblClick(MesHwndMouseEventArgs args) + // { + // var handler = HwndLButtonDblClick; + // if (handler != null) + // handler(this, args); + // } + + // protected virtual void RaiseHwndRButtonDblClick(MesHwndMouseEventArgs args) + // { + // var handler = HwndRButtonDblClick; + // if (handler != null) + // handler(this, args); + // } + + // protected virtual void RaiseHwndMButtonDblClick(MesHwndMouseEventArgs args) + // { + // var handler = HwndMButtonDblClick; + // if (handler != null) + // handler(this, args); + // } + + // protected virtual void RaiseHwndMouseEnter(MesHwndMouseEventArgs args) + // { + // var handler = HwndMouseEnter; + // if (handler != null) + // handler(this, args); + // } + + // protected virtual void RaiseHwndX1ButtonDown(MesHwndMouseEventArgs args) + // { + // var handler = HwndX1ButtonDown; + // if (handler != null) + // handler(this, args); + // } + + // protected virtual void RaiseHwndX1ButtonUp(MesHwndMouseEventArgs args) + // { + // var handler = HwndX1ButtonUp; + // if (handler != null) + // handler(this, args); + // } + + // protected virtual void RaiseHwndX2ButtonDown(MesHwndMouseEventArgs args) + // { + // var handler = HwndX2ButtonDown; + // if (handler != null) + // handler(this, args); + // } + + // protected virtual void RaiseHwndX2ButtonUp(MesHwndMouseEventArgs args) + // { + // var handler = HwndX2ButtonUp; + // if (handler != null) + // handler(this, args); + // } + + // protected virtual void RaiseHwndX1ButtonDblClick(MesHwndMouseEventArgs args) + // { + // var handler = HwndX1ButtonDblClick; + // if (handler != null) + // handler(this, args); + // } + + // protected virtual void RaiseHwndX2ButtonDblClick(MesHwndMouseEventArgs args) + // { + // var handler = HwndX2ButtonDblClick; + // if (handler != null) + // handler(this, args); + // } + + // protected virtual void RaiseHwndMouseLeave(MesHwndMouseEventArgs args) + // { + // var handler = HwndMouseLeave; + // if (handler != null) + // handler(this, args); + // } + + // protected virtual void RaiseHwndMouseMove(MesHwndMouseEventArgs args) + // { + // var handler = HwndMouseMove; + // if (handler != null) + // handler(this, args); + // } + + // protected virtual void RaiseHwndMouseWheel(MesHwndMouseEventArgs args) + // { + // var handler = HwndMouseWheel; + // if (handler != null) + // handler(this, args); + // } + + // #endregion WndProc Implementation + // } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesLayoutInitializer.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesLayoutInitializer.cs new file mode 100644 index 00000000..cc460aab --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesLayoutInitializer.cs @@ -0,0 +1,118 @@ +// using AvalonDock.Layout; +using MinoriEditorShell.Services; +using System; +using System.Linq; +using System.Windows; +//using System.Windows.Controls; + +namespace MinoriEditorShell.Platforms.Wpf.Controls +{ + // public class MesLayoutInitializer : ILayoutUpdateStrategy + // { + // // public Boolean BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer) + // // { + // // if (anchorableToShow.Content is IMesTool tool) + // // { + // // MesPaneLocation preferredLocation = tool.PreferredLocation; + // // String paneName = GetPaneName(preferredLocation); + // // LayoutAnchorablePane toolsPane = layout.Descendents().OfType().FirstOrDefault(d => d.Name == paneName); + // // if (toolsPane == null) + // // { + // // switch (preferredLocation) + // // { + // // case MesPaneLocation.Left: + // // toolsPane = CreateAnchorablePane(layout, Orientation.Horizontal, paneName, InsertPosition.Start); + // // break; + + // // case MesPaneLocation.Right: + // // toolsPane = CreateAnchorablePane(layout, Orientation.Horizontal, paneName, InsertPosition.End); + // // break; + + // // case MesPaneLocation.Bottom: + // // toolsPane = CreateAnchorablePane(layout, Orientation.Vertical, paneName, InsertPosition.End); + // // break; + + // // default: + // // throw new ArgumentOutOfRangeException(); + // // } + // // } + // // toolsPane.Children.Add(anchorableToShow); + // // return true; + // // } + + // // return false; + // // } + + // // private static String GetPaneName(MesPaneLocation location) + // // { + // // switch (location) + // // { + // // case MesPaneLocation.Left: + // // return "LeftPane"; + + // // case MesPaneLocation.Right: + // // return "RightPane"; + + // // case MesPaneLocation.Bottom: + // // return "BottomPane"; + + // // default: + // // throw new ArgumentOutOfRangeException("location"); + // // } + // // } + + // // private static LayoutAnchorablePane CreateAnchorablePane(LayoutRoot layout, Orientation orientation, + // // String paneName, InsertPosition position) + // // { + // // LayoutPanel parent = layout.Descendents().OfType().First(d => d.Orientation == orientation); + // // LayoutAnchorablePane toolsPane = new LayoutAnchorablePane { Name = paneName }; + // // if (position == InsertPosition.Start) + // // { + // // parent.InsertChildAt(0, toolsPane); + // // } + // // else + // // { + // // parent.Children.Add(toolsPane); + // // } + + // // return toolsPane; + // // } + + // // private enum InsertPosition + // // { + // // Start, + // // End + // // } + + // // public void AfterInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableShown) + // // { + // // // If this is the first anchorable added to this pane, then use the preferred size. + // // if (anchorableShown.Content is IMesTool tool) + // // { + // // if (anchorableShown.Parent is LayoutAnchorablePane anchorablePane && anchorablePane.ChildrenCount == 1) + // // { + // // switch (tool.PreferredLocation) + // // { + // // case MesPaneLocation.Left: + // // case MesPaneLocation.Right: + // // anchorablePane.DockWidth = new GridLength(tool.PreferredWidth, GridUnitType.Pixel); + // // break; + + // // case MesPaneLocation.Bottom: + // // anchorablePane.DockHeight = new GridLength(tool.PreferredHeight, GridUnitType.Pixel); + // // break; + + // // default: + // // throw new ArgumentOutOfRangeException(); + // // } + // // } + // // } + // // } + + // // public Boolean BeforeInsertDocument(LayoutRoot layout, LayoutDocument anchorableToShow, ILayoutContainer destinationContainer) => false; + + // // public void AfterInsertDocument(LayoutRoot layout, LayoutDocument anchorableShown) + // // { + // // } + // } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesPanesStyleSelector.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesPanesStyleSelector.cs new file mode 100644 index 00000000..7ad5482e --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesPanesStyleSelector.cs @@ -0,0 +1,28 @@ +using MinoriEditorShell.Services; +using System; +using System.Windows; +//using System.Windows.Controls; + +namespace MinoriEditorShell.Platforms.Wpf.Controls +{ + // public class MesPanesStyleSelector : StyleSelector + // { + // public Style ToolStyle { get; set; } + // public Style DocumentStyle { get; set; } + + // public override Style SelectStyle(Object item, DependencyObject container) + // { + // switch (item) + // { + // case IMesTool _: + // return ToolStyle; + + // case IMesDocument _: + // return DocumentStyle; + + // default: + // return base.SelectStyle(item, container); + // } + // } + // } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesPanesTemplateSelector.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesPanesTemplateSelector.cs new file mode 100644 index 00000000..78a95b2e --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesPanesTemplateSelector.cs @@ -0,0 +1,27 @@ +using MinoriEditorShell.Services; +using System.Windows; +//using System.Windows.Controls; + +namespace MinoriEditorShell.Platforms.Wpf.Controls +{ + // public class MesPanesTemplateSelector : DataTemplateSelector + // { + // public DataTemplate ToolTemplate { get; set; } + // public DataTemplate DocumentTemplate { get; set; } + + // public override DataTemplate SelectTemplate(object item, DependencyObject container) + // { + // switch (item) + // { + // case IMesTool _: + // return ToolTemplate; + + // case IMesDocument _: + // return DocumentTemplate; + + // default: + // return base.SelectTemplate(item, container); + // } + // } + // } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesSliderEx.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesSliderEx.cs new file mode 100644 index 00000000..58b01b40 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesSliderEx.cs @@ -0,0 +1,33 @@ +using System.ComponentModel; +// using System.Windows.Controls; +// using System.Windows.Controls.Primitives; + +namespace MinoriEditorShell.Platforms.Wpf.Controls +{ + /// + /// Slider that exposes the thumb drag started / completed events directly + /// to allow Caliburn Micro to attach to the messages. + /// +// public class MesSliderEx : Slider +// { +// [Category("Behavior")] +// public event DragStartedEventHandler ThumbDragStarted; + +// [Category("Behavior")] +// public event DragCompletedEventHandler ThumbDragCompleted; + +// protected override void OnThumbDragStarted(DragStartedEventArgs e) +// { +// ThumbDragStarted?.Invoke(this, e); + +// base.OnThumbDragStarted(e); +// } + +// protected override void OnThumbDragCompleted(DragCompletedEventArgs e) +// { +// ThumbDragCompleted?.Invoke(this, e); + +// base.OnThumbDragCompleted(e); +// } +// } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesVisualTreeUtility.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesVisualTreeUtility.cs new file mode 100644 index 00000000..32868f95 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesVisualTreeUtility.cs @@ -0,0 +1,23 @@ +using System.Windows; +//using System.Windows.Media; + +namespace MinoriEditorShell.Platforms.Wpf.Controls +{ + public static class MesVisualTreeUtility + { + // public static T FindParent(DependencyObject child) + // where T : DependencyObject + // { + // var parentObject = VisualTreeHelper.GetParent(child); + + // if (parentObject == null) + // return null; + + // var parent = parentObject as T; + // if (parent != null) + // return parent; + + // return FindParent(parentObject); + // } + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/BoolToInsertModeConverter.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/BoolToInsertModeConverter.cs new file mode 100644 index 00000000..2fe3216d --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/BoolToInsertModeConverter.cs @@ -0,0 +1,39 @@ +#region License + +// Copyright (c) 2018 Mark Kromis +// Copyright (c) 2013 Chandramouleswaran Ravichandran +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion License + +using System; +//using System.Windows.Data; + +namespace MinoriEditorShell.Platforms.Wpf.Converters +{ + // public class BoolToInsertModeConverter : IValueConverter + // { + // #region IValueConverter Members + + // public Object Convert(Object value, Type targetType, Object parameter, System.Globalization.CultureInfo culture) + // { + // Boolean? actValue = value as Boolean?; + // if (actValue == null) + // { + // return null; + // } + + // return actValue == false ? "INS" : "OVR"; + // } + + // public Object ConvertBack(Object value, Type targetType, Object parameter, + // System.Globalization.CultureInfo culture) => throw new NotImplementedException(); + + // #endregion IValueConverter Members + // } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/DrawingColorToMediaBrushConverter.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/DrawingColorToMediaBrushConverter.cs new file mode 100644 index 00000000..d84d5df1 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/DrawingColorToMediaBrushConverter.cs @@ -0,0 +1,25 @@ +using System; +using System.Globalization; +//using System.Windows.Data; +//using System.Windows.Media; + +namespace MinoriEditorShell.Platforms.Wpf.Converters +{ + // public class DrawingColorToMediaBrushConverter : IValueConverter + // { + // // Convert from Drawing Color to meda brush + // public Object Convert(Object value, Type targetType, Object parameter, CultureInfo culture) + // { + // System.Drawing.Color? color = value as System.Drawing.Color?; + // return color == null ? null : + // new SolidColorBrush(Color.FromArgb(color.Value.A, color.Value.R, color.Value.G, color.Value.B)); + // } + + // public Object ConvertBack(Object value, Type targetType, Object parameter, CultureInfo culture) + // { + // Color? color = value as Color?; + // return color == null ? System.Drawing.Color.Empty : + // System.Drawing.Color.FromArgb(color.Value.A, color.Value.R, color.Value.G, color.Value.B); + // } + // } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/DrawingColorToMediaColorConverter.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/DrawingColorToMediaColorConverter.cs new file mode 100644 index 00000000..3bbbf2cb --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/DrawingColorToMediaColorConverter.cs @@ -0,0 +1,24 @@ +using System; +using System.Globalization; +// using System.Windows.Data; +// using System.Windows.Media; + +namespace MinoriEditorShell.Platforms.Wpf.Converters +{ + // public class DrawingColorToMediaColorConverter : IValueConverter + // { + // // Convert from Drawing Color to meda brush + // public Object Convert(Object value, Type targetType, Object parameter, CultureInfo culture) + // { + // System.Drawing.Color? color = value as System.Drawing.Color?; + // return color == null ? null : (Object)System.Windows.Media.Color.FromArgb(color.Value.A, color.Value.R, color.Value.G, color.Value.B); + // } + + // public Object ConvertBack(Object value, Type targetType, Object parameter, CultureInfo culture) + // { + // Color? color = value as Color?; + // return color == null ? System.Drawing.Color.Empty : + // System.Drawing.Color.FromArgb(color.Value.A, color.Value.R, color.Value.G, color.Value.B); + // } + // } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/NativeConverters.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/NativeConverters.cs new file mode 100644 index 00000000..01d15d27 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/NativeConverters.cs @@ -0,0 +1,8 @@ +// using MvvmCross.Platforms.Wpf.Converters; + +namespace MinoriEditorShell.Platforms.Wpf.Converters +{ + // public class CultureInfoNameConverter : MvxNativeValueConverter + // { + // } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/NullObjectToVisibiltyConverter.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/NullObjectToVisibiltyConverter.cs new file mode 100644 index 00000000..cc24ea7b --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/NullObjectToVisibiltyConverter.cs @@ -0,0 +1,28 @@ +#region License + +// Copyright (c) 2018 Mark Kromis +// Copyright (c) 2013 Chandramouleswaran Ravichandran +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion License + +using System; +using System.Globalization; +using System.Windows; +//using System.Windows.Data; + +namespace MinoriEditorShell.Platforms.Wpf.Converters +{ + // public class NullObjectToVisibiltyConverter : IValueConverter + // { + // public Object Convert(Object value, Type targetType, Object parameter, CultureInfo culture) => + // (value == null) ? Visibility.Collapsed : Visibility.Visible; + + // public Object ConvertBack(Object value, Type targetType, Object parameter, CultureInfo culture) => null; + // } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/NullableValueConverter.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/NullableValueConverter.cs new file mode 100644 index 00000000..1b330bbb --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/NullableValueConverter.cs @@ -0,0 +1,17 @@ +using System; +using System.Globalization; +using System.Windows; +//using System.Windows.Data; + +namespace MinoriEditorShell.Platforms.Wpf.Converters +{ + // public class NullableValueConverter : IValueConverter + // { + // public Object Convert(Object value, Type targetType, object parameter, CultureInfo culture) => value == null ? DependencyProperty.UnsetValue : value; + + // public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + // { + // throw new NotSupportedException(); + // } + // } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/TreeViewIndentConverter.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/TreeViewIndentConverter.cs new file mode 100644 index 00000000..4d605f3c --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/TreeViewIndentConverter.cs @@ -0,0 +1,43 @@ +using System; +using System.Globalization; +using System.Windows; +// using System.Windows.Controls; +// using System.Windows.Data; +// using System.Windows.Media; + +namespace MinoriEditorShell.Platforms.Wpf.Converters +{ + // public class TreeViewIndentConverter : IValueConverter + // { + // public double Indent { get; set; } + + // private static int GetItemDepth(TreeViewItem item) + // { + // DependencyObject target = item; + + // var depth = 0; + // do + // { + // if (target is TreeView) + // return depth - 1; + // if (target is TreeViewItem) + // depth++; + // } while ((target = VisualTreeHelper.GetParent(target)) != null); + + // return 0; + // } + + // public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + // { + // if (!(value is TreeViewItem item)) + // return new Thickness(0); + + // return new Thickness(Indent * GetItemDepth(item), 0, 0, 0); + // } + + // public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + // { + // throw new NotImplementedException(); + // } + // } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Core/IMesAvaSetup.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/IMesAvaSetup.cs new file mode 100644 index 00000000..a2e4e6e9 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/IMesAvaSetup.cs @@ -0,0 +1,13 @@ +using Avalonia.Controls; +using Avalonia.Threading; +using MinoriEditorShell.Platforms.Avalonia.Presenters; +using MvvmCross.Core; + +namespace MinoriEditorShell.Platforms.Avalonia +{ + public interface IMvxWpfSetup : IMvxSetup + { + void PlatformInitialize(Dispatcher uiThreadDispatcher, IMesAvaViewPresenter presenter); + void PlatformInitialize(Dispatcher uiThreadDispatcher, ContentControl root); + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvaSetup.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvaSetup.cs new file mode 100644 index 00000000..087dc692 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvaSetup.cs @@ -0,0 +1,211 @@ +using Avalonia; +using MinoriEditorShell.Messages; +using MinoriEditorShell.Modules.Services; +using MinoriEditorShell.Platforms.Avalonia.Presenters; +//using MinoriEditorShell.Platforms.Avalonia.Services; +//using MinoriEditorShell.Platforms.Avalonia.ViewModels; +using MinoriEditorShell.Platforms.Avalonia.Views; +using MinoriEditorShell.Services; +using MinoriEditorShell.ViewModels; +using MvvmCross; +using MvvmCross.Core; +using MvvmCross.IoC; +using MvvmCross.Plugin; +using MvvmCross.ViewModels; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; + +namespace MinoriEditorShell.Platforms.Wpf +{ + /// + /// This is the main initializer for the kit. Call or over-ride this simualr to any other MvxWpfSetup setup + /// + public class MesAvaSetup : MvxSetup + { + // To handle messages between classes + private MvvmCross.Plugin.Messenger.IMvxMessenger _messenger; + + /// + /// Creates the inital view for the setup + /// + /// Control of the main windows for wpf + /// + // protected override IMvxWpfViewPresenter CreateViewPresenter(ContentControl root) + // { + // // This handles main window. + // return new MesWpfPresenter(root); + // } + + /// + /// Creates the app. + /// + /// An instance of MvxApplication + protected override IMvxApplication CreateApp() + { + _messenger = Mvx.IoCProvider.Resolve(); + Properties.Settings.Default.PropertyChanged += (s, e) => + { + MesSettingsChangedMessage message = new MesSettingsChangedMessage( + s, e.PropertyName, + Properties.Settings.Default.PropertyValues[e.PropertyName]); + _messenger.Publish(message); + }; + + return new TApplication(); + } + + /// + /// Load any additional plugins, calling parent + /// + /// + public override void LoadPlugins(IMvxPluginManager pluginManager) + { + base.LoadPlugins(pluginManager); + pluginManager.EnsurePluginLoaded(); + } + + /// + /// Sets up the dictionary that connects the viewmodel to the view. + /// + /// + protected override IDictionary InitializeLookupDictionary() + { + IDictionary container = base.InitializeLookupDictionary(); + container.Add(typeof(MesSettingsManagerViewModel), typeof(MesSettingsView)); + container.Add(typeof(MesGeneralSettingsViewModel), typeof(MesGeneralSettingsView)); + return container; + } + + /// + /// Used to ensure plugins are loaded. + /// + /// returns base manager + protected override IMvxPluginManager CreatePluginManager() + { + IMvxPluginManager manager = base.CreatePluginManager(); + manager.EnsurePluginLoaded(); + return manager; + } + + /// + /// Sets up initial connected types and setup + /// + public override void InitializePrimary() + { + base.InitializePrimary(); + + // register necessary interfaces + Mvx.IoCProvider.LazyConstructAndRegisterSingleton(); + Mvx.IoCProvider.LazyConstructAndRegisterSingleton(); + Mvx.IoCProvider.LazyConstructAndRegisterSingleton(); + Mvx.IoCProvider.RegisterType(); + + // Register themes + Mvx.IoCProvider.LazyConstructAndRegisterSingleton(); + + // try to setup culture info + String code = Properties.Settings.Default.LanguageCode; + + if (!String.IsNullOrWhiteSpace(code)) + { + CultureInfo culture = CultureInfo.GetCultureInfo(code); + // If code == "en", force to use default resource (Resources.resx) + // See PO #243 +#warning fix translator depends + //if (!Translator.Cultures.Contains(culture)) + // culture = CultureInfo.InvariantCulture; + //Translator.Culture = culture; + Thread.CurrentThread.CurrentUICulture = culture; + Thread.CurrentThread.CurrentCulture = culture; + } + } + } + + ///// + ///// By default, we are configured to use MEF + ///// + //protected override void Configure() + //{ + // // Add all assemblies to AssemblySource (using a temporary DirectoryCatalog). + // var directoryCatalog = new DirectoryCatalog(@"./"); + // AssemblySource.Instance.AddRange( + // directoryCatalog.Parts + // .Select(part => ReflectionModelServices.GetPartType(part).Value.Assembly) + // .Where(assembly => !AssemblySource.Instance.Contains(assembly))); + + // // Prioritise the executable assembly. This allows the client project to override exports, including IShell. + // // The client project can override SelectAssemblies to choose which assemblies are prioritised. + // _priorityAssemblies = SelectAssemblies().ToList(); + // var priorityCatalog = new AggregateCatalog(_priorityAssemblies.Select(x => new AssemblyCatalog(x))); + // var priorityProvider = new CatalogExportProvider(priorityCatalog); + + // // Now get all other assemblies (excluding the priority assemblies). + // var mainCatalog = new AggregateCatalog( + // AssemblySource.Instance + // .Where(assembly => !_priorityAssemblies.Contains(assembly)) + // .Select(x => new AssemblyCatalog(x))); + // var mainProvider = new CatalogExportProvider(mainCatalog); + + // Container = new CompositionContainer(priorityProvider, mainProvider); + // priorityProvider.SourceProvider = Container; + // mainProvider.SourceProvider = Container; + + // var batch = new CompositionBatch(); + + // BindServices(batch); + // batch.AddExportedValue(mainCatalog); + + // Container.Compose(batch); + //} + + // protected virtual void BindServices(CompositionBatch batch) + // { + // batch.AddExportedValue(new WindowManager()); + // batch.AddExportedValue(new EventAggregator()); + // batch.AddExportedValue(Container); + // batch.AddExportedValue(this); + // } + + //protected override object GetInstance(Type serviceType, string key) + //{ + // string contract = string.IsNullOrEmpty(key) ? AttributedModelServices.GetContractName(serviceType) : key; + // var exports = Container.GetExports(contract); + + // if (exports.Any()) + // return exports.First().Value; + + // throw new Exception(string.Format("Could not locate any instances of contract {0}.", contract)); + //} + + //protected override IEnumerable GetAllInstances(Type serviceType) + //{ + // return Container.GetExportedValues(AttributedModelServices.GetContractName(serviceType)); + //} + + //protected override void BuildUp(object instance) + //{ + // Container.SatisfyImportsOnce(instance); + //} + + // protected override IEnumerable SelectAssemblies() + // { + // return new[] { Assembly.GetEntryAssembly() }; + // } + // } + + /// + /// This is the main initializer for the kit. Call or over-ride this simualr to any other MvxWpfSetup setup + /// + /// + // public class MesAvaSetup : MvxAvaSetup where TApplication : class, IMvxApplication, new() + // { + // protected override IMvxApplication CreateApp() => Mvx.IoCProvider.IoCConstruct(); + + // public override IEnumerable GetViewModelAssemblies() + // { + // return new[] { typeof(TApplication).GetTypeInfo().Assembly }; + // } + // } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Extensions/ConsoleModifiersExtension.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Extensions/ConsoleModifiersExtension.cs new file mode 100644 index 00000000..5170998e --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Extensions/ConsoleModifiersExtension.cs @@ -0,0 +1,26 @@ +using System; +using System.Windows.Input; + +namespace MinoriEditorShell.Platforms.Wpf.Extensions +{ + public static class ConsoleModifiersExtension + { + // public static ModifierKeys ToModifierKeys(this ConsoleModifiers console) + // { + // switch (console) + // { + // case ConsoleModifiers.Alt: + // return ModifierKeys.Alt; + + // case ConsoleModifiers.Shift: + // return ModifierKeys.Shift; + + // case ConsoleModifiers.Control: + // return ModifierKeys.Control; + + // default: + // return ModifierKeys.None; + // } + // } + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/MesPersistedDocument.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/MesPersistedDocument.cs new file mode 100644 index 00000000..cce6ae99 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/MesPersistedDocument.cs @@ -0,0 +1,84 @@ +using MinoriEditorShell.Services; +using System; +using System.IO; +using System.Threading.Tasks; + +namespace MinoriEditorShell.Platforms.Wpf +{ + public abstract class MesPersistedDocument : MesDocument, IMesPersistedDocument + { + private Boolean _isDirty; + + public Boolean IsNew { get; private set; } + public String FileName { get; private set; } + public String FilePath { get; private set; } + + public Boolean IsDirty + { + get => _isDirty; + set + { + if (value == _isDirty) + { + return; + } + + _isDirty = value; + RaisePropertyChanged(() => IsDirty); + UpdateDisplayName(); + } + } + +#warning CanClose +#if false + public override void CanClose(System.Action callback) + { + // TODO: Show save prompt. + callback(!IsDirty); + } +#endif + + private void UpdateDisplayName() => DisplayName = (IsDirty) ? FileName + "*" : FileName; + + public async Task New(String fileName) + { + FileName = fileName; + UpdateDisplayName(); + + IsNew = true; + IsDirty = false; + + await DoNew(); + } + + protected abstract Task DoNew(); + + public async Task Load(String filePath) + { + FilePath = filePath; + FileName = Path.GetFileName(filePath); + UpdateDisplayName(); + + IsNew = false; + IsDirty = false; + + await DoLoad(filePath); + } + + protected abstract Task DoLoad(String filePath); + + public async Task Save(String filePath) + { + FilePath = filePath; + FileName = Path.GetFileName(filePath); + UpdateDisplayName(); + + await DoSave(filePath); + + IsDirty = false; + IsNew = false; + } + + protected abstract Task DoSave(String filePath); + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/Attributes/MesContentPresentationAttributes.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/Attributes/MesContentPresentationAttributes.cs new file mode 100644 index 00000000..6c238a56 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/Attributes/MesContentPresentationAttributes.cs @@ -0,0 +1,10 @@ +using MvvmCross.Presenters.Attributes; + +namespace MinoriEditorShell.Platforms.Avalonia.Presenters.Attributes +{ + public class MesContentPresentationAttribute : MvxBasePresentationAttribute + { + public string WindowIdentifier { get; set; } + public bool StackNavigation { get; set; } = true; + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/Attributes/MesWindowPresentationAttribute.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/Attributes/MesWindowPresentationAttribute.cs new file mode 100644 index 00000000..2525eff7 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/Attributes/MesWindowPresentationAttribute.cs @@ -0,0 +1,11 @@ + +using MvvmCross.Presenters.Attributes; + +namespace MinoriEditorShell.Platforms.Avalonia.Presenters.Attributes +{ + public class MesWindowPresentationAttribute : MvxBasePresentationAttribute + { + public string Identifier { get; set; } + public bool Modal { get; set; } + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/IMesAvaViewPresenter.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/IMesAvaViewPresenter.cs new file mode 100644 index 00000000..0a3382f2 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/IMesAvaViewPresenter.cs @@ -0,0 +1,6 @@ +using MvvmCross.Presenters; + +namespace MinoriEditorShell.Platforms.Avalonia.Presenters +{ + public interface IMesAvaViewPresenter : IMvxViewPresenter {} +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvaViewPresenter.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvaViewPresenter.cs new file mode 100644 index 00000000..86d79296 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvaViewPresenter.cs @@ -0,0 +1,134 @@ +using Avalonia.Controls; +using MinoriEditorShell.Platforms.Avalonia.Presenters.Attributes; +using MinoriEditorShell.Services; +using MvvmCross; +using MvvmCross.Exceptions; +using MvvmCross.Logging; +using MvvmCross.Presenters; +using MvvmCross.Presenters.Attributes; +using MvvmCross.ViewModels; +using MvvmCross.Views; +using System; +using System.Threading.Tasks; +using System.Windows; + +namespace MinoriEditorShell.Platforms.Avalonia.Presenters +{ + /// + /// Main presenter that allows document and tools to naviage to MesDocumentController + /// + public class MesAvaViewPresenter : MvxAttributeViewPresenter, IMesAvaViewPresenter + { + private IMvxLog _log; + + /// + /// Main constructor for the presenter, this gets the main window. + /// + /// + public MesAvaViewPresenter(ContentControl mainWindow) : base(mainWindow) + { + IMvxLogProvider provider = Mvx.IoCProvider.Resolve(); + _log = provider.GetLogFor(); + _log.Trace("Setup: Creating Presenter"); + + // Setup main window as singleton + if (mainWindow is IMesWindow mesWindow) + { + _log.Trace("Setting IMesWindow to main window"); + Mvx.IoCProvider.RegisterSingleton(mesWindow); + } + } + + public override MvxBasePresentationAttribute CreatePresentationAttribute(Type viewModelType, Type viewType) + { + if (viewType.IsSubclassOf(typeof(Window))) + { + MvxLog.Instance.Trace($"PresentationAttribute not found for {viewType.Name}. " + + $"Assuming window presentation"); + return new MvxWindowPresentationAttribute(); + } + + MvxLog.Instance.Trace($"PresentationAttribute not found for {viewType.Name}. " + + $"Assuming content presentation"); + return new MvxContentPresentationAttribute(); + } + + public override void RegisterAttributeTypes() + { + AttributeTypesToActionsDictionary.Register( + (viewType, attribute, request) => + { + var view = WpfViewLoader.CreateView(request); + return ShowWindow(view, (MvxWindowPresentationAttribute)attribute, request); + }, + (viewModel, attribute) => CloseWindow(viewModel)); + + AttributeTypesToActionsDictionary.Register( + (viewType, attribute, request) => + { + var view = WpfViewLoader.CreateView(request); + return ShowContentView(view, (MvxContentPresentationAttribute)attribute, request); + }, + (viewModel, attribute) => CloseContentView(viewModel)); + } + + /// + /// This gets called when navigation to view model happens. + /// Depending on what the type is, will define where the class goes. + /// Either to MesDocumentManager or main view if not a IMesDocument or IMesTool + /// + /// + /// + /// + /// + protected async Task ShowContentView( + IMvxView element, MesContentPresentationAttribute attribute, MvxViewModelRequest request) + { + try + { + // Everything that passes here should be a view + IMvxView view = element as IMvxView; + IMesDocumentManager manager = Mvx.IoCProvider.Resolve(); + + // from which we can now get the view model. + switch (view.ViewModel) + { + case IMesDocument document: + + // Try to set view, this is needed for DocumentManager + IMesDocument docViewModel = (IMesDocument)view.ViewModel; + docViewModel.View = view; // Needed for Binding with AvalonDock + + // Add to manager model + manager.Documents.Add(docViewModel); + _log.Trace($"Add {document} to IMesDocumentManager.Documents"); + return true; + + case IMesTool tool: + // Try to set view, this is needed for DocumentManager + IMesTool toolViewModel = (IMesTool)view.ViewModel; + toolViewModel.View = view; // Needed for Binding with AvalonDock + + // Add to manager model + manager.Tools.Add(toolViewModel); + _log.Trace($"Add {tool} to IDocumentManager.Tools"); + return true; + + default: + _log.Trace($"Passing to parent {view.ViewModel.ToString()}"); + return await base.ShowContentView(element, attribute, request); + } + } + catch (Exception exception) + { + if (_log == null) + { + _log = Mvx.IoCProvider.Resolve(); + } + _log.ErrorException("Error seen during navigation request to {0} - error {1}", + exception, request.ViewModelType.Name, exception.ToLongString()); + throw; + } + } + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Services/IMesInputManager.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/IMesInputManager.cs new file mode 100644 index 00000000..ba5f908d --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/IMesInputManager.cs @@ -0,0 +1,12 @@ +using System.Windows; +using System.Windows.Input; + +namespace MinoriEditorShell.Platforms.Wpf.Services +{ + // public interface IMesInputManager + // { + // void SetShortcut(DependencyObject view, InputGesture gesture, object handler); + + // void SetShortcut(InputGesture gesture, object handler); + // } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Services/IMesMainWindow.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/IMesMainWindow.cs new file mode 100644 index 00000000..4a17514b --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/IMesMainWindow.cs @@ -0,0 +1,18 @@ +using MinoriEditorShell.Services; +using System.Windows; +// using System.Windows.Media; + +namespace MinoriEditorShell.Platforms.Wpf.Services +{ + public interface IMesMainWindow + { + // WindowState WindowState { get; set; } + double Width { get; set; } + double Height { get; set; } + + string Title { get; set; } + // ImageSource Icon { get; set; } + + IMesDocumentManager Shell { get; } + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Services/IMesResourceManager.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/IMesResourceManager.cs new file mode 100644 index 00000000..84a10cc9 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/IMesResourceManager.cs @@ -0,0 +1,14 @@ +using System.IO; +// using System.Windows.Media.Imaging; + +namespace MinoriEditorShell.Platforms.Wpf.Services +{ + public interface IMesResourceManager + { + Stream GetStream(string relativeUri, string assemblyName); + + // BitmapImage GetBitmap(string relativeUri, string assemblyName); + + // BitmapImage GetBitmap(string relativeUri); + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesInputBindingTrigger.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesInputBindingTrigger.cs new file mode 100644 index 00000000..d2b76a68 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesInputBindingTrigger.cs @@ -0,0 +1,42 @@ +//using System.Windows.Interactivity; + +namespace MinoriEditorShell.Platforms.Wpf.Services +{ + //public class MesInputBindingTrigger : TriggerBase, ICommand + //{ + // public static readonly DependencyProperty InputBindingProperty = + // DependencyProperty.Register("InputBinding", typeof(InputBinding), + // typeof(MesInputBindingTrigger), new UIPropertyMetadata(null)); + + // public InputBinding InputBinding + // { + // get { return (InputBinding)GetValue(InputBindingProperty); } + // set { SetValue(InputBindingProperty, value); } + // } + + // protected override void OnAttached() + // { + // if (InputBinding != null) + // { + // InputBinding.Command = this; + // AssociatedObject.InputBindings.Add(InputBinding); + // } + // base.OnAttached(); + // } + + // #region ICommand Members + // public bool CanExecute(object parameter) + // { + // // action is anyway blocked by Caliburn at the invoke level + // return true; + // } + // public event EventHandler CanExecuteChanged = delegate { }; + + // public void Execute(object parameter) + // { + // InvokeActions(parameter); + // } + + // #endregion + //} +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesInputManager.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesInputManager.cs new file mode 100644 index 00000000..568ea352 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesInputManager.cs @@ -0,0 +1,52 @@ +//using System.Windows.Interactivity; + +namespace MinoriEditorShell.Platforms.Wpf.Services +{ + // [Export(typeof(IMesInputManager))] + // public class MesInputManager : IMesInputManager + // { + // public void SetShortcut(DependencyObject view, InputGesture gesture, object handler) + // { + // var inputBindingTrigger = new MesInputBindingTrigger(); + // inputBindingTrigger.InputBinding = new InputBinding(new RoutedCommand(), gesture); + + // //var target = ViewLocator.LocateForModel(handler, null, null); + // Interaction.GetTriggers(view).Add(inputBindingTrigger); + + // inputBindingTrigger.Actions.Add(new TestTriggerAction(handler)); + // } + + // public void SetShortcut(InputGesture gesture, object handler) + // { + // SetShortcut(Application.Current.MainWindow, gesture, handler); + // } + + // private class TestTriggerAction : TriggerAction + // { + // private readonly object _handler; + + // public TestTriggerAction(object handler) + // { + // _handler = handler; + // } + + // protected override void Invoke(object parameter) + // { + // throw new NotImplementedException(); + //#warning Invoke + //#if false + // var context = new ActionExecutionContext + // { + // Target = _handler, + // Message = new ActionMessage { MethodName = "Execute" }, + // Method = _handler.GetType().GetMethod("Execute") + // }; + // ActionMessage.PrepareContext(context); + + // if (context.CanExecute()) + // ActionMessage.InvokeAction(context); + //#endif + // } + // } + // } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesMessageBox.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesMessageBox.cs new file mode 100644 index 00000000..bb6a7971 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesMessageBox.cs @@ -0,0 +1,13 @@ +using MinoriEditorShell.Services; +using System; + +namespace MinoriEditorShell.Platforms.Wpf.Services +{ + // internal class MesMessageBox : IMesMessageBox + // { + // // public void Alert(String text, String caption) + // // { + // // System.Windows.MessageBox.Show(text, caption); + // // } + // } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesResourceManager.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesResourceManager.cs new file mode 100644 index 00000000..ac234a56 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesResourceManager.cs @@ -0,0 +1,49 @@ +using MinoriEditorShell.Services; +using System; +using System.ComponentModel.Composition; +using System.IO; +using System.Windows; +// using System.Windows.Media.Imaging; +// using System.Windows.Resources; + +namespace MinoriEditorShell.Platforms.Wpf.Services +{ + // [Export(typeof(IMesResourceManager))] + // public class MesResourceManager : IMesResourceManager + // { + // // public Stream GetStream(String relativeUri, String assemblyName) + // // { + // // try + // // { + // // StreamResourceInfo resource = Application.GetResourceStream(new Uri(assemblyName + ";component/" + relativeUri, UriKind.Relative)) + // // ?? Application.GetResourceStream(new Uri(relativeUri, UriKind.Relative)); + + // // return (resource != null) + // // ? resource.Stream + // // : null; + // // } + // // catch + // // { + // // return null; + // // } + // // } + + // // public BitmapImage GetBitmap(string relativeUri, string assemblyName) + // // { + // // Stream s = GetStream(relativeUri, assemblyName); + // // if (s == null) { return null; } + + // // using (s) + // // { + // // BitmapImage bmp = new BitmapImage(); + // // bmp.BeginInit(); + // // bmp.StreamSource = s; + // // bmp.EndInit(); + // // bmp.Freeze(); + // // return bmp; + // // } + // // } + + // // public BitmapImage GetBitmap(string relativeUri) => GetBitmap(relativeUri, MesExtensionMethods.GetExecutingAssemblyName()); + // } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesThemeManager.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesThemeManager.cs new file mode 100644 index 00000000..230053a7 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesThemeManager.cs @@ -0,0 +1,100 @@ +using MinoriEditorShell.Extensions; +using MinoriEditorShell.Messages; +using MinoriEditorShell.Services; +using MvvmCross; +using MvvmCross.Base; +using MvvmCross.Logging; +using MvvmCross.Plugin.Messenger; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows; + +namespace MinoriEditorShell.Platforms.Wpf.Services +{ + public class MesThemeManager : IMesThemeManager + { + // IOC + private readonly IMvxMessenger _messenger; + + private readonly IMvxLog _log; + + public IEnumerable Themes { get; private set; } + + public IMesTheme CurrentTheme { get; private set; } + + public MesThemeManager(IMvxMessenger messenger, IMvxLogProvider provider) + { + _log = provider.GetLogFor(); + _messenger = messenger; + + Themes = Mvx.IoCProvider.GetAll(); + + _messenger.Subscribe((x) => + { + if (x.Name == "ThemeName") + { + SetCurrentTheme(x.Name); + } + }); + } + + // Needed for Interface + public Boolean SetCurrentTheme(String name) => SetCurrentTheme(name, true); + + public Boolean SetCurrentTheme(String name, Boolean applySetting) + { + try + { + // Find theme for name + IMesTheme theme = Themes.FirstOrDefault(x => x.Name == name); + if (theme == null) { return false; } + CurrentTheme = theme; + + // Setup asnc info + Mvx.IoCProvider.Resolve() + .ExecuteOnMainThreadAsync(() => + { + // // Setup app style + // ResourceDictionary appTheme = + // Application.Current.Resources.MergedDictionaries.Count > 0 + // ? Application.Current.Resources.MergedDictionaries[0] : null; + + // if (appTheme == null) + // { + // appTheme = new ResourceDictionary(); + // Application.Current.Resources.MergedDictionaries.Add(appTheme); + // } + + // appTheme.BeginInit(); + + // appTheme.MergedDictionaries.Clear(); + // foreach (Uri uri in theme.ApplicationResources) + // { + // ResourceDictionary newDict = new ResourceDictionary { Source = uri }; + // appTheme.MergedDictionaries.Add(newDict); + // } + // appTheme.EndInit(); + }); + + _log.Info($"Theme set to {name}"); + + // publish event + _messenger.Publish(new MesThemeChangeMessage(this, CurrentTheme.Name)); + + if (applySetting) + { + Properties.Settings.Default.ThemeName = CurrentTheme.GetType().Name; + Properties.Settings.Default.Save(); + } + + return true; + } + catch (Exception e) + { + _log.InfoException("Log Theme Setting", e); + return false; + } + } + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesGrayscaleEffect.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesGrayscaleEffect.cs new file mode 100644 index 00000000..9a8d6df0 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesGrayscaleEffect.cs @@ -0,0 +1,21 @@ +using System.Windows; +// using System.Windows.Media; + +namespace MinoriEditorShell.Platforms.Wpf.ShaderEffects +{ + // public class MesGrayscaleEffect : MesShaderEffectBase + // { + // // public static readonly DependencyProperty InputProperty = RegisterPixelShaderSamplerProperty("Input", typeof(MesGrayscaleEffect), 0); + + // // public Brush Input + // // { + // // get => (Brush)GetValue(InputProperty); + // // set => SetValue(InputProperty, value); + // // } + + // // public MesGrayscaleEffect() + // // { + // // UpdateShaderValue(InputProperty); + // // } + // } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesGrayscaleEffect.ps b/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesGrayscaleEffect.ps new file mode 100644 index 0000000000000000000000000000000000000000..52ccfa0670cee1cb7715bc88b2e42ad815e14958 GIT binary patch literal 236 zcmZQz`v3pme?f)ryz4AQR<*E&@^wKo@L)vL`Tb@Go!z lJBc4C{$v9K$CCvdU_LvDzW|6EfbL-essr&G{{LrS003NHFoysD literal 0 HcmV?d00001 diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesShaderEffectBase.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesShaderEffectBase.cs new file mode 100644 index 00000000..76685e8e --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesShaderEffectBase.cs @@ -0,0 +1,18 @@ +using System; +// using System.Windows.Media.Effects; + +namespace MinoriEditorShell.Platforms.Wpf.ShaderEffects +{ + // public class MesShaderEffectBase : ShaderEffect, IDisposable + // where T : MesShaderEffectBase + // { + // [ThreadStatic] + // private static PixelShader _shader; + + // private static PixelShader Shader => _shader ?? (_shader = MesShaderEffectUtility.GetPixelShader(typeof(T).Name)); + + // protected MesShaderEffectBase() => PixelShader = Shader; + + // void IDisposable.Dispose() => PixelShader = null; + // } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesShaderEffectUtility.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesShaderEffectUtility.cs new file mode 100644 index 00000000..e8f65d73 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesShaderEffectUtility.cs @@ -0,0 +1,13 @@ +using System; +// using System.Windows.Media.Effects; + +namespace MinoriEditorShell.Platforms.Wpf.ShaderEffects +{ + internal static class MesShaderEffectUtility + { + // public static PixelShader GetPixelShader(string name) => new PixelShader + // { + // UriSource = new Uri($@"pack://application:,,,/MinoriEditorStudio;component/Framework/ShaderEffects/{name}.ps") + // }; + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/BlueTheme.xaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/BlueTheme.xaml new file mode 100644 index 00000000..1aaa5274 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/BlueTheme.xaml @@ -0,0 +1,448 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Button.xaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Button.xaml new file mode 100644 index 00000000..868c148c --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Button.xaml @@ -0,0 +1,43 @@ + + + + + + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/ColorCanvas.xaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/ColorCanvas.xaml new file mode 100644 index 00000000..fcf99b15 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/ColorCanvas.xaml @@ -0,0 +1,196 @@ + + + + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/ColorPicker.xaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/ColorPicker.xaml new file mode 100644 index 00000000..1746d2a2 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/ColorPicker.xaml @@ -0,0 +1,309 @@ + + + + + + + + + + + + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/ComboBox.xaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/ComboBox.xaml new file mode 100644 index 00000000..991a1036 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/ComboBox.xaml @@ -0,0 +1,193 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Focus.xaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Focus.xaml new file mode 100644 index 00000000..804773f7 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Focus.xaml @@ -0,0 +1,16 @@ + + + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Generic.xaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Generic.xaml new file mode 100644 index 00000000..21d2aae9 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Generic.xaml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Label.xaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Label.xaml new file mode 100644 index 00000000..2f0180f7 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Label.xaml @@ -0,0 +1,24 @@ + + + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Menu.xaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Menu.xaml new file mode 100644 index 00000000..bac725c7 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Menu.xaml @@ -0,0 +1,371 @@ + + + + + M 0,5.1 L 1.7,5.2 L 3.4,7.1 L 8,0.4 L 9.2,0 L 3.3,10.8 Z + + + M 0,0 L 4,3.5 L 0,7 Z + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Slider.xaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Slider.xaml new file mode 100644 index 00000000..c9f87f63 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Slider.xaml @@ -0,0 +1,258 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Styles.xaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Styles.xaml new file mode 100644 index 00000000..8e094c80 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Styles.xaml @@ -0,0 +1,21 @@ + + + + + + + + + + + + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/TextBox.xaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/TextBox.xaml new file mode 100644 index 00000000..2f6fa04b --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/TextBox.xaml @@ -0,0 +1,46 @@ + + + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/ToolBarStyles.xaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/ToolBarStyles.xaml new file mode 100644 index 00000000..e5ac73dc --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/ToolBarStyles.xaml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Toolbar.xaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Toolbar.xaml new file mode 100644 index 00000000..ea6b2885 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Toolbar.xaml @@ -0,0 +1,362 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Tooltip.xaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Tooltip.xaml new file mode 100644 index 00000000..2086722f --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Tooltip.xaml @@ -0,0 +1,34 @@ + + + + \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/TreeView.xaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/TreeView.xaml new file mode 100644 index 00000000..858b4fce --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/TreeView.xaml @@ -0,0 +1,166 @@ + + + + + + + + + + + + + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Window.xaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Window.xaml new file mode 100644 index 00000000..40047618 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/Window.xaml @@ -0,0 +1,33 @@ + + + + + + + + + 16 + + Segoe UI, Segoe UI Light, Lucida Sans Unicode, Verdana + + + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/WindowCommands.xaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/WindowCommands.xaml new file mode 100644 index 00000000..cdbe51f1 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/Controls/WindowCommands.xaml @@ -0,0 +1,95 @@ + + + + + + + + + + + + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/DarkTheme.xaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/DarkTheme.xaml new file mode 100644 index 00000000..7c5ecbd1 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/DarkTheme.xaml @@ -0,0 +1,449 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/LightTheme.xaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/LightTheme.xaml new file mode 100644 index 00000000..338e065b --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/LightTheme.xaml @@ -0,0 +1,449 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesBlueTheme.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesBlueTheme.cs new file mode 100644 index 00000000..bdcd72a1 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesBlueTheme.cs @@ -0,0 +1,20 @@ +using System; + +namespace MinoriEditorShell.Platforms.Wpf.Themes +{ + /// + /// Blue Theme + /// + public class MesBlueTheme : MesThemeBase + { + /// + /// Name of theme + /// + public override String Name => Properties.Resources.ThemeBlueName; + + /// + /// Blue theme constructor + /// + public MesBlueTheme() : base() => Add(new Uri("pack://application:,,,/MinoriEditorShell.Platforms.Wpf;component/Themes/BlueTheme.xaml")); + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesDarkTheme.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesDarkTheme.cs new file mode 100644 index 00000000..8ae66012 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesDarkTheme.cs @@ -0,0 +1,20 @@ +using System; + +namespace MinoriEditorShell.Platforms.Wpf.Themes +{ + /// + /// Dark theme definition + /// + public class MesDarkTheme : MesThemeBase + { + /// + /// Name of dark theme + /// + public override String Name => Properties.Resources.ThemeDarkName; + + /// + /// Constructor for theme + /// + public MesDarkTheme() => Add(new Uri("pack://application:,,,/MinoriEditorShell.Platforms.Wpf;component/Themes/DarkTheme.xaml")); + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesLightTheme.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesLightTheme.cs new file mode 100644 index 00000000..2d8afa3a --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesLightTheme.cs @@ -0,0 +1,20 @@ +using System; + +namespace MinoriEditorShell.Platforms.Wpf.Themes +{ + /// + /// Light theme definition + /// + public class MesLightTheme : MesThemeBase + { + /// + /// Name of the light theme + /// + public override String Name => Properties.Resources.ThemeLightName; + + /// + /// Light theme constructor + /// + public MesLightTheme() : base() => Add(new Uri("pack://application:,,,/MinoriEditorShell.Platforms.Wpf;component/Themes/LightTheme.xaml")); + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesThemeBase.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesThemeBase.cs new file mode 100644 index 00000000..5011a9f6 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesThemeBase.cs @@ -0,0 +1,45 @@ +using MinoriEditorShell.Services; +using System; +using System.Collections.Generic; + +namespace MinoriEditorShell.Platforms.Wpf.Themes +{ + /// + /// Base theme to initilizer + /// + public abstract class MesThemeBase : IMesTheme + { + private readonly List _resources; + + /// + /// Name of theme + /// + public virtual String Name => null; + + /// + /// Add resources to themes + /// + /// + public void Add(Uri uri) => _resources.Add(uri); + + /// + /// Add multiple resources Uri + /// + /// + public void AddRange(IEnumerable uri) => _resources.AddRange(uri); + + /// + /// Get resources for application (All Resources) + /// + public IEnumerable ApplicationResources => _resources; + + /// + /// Setup base load definition + /// + protected MesThemeBase() + { + // Initialize the base Mahapps.Metro resources. + _resources = new List(); + } + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesStatusBarItemViewModel.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesStatusBarItemViewModel.cs new file mode 100644 index 00000000..f877bdd1 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesStatusBarItemViewModel.cs @@ -0,0 +1,32 @@ +using MvvmCross.ViewModels; +using System; +using System.Windows; + +namespace MinoriEditorShell.Platforms.Wpf.ViewModels +{ + public class MesStatusBarItemViewModel : MvxNotifyPropertyChanged + { + private Int32 _index; + private String _message; + + public Int32 Index + { + get => _index; + internal set => SetProperty(ref _index, value); + } + + public String Message + { + get => _message; + set => SetProperty(ref _message, value); + } + + // public GridLength Width { get; } + + // public MesStatusBarItemViewModel(String message, GridLength width) + // { + // _message = message; + // Width = width; + // } + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesApplicatioin.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesApplicatioin.cs index f0bb6948..994944c0 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesApplicatioin.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesApplicatioin.cs @@ -23,11 +23,11 @@ public MesApplication() : base() public virtual void ApplicationInitialized() { - // if (MainWindow == null) return; + if (MainWindow == null) return; // MvxWpfSetupSingleton.EnsureSingletonAvailable(Dispatcher, MainWindow).EnsureInitialized(); - // RunAppStart(); + RunAppStart(); } protected virtual void RunAppStart(object hint = null) diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.xaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.xaml new file mode 100644 index 00000000..1dcf8e26 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.xaml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.xaml.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.xaml.cs new file mode 100644 index 00000000..b611f2af --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.xaml.cs @@ -0,0 +1,54 @@ +//using AvalonDock.Controls; +using MinoriEditorShell.Services; +using MinoriEditorShell.ViewModels; +using MvvmCross; +using System; +using System.Collections.Generic; +using System.IO; +using System.Windows; +// using System.Windows.Media; + +namespace MinoriEditorShell.Platforms.Wpf.Views +{ + // public partial class MesDocumentManagerView : IMesDocumentManagerView + // { + // // public MesDocumentManagerView() + // // { + // // InitializeComponent(); + + // // try + // // { + // // IMesDocumentManager manager = Mvx.IoCProvider.Resolve(); + // // manager.ManagerView = this; + // // DataContext = manager; + // // } + // // catch { } + // // } + + // // public void LoadLayout( + // // Stream stream, + // // Action addToolCallback, + // // Action addDocumentCallback, + // // Dictionary itemsState) => + // // MesLayoutUtility.LoadLayout(Manager, stream, addDocumentCallback, addToolCallback, itemsState); + + // // public void SaveLayout(Stream stream) => MesLayoutUtility.SaveLayout(Manager, stream); + + // // private void OnManagerLayoutUpdated(Object sender, EventArgs e) => UpdateFloatingWindows(); + + // public void UpdateFloatingWindows() + // { + // // Window mainWindow = Window.GetWindow(this); + // // if (mainWindow != null) + // // { + // // ImageSource mainWindowIcon = mainWindow.Icon; + // // Boolean showFloatingWindowsInTaskbar = ((MesDocumentManagerViewModel)DataContext).ShowFloatingWindowsInTaskbar; + // // foreach (LayoutFloatingWindowControl window in Manager?.FloatingWindows) + // // { + // // window.Icon = mainWindowIcon; + // // window.ShowInTaskbar = showFloatingWindowsInTaskbar; + // // } + // // } + // } + // } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesGeneralSettingsView.xaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesGeneralSettingsView.xaml new file mode 100644 index 00000000..838f69d2 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesGeneralSettingsView.xaml @@ -0,0 +1,41 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesGeneralSettingsView.xaml.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesGeneralSettingsView.xaml.cs new file mode 100644 index 00000000..5d077f75 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesGeneralSettingsView.xaml.cs @@ -0,0 +1,13 @@ +namespace MinoriEditorShell.Platforms.Wpf.Views +{ + /// + /// Interaction logic for MainMenuSettingsView.xaml + /// + public partial class MesGeneralSettingsView + { + public MesGeneralSettingsView() + { + // InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesLayoutUtility.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesLayoutUtility.cs new file mode 100644 index 00000000..ad87a478 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesLayoutUtility.cs @@ -0,0 +1,71 @@ +// using AvalonDock; +// using AvalonDock.Layout; +// using AvalonDock.Layout.Serialization; +using MinoriEditorShell.Services; +using System; +using System.Collections.Generic; +using System.IO; + +namespace MinoriEditorShell.Platforms.Wpf.Views +{ + internal static class MesLayoutUtility + { + // public static void SaveLayout(DockingManager manager, Stream stream) + // { + // XmlLayoutSerializer layoutSerializer = new XmlLayoutSerializer(manager); + // layoutSerializer.Serialize(stream); + // } + +// public static void LoadLayout( +// DockingManager manager, Stream stream, Action addDocumentCallback, +// Action addToolCallback, Dictionary items) +// { +// XmlLayoutSerializer layoutSerializer = new XmlLayoutSerializer(manager); + +// layoutSerializer.LayoutSerializationCallback += (s, e) => +// { +// if (items.TryGetValue(e.Model.ContentId, out IMesLayoutItem item)) +// { +// e.Content = item; + +// // if (item is IMesTool tool && e.Model is LayoutAnchorable anchorable) +// // { +// // addToolCallback(tool); +// // tool.IsVisible = anchorable.IsVisible; + +// // #warning tool.Activate +// // //if (anchorable.IsActive) +// // // tool.Activate(); + +// // tool.IsSelected = e.Model.IsSelected; + +// // return; +// // } + +// // if (item is IMesDocument document && e.Model is LayoutDocument layoutDocument) +// // { +// // addDocumentCallback(document); + +// // // Nasty hack to get around issue that occurs if documents are loaded from state, +// // // and more documents are opened programmatically. +// // layoutDocument.GetType().GetProperty("IsLastFocusedDocument").SetValue(layoutDocument, false, null); + +// // document.IsSelected = layoutDocument.IsSelected; +// // return; +// // } +// } + +// // Don't create any panels if something went wrong. +// e.Cancel = true; +// }; + +// try +// { +// layoutSerializer.Deserialize(stream); +// } +// catch +// { +// } +// } + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesMainWindowView.xaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesMainWindowView.xaml new file mode 100644 index 00000000..c8aea8a4 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesMainWindowView.xaml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesMainWindowView.xaml.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesMainWindowView.xaml.cs new file mode 100644 index 00000000..5ad29ee4 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesMainWindowView.xaml.cs @@ -0,0 +1,10 @@ +namespace MinoriEditorShell.Platforms.Wpf.Views +{ + public partial class MesMainWindowView + { + public MesMainWindowView() + { + // InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesSettingsView.xaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesSettingsView.xaml new file mode 100644 index 00000000..9cc385bc --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesSettingsView.xaml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesSettingsView.xaml.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesSettingsView.xaml.cs new file mode 100644 index 00000000..085d563f --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesSettingsView.xaml.cs @@ -0,0 +1,18 @@ +using System.Windows; + +namespace MinoriEditorShell.Platforms.Wpf.Views +{ + /// + /// Interaction logic for SettingsView.xaml + /// + public partial class MesSettingsView + { + public MesSettingsView() + { + // InitializeComponent(); + // Owner = Application.Current.MainWindow; + + // Closing += (s, e) => Owner.Focus(); + } + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesStatusBarView.xaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesStatusBarView.xaml new file mode 100644 index 00000000..85294eb9 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesStatusBarView.xaml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesStatusBarView.xaml.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesStatusBarView.xaml.cs new file mode 100644 index 00000000..3369084f --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesStatusBarView.xaml.cs @@ -0,0 +1,25 @@ +using MinoriEditorShell.Services; +using MvvmCross; +// using System.Windows.Controls; + +namespace MinoriEditorShell.Platforms.Wpf.Views +{ + /// + /// Interaction logic for StatusBarView.xaml + /// + // public partial class MesStatusBarView : UserControl + // { + // public MesStatusBarView() + // { + // InitializeComponent(); + + // // for Design Editor + // try + // { + // IMesStatusBar statusBar = Mvx.IoCProvider.Resolve(); + // DataContext = statusBar; + // } + // catch { } + // } + // } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesWindow.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesWindow.cs new file mode 100644 index 00000000..8a289f56 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesWindow.cs @@ -0,0 +1,129 @@ +// using MahApps.Metro.Controls; +using MinoriEditorShell.Services; +using MvvmCross; +using MvvmCross.Binding.BindingContext; +// using MvvmCross.Platforms.Wpf.Views; +using MvvmCross.ViewModels; +using System; +using System.Linq; +using System.Windows; +// using MvxApplication = MvvmCross.Platforms.Wpf.Views.MvxApplication; + +namespace MinoriEditorShell.Platforms.Wpf.Views +{ +// public class MesWindow : MetroWindow, IMesWindow, IMvxWindow, IMvxWpfView +// { +// private IMvxViewModel _viewModel; +// private IMvxBindingContext _bindingContext; + +// public IMvxViewModel ViewModel +// { +// get => _viewModel; +// set +// { +// _viewModel = value; +// DataContext = value; +// BindingContext.DataContext = value; +// } +// } + +// public String Identifier { get; set; } + +// public IMvxBindingContext BindingContext +// { +// get +// { +// if (_bindingContext != null) +// { +// return _bindingContext; +// } + +// if (Mvx.IoCProvider != null) +// { +// this.CreateBindingContext(); +// } + +// return _bindingContext; +// } +// set => _bindingContext = value; +// } + +// public String DisplayName +// { +// get => Title; +// set => Title = value; +// } + +// public MesWindow() +// { +// Unloaded += MesWindow_Unloaded; +// Loaded += MesWindow_Loaded; +// Initialized += MesWindow_Initialized; +// } + +// private void MesWindow_Initialized(Object sender, EventArgs e) +// { +// if (this == Application.Current.MainWindow) +// { +// // Application startup +// (Application.Current as MvxApplication).ApplicationInitialized(); + +// // Init mes setup +// Mvx.IoCProvider.Resolve(); + +// #warning fix style +// //WindowCloseButtonStyle = Application.Current.Resources.MergedDictionaries +// //WindowCloseButtonStyle = "{DynamicResource MetroWindowButtonStyle}" +// //WindowMinButtonStyle = "{DynamicResource MetroWindowButtonStyle}" +// //WindowMaxButtonStyle = "{DynamicResource MetroWindowButtonStyle}" +// } +// } + +// private void MesWindow_Unloaded(Object sender, RoutedEventArgs e) +// { +// ViewModel?.ViewDisappearing(); +// ViewModel?.ViewDisappeared(); +// ViewModel?.ViewDestroy(); +// } + +// /// +// /// Load inital settings if possible +// /// +// /// +// /// +// private void MesWindow_Loaded(Object sender, RoutedEventArgs e) +// { +// String blueTheme = "MesBlueTheme"; + +// // Get main theme property if possible +// String themeName = Properties.Settings.Default.ThemeName; +// if (String.IsNullOrEmpty(themeName)) themeName = blueTheme; + +// // Set theme from name +// IMesThemeManager manager = Mvx.IoCProvider.Resolve(); +// IMesTheme theme = manager.Themes.FirstOrDefault(x => x.GetType().Name == themeName); + +// // Set to defualt if missing or error +// if (theme == null) theme = manager.Themes.First(x => x.GetType().Name == themeName); + +// manager.SetCurrentTheme(theme.Name); + +// ViewModel?.ViewAppearing(); +// ViewModel?.ViewAppeared(); +// } +// } + +// public class MesWindow : MesWindow, IMvxWpfView where TViewModel : class, IMvxViewModel +// { +// public new TViewModel ViewModel +// { +// get => (TViewModel)base.ViewModel; +// set => base.ViewModel = value; +// } + +// MvxFluentBindingDescriptionSet, TViewModel> IMvxWpfView.CreateBindingSet() +// { +// return this.CreateBindingSet, TViewModel>(); +// } +// } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Win32/NativeMethods.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Win32/NativeMethods.cs new file mode 100644 index 00000000..a1ee1b4c --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Win32/NativeMethods.cs @@ -0,0 +1,208 @@ +using System; +using System.Runtime.InteropServices; + +namespace MinoriEditorShell.Platforms.Wpf.Win32 +{ + internal static class NativeMethods + { + #region Constants + + public const int GWL_STYLE = -16; + public const int GWL_EXSTYLE = -20; + + public const int WS_MAXIMIZEBOX = 0x10000; + public const int WS_MINIMIZEBOX = 0x20000; + + public const int WS_EX_DLGMODALFRAME = 0x00000001; + + public const int SWP_NOSIZE = 0x0001; + public const int SWP_NOMOVE = 0x0002; + public const int SWP_NOZORDER = 0x0004; + public const int SWP_FRAMECHANGED = 0x0020; + + public const uint WM_SETICON = 0x0080; + + // Define the window styles we use + public const int WS_CHILD = 0x40000000; + + public const int WS_VISIBLE = 0x10000000; + + // Define the Windows messages we will handle + public const int WM_MOUSEMOVE = 0x0200; + + public const int WM_LBUTTONDOWN = 0x0201; + public const int WM_LBUTTONUP = 0x0202; + public const int WM_LBUTTONDBLCLK = 0x0203; + public const int WM_RBUTTONDOWN = 0x0204; + public const int WM_RBUTTONUP = 0x0205; + public const int WM_RBUTTONDBLCLK = 0x0206; + public const int WM_MBUTTONDOWN = 0x0207; + public const int WM_MBUTTONUP = 0x0208; + public const int WM_MBUTTONDBLCLK = 0x0209; + public const int WM_MOUSEWHEEL = 0x020A; + public const int WM_XBUTTONDOWN = 0x020B; + public const int WM_XBUTTONUP = 0x020C; + public const int WM_XBUTTONDBLCLK = 0x020D; + public const int WM_MOUSELEAVE = 0x02A3; + + // Define the values that let us differentiate between the two extra mouse buttons + public const int MK_XBUTTON1 = 0x020; + + public const int MK_XBUTTON2 = 0x040; + + // Define the cursor icons we use + public const int IDC_ARROW = 32512; + + // Define the TME_LEAVE value so we can register for WM_MOUSELEAVE messages + public const uint TME_LEAVE = 0x00000002; + + #endregion Constants + + #region Delegates and Structs + + public delegate IntPtr WndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam); + + public static readonly WndProc DefaultWindowProc = DefWindowProc; + + [StructLayout(LayoutKind.Sequential)] + public struct TRACKMOUSEEVENT + { + public int cbSize; + public uint dwFlags; + public IntPtr hWnd; + public uint dwHoverTime; + } + + [StructLayout(LayoutKind.Sequential)] + public struct WNDCLASSEX + { + public uint cbSize; + public uint style; + + [MarshalAs(UnmanagedType.FunctionPtr)] + public WndProc lpfnWndProc; + + public int cbClsExtra; + public int cbWndExtra; + public IntPtr hInstance; + public IntPtr hIcon; + public IntPtr hCursor; + public IntPtr hbrBackground; + public string lpszMenuName; + public string lpszClassName; + public IntPtr hIconSm; + } + + [StructLayout(LayoutKind.Sequential)] + public struct NativePoint + { + public int X; + public int Y; + } + + #endregion Delegates and Structs + + #region DllImports + + [DllImport("user32.dll")] + public extern static int GetWindowLong(IntPtr hwnd, int index); + + [DllImport("user32.dll")] + public extern static int SetWindowLong(IntPtr hwnd, int index, int value); + + [DllImport("user32.dll")] + public extern static bool SetWindowPos(IntPtr hwnd, IntPtr hwndInsertAfter, + int x, int y, int width, int height, uint flags); + + [DllImport("user32.dll")] + public static extern IntPtr SendMessage(IntPtr hwnd, uint msg, + IntPtr wParam, IntPtr lParam); + + [DllImport("user32.dll", EntryPoint = "CreateWindowEx", CharSet = CharSet.Auto)] + public static extern IntPtr CreateWindowEx( + int exStyle, + string className, + string windowName, + int style, + int x, int y, + int width, int height, + IntPtr hwndParent, + IntPtr hMenu, + IntPtr hInstance, + [MarshalAs(UnmanagedType.AsAny)] object pvParam); + + [DllImport("user32.dll", EntryPoint = "DestroyWindow", CharSet = CharSet.Auto)] + public static extern bool DestroyWindow(IntPtr hwnd); + + [DllImport("user32.dll")] + public static extern IntPtr DefWindowProc(IntPtr hWnd, uint uMsg, IntPtr wParam, IntPtr lParam); + + [DllImport("kernel32.dll")] + public static extern IntPtr GetModuleHandle(string module); + + [DllImport("user32.dll")] + public static extern IntPtr LoadCursor(IntPtr hInstance, int lpCursorName); + + [DllImport("user32.dll")] + public static extern int TrackMouseEvent(ref TRACKMOUSEEVENT lpEventTrack); + + [DllImport("user32.dll")] + [return: MarshalAs(UnmanagedType.U2)] + public static extern short RegisterClassEx([In] ref WNDCLASSEX lpwcx); + + [DllImport("user32.dll")] + public static extern int ScreenToClient(IntPtr hWnd, ref NativePoint pt); + + [DllImport("user32.dll")] + public static extern int SetFocus(IntPtr hWnd); + + [DllImport("user32.dll")] + public static extern IntPtr GetFocus(); + + [DllImport("user32.dll")] + public static extern IntPtr SetCapture(IntPtr hWnd); + + [DllImport("user32.dll")] + public static extern bool ReleaseCapture(); + + [DllImport("user32.dll")] + public static extern bool GetCursorPos(ref NativePoint point); + + [DllImport("user32.dll")] + public static extern bool SetCursorPos(int x, int y); + + [DllImport("user32.dll")] + public static extern int ShowCursor(bool bShow); + + #endregion DllImports + + #region Helpers + + public static int GetXLParam(int lParam) + { + return LowWord(lParam); + } + + public static int GetYLParam(int lParam) + { + return HighWord(lParam); + } + + public static int GetWheelDeltaWParam(int wParam) + { + return HighWord(wParam); + } + + public static int LowWord(int input) + { + return (short)(input & 0xffff); + } + + public static int HighWord(int input) + { + return (short)(input >> 16); + } + + #endregion Helpers + } +} \ No newline at end of file From a5d9a59fd0b3b48b07e517e4d12dc051a50c955f Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sat, 20 Feb 2021 16:46:46 -0500 Subject: [PATCH 07/68] nuget updates --- .../MinoriDemo.Core/MinoriDemo.Core.csproj | 8 +++---- .../MinoriDemo.RibbonWPF.csproj | 12 +++++----- .../MinoriDemo.RibbonWpfCore.csproj | 4 ++-- .../MinoriDemo.WPF/MinoriDemo.WPF.csproj | 4 ++-- .../MinoriDemo.WpfCore.csproj | 2 +- .../SimpleDemo.Core/SimpleDemo.Core.csproj | 6 ++--- .../SimpleDemo.RibbonWPF.csproj | 6 ++--- .../SimpleDemo.RibbonWpfCore.csproj | 2 +- .../SimpleDemo.WPF/SimpleDemo.WPF.csproj | 4 ++-- .../SimpleDemo.WpfCore.csproj | 2 +- MinoriEditorShell.sln | 7 ++++++ ...inoriEditorShell.Platforms.Avolonia.csproj | 20 ++++++++-------- .../MinoriEditorShell.Platforms.Wpf.csproj | 24 +++++++++---------- .../MinoriEditorShell.Ribbon.csproj | 10 ++++---- ...orShell.VirtualCanvas.Platforms.Wpf.csproj | 4 ++-- .../MinoriEditorShell.VirtualCanvas.csproj | 4 ++-- .../MinoriEditorShell.csproj | 16 ++++++------- ...inoriEditorShell.Platforms.WpfTests.csproj | 12 +++++----- .../MinoriEditorShell.RibbonTests.csproj | 12 +++++----- 19 files changed, 83 insertions(+), 76 deletions(-) diff --git a/Demos/MinoriDemo/MinoriDemo.Core/MinoriDemo.Core.csproj b/Demos/MinoriDemo/MinoriDemo.Core/MinoriDemo.Core.csproj index 1e758e9c..b7b0611f 100644 --- a/Demos/MinoriDemo/MinoriDemo.Core/MinoriDemo.Core.csproj +++ b/Demos/MinoriDemo/MinoriDemo.Core/MinoriDemo.Core.csproj @@ -16,13 +16,13 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.csproj b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.csproj index de9cb688..f45f11aa 100644 --- a/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.csproj +++ b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.csproj @@ -168,24 +168,24 @@ - 1.6.0 + 1.6.2 - 8.0.0 + 8.0.3 - 5.3.7 + 5.5.1 runtime; build; native; contentfiles; analyzers; buildtransitive all - 7.0.0 + 7.1.2 - 7.0.0 + 7.1.2 - 7.0.0 + 7.1.2 1.1.1 diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/MinoriDemo.RibbonWpfCore.csproj b/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/MinoriDemo.RibbonWpfCore.csproj index dc962913..c72c6c04 100644 --- a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/MinoriDemo.RibbonWpfCore.csproj +++ b/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/MinoriDemo.RibbonWpfCore.csproj @@ -17,8 +17,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.csproj b/Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.csproj index a173ed06..a688baa8 100644 --- a/Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.csproj +++ b/Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.csproj @@ -131,12 +131,12 @@ - 5.3.7 + 5.5.1 runtime; build; native; contentfiles; analyzers; buildtransitive all - 7.0.0 + 7.1.2 diff --git a/Demos/MinoriDemo/MinoriDemo.WpfCore/MinoriDemo.WpfCore.csproj b/Demos/MinoriDemo/MinoriDemo.WpfCore/MinoriDemo.WpfCore.csproj index 6cb8ba1a..f02ef02a 100644 --- a/Demos/MinoriDemo/MinoriDemo.WpfCore/MinoriDemo.WpfCore.csproj +++ b/Demos/MinoriDemo/MinoriDemo.WpfCore/MinoriDemo.WpfCore.csproj @@ -13,7 +13,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core.csproj b/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core.csproj index b67bf44a..248dfa60 100644 --- a/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core.csproj +++ b/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core.csproj @@ -10,12 +10,12 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/Demos/SimpleDemo/SimpleDemo.RibbonWPF/SimpleDemo.RibbonWPF.csproj b/Demos/SimpleDemo/SimpleDemo.RibbonWPF/SimpleDemo.RibbonWPF.csproj index f12c5d9f..1a1e8445 100644 --- a/Demos/SimpleDemo/SimpleDemo.RibbonWPF/SimpleDemo.RibbonWPF.csproj +++ b/Demos/SimpleDemo/SimpleDemo.RibbonWPF/SimpleDemo.RibbonWPF.csproj @@ -134,15 +134,15 @@ - 8.0.0 + 8.0.3 - 5.3.7 + 5.5.1 runtime; build; native; contentfiles; analyzers; buildtransitive all - 7.0.0 + 7.1.2 diff --git a/Demos/SimpleDemo/SimpleDemo.RibbonWpfCore/SimpleDemo.RibbonWpfCore.csproj b/Demos/SimpleDemo/SimpleDemo.RibbonWpfCore/SimpleDemo.RibbonWpfCore.csproj index fa8e9bd0..e4845d87 100644 --- a/Demos/SimpleDemo/SimpleDemo.RibbonWpfCore/SimpleDemo.RibbonWpfCore.csproj +++ b/Demos/SimpleDemo/SimpleDemo.RibbonWpfCore/SimpleDemo.RibbonWpfCore.csproj @@ -13,7 +13,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Demos/SimpleDemo/SimpleDemo.WPF/SimpleDemo.WPF.csproj b/Demos/SimpleDemo/SimpleDemo.WPF/SimpleDemo.WPF.csproj index c6390de8..4db0d757 100644 --- a/Demos/SimpleDemo/SimpleDemo.WPF/SimpleDemo.WPF.csproj +++ b/Demos/SimpleDemo/SimpleDemo.WPF/SimpleDemo.WPF.csproj @@ -130,12 +130,12 @@ - 5.3.7 + 5.5.1 runtime; build; native; contentfiles; analyzers; buildtransitive all - 7.0.0 + 7.1.2 diff --git a/Demos/SimpleDemo/SimpleDemo.WpfCore/SimpleDemo.WpfCore.csproj b/Demos/SimpleDemo/SimpleDemo.WpfCore/SimpleDemo.WpfCore.csproj index df8875e1..5518d1d8 100644 --- a/Demos/SimpleDemo/SimpleDemo.WpfCore/SimpleDemo.WpfCore.csproj +++ b/Demos/SimpleDemo/SimpleDemo.WpfCore/SimpleDemo.WpfCore.csproj @@ -13,7 +13,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/MinoriEditorShell.sln b/MinoriEditorShell.sln index 66e4695c..5f8ef2ff 100644 --- a/MinoriEditorShell.sln +++ b/MinoriEditorShell.sln @@ -65,6 +65,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Images", "Images", "{DE4AEC EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MinoriEditorShell.RibbonTests", "Tests\MinoriEditorShell.RibbonTests\MinoriEditorShell.RibbonTests.csproj", "{7A48AD22-69BF-49A7-8988-E163F779997E}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MinoriEditorShell.Platforms.Avolonia", "Modules\MinoriEditorShell.Platforms.Avalonia\MinoriEditorShell.Platforms.Avolonia.csproj", "{C5BE3B91-AB91-4A03-A27E-75D28C56EE8D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -139,6 +141,10 @@ Global {7A48AD22-69BF-49A7-8988-E163F779997E}.Debug|Any CPU.Build.0 = Debug|Any CPU {7A48AD22-69BF-49A7-8988-E163F779997E}.Release|Any CPU.ActiveCfg = Release|Any CPU {7A48AD22-69BF-49A7-8988-E163F779997E}.Release|Any CPU.Build.0 = Release|Any CPU + {C5BE3B91-AB91-4A03-A27E-75D28C56EE8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C5BE3B91-AB91-4A03-A27E-75D28C56EE8D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C5BE3B91-AB91-4A03-A27E-75D28C56EE8D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C5BE3B91-AB91-4A03-A27E-75D28C56EE8D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -164,6 +170,7 @@ Global {31D34D4B-888E-4667-82CE-C9599FD4A974} = {0D78D57D-5ED4-4898-A3E5-39C7B5ECEF0C} {DE4AECF4-649F-45C0-B260-419F68EB5707} = {748FD7C1-877B-451D-809A-68E032C39B34} {7A48AD22-69BF-49A7-8988-E163F779997E} = {D96C6D53-E9ED-4E32-9856-B858A63C9D9E} + {C5BE3B91-AB91-4A03-A27E-75D28C56EE8D} = {417CE623-3714-4105-8A2F-4C1A7DB61AA7} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C4DE08D7-0160-4FCF-876A-904438A56A8A} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avolonia.csproj b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avolonia.csproj index 6ae8d0d4..0f3d4486 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avolonia.csproj +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avolonia.csproj @@ -31,23 +31,23 @@ This uses AvalonDock and has an MVVM architecture based on MvvmCross. - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj b/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj index f9279300..7ccfa7cd 100644 --- a/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj +++ b/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj @@ -32,25 +32,25 @@ This uses AvalonDock and has an MVVM architecture based on MvvmCross. - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + - - - - + + + + diff --git a/Modules/MinoriEditorShell.Ribbon/MinoriEditorShell.Ribbon.csproj b/Modules/MinoriEditorShell.Ribbon/MinoriEditorShell.Ribbon.csproj index 110c5691..320fb4ee 100644 --- a/Modules/MinoriEditorShell.Ribbon/MinoriEditorShell.Ribbon.csproj +++ b/Modules/MinoriEditorShell.Ribbon/MinoriEditorShell.Ribbon.csproj @@ -22,15 +22,15 @@ - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Modules/MinoriEditorShell.VirtualCanvas.Platforms.Wpf/MinoriEditorShell.VirtualCanvas.Platforms.Wpf.csproj b/Modules/MinoriEditorShell.VirtualCanvas.Platforms.Wpf/MinoriEditorShell.VirtualCanvas.Platforms.Wpf.csproj index 11d5602c..e86d5bcb 100644 --- a/Modules/MinoriEditorShell.VirtualCanvas.Platforms.Wpf/MinoriEditorShell.VirtualCanvas.Platforms.Wpf.csproj +++ b/Modules/MinoriEditorShell.VirtualCanvas.Platforms.Wpf/MinoriEditorShell.VirtualCanvas.Platforms.Wpf.csproj @@ -24,11 +24,11 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Modules/MinoriEditorShell.VirtualCanvas/MinoriEditorShell.VirtualCanvas.csproj b/Modules/MinoriEditorShell.VirtualCanvas/MinoriEditorShell.VirtualCanvas.csproj index 5fd7e57d..c222cbde 100644 --- a/Modules/MinoriEditorShell.VirtualCanvas/MinoriEditorShell.VirtualCanvas.csproj +++ b/Modules/MinoriEditorShell.VirtualCanvas/MinoriEditorShell.VirtualCanvas.csproj @@ -21,12 +21,12 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Modules/MinoriEditorShell/MinoriEditorShell.csproj b/Modules/MinoriEditorShell/MinoriEditorShell.csproj index e1b9b874..fb6f583b 100644 --- a/Modules/MinoriEditorShell/MinoriEditorShell.csproj +++ b/Modules/MinoriEditorShell/MinoriEditorShell.csproj @@ -23,21 +23,21 @@ This uses AvalonDock and has an MVVM architecture based on MvvmCross. - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + diff --git a/Tests/MinoriEditorShell.Platforms.WpfTests/MinoriEditorShell.Platforms.WpfTests.csproj b/Tests/MinoriEditorShell.Platforms.WpfTests/MinoriEditorShell.Platforms.WpfTests.csproj index 522cd5d6..50a1dc29 100644 --- a/Tests/MinoriEditorShell.Platforms.WpfTests/MinoriEditorShell.Platforms.WpfTests.csproj +++ b/Tests/MinoriEditorShell.Platforms.WpfTests/MinoriEditorShell.Platforms.WpfTests.csproj @@ -7,20 +7,20 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/Tests/MinoriEditorShell.RibbonTests/MinoriEditorShell.RibbonTests.csproj b/Tests/MinoriEditorShell.RibbonTests/MinoriEditorShell.RibbonTests.csproj index 8d12cd91..1162e84f 100644 --- a/Tests/MinoriEditorShell.RibbonTests/MinoriEditorShell.RibbonTests.csproj +++ b/Tests/MinoriEditorShell.RibbonTests/MinoriEditorShell.RibbonTests.csproj @@ -7,20 +7,20 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + From 030456c790a7c4455d72103aa027f2287140d027 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sat, 20 Feb 2021 17:04:22 -0500 Subject: [PATCH 08/68] removed sonar, using lint instead --- .../MinoriEditorShell.Platforms.Avolonia.csproj | 4 ---- .../MinoriEditorShell.Platforms.Wpf.csproj | 4 ---- .../MinoriEditorShell.Ribbon/MinoriEditorShell.Ribbon.csproj | 4 ---- .../MinoriEditorShell.VirtualCanvas.Platforms.Wpf.csproj | 4 ---- .../MinoriEditorShell.VirtualCanvas.csproj | 5 ----- Modules/MinoriEditorShell/MinoriEditorShell.csproj | 4 ---- 6 files changed, 25 deletions(-) diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avolonia.csproj b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avolonia.csproj index 0f3d4486..758ebf5f 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avolonia.csproj +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avolonia.csproj @@ -42,10 +42,6 @@ This uses AvalonDock and has an MVVM architecture based on MvvmCross. - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj b/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj index 7ccfa7cd..2d0efe68 100644 --- a/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj +++ b/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj @@ -40,10 +40,6 @@ This uses AvalonDock and has an MVVM architecture based on MvvmCross. - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/Modules/MinoriEditorShell.Ribbon/MinoriEditorShell.Ribbon.csproj b/Modules/MinoriEditorShell.Ribbon/MinoriEditorShell.Ribbon.csproj index 320fb4ee..b3baaca4 100644 --- a/Modules/MinoriEditorShell.Ribbon/MinoriEditorShell.Ribbon.csproj +++ b/Modules/MinoriEditorShell.Ribbon/MinoriEditorShell.Ribbon.csproj @@ -30,9 +30,5 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/Modules/MinoriEditorShell.VirtualCanvas.Platforms.Wpf/MinoriEditorShell.VirtualCanvas.Platforms.Wpf.csproj b/Modules/MinoriEditorShell.VirtualCanvas.Platforms.Wpf/MinoriEditorShell.VirtualCanvas.Platforms.Wpf.csproj index e86d5bcb..80696868 100644 --- a/Modules/MinoriEditorShell.VirtualCanvas.Platforms.Wpf/MinoriEditorShell.VirtualCanvas.Platforms.Wpf.csproj +++ b/Modules/MinoriEditorShell.VirtualCanvas.Platforms.Wpf/MinoriEditorShell.VirtualCanvas.Platforms.Wpf.csproj @@ -28,9 +28,5 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - \ No newline at end of file diff --git a/Modules/MinoriEditorShell.VirtualCanvas/MinoriEditorShell.VirtualCanvas.csproj b/Modules/MinoriEditorShell.VirtualCanvas/MinoriEditorShell.VirtualCanvas.csproj index c222cbde..489ede27 100644 --- a/Modules/MinoriEditorShell.VirtualCanvas/MinoriEditorShell.VirtualCanvas.csproj +++ b/Modules/MinoriEditorShell.VirtualCanvas/MinoriEditorShell.VirtualCanvas.csproj @@ -25,11 +25,6 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/Modules/MinoriEditorShell/MinoriEditorShell.csproj b/Modules/MinoriEditorShell/MinoriEditorShell.csproj index fb6f583b..fa8e21b2 100644 --- a/Modules/MinoriEditorShell/MinoriEditorShell.csproj +++ b/Modules/MinoriEditorShell/MinoriEditorShell.csproj @@ -31,10 +31,6 @@ This uses AvalonDock and has an MVVM architecture based on MvvmCross. - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - From b0ab0b27f75dc1f449bd25f68a3456fa67514503 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sat, 20 Feb 2021 17:25:58 -0500 Subject: [PATCH 09/68] SonarLint Connections --- .sonarlint/MinoriEditorShell.slconfig | 13 +- .../CSharp/SonarLint.xml | 89 +++++ ...ankitsune_minorieditorshell2csharp.ruleset | 371 ++++++++++++++++++ 3 files changed, 468 insertions(+), 5 deletions(-) create mode 100644 .sonarlint/torisankitsune_minorieditorshell2/CSharp/SonarLint.xml create mode 100644 .sonarlint/torisankitsune_minorieditorshell2csharp.ruleset diff --git a/.sonarlint/MinoriEditorShell.slconfig b/.sonarlint/MinoriEditorShell.slconfig index 4e0f1215..94f7c454 100644 --- a/.sonarlint/MinoriEditorShell.slconfig +++ b/.sonarlint/MinoriEditorShell.slconfig @@ -1,12 +1,15 @@ { - "ServerUri": "http://localhost:9000", - "Organization": null, - "ProjectKey": "MinoriEditorShell", + "ServerUri": "https://sonarcloud.io/", + "Organization": { + "Key": "torisankitsune-1", + "Name": "torisankitsune-1" + }, + "ProjectKey": "TorisanKitsune_MinoriEditorShell2", "ProjectName": "MinoriEditorShell", "Profiles": { "CSharp": { - "ProfileKey": "AXJr3KqQtbcUywwuo8zS", - "ProfileTimestamp": "2020-05-31T17:52:03Z" + "ProfileKey": "AXfBiG4ncmi_3V30EHaZ", + "ProfileTimestamp": "2021-02-15T09:35:56Z" } } } \ No newline at end of file diff --git a/.sonarlint/torisankitsune_minorieditorshell2/CSharp/SonarLint.xml b/.sonarlint/torisankitsune_minorieditorshell2/CSharp/SonarLint.xml new file mode 100644 index 00000000..21acd70e --- /dev/null +++ b/.sonarlint/torisankitsune_minorieditorshell2/CSharp/SonarLint.xml @@ -0,0 +1,89 @@ + + + + + sonar.cs.analyzeGeneratedCode + false + + + sonar.cs.file.suffixes + .cs + + + sonar.cs.ignoreHeaderComments + true + + + sonar.cs.roslyn.ignoreIssues + false + + + + + S107 + + + max + 7 + + + + + S110 + + + max + 5 + + + + + S1479 + + + maximum + 30 + + + + + S2342 + + + flagsAttributeFormat + ^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?s$ + + + format + ^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?$ + + + + + S2436 + + + max + 2 + + + maxMethod + 3 + + + + + S3776 + + + propertyThreshold + 3 + + + threshold + 15 + + + + + \ No newline at end of file diff --git a/.sonarlint/torisankitsune_minorieditorshell2csharp.ruleset b/.sonarlint/torisankitsune_minorieditorshell2csharp.ruleset new file mode 100644 index 00000000..607decdc --- /dev/null +++ b/.sonarlint/torisankitsune_minorieditorshell2csharp.ruleset @@ -0,0 +1,371 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From c53c6657d18a576cd3a8de91b854b9c2c6573895 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sat, 20 Feb 2021 18:02:51 -0500 Subject: [PATCH 10/68] namespace changes --- MinoriEditorShell.sln | 12 ++++++------ .../Behaviors/CustomGlowWindowBehavior.cs | 2 +- .../MesBindableTreeViewSelectedItemBehavior.cs | 2 +- .../Behaviors/MesKeyboardFocusBehavior.cs | 2 +- .../Behaviors/MesWindowOptionsBehavior.cs | 2 +- .../Controls/MesClippingHwndHost.cs | 4 ++-- .../Controls/MesCustomToggleButton.cs | 2 +- .../Controls/MesDynamicStyle.cs | 2 +- .../Controls/MesExpanderEx.cs | 2 +- .../Controls/MesHwndMouse.cs | 4 ++-- .../Controls/MesHwndMouseEventArgs.cs | 2 +- .../Controls/MesHwndMouseState.cs | 2 +- .../Controls/MesHwndWrapper.cs | 4 ++-- .../Controls/MesLayoutInitializer.cs | 2 +- .../Controls/MesPanesStyleSelector.cs | 2 +- .../Controls/MesPanesTemplateSelector.cs | 2 +- .../Controls/MesSliderEx.cs | 2 +- .../Controls/MesVisualTreeUtility.cs | 2 +- .../Converters/BoolToInsertModeConverter.cs | 2 +- .../DrawingColorToMediaBrushConverter.cs | 2 +- .../DrawingColorToMediaColorConverter.cs | 2 +- .../Converters/NativeConverters.cs | 2 +- .../NullObjectToVisibiltyConverter.cs | 2 +- .../Converters/NullableValueConverter.cs | 2 +- .../Converters/TreeViewIndentConverter.cs | 2 +- .../Core/{IMesAvaSetup.cs => IMesAvnSetup.cs} | 0 .../Core/{MesAvaSetup.cs => MesAvnSetup.cs} | 18 +++++++++++------- .../Extensions/ConsoleModifiersExtension.cs | 2 +- .../MesPersistedDocument.cs | 2 +- ...inoriEditorShell.Platforms.Avalonia.csproj} | 2 +- .../Presenters/MesAvaViewPresenter.cs | 2 +- .../Services/IMesInputManager.cs | 2 +- .../Services/IMesMainWindow.cs | 2 +- .../Services/IMesResourceManager.cs | 2 +- .../Services/MesInputBindingTrigger.cs | 2 +- .../Services/MesInputManager.cs | 2 +- .../Services/MesMessageBox.cs | 2 +- .../Services/MesResourceManager.cs | 2 +- .../Services/MesThemeManager.cs | 2 +- .../ShaderEffects/MesGrayscaleEffect.cs | 2 +- .../ShaderEffects/MesShaderEffectBase.cs | 2 +- .../ShaderEffects/MesShaderEffectUtility.cs | 2 +- .../Themes/MesBlueTheme.cs | 4 ++-- .../Themes/MesDarkTheme.cs | 4 ++-- .../Themes/MesLightTheme.cs | 2 +- .../Themes/MesThemeBase.cs | 2 +- .../ViewModels/MesStatusBarItemViewModel.cs | 2 +- .../Views/MesDocumentManagerView.xaml | 2 +- .../Views/MesDocumentManagerView.xaml.cs | 2 +- .../Views/MesGeneralSettingsView.xaml | 2 +- .../Views/MesGeneralSettingsView.xaml.cs | 2 +- .../Views/MesLayoutUtility.cs | 2 +- .../Views/MesMainWindowView.xaml | 2 +- .../Views/MesMainWindowView.xaml.cs | 2 +- .../Views/MesSettingsView.xaml | 2 +- .../Views/MesSettingsView.xaml.cs | 2 +- .../Views/MesStatusBarView.xaml | 2 +- .../Views/MesStatusBarView.xaml.cs | 2 +- .../Views/MesWindow.cs | 2 +- .../Win32/NativeMethods.cs | 2 +- 60 files changed, 79 insertions(+), 75 deletions(-) rename Modules/MinoriEditorShell.Platforms.Avalonia/Core/{IMesAvaSetup.cs => IMesAvnSetup.cs} (100%) rename Modules/MinoriEditorShell.Platforms.Avalonia/Core/{MesAvaSetup.cs => MesAvnSetup.cs} (94%) rename Modules/MinoriEditorShell.Platforms.Avalonia/{MinoriEditorShell.Platforms.Avolonia.csproj => MinoriEditorShell.Platforms.Avalonia.csproj} (95%) diff --git a/MinoriEditorShell.sln b/MinoriEditorShell.sln index 5f8ef2ff..0b1e110f 100644 --- a/MinoriEditorShell.sln +++ b/MinoriEditorShell.sln @@ -65,7 +65,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Images", "Images", "{DE4AEC EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MinoriEditorShell.RibbonTests", "Tests\MinoriEditorShell.RibbonTests\MinoriEditorShell.RibbonTests.csproj", "{7A48AD22-69BF-49A7-8988-E163F779997E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MinoriEditorShell.Platforms.Avolonia", "Modules\MinoriEditorShell.Platforms.Avalonia\MinoriEditorShell.Platforms.Avolonia.csproj", "{C5BE3B91-AB91-4A03-A27E-75D28C56EE8D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MinoriEditorShell.Platforms.Avalonia", "Modules\MinoriEditorShell.Platforms.Avalonia\MinoriEditorShell.Platforms.Avalonia.csproj", "{C8944E3A-2D90-41D7-B16A-360CE60235A4}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -141,10 +141,10 @@ Global {7A48AD22-69BF-49A7-8988-E163F779997E}.Debug|Any CPU.Build.0 = Debug|Any CPU {7A48AD22-69BF-49A7-8988-E163F779997E}.Release|Any CPU.ActiveCfg = Release|Any CPU {7A48AD22-69BF-49A7-8988-E163F779997E}.Release|Any CPU.Build.0 = Release|Any CPU - {C5BE3B91-AB91-4A03-A27E-75D28C56EE8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C5BE3B91-AB91-4A03-A27E-75D28C56EE8D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C5BE3B91-AB91-4A03-A27E-75D28C56EE8D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C5BE3B91-AB91-4A03-A27E-75D28C56EE8D}.Release|Any CPU.Build.0 = Release|Any CPU + {C8944E3A-2D90-41D7-B16A-360CE60235A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C8944E3A-2D90-41D7-B16A-360CE60235A4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C8944E3A-2D90-41D7-B16A-360CE60235A4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C8944E3A-2D90-41D7-B16A-360CE60235A4}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -170,7 +170,7 @@ Global {31D34D4B-888E-4667-82CE-C9599FD4A974} = {0D78D57D-5ED4-4898-A3E5-39C7B5ECEF0C} {DE4AECF4-649F-45C0-B260-419F68EB5707} = {748FD7C1-877B-451D-809A-68E032C39B34} {7A48AD22-69BF-49A7-8988-E163F779997E} = {D96C6D53-E9ED-4E32-9856-B858A63C9D9E} - {C5BE3B91-AB91-4A03-A27E-75D28C56EE8D} = {417CE623-3714-4105-8A2F-4C1A7DB61AA7} + {C8944E3A-2D90-41D7-B16A-360CE60235A4} = {417CE623-3714-4105-8A2F-4C1A7DB61AA7} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C4DE08D7-0160-4FCF-876A-904438A56A8A} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/CustomGlowWindowBehavior.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/CustomGlowWindowBehavior.cs index c41d1fae..00890f2b 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/CustomGlowWindowBehavior.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/CustomGlowWindowBehavior.cs @@ -1,4 +1,4 @@ -//namespace MinoriEditorShell.Platforms.Wpf.Behaviors +//namespace MinoriEditorShell.Platforms.Avalonia.Behaviors //{ // Copied from MahApp's GlowWindowBehavior, because that one has a bug if GlowBrush is set in a style, rather than directly. //public class CustomGlowWindowBehavior : Behavior diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesBindableTreeViewSelectedItemBehavior.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesBindableTreeViewSelectedItemBehavior.cs index b57be102..3aad14e7 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesBindableTreeViewSelectedItemBehavior.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesBindableTreeViewSelectedItemBehavior.cs @@ -1,4 +1,4 @@ -namespace MinoriEditorShell.Platforms.Wpf.Behaviors +namespace MinoriEditorShell.Platforms.Avalonia.Behaviors { // From http://stackoverflow.com/a/20636049/208817 // public class MesBindableTreeViewSelectedItemBehavior : Behavior diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesKeyboardFocusBehavior.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesKeyboardFocusBehavior.cs index c6eebe76..4bd65d80 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesKeyboardFocusBehavior.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesKeyboardFocusBehavior.cs @@ -1,6 +1,6 @@ //using System.Windows.Interactivity; -namespace MinoriEditorShell.Platforms.Wpf.Behaviors +namespace MinoriEditorShell.Platforms.Avalonia.Behaviors { //public class MesKeyboardFocusBehavior : Behavior //{ diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesWindowOptionsBehavior.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesWindowOptionsBehavior.cs index 02df7cb9..a43a6f1b 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesWindowOptionsBehavior.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesWindowOptionsBehavior.cs @@ -1,6 +1,6 @@ //using System.Windows.Interactivity; -namespace MinoriEditorShell.Platforms.Wpf.Behaviors +namespace MinoriEditorShell.Platforms.Avalonia.Behaviors { //public class MesWindowOptionsBehavior : Behavior //{ diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesClippingHwndHost.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesClippingHwndHost.cs index f80f261a..acf32c13 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesClippingHwndHost.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesClippingHwndHost.cs @@ -1,4 +1,4 @@ -using MinoriEditorShell.Platforms.Wpf.Win32; +using MinoriEditorShell.Platforms.Avalonia.Win32; using System; using System.Collections; using System.Runtime.InteropServices; @@ -6,7 +6,7 @@ // using System.Windows.Interop; // using System.Windows.Media; -namespace MinoriEditorShell.Platforms.Wpf.Controls +namespace MinoriEditorShell.Platforms.Avalonia.Controls { // public class MesClippingHwndHost : HwndHost // { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesCustomToggleButton.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesCustomToggleButton.cs index 89b5804c..5e8cedfc 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesCustomToggleButton.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesCustomToggleButton.cs @@ -1,6 +1,6 @@ //using System.Windows.Controls.Primitives; -namespace MinoriEditorShell.Platforms.Wpf.Controls +namespace MinoriEditorShell.Platforms.Avalonia.Controls { // public class MesCustomToggleButton : ToggleButton // { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesDynamicStyle.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesDynamicStyle.cs index 8f4b5cc8..ae6c684f 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesDynamicStyle.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesDynamicStyle.cs @@ -2,7 +2,7 @@ using System.Windows; //using System.Windows.Controls; -namespace MinoriEditorShell.Platforms.Wpf.Controls +namespace MinoriEditorShell.Platforms.Avalonia.Controls { // Based on http://stackoverflow.com/questions/9490264/dynamicresource-for-style-basedon // public class MesDynamicStyle diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesExpanderEx.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesExpanderEx.cs index bbbb200a..f322a180 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesExpanderEx.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesExpanderEx.cs @@ -1,7 +1,7 @@ using System.Windows; //using System.Windows.Controls; -namespace MinoriEditorShell.Platforms.Wpf.Controls +namespace MinoriEditorShell.Platforms.Avalonia.Controls { // public class MesExpanderEx : Expander // { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouse.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouse.cs index cb3b1162..1767d6be 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouse.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouse.cs @@ -1,8 +1,8 @@ -using MinoriEditorShell.Platforms.Wpf.Win32; +using MinoriEditorShell.Platforms.Avalonia.Win32; using System; using System.Windows; -namespace MinoriEditorShell.Platforms.Wpf.Controls +namespace MinoriEditorShell.Platforms.Avalonia.Controls { public static class MesHwndMouse { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouseEventArgs.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouseEventArgs.cs index 340fa78e..34c26a99 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouseEventArgs.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouseEventArgs.cs @@ -12,7 +12,7 @@ using System.Windows; using System.Windows.Input; -namespace MinoriEditorShell.Platforms.Wpf.Controls +namespace MinoriEditorShell.Platforms.Avalonia.Controls { // public class MesHwndMouseEventArgs : EventArgs // { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouseState.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouseState.cs index 8a979ef7..608d13b6 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouseState.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouseState.cs @@ -11,7 +11,7 @@ using System.Windows; using System.Windows.Input; -namespace MinoriEditorShell.Platforms.Wpf.Controls +namespace MinoriEditorShell.Platforms.Avalonia.Controls { public class MesHwndMouseState { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndWrapper.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndWrapper.cs index 4b2dc7c4..ef68da59 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndWrapper.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndWrapper.cs @@ -8,7 +8,7 @@ #endregion File Description -using MinoriEditorShell.Platforms.Wpf.Win32; +using MinoriEditorShell.Platforms.Avalonia.Win32; using System; using System.Linq; using System.Runtime.InteropServices; @@ -17,7 +17,7 @@ //using System.Windows.Interop; //using System.Windows.Media; -namespace MinoriEditorShell.Platforms.Wpf.Controls +namespace MinoriEditorShell.Platforms.Avalonia.Controls { /// /// A control that enables graphics rendering inside a WPF control through diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesLayoutInitializer.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesLayoutInitializer.cs index cc460aab..2786803e 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesLayoutInitializer.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesLayoutInitializer.cs @@ -5,7 +5,7 @@ using System.Windows; //using System.Windows.Controls; -namespace MinoriEditorShell.Platforms.Wpf.Controls +namespace MinoriEditorShell.Platforms.Avalonia.Controls { // public class MesLayoutInitializer : ILayoutUpdateStrategy // { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesPanesStyleSelector.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesPanesStyleSelector.cs index 7ad5482e..3f7fb354 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesPanesStyleSelector.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesPanesStyleSelector.cs @@ -3,7 +3,7 @@ using System.Windows; //using System.Windows.Controls; -namespace MinoriEditorShell.Platforms.Wpf.Controls +namespace MinoriEditorShell.Platforms.Avalonia.Controls { // public class MesPanesStyleSelector : StyleSelector // { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesPanesTemplateSelector.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesPanesTemplateSelector.cs index 78a95b2e..f6cacf4c 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesPanesTemplateSelector.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesPanesTemplateSelector.cs @@ -2,7 +2,7 @@ using System.Windows; //using System.Windows.Controls; -namespace MinoriEditorShell.Platforms.Wpf.Controls +namespace MinoriEditorShell.Platforms.Avalonia.Controls { // public class MesPanesTemplateSelector : DataTemplateSelector // { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesSliderEx.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesSliderEx.cs index 58b01b40..a8995dfa 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesSliderEx.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesSliderEx.cs @@ -2,7 +2,7 @@ // using System.Windows.Controls; // using System.Windows.Controls.Primitives; -namespace MinoriEditorShell.Platforms.Wpf.Controls +namespace MinoriEditorShell.Platforms.Avalonia.Controls { /// /// Slider that exposes the thumb drag started / completed events directly diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesVisualTreeUtility.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesVisualTreeUtility.cs index 32868f95..a289b919 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesVisualTreeUtility.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesVisualTreeUtility.cs @@ -1,7 +1,7 @@ using System.Windows; //using System.Windows.Media; -namespace MinoriEditorShell.Platforms.Wpf.Controls +namespace MinoriEditorShell.Platforms.Avalonia.Controls { public static class MesVisualTreeUtility { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/BoolToInsertModeConverter.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/BoolToInsertModeConverter.cs index 2fe3216d..2c9293ae 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/BoolToInsertModeConverter.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/BoolToInsertModeConverter.cs @@ -14,7 +14,7 @@ using System; //using System.Windows.Data; -namespace MinoriEditorShell.Platforms.Wpf.Converters +namespace MinoriEditorShell.Platforms.Avalonia.Converters { // public class BoolToInsertModeConverter : IValueConverter // { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/DrawingColorToMediaBrushConverter.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/DrawingColorToMediaBrushConverter.cs index d84d5df1..d32dda6c 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/DrawingColorToMediaBrushConverter.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/DrawingColorToMediaBrushConverter.cs @@ -3,7 +3,7 @@ //using System.Windows.Data; //using System.Windows.Media; -namespace MinoriEditorShell.Platforms.Wpf.Converters +namespace MinoriEditorShell.Platforms.Avalonia.Converters { // public class DrawingColorToMediaBrushConverter : IValueConverter // { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/DrawingColorToMediaColorConverter.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/DrawingColorToMediaColorConverter.cs index 3bbbf2cb..575d6168 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/DrawingColorToMediaColorConverter.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/DrawingColorToMediaColorConverter.cs @@ -3,7 +3,7 @@ // using System.Windows.Data; // using System.Windows.Media; -namespace MinoriEditorShell.Platforms.Wpf.Converters +namespace MinoriEditorShell.Platforms.Avalonia.Converters { // public class DrawingColorToMediaColorConverter : IValueConverter // { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/NativeConverters.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/NativeConverters.cs index 01d15d27..0f066d30 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/NativeConverters.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/NativeConverters.cs @@ -1,6 +1,6 @@ // using MvvmCross.Platforms.Wpf.Converters; -namespace MinoriEditorShell.Platforms.Wpf.Converters +namespace MinoriEditorShell.Platforms.Avalonia.Converters { // public class CultureInfoNameConverter : MvxNativeValueConverter // { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/NullObjectToVisibiltyConverter.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/NullObjectToVisibiltyConverter.cs index cc24ea7b..795982b3 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/NullObjectToVisibiltyConverter.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/NullObjectToVisibiltyConverter.cs @@ -16,7 +16,7 @@ using System.Windows; //using System.Windows.Data; -namespace MinoriEditorShell.Platforms.Wpf.Converters +namespace MinoriEditorShell.Platforms.Avalonia.Converters { // public class NullObjectToVisibiltyConverter : IValueConverter // { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/NullableValueConverter.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/NullableValueConverter.cs index 1b330bbb..f6cfbccf 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/NullableValueConverter.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/NullableValueConverter.cs @@ -3,7 +3,7 @@ using System.Windows; //using System.Windows.Data; -namespace MinoriEditorShell.Platforms.Wpf.Converters +namespace MinoriEditorShell.Platforms.Avalonia.Converters { // public class NullableValueConverter : IValueConverter // { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/TreeViewIndentConverter.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/TreeViewIndentConverter.cs index 4d605f3c..bd6fc637 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/TreeViewIndentConverter.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/TreeViewIndentConverter.cs @@ -5,7 +5,7 @@ // using System.Windows.Data; // using System.Windows.Media; -namespace MinoriEditorShell.Platforms.Wpf.Converters +namespace MinoriEditorShell.Platforms.Avalonia.Converters { // public class TreeViewIndentConverter : IValueConverter // { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Core/IMesAvaSetup.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/IMesAvnSetup.cs similarity index 100% rename from Modules/MinoriEditorShell.Platforms.Avalonia/Core/IMesAvaSetup.cs rename to Modules/MinoriEditorShell.Platforms.Avalonia/Core/IMesAvnSetup.cs diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvaSetup.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs similarity index 94% rename from Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvaSetup.cs rename to Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs index 087dc692..796aa83d 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvaSetup.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs @@ -1,10 +1,14 @@ using Avalonia; +using Avalonia.Controls; using MinoriEditorShell.Messages; using MinoriEditorShell.Modules.Services; using MinoriEditorShell.Platforms.Avalonia.Presenters; //using MinoriEditorShell.Platforms.Avalonia.Services; //using MinoriEditorShell.Platforms.Avalonia.ViewModels; using MinoriEditorShell.Platforms.Avalonia.Views; +using MinoriEditorShell.Platforms.Avalonia.Services; +using MinoriEditorShell.Platforms.Avalonia.ViewModels; +using MinoriEditorShell.Platforms.Avalonia.Views; using MinoriEditorShell.Services; using MinoriEditorShell.ViewModels; using MvvmCross; @@ -17,12 +21,12 @@ using System.Globalization; using System.Threading; -namespace MinoriEditorShell.Platforms.Wpf +namespace MinoriEditorShell.Platforms.Avalonia { /// /// This is the main initializer for the kit. Call or over-ride this simualr to any other MvxWpfSetup setup /// - public class MesAvaSetup : MvxSetup + public class MesAvnSetup : MvxSetup { // To handle messages between classes private MvvmCross.Plugin.Messenger.IMvxMessenger _messenger; @@ -32,11 +36,11 @@ public class MesAvaSetup : MvxSetup /// /// Control of the main windows for wpf /// - // protected override IMvxWpfViewPresenter CreateViewPresenter(ContentControl root) - // { - // // This handles main window. - // return new MesWpfPresenter(root); - // } + protected override IMvxWpfViewPresenter CreateViewPresenter(ContentControl root) + { + // This handles main window. + return new MesWpfPresenter(root); + } /// /// Creates the app. diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Extensions/ConsoleModifiersExtension.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Extensions/ConsoleModifiersExtension.cs index 5170998e..3bd8c52d 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Extensions/ConsoleModifiersExtension.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Extensions/ConsoleModifiersExtension.cs @@ -1,7 +1,7 @@ using System; using System.Windows.Input; -namespace MinoriEditorShell.Platforms.Wpf.Extensions +namespace MinoriEditorShell.Platforms.Avalonia.Extensions { public static class ConsoleModifiersExtension { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/MesPersistedDocument.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/MesPersistedDocument.cs index cce6ae99..be11073b 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/MesPersistedDocument.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/MesPersistedDocument.cs @@ -3,7 +3,7 @@ using System.IO; using System.Threading.Tasks; -namespace MinoriEditorShell.Platforms.Wpf +namespace MinoriEditorShell.Platforms.Avalonia { public abstract class MesPersistedDocument : MesDocument, IMesPersistedDocument { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avolonia.csproj b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj similarity index 95% rename from Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avolonia.csproj rename to Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj index 758ebf5f..37d84a5d 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avolonia.csproj +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj @@ -9,7 +9,7 @@ This uses AvalonDock and has an MVVM architecture based on MvvmCross.https://github.com/TorisanKitsune/MinoriEditorShell git - .net40 netcoreapp WPF MvvmCross AvalonDock Visual Studio IDE Shell + .net40 netcoreapp AvaloniaUI MvvmCross AvalonDock Visual Studio IDE Shell true Mark Kromis Mark Kromis diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvaViewPresenter.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvaViewPresenter.cs index 86d79296..402b52a2 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvaViewPresenter.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvaViewPresenter.cs @@ -28,7 +28,7 @@ public class MesAvaViewPresenter : MvxAttributeViewPresenter, IMesAvaViewPresent public MesAvaViewPresenter(ContentControl mainWindow) : base(mainWindow) { IMvxLogProvider provider = Mvx.IoCProvider.Resolve(); - _log = provider.GetLogFor(); + _log = provider.GetLogFor(); _log.Trace("Setup: Creating Presenter"); // Setup main window as singleton diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Services/IMesInputManager.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/IMesInputManager.cs index ba5f908d..11601780 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Services/IMesInputManager.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/IMesInputManager.cs @@ -1,7 +1,7 @@ using System.Windows; using System.Windows.Input; -namespace MinoriEditorShell.Platforms.Wpf.Services +namespace MinoriEditorShell.Platforms.Avalonia.Services { // public interface IMesInputManager // { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Services/IMesMainWindow.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/IMesMainWindow.cs index 4a17514b..eb32cef9 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Services/IMesMainWindow.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/IMesMainWindow.cs @@ -2,7 +2,7 @@ using System.Windows; // using System.Windows.Media; -namespace MinoriEditorShell.Platforms.Wpf.Services +namespace MinoriEditorShell.Platforms.Avalonia.Services { public interface IMesMainWindow { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Services/IMesResourceManager.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/IMesResourceManager.cs index 84a10cc9..d146633c 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Services/IMesResourceManager.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/IMesResourceManager.cs @@ -1,7 +1,7 @@ using System.IO; // using System.Windows.Media.Imaging; -namespace MinoriEditorShell.Platforms.Wpf.Services +namespace MinoriEditorShell.Platforms.Avalonia.Services { public interface IMesResourceManager { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesInputBindingTrigger.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesInputBindingTrigger.cs index d2b76a68..4ab2c2c6 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesInputBindingTrigger.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesInputBindingTrigger.cs @@ -1,6 +1,6 @@ //using System.Windows.Interactivity; -namespace MinoriEditorShell.Platforms.Wpf.Services +namespace MinoriEditorShell.Platforms.Avalonia.Services { //public class MesInputBindingTrigger : TriggerBase, ICommand //{ diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesInputManager.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesInputManager.cs index 568ea352..f11c28e6 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesInputManager.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesInputManager.cs @@ -1,6 +1,6 @@ //using System.Windows.Interactivity; -namespace MinoriEditorShell.Platforms.Wpf.Services +namespace MinoriEditorShell.Platforms.Avalonia.Services { // [Export(typeof(IMesInputManager))] // public class MesInputManager : IMesInputManager diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesMessageBox.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesMessageBox.cs index bb6a7971..4eb04635 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesMessageBox.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesMessageBox.cs @@ -1,7 +1,7 @@ using MinoriEditorShell.Services; using System; -namespace MinoriEditorShell.Platforms.Wpf.Services +namespace MinoriEditorShell.Platforms.Avalonia.Services { // internal class MesMessageBox : IMesMessageBox // { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesResourceManager.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesResourceManager.cs index ac234a56..3a899881 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesResourceManager.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesResourceManager.cs @@ -6,7 +6,7 @@ // using System.Windows.Media.Imaging; // using System.Windows.Resources; -namespace MinoriEditorShell.Platforms.Wpf.Services +namespace MinoriEditorShell.Platforms.Avalonia.Services { // [Export(typeof(IMesResourceManager))] // public class MesResourceManager : IMesResourceManager diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesThemeManager.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesThemeManager.cs index 230053a7..d14b482c 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesThemeManager.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesThemeManager.cs @@ -10,7 +10,7 @@ using System.Linq; using System.Windows; -namespace MinoriEditorShell.Platforms.Wpf.Services +namespace MinoriEditorShell.Platforms.Avalonia.Services { public class MesThemeManager : IMesThemeManager { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesGrayscaleEffect.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesGrayscaleEffect.cs index 9a8d6df0..53195811 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesGrayscaleEffect.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesGrayscaleEffect.cs @@ -1,7 +1,7 @@ using System.Windows; // using System.Windows.Media; -namespace MinoriEditorShell.Platforms.Wpf.ShaderEffects +namespace MinoriEditorShell.Platforms.Avalonia.ShaderEffects { // public class MesGrayscaleEffect : MesShaderEffectBase // { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesShaderEffectBase.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesShaderEffectBase.cs index 76685e8e..28de2b2d 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesShaderEffectBase.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesShaderEffectBase.cs @@ -1,7 +1,7 @@ using System; // using System.Windows.Media.Effects; -namespace MinoriEditorShell.Platforms.Wpf.ShaderEffects +namespace MinoriEditorShell.Platforms.Avalonia.ShaderEffects { // public class MesShaderEffectBase : ShaderEffect, IDisposable // where T : MesShaderEffectBase diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesShaderEffectUtility.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesShaderEffectUtility.cs index e8f65d73..00dbf00f 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesShaderEffectUtility.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesShaderEffectUtility.cs @@ -1,7 +1,7 @@ using System; // using System.Windows.Media.Effects; -namespace MinoriEditorShell.Platforms.Wpf.ShaderEffects +namespace MinoriEditorShell.Platforms.Avalonia.ShaderEffects { internal static class MesShaderEffectUtility { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesBlueTheme.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesBlueTheme.cs index bdcd72a1..aa5c848b 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesBlueTheme.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesBlueTheme.cs @@ -1,6 +1,6 @@ using System; -namespace MinoriEditorShell.Platforms.Wpf.Themes +namespace MinoriEditorShell.Platforms.Avalonia.Themes { /// /// Blue Theme @@ -15,6 +15,6 @@ public class MesBlueTheme : MesThemeBase /// /// Blue theme constructor /// - public MesBlueTheme() : base() => Add(new Uri("pack://application:,,,/MinoriEditorShell.Platforms.Wpf;component/Themes/BlueTheme.xaml")); + public MesBlueTheme() : base() => Add(new Uri("pack://application:,,,/MinoriEditorShell.Platforms.Avalonia;component/Themes/BlueTheme.xaml")); } } \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesDarkTheme.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesDarkTheme.cs index 8ae66012..737311fc 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesDarkTheme.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesDarkTheme.cs @@ -1,6 +1,6 @@ using System; -namespace MinoriEditorShell.Platforms.Wpf.Themes +namespace MinoriEditorShell.Platforms.Avalonia.Themes { /// /// Dark theme definition @@ -15,6 +15,6 @@ public class MesDarkTheme : MesThemeBase /// /// Constructor for theme /// - public MesDarkTheme() => Add(new Uri("pack://application:,,,/MinoriEditorShell.Platforms.Wpf;component/Themes/DarkTheme.xaml")); + public MesDarkTheme() => Add(new Uri("pack://application:,,,/MinoriEditorShell.Platforms.Avalonia;component/Themes/DarkTheme.xaml")); } } \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesLightTheme.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesLightTheme.cs index 2d8afa3a..dcd251de 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesLightTheme.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesLightTheme.cs @@ -1,6 +1,6 @@ using System; -namespace MinoriEditorShell.Platforms.Wpf.Themes +namespace MinoriEditorShell.Platforms.Avalonia.Themes { /// /// Light theme definition diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesThemeBase.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesThemeBase.cs index 5011a9f6..4119ee37 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesThemeBase.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesThemeBase.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; -namespace MinoriEditorShell.Platforms.Wpf.Themes +namespace MinoriEditorShell.Platforms.Avalonia.Themes { /// /// Base theme to initilizer diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesStatusBarItemViewModel.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesStatusBarItemViewModel.cs index f877bdd1..60d8c038 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesStatusBarItemViewModel.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesStatusBarItemViewModel.cs @@ -2,7 +2,7 @@ using System; using System.Windows; -namespace MinoriEditorShell.Platforms.Wpf.ViewModels +namespace MinoriEditorShell.Platforms.Avalonia.ViewModels { public class MesStatusBarItemViewModel : MvxNotifyPropertyChanged { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.xaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.xaml index 1dcf8e26..466c0f51 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.xaml +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.xaml @@ -1,5 +1,5 @@ /// Interaction logic for MainMenuSettingsView.xaml diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesLayoutUtility.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesLayoutUtility.cs index ad87a478..fd2e4a09 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesLayoutUtility.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesLayoutUtility.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.IO; -namespace MinoriEditorShell.Platforms.Wpf.Views +namespace MinoriEditorShell.Platforms.Avalonia.Views { internal static class MesLayoutUtility { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesMainWindowView.xaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesMainWindowView.xaml index c8aea8a4..b697a7e0 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesMainWindowView.xaml +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesMainWindowView.xaml @@ -1,6 +1,6 @@ /// Interaction logic for SettingsView.xaml diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesStatusBarView.xaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesStatusBarView.xaml index 85294eb9..85416928 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesStatusBarView.xaml +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesStatusBarView.xaml @@ -1,5 +1,5 @@  /// Interaction logic for StatusBarView.xaml diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesWindow.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesWindow.cs index 8a289f56..3cb922b2 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesWindow.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesWindow.cs @@ -9,7 +9,7 @@ using System.Windows; // using MvxApplication = MvvmCross.Platforms.Wpf.Views.MvxApplication; -namespace MinoriEditorShell.Platforms.Wpf.Views +namespace MinoriEditorShell.Platforms.Avalonia.Views { // public class MesWindow : MetroWindow, IMesWindow, IMvxWindow, IMvxWpfView // { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Win32/NativeMethods.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Win32/NativeMethods.cs index a1ee1b4c..d2c003a7 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Win32/NativeMethods.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Win32/NativeMethods.cs @@ -1,7 +1,7 @@ using System; using System.Runtime.InteropServices; -namespace MinoriEditorShell.Platforms.Wpf.Win32 +namespace MinoriEditorShell.Platforms.Avalonia.Win32 { internal static class NativeMethods { From ea9c60ef90f2dffe87b6e30e449a2a6667f6cd4c Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sun, 21 Feb 2021 10:09:31 -0500 Subject: [PATCH 11/68] Barrowed from patforms.wpf --- .../Binding/Bi.n.d.cs | 79 ++++ .../Binding/IMesBindingCreator.cs | 15 + .../Binding/IMesWindowsAssemblyCache.cs | 10 + .../Binding/Import.cs | 57 +++ .../Binding/La.n.g.cs | 71 ++++ .../MesBinding/MesMvvmCrossBindingCreator.cs | 121 +++++++ .../MesWindowsTargetBindingFactoryRegistry.cs | 51 +++ .../Target/MesCollapsedTargetBinding.cs | 18 + .../MesDependencyPropertyTargetBinding.cs | 96 +++++ .../Target/MesVisibleTargetBinding.cs | 25 ++ .../Binding/MesBindingCreator.cs | 35 ++ .../MesDependencyPropertyExtensions.cs | 77 ++++ .../Binding/MesDesignTimeChecker.cs | 27 ++ .../Binding/MesWindowsAssemblyCache.cs | 30 ++ .../Binding/MesWindowsBindingBuilder.cs | 132 +++++++ .../Binding/MesWindowsPropertyBinding.cs | 9 + .../MesWindowsPropertyBindingExtensions.cs | 14 + .../AvnWindowsBindingCreator.cs | 103 ++++++ .../Converters/MvxNativeValueConverters.cs | 69 ++++ .../Core/IMesAvnSetup.cs | 4 +- .../Core/MesAvnSetup.cs | 315 +++++++++------- ...inoriEditorShell.Platforms.Avalonia.csproj | 4 +- ...ewPresenter.cs => IMesAvnViewPresenter.cs} | 2 +- ...iewPresenter.cs => MesAvnViewPresenter.cs} | 22 +- .../Views/IMesAvnView.cs | 21 ++ .../Views/IMesAvnViewLoader.cs | 6 + .../Views/IMesAvnViewsContainer.cs | 10 + .../{MesApplicatioin.cs => MesApplication.cs} | 38 +- .../Views/MesAvnUIThreadDispatcher.cs | 39 ++ .../Views/MesAvnView.cs | 97 +++++ .../Views/MesAvnViewDispatcher.cs | 34 ++ .../Views/MesAvnViewsContainer.cs | 10 + .../Views/MesWindow.cs | 342 ++++++++++++------ 33 files changed, 1706 insertions(+), 277 deletions(-) create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Binding/Bi.n.d.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Binding/IMesBindingCreator.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Binding/IMesWindowsAssemblyCache.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Binding/Import.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Binding/La.n.g.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/MesMvvmCrossBindingCreator.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/MesWindowsTargetBindingFactoryRegistry.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/Target/MesCollapsedTargetBinding.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/Target/MesDependencyPropertyTargetBinding.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/Target/MesVisibleTargetBinding.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBindingCreator.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesDependencyPropertyExtensions.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesDesignTimeChecker.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsAssemblyCache.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsBindingBuilder.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsPropertyBinding.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsPropertyBindingExtensions.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Binding/WindowsBinding/AvnWindowsBindingCreator.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Converters/MvxNativeValueConverters.cs rename Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/{IMesAvaViewPresenter.cs => IMesAvnViewPresenter.cs} (58%) rename Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/{MesAvaViewPresenter.cs => MesAvnViewPresenter.cs} (86%) create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnView.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnViewLoader.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnViewsContainer.cs rename Modules/MinoriEditorShell.Platforms.Avalonia/Views/{MesApplicatioin.cs => MesApplication.cs} (51%) create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnUIThreadDispatcher.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnView.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnViewDispatcher.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnViewsContainer.cs diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/Bi.n.d.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/Bi.n.d.cs new file mode 100644 index 00000000..9cef3f67 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/Bi.n.d.cs @@ -0,0 +1,79 @@ +using System.Collections.Generic; +using System.Windows; +using MvvmCross.Base; +using MvvmCross.Exceptions; +using MvvmCross.Binding; +using MvvmCross.Binding.Bindings; +using MvvmCross; + +namespace MinoriEditorShell.Platforms.Avalonia.Binding +{ + // ReSharper disable InconsistentNaming + public static class Bi + // ReSharper restore InconsistentNaming + { + static Bi() + { + MesDesignTimeChecker.Check(); + } + + // ReSharper disable InconsistentNaming + public static readonly DependencyProperty ndProperty = + // ReSharper restore InconsistentNaming + DependencyProperty.RegisterAttached("nd", + typeof(string), + typeof(Bi), + new PropertyMetadata(null, CallBackWhenndIsChanged)); + + public static string Getnd(DependencyObject obj) + { + return obj.GetValue(ndProperty) as string; + } + + public static void Setnd( + DependencyObject obj, + string value) + { + obj.SetValue(ndProperty, value); + } + + private static IMesBindingCreator _bindingCreator; + + private static IMesBindingCreator BindingCreator + { + get + { + _bindingCreator = _bindingCreator ?? ResolveBindingCreator(); + return _bindingCreator; + } + } + + private static IMesBindingCreator ResolveBindingCreator() + { + IMesBindingCreator toReturn; + if (!Mvx.IoCProvider.TryResolve(out toReturn)) + { + throw new MvxException("Unable to resolve the binding creator - have you initialized Windows Binding"); + } + + return toReturn; + } + + private static void CallBackWhenndIsChanged( + object sender, + DependencyPropertyChangedEventArgs args) + { + var bindingCreator = BindingCreator; + + bindingCreator?.CreateBindings(sender, args, ParseBindingDescriptions); + } + + private static IEnumerable ParseBindingDescriptions(string bindingText) + { + if (MvxSingleton.Instance == null) + return null; + + return MvxSingleton.Instance.BindingDescriptionParser.Parse(bindingText); + } + } +} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/IMesBindingCreator.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/IMesBindingCreator.cs new file mode 100644 index 00000000..bcb461e0 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/IMesBindingCreator.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Windows; +using MvvmCross.Binding.Bindings; + +namespace MinoriEditorShell.Platforms.Avalonia.Binding +{ + public interface IMesBindingCreator + { + void CreateBindings( + object sender, + DependencyPropertyChangedEventArgs args, + Func> parseBindingDescriptions); + } +} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/IMesWindowsAssemblyCache.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/IMesWindowsAssemblyCache.cs new file mode 100644 index 00000000..e570205f --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/IMesWindowsAssemblyCache.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using System.Reflection; + +namespace MinoriEditorShell.Platforms.Avalonia.Binding +{ + public interface IMesWindowsAssemblyCache + { + IList Assemblies { get; } + } +} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/Import.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/Import.cs new file mode 100644 index 00000000..914d7108 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/Import.cs @@ -0,0 +1,57 @@ +using System.Reflection; +using MvvmCross.Base; +using MvvmCross.Converters; +using MvvmCross.IoC; +using MvvmCross.Binding.Combiners; +using MvvmCross; + +namespace MinoriEditorShell.Platforms.Avalonia.Binding +{ + public class Import + { + static Import() + { + MesDesignTimeChecker.Check(); + } + + private object _from; + + public object From + { + get { return _from; } + set + { + if (_from == value) + return; + + _from = value; + if (_from != null) + { + RegisterAssembly(_from.GetType().Assembly); + } + } + } + + private static void RegisterAssembly(Assembly assembly) + { + if (MvxSingleton.Instance == null) + { + MesWindowsAssemblyCache.EnsureInitialized(); + MesWindowsAssemblyCache.Instance?.Assemblies.Add(assembly); + } + else + { + Mvx.IoCProvider.CallbackWhenRegistered( + registry => + { + registry.AddOrOverwriteFrom(assembly); + }); + Mvx.IoCProvider.CallbackWhenRegistered( + registry => + { + registry.AddOrOverwriteFrom(assembly); + }); + } + } + } +} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/La.n.g.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/La.n.g.cs new file mode 100644 index 00000000..ee160e51 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/La.n.g.cs @@ -0,0 +1,71 @@ +using System; +using System.Windows; +using System.Collections.Generic; +using MvvmCross.Binding.Bindings; +using MvvmCross.Base; +using MvvmCross.Binding; +using MvvmCross.Core; + +namespace MinoriEditorShell.Platforms.Avalonia.Binding +{ + // ReSharper disable InconsistentNaming + public static class La + // ReSharper restore InconsistentNaming + { + static La() + { + MesDesignTimeChecker.Check(); + } + + // ReSharper disable InconsistentNaming + public static readonly DependencyProperty ngProperty = + // ReSharper restore InconsistentNaming + DependencyProperty.RegisterAttached("ng", + typeof(string), + typeof(La), + new PropertyMetadata(null, CallBackWhenngIsChanged)); + + public static string Getng(DependencyObject obj) + { + return obj.GetValue(ngProperty) as string; + } + + public static void Setng( + DependencyObject obj, + string value) + { + obj.SetValue(ngProperty, value); + } + + private static IMesBindingCreator _bindingCreator; + + private static IMesBindingCreator BindingCreator + { + get + { + _bindingCreator = _bindingCreator ?? Mvx.IoCProvider.Resolve(); + return _bindingCreator; + } + } + + private static void CallBackWhenngIsChanged( + object sender, + DependencyPropertyChangedEventArgs args) + { + // bindingCreator may be null in the designer currently + var bindingCreator = BindingCreator; + if (bindingCreator == null) + return; + + bindingCreator.CreateBindings(sender, args, ParseBindingDescriptions); + } + + private static IEnumerable ParseBindingDescriptions(string languageText) + { + if (MvxSingleton.Instance == null) + return null; + + return MvxSingleton.Instance.BindingDescriptionParser.LanguageParse(languageText); + } + } +} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/MesMvvmCrossBindingCreator.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/MesMvvmCrossBindingCreator.cs new file mode 100644 index 00000000..560df9ab --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/MesMvvmCrossBindingCreator.cs @@ -0,0 +1,121 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using MvvmCross.Binding; +using MvvmCross.Binding.Bindings; + +namespace MinoriEditorShell.Platforms.Avalonia.Binding.MesBinding +{ + public class MesMvvmCrossBindingCreator : MesBindingCreator + { + protected override void ApplyBindings(FrameworkElement attachedObject, + IEnumerable bindingDescriptions) + { + var binder = MvxBindingSingletonCache.Instance.Binder; + var bindingDescriptionList = bindingDescriptions.ToList(); + var bindings = binder.Bind(attachedObject.DataContext, attachedObject, bindingDescriptionList); + RegisterBindingsForUpdates(attachedObject, bindings); + } + + private void RegisterBindingsForUpdates(FrameworkElement attachedObject, + IEnumerable bindings) + { + if (bindings == null) + return; + + var bindingsList = GetOrCreateBindingsList(attachedObject); + foreach (var binding in bindings) + { + bindingsList.Add(binding); + } + } + + private IList GetOrCreateBindingsList(FrameworkElement attachedObject) + { + var existing = attachedObject.GetValue(BindingsListProperty) as IList; + if (existing != null) + return existing; + + // attach the list + var newList = new List(); + attachedObject.SetValue(BindingsListProperty, newList); + + // create a binding watcher for the list + var binding = new System.Windows.Data.Binding(); + bool attached = false; + Action attachAction = () => + { + if (attached) + return; + BindingOperations.SetBinding(attachedObject, DataContextWatcherProperty, binding); + attached = true; + }; + + Action detachAction = () => + { + if (!attached) + return; + + BindingOperations.ClearBinding(attachedObject, DataContextWatcherProperty); + attached = false; + }; + attachAction(); + attachedObject.Loaded += (o, args) => + { + attachAction(); + }; + attachedObject.Unloaded += (o, args) => + { + detachAction(); + }; + + return newList; + } + + public static readonly DependencyProperty DataContextWatcherProperty = DependencyProperty.Register( + "DataContextWatcher", + typeof(object), + typeof(FrameworkElement), + new PropertyMetadata(null, DataContext_Changed)); + + public static object GetDataContextWatcher(DependencyObject d) + { + return d.GetValue(DataContextWatcherProperty); + } + + public static void SetDataContextWatcher(DependencyObject d, string value) + { + d.SetValue(DataContextWatcherProperty, value); + } + + public static readonly DependencyProperty BindingsListProperty = DependencyProperty.Register( + "BindingsList", + typeof(IList), + typeof(FrameworkElement), + new PropertyMetadata(null)); + + public static IList GetBindingsList(DependencyObject d) + { + return d.GetValue(BindingsListProperty) as IList; + } + + public static void SetBindingsList(DependencyObject d, string value) + { + d.SetValue(BindingsListProperty, value); + } + + private static void DataContext_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var frameworkElement = d as FrameworkElement; + + var bindings = frameworkElement?.GetValue(BindingsListProperty) as IList; + if (bindings == null) + return; + + foreach (var binding in bindings) + { + binding.DataContext = e.NewValue; + } + } + } +} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/MesWindowsTargetBindingFactoryRegistry.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/MesWindowsTargetBindingFactoryRegistry.cs new file mode 100644 index 00000000..47fa3344 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/MesWindowsTargetBindingFactoryRegistry.cs @@ -0,0 +1,51 @@ +using MvvmCross.Binding; +using MvvmCross.Binding.Bindings.Target; +using MvvmCross.Binding.Bindings.Target.Construction; + +namespace MinoriEditorShell.Platforms.Avalonia.Binding.MesBinding +{ + public class MesWindowsTargetBindingFactoryRegistry : MvxTargetBindingFactoryRegistry + { + protected override bool TryCreateReflectionBasedBinding(object target, string targetName, + out IMvxTargetBinding binding) + { + if (TryCreatePropertyDependencyBasedBinding(target, targetName, out binding)) + { + return true; + } + + return base.TryCreateReflectionBasedBinding(target, targetName, out binding); + } + + private static bool TryCreatePropertyDependencyBasedBinding(object target, string targetName, + out IMvxTargetBinding binding) + { + if (target == null) + { + binding = null; + return false; + } + + if (string.IsNullOrEmpty(targetName)) + { + MvxBindingLog.Error( + "Empty binding target passed to MvxWindowsTargetBindingFactoryRegistry"); + binding = null; + return false; + } + + var dependencyProperty = target.GetType().FindDependencyProperty(targetName); + if (dependencyProperty == null) + { + binding = null; + return false; + } + + var actualProperty = target.GetType().FindActualProperty(targetName); + var actualPropertyType = actualProperty?.PropertyType ?? typeof(object); + + binding = new MvxDependencyPropertyTargetBinding(target, targetName, dependencyProperty, actualPropertyType); + return true; + } + } +} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/Target/MesCollapsedTargetBinding.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/Target/MesCollapsedTargetBinding.cs new file mode 100644 index 00000000..29aa1241 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/Target/MesCollapsedTargetBinding.cs @@ -0,0 +1,18 @@ +namespace MinoriEditorShell.Platforms.Avalonia.Binding.MesBinding.Target +{ + public class MesCollapsedTargetBinding : MesVisibleTargetBinding + { + public MesCollapsedTargetBinding(object target) + : base(target) + { + } + + public override void SetValue(object value) + { + if (value == null) + value = false; + var boolValue = (bool)value; + base.SetValue(!boolValue); + } + } +} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/Target/MesDependencyPropertyTargetBinding.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/Target/MesDependencyPropertyTargetBinding.cs new file mode 100644 index 00000000..2c8b25c9 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/Target/MesDependencyPropertyTargetBinding.cs @@ -0,0 +1,96 @@ +using System; +using System.ComponentModel; +using MvvmCross.Binding; +using MvvmCross.Binding.Bindings.Target; +using MvvmCross.Binding.Extensions; + +namespace MinoriEditorShell.Platforms.Avalonia.Binding.MesBinding.Target +{ + public class MesDependencyPropertyTargetBinding : MvxConvertingTargetBinding + { + private readonly string _targetName; + private readonly DependencyProperty _targetDependencyProperty; + private readonly Type _actualPropertyType; + private readonly TypeConverter _typeConverter; + + public MesDependencyPropertyTargetBinding(object target, string targetName, DependencyProperty targetDependencyProperty, Type actualPropertyType) + : base(target) + { + _targetDependencyProperty = targetDependencyProperty; + _actualPropertyType = actualPropertyType; + _targetName = targetName; + _typeConverter = _actualPropertyType.TypeConverter(); + + // if we return TwoWay for ImageSource then we end up in + // problems with WP7 not doing the auto-conversion + // see some of my angst in http://stackoverflow.com/questions/16752242/how-does-xaml-create-the-string-to-bitmapimage-value-conversion-when-binding-to/16753488#16753488 + // Note: if we discover other issues here, then we should make a more flexible solution + if (_actualPropertyType == typeof(ImageSource)) + { + _defaultBindingMode = MvxBindingMode.OneWay; + } + } + + public override void SubscribeToEvents() + { + var frameworkElement = Target as FrameworkElement; + if (frameworkElement == null) + return; + var listenerBinding = new System.Windows.Data.Binding(_targetName) + { Source = frameworkElement }; + + var attachedProperty = DependencyProperty.RegisterAttached( + "ListenAttached" + _targetName + Guid.NewGuid().ToString("N") + , typeof(object) + , typeof(FrameworkElement) + , new PropertyMetadata(null, (s, e) => FireValueChanged(e.NewValue))); + frameworkElement.SetBinding(attachedProperty, listenerBinding); + } + + public override Type TargetType => _actualPropertyType; + + private MvxBindingMode _defaultBindingMode = MvxBindingMode.TwoWay; + public override MvxBindingMode DefaultMode => _defaultBindingMode; + + protected virtual object GetValueByReflection() + { + var target = Target as FrameworkElement; + if (target == null) + { + MvxBindingLog.Warning("Weak Target is null in {0} - skipping Get", GetType().Name); + return null; + } + + return target.GetValue(_targetDependencyProperty); + } + + protected override void SetValueImpl(object target, object value) + { + MvxBindingLog.Trace("Receiving setValue to " + (value ?? "")); + var frameworkElement = target as FrameworkElement; + if (frameworkElement == null) + { + MvxBindingLog.Warning("Weak Target is null in {0} - skipping set", GetType().Name); + return; + } + + frameworkElement.SetValue(_targetDependencyProperty, value); + } + + protected override object MakeSafeValue(object value) + { + if (_actualPropertyType.IsInstanceOfType(value)) + return value; + + if (_typeConverter == null + || value == null) + // TODO - is this correct? Do we need to do more here? See #297 + return _actualPropertyType.MakeSafeValue(value); + + if (!_typeConverter.CanConvertFrom(value.GetType())) + return null; // TODO - is this correct? Do we need to do more here? See #297 + + return _typeConverter.ConvertFrom(value); + } + } +} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/Target/MesVisibleTargetBinding.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/Target/MesVisibleTargetBinding.cs new file mode 100644 index 00000000..bd97a321 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/Target/MesVisibleTargetBinding.cs @@ -0,0 +1,25 @@ +using System; +using MvvmCross.Binding; + +namespace MinoriEditorShell.Platforms.Avalonia.Binding.MesBinding.Target +{ + public class MesVisibleTargetBinding : MesDependencyPropertyTargetBinding + { + public MesVisibleTargetBinding(object target) + : base(target, "Visibility", UIElement.VisibilityProperty, typeof(Visibility)) + { + } + + public override MvxBindingMode DefaultMode => MvxBindingMode.OneWay; + + public override Type TargetType => typeof(bool); + + public override void SetValue(object value) + { + if (value == null) + value = false; + var boolValue = (bool)value; + base.SetValue(boolValue ? Visibility.Visible : Visibility.Collapsed); + } + } +} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBindingCreator.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBindingCreator.cs new file mode 100644 index 00000000..6a51c3b6 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBindingCreator.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Windows; +using MvvmCross.Logging; +using MvvmCross.Binding.Bindings; + +namespace MinoriEditorShell.Platforms.Avalonia.Binding +{ + public abstract class MesBindingCreator : IMesBindingCreator + { + public void CreateBindings(object sender, DependencyPropertyChangedEventArgs args, + Func> parseBindingDescriptions) + { + var attachedObject = sender as FrameworkElement; + if (attachedObject == null) + { + MvxLog.Instance.Warn("Null attached FrameworkElement seen in Bi.nd binding"); + return; + } + + var text = args.NewValue as string; + if (string.IsNullOrEmpty(text)) + return; + + var bindingDescriptions = parseBindingDescriptions(text); + if (bindingDescriptions == null) + return; + + ApplyBindings(attachedObject, bindingDescriptions); + } + + protected abstract void ApplyBindings(FrameworkElement attachedObject, + IEnumerable bindingDescriptions); + } +} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesDependencyPropertyExtensions.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesDependencyPropertyExtensions.cs new file mode 100644 index 00000000..2fbe9005 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesDependencyPropertyExtensions.cs @@ -0,0 +1,77 @@ +using System; +using System.ComponentModel; +using System.Linq; +using System.Reflection; +using System.Windows; + +namespace MinoriEditorShell.Platforms.Avalonia.Binding +{ + public static class MesDependencyPropertyExtensions + { + public static TypeConverter TypeConverter(this Type type) + { + var typeConverter = + type.GetCustomAttributes(typeof(TypeConverterAttribute), true).FirstOrDefault() as + TypeConverterAttribute; + if (typeConverter == null) + return null; + + var converterType = Type.GetType(typeConverter.ConverterTypeName); + if (converterType == null) + return null; + var converter = Activator.CreateInstance(converterType) as TypeConverter; + + return converter; + } + + public static PropertyInfo FindActualProperty(this Type type, string name) + { + if (string.IsNullOrEmpty(name)) + return null; + + var property = type.GetProperty(name, BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Instance); + return property; + } + + public static FieldInfo FindDependencyPropertyInfo(this Type type, string dependencyPropertyName) + { + if (string.IsNullOrEmpty(dependencyPropertyName)) + return null; + + if (!EnsureIsDependencyPropertyName(ref dependencyPropertyName)) + return null; + + var candidateType = type; + while (candidateType != null) + { + var fieldInfo = candidateType.GetField(dependencyPropertyName, BindingFlags.Static | BindingFlags.Public); + if (fieldInfo != null) + return fieldInfo; + + candidateType = candidateType.BaseType; + } + + return null; + } + + public static DependencyProperty FindDependencyProperty(this Type type, string name) + { + if (string.IsNullOrEmpty(name)) + return null; + + var propertyInfo = FindDependencyPropertyInfo(type, name); + + return propertyInfo?.GetValue(null) as DependencyProperty; + } + + private static bool EnsureIsDependencyPropertyName(ref string dependencyPropertyName) + { + if (string.IsNullOrEmpty(dependencyPropertyName)) + return false; + + if (!dependencyPropertyName.EndsWith("Property")) + dependencyPropertyName += "Property"; + return true; + } + } +} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesDesignTimeChecker.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesDesignTimeChecker.cs new file mode 100644 index 00000000..5aeaeec9 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesDesignTimeChecker.cs @@ -0,0 +1,27 @@ +using MvvmCross.Binding.Parse.Binding; + +namespace MinoriEditorShell.Platforms.Avalonia.Binding +{ + public static class MesDesignTimeChecker + { + private static bool _checked; + + public static void Check() + { + if (_checked) + return; + + _checked = true; + if (!MvxDesignTimeHelper.IsInDesignTime) + return; + + MvxDesignTimeHelper.Initialize(); + + if (!Mvx.IoCProvider.CanResolve()) + { + var builder = new MesWindowsBindingBuilder(MesWindowsBindingBuilder.BindingType.MvvmCross); + builder.DoRegistration(); + } + } + } +} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsAssemblyCache.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsAssemblyCache.cs new file mode 100644 index 00000000..721fb894 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsAssemblyCache.cs @@ -0,0 +1,30 @@ +using System.Collections.Generic; +using System.Reflection; +using MvvmCross.Base; +using MvvmCross.Exceptions; + +namespace MinoriEditorShell.Platforms.Avalonia.Binding +{ + public class MesWindowsAssemblyCache + : MvxSingleton + , IMesWindowsAssemblyCache + { + public static void EnsureInitialized() + { + if (Instance != null) + return; + + var instance = new MesWindowsAssemblyCache(); + + if (Instance != instance) + throw new MvxException("Error initialising MvxWindowsAssemblyCache"); + } + + public MesWindowsAssemblyCache() + { + Assemblies = new List(); + } + + public IList Assemblies { get; } + } +} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsBindingBuilder.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsBindingBuilder.cs new file mode 100644 index 00000000..ccf75bdf --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsBindingBuilder.cs @@ -0,0 +1,132 @@ +using System; +using MvvmCross.Base; +using MvvmCross.Converters; +using MvvmCross.Binding; +using MvvmCross.Binding.Binders; +using MvvmCross.Binding.Bindings.Target.Construction; +using MvvmCross.Binding.Combiners; +using MvvmCross.Platforms.Wpf.Binding.MvxBinding; +using MvvmCross.Platforms.Wpf.Binding.MvxBinding.Target; +using MvvmCross.Platforms.Wpf.Binding.WindowsBinding; + +namespace MinoriEditorShell.Platforms.Avalonia.Binding +{ + public class MesWindowsBindingBuilder : MvxBindingBuilder + { + public enum BindingType + { + Windows, + MvvmCross + } + + private readonly BindingType _bindingType; + + public MesWindowsBindingBuilder( + BindingType bindingType = BindingType.MvvmCross) + { + _bindingType = bindingType; + } + + public override void DoRegistration() + { + base.DoRegistration(); + InitializeBindingCreator(); + } + + protected override void RegisterBindingFactories() + { + switch (_bindingType) + { + case BindingType.Windows: + // no need for MvvmCross binding factories - so don't create them + break; + + case BindingType.MvvmCross: + base.RegisterBindingFactories(); + break; + + default: + throw new ArgumentOutOfRangeException(); + } + } + + protected override IMvxTargetBindingFactoryRegistry CreateTargetBindingRegistry() + { + switch (_bindingType) + { + case BindingType.Windows: + return base.CreateTargetBindingRegistry(); + + case BindingType.MvvmCross: + return new MvxWindowsTargetBindingFactoryRegistry(); + + default: + throw new ArgumentOutOfRangeException(); + } + } + + private void InitializeBindingCreator() + { + var creator = CreateBindingCreator(); + Mvx.IoCProvider.RegisterSingleton(creator); + } + + protected virtual IMesBindingCreator CreateBindingCreator() + { + switch (_bindingType) + { + case BindingType.Windows: + return new MvxWindowsBindingCreator(); + + case BindingType.MvvmCross: + return new MvxMvvmCrossBindingCreator(); + + default: + throw new ArgumentOutOfRangeException(); + } + } + + protected override void FillValueConverters(IMvxValueConverterRegistry registry) + { + base.FillValueConverters(registry); + + if (MvxSingleton.Instance != null) + { + foreach (var assembly in MvxSingleton.Instance.Assemblies) + { + registry.Fill(assembly); + } + } + } + + protected override void FillValueCombiners(IMvxValueCombinerRegistry registry) + { + base.FillValueCombiners(registry); + + if (MvxSingleton.Instance != null) + { + foreach (var assembly in MvxSingleton.Instance.Assemblies) + { + registry.Fill(assembly); + } + } + } + + protected override void FillTargetFactories(IMvxTargetBindingFactoryRegistry registry) + { + registry.RegisterCustomBindingFactory( + MesWindowsPropertyBinding.FrameworkElement_Visible, + view => new MvxVisibleTargetBinding(view)); + + registry.RegisterCustomBindingFactory( + MesWindowsPropertyBinding.FrameworkElement_Collapsed, + view => new MvxCollapsedTargetBinding(view)); + + registry.RegisterCustomBindingFactory( + MesWindowsPropertyBinding.FrameworkElement_Hidden, + view => new MvxCollapsedTargetBinding(view)); + + base.FillTargetFactories(registry); + } + } +} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsPropertyBinding.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsPropertyBinding.cs new file mode 100644 index 00000000..8da903b2 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsPropertyBinding.cs @@ -0,0 +1,9 @@ +namespace MinoriEditorShell.Platforms.Avalonia.Binding +{ + internal static class MesWindowsPropertyBinding + { + public const string FrameworkElement_Visible = "Visible"; + public const string FrameworkElement_Collapsed = "Collapsed"; + public const string FrameworkElement_Hidden = "Hidden"; + } +} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsPropertyBindingExtensions.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsPropertyBindingExtensions.cs new file mode 100644 index 00000000..898df8f3 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsPropertyBindingExtensions.cs @@ -0,0 +1,14 @@ +namespace MinoriEditorShell.Platforms.Avalonia.Binding +{ + public static class MesWindowsPropertyBindingExtensions + { + public static string BindVisible(this FrameworkElement frameworkElement) + => MesWindowsPropertyBinding.FrameworkElement_Visible; + + public static string BindCollapsed(this FrameworkElement frameworkElement) + => MesWindowsPropertyBinding.FrameworkElement_Collapsed; + + public static string BindHidden(this FrameworkElement frameworkElement) + => MesWindowsPropertyBinding.FrameworkElement_Hidden; + } +} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/WindowsBinding/AvnWindowsBindingCreator.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/WindowsBinding/AvnWindowsBindingCreator.cs new file mode 100644 index 00000000..fb76db55 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/WindowsBinding/AvnWindowsBindingCreator.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using MvvmCross.Converters; +using MvvmCross.Logging; +using MvvmCross.Binding; +using MvvmCross.Binding.Bindings; +using MvvmCross.Binding.Bindings.SourceSteps; +using Avalonia.Data; +using MinoriEditorShell.Platforms.Avalonia.Binding; +using Avalonia.Data.Core; +using Avalonia.Data.Converters; +using MinoriEditorShell.Platforms.Avalonia.Converters; + +namespace MinoriEditorShell.Platforms.Avalonia.Binding.WindowsBinding +{ + public class AvnWindowsBindingCreator : MesBindingCreator + { + protected virtual void ApplyBinding(MvxBindingDescription bindingDescription, Type actualType, + FrameworkElement attachedObject) + { + DependencyProperty dependencyProperty = actualType.FindDependencyProperty(bindingDescription.TargetName); + if (dependencyProperty == null) + { + MvxLog.Instance.Warn("Dependency property not found for {0}", bindingDescription.TargetName); + return; + } + + var property = actualType.FindActualProperty(bindingDescription.TargetName); + if (property == null) + { + MvxLog.Instance.Warn("Property not returned {0} - may cause issues", bindingDescription.TargetName); + } + + var sourceStep = bindingDescription.Source as MvxPathSourceStepDescription; + if (sourceStep == null) + { + MvxLog.Instance.Warn("Binding description for {0} is not a simple path - Windows Binding cannot cope with this", bindingDescription.TargetName); + return; + } + + var newBinding = new System.Windows.Data.Binding + { + Path = new PropertyPath(sourceStep.SourcePropertyPath), + Mode = ConvertMode(bindingDescription.Mode, property?.PropertyType ?? typeof(object)), + Converter = GetConverter(sourceStep.Converter), + ConverterParameter = sourceStep.ConverterParameter, + }; + + BindingOperations.SetBinding(attachedObject, dependencyProperty, newBinding); + } + + protected override void ApplyBindings(FrameworkElement attachedObject, + IEnumerable bindingDescriptions) + { + var actualType = attachedObject.GetType(); + foreach (var bindingDescription in bindingDescriptions) + { + ApplyBinding(bindingDescription, actualType, attachedObject); + } + } + + protected static IValueConverter GetConverter(IMvxValueConverter converter) + { + if (converter == null) + return null; + + // TODO - consider caching this wrapper - it is a tiny bit wasteful creating a wrapper for each binding + return new MvxNativeValueConverter(converter); + } + + protected static BindingMode ConvertMode(MvxBindingMode mode, Type propertyType) + { + switch (mode) + { + case MvxBindingMode.Default: + // if we return TwoWay for ImageSource then we end up in + // problems with WP7 not doing the auto-conversion + // see some of my angst in http://stackoverflow.com/questions/16752242/how-does-xaml-create-the-string-to-bitmapimage-value-conversion-when-binding-to/16753488#16753488 + // Note: if we discover other issues here, then we should make a more flexible solution + if (propertyType == typeof(ImageSource)) + return BindingMode.OneWay; + + return BindingMode.TwoWay; + + case MvxBindingMode.TwoWay: + return BindingMode.TwoWay; + + case MvxBindingMode.OneWay: + return BindingMode.OneWay; + + case MvxBindingMode.OneTime: + return BindingMode.OneTime; + + case MvxBindingMode.OneWayToSource: + MvxLog.Instance.Warn("WinPhone doesn't support OneWayToSource"); + return BindingMode.TwoWay; + + default: + throw new ArgumentOutOfRangeException(nameof(mode)); + } + } + } +} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/MvxNativeValueConverters.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/MvxNativeValueConverters.cs new file mode 100644 index 00000000..5d24ba81 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Converters/MvxNativeValueConverters.cs @@ -0,0 +1,69 @@ +using Avalonia.Data.Converters; +using Avalonia.Markup.Xaml; +using MvvmCross.Converters; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text; + +namespace MinoriEditorShell.Platforms.Avalonia.Converters +{ + public class MvxNativeValueConverter + : MarkupExtension, IValueConverter + { + private readonly IMvxValueConverter _wrapped; + + public MvxNativeValueConverter(IMvxValueConverter wrapped) + { + _wrapped = wrapped; + } + + protected IMvxValueConverter Wrapped => _wrapped; + + public virtual object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + var toReturn = _wrapped.Convert(value, targetType, parameter, culture); + return MapIfSpecialValue(toReturn); + } + + public virtual object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + var toReturn = _wrapped.ConvertBack(value, targetType, parameter, culture); + return MapIfSpecialValue(toReturn); + } + + private static object MapIfSpecialValue(object toReturn) + { + if (toReturn == MvxBindingConstant.DoNothing) + { + throw new NotImplementedException(); + //return System.Windows.Data.Binding.DoNothing; + } + + if (toReturn == MvxBindingConstant.UnsetValue) + { + throw new NotImplementedException(); + //return DependencyProperty.UnsetValue; + } + + return toReturn; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } + + public class MvxNativeValueConverter + : MvxNativeValueConverter + where T : IMvxValueConverter, new() + { + protected new T Wrapped => (T)base.Wrapped; + + public MvxNativeValueConverter() + : base(new T()) + { + } + } +} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Core/IMesAvnSetup.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/IMesAvnSetup.cs index a2e4e6e9..8d123078 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Core/IMesAvnSetup.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/IMesAvnSetup.cs @@ -5,9 +5,9 @@ namespace MinoriEditorShell.Platforms.Avalonia { - public interface IMvxWpfSetup : IMvxSetup + public interface IMvxAvnSetup : IMvxSetup { - void PlatformInitialize(Dispatcher uiThreadDispatcher, IMesAvaViewPresenter presenter); + void PlatformInitialize(Dispatcher uiThreadDispatcher, IMesAvnViewPresenter presenter); void PlatformInitialize(Dispatcher uiThreadDispatcher, ContentControl root); } } \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs index 796aa83d..0d65e326 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs @@ -3,8 +3,6 @@ using MinoriEditorShell.Messages; using MinoriEditorShell.Modules.Services; using MinoriEditorShell.Platforms.Avalonia.Presenters; -//using MinoriEditorShell.Platforms.Avalonia.Services; -//using MinoriEditorShell.Platforms.Avalonia.ViewModels; using MinoriEditorShell.Platforms.Avalonia.Views; using MinoriEditorShell.Platforms.Avalonia.Services; using MinoriEditorShell.Platforms.Avalonia.ViewModels; @@ -20,26 +18,89 @@ using System.Collections.Generic; using System.Globalization; using System.Threading; +using MvvmCross.Presenters; +using MinoriEditorShell.Platforms.Wpf.ViewModels; +using Avalonia.Threading; +using System.Reflection; +using System.Linq; +using MvvmCross.Views; +using MvvmCross.Binding; +using MvvmCross.Converters; +using MvvmCross.Binding.BindingContext; +using MvvmCross.Binding.Bindings.Target.Construction; +using MvvmCross.Binding.Binders; +// Portions of this was barrowed from MvvmCross. namespace MinoriEditorShell.Platforms.Avalonia { /// /// This is the main initializer for the kit. Call or over-ride this simualr to any other MvxWpfSetup setup /// - public class MesAvnSetup : MvxSetup - { - // To handle messages between classes - private MvvmCross.Plugin.Messenger.IMvxMessenger _messenger; + public abstract class MesAvnSetup : MvxSetup, IMvxAvnSetup + { + // To handle messages between classes + private MvvmCross.Plugin.Messenger.IMvxMessenger _messenger; + private IMesAvnViewPresenter _presenter; + private ContentControl _root; + private Dispatcher _uiThreadDispatcher; + /// + /// Sets up initial connected types and setup + /// + public override void InitializePrimary() + { + base.InitializePrimary(); + + // register necessary interfaces + Mvx.IoCProvider.LazyConstructAndRegisterSingleton(); + Mvx.IoCProvider.LazyConstructAndRegisterSingleton(); + Mvx.IoCProvider.LazyConstructAndRegisterSingleton(); + Mvx.IoCProvider.RegisterType(); + + // Register themes + Mvx.IoCProvider.LazyConstructAndRegisterSingleton(); + + // try to setup culture info + String code = Properties.Settings.Default.LanguageCode; + + if (!String.IsNullOrWhiteSpace(code)) + { + CultureInfo culture = CultureInfo.GetCultureInfo(code); + // If code == "en", force to use default resource (Resources.resx) + // See PO #243 +#warning fix translator depends + //if (!Translator.Cultures.Contains(culture)) + // culture = CultureInfo.InvariantCulture; + //Translator.Culture = culture; + Thread.CurrentThread.CurrentUICulture = culture; + Thread.CurrentThread.CurrentCulture = culture; + } + } /// - /// Creates the inital view for the setup + /// Load any additional plugins, calling parent /// - /// Control of the main windows for wpf - /// - protected override IMvxWpfViewPresenter CreateViewPresenter(ContentControl root) + /// + public override void LoadPlugins(IMvxPluginManager pluginManager) { - // This handles main window. - return new MesWpfPresenter(root); + base.LoadPlugins(pluginManager); + pluginManager.EnsurePluginLoaded(); + } + + public void PlatformInitialize(Dispatcher uiThreadDispatcher, IMesAvnViewPresenter presenter) + { + _uiThreadDispatcher = uiThreadDispatcher; + _presenter = presenter; + } + + public void PlatformInitialize(Dispatcher uiThreadDispatcher, ContentControl root) + { + _uiThreadDispatcher = uiThreadDispatcher; + _root = root; + } + + public override IEnumerable GetViewAssemblies() + { + return base.GetViewAssemblies().Union(new[] { Assembly.GetEntryAssembly() }); } /// @@ -57,19 +118,45 @@ protected override IMvxApplication CreateApp() _messenger.Publish(message); }; - return new TApplication(); + throw new NotImplementedException(); + //return new TApplication(); + } + + protected sealed override IMvxViewsContainer CreateViewsContainer(IMvxIoCProvider iocProvider) + { + ValidateArguments(iocProvider); + + var toReturn = CreateAvnViewsContainer(); + iocProvider.RegisterSingleton(toReturn); + return toReturn; + } + + protected virtual IMesAvnViewsContainer CreateAvnViewsContainer() + { + return new MesAvnViewsContainer(); } /// - /// Load any additional plugins, calling parent + /// Used to ensure plugins are loaded. /// - /// - public override void LoadPlugins(IMvxPluginManager pluginManager) + /// returns base manager + protected override IMvxPluginManager CreatePluginManager() { - base.LoadPlugins(pluginManager); - pluginManager.EnsurePluginLoaded(); + IMvxPluginManager manager = base.CreatePluginManager(); + manager.EnsurePluginLoaded(); + return manager; } + /// + /// Creates the inital view for the setup + /// + /// Control of the main windows for wpf + /// + protected override IMvxViewPresenter CreateViewPresenter(ContentControl root) + { + // This handles main window. + return new MesAvnViewPresenter(root); + } /// /// Sets up the dictionary that connects the viewmodel to the view. /// @@ -82,122 +169,104 @@ protected override IDictionary InitializeLookupDictionary() return container; } - /// - /// Used to ensure plugins are loaded. - /// - /// returns base manager - protected override IMvxPluginManager CreatePluginManager() + + protected IMesAvnViewPresenter Presenter { - IMvxPluginManager manager = base.CreatePluginManager(); - manager.EnsurePluginLoaded(); - return manager; + get + { + _presenter = CreateViewPresenter(_root); + return _presenter; + } } - /// - /// Sets up initial connected types and setup - /// - public override void InitializePrimary() + protected virtual IMesAvnViewPresenter CreateViewPresenter(ContentControl root) { - base.InitializePrimary(); + return new MesAvnViewPresenter(root); + } - // register necessary interfaces - Mvx.IoCProvider.LazyConstructAndRegisterSingleton(); - Mvx.IoCProvider.LazyConstructAndRegisterSingleton(); - Mvx.IoCProvider.LazyConstructAndRegisterSingleton(); - Mvx.IoCProvider.RegisterType(); + protected override IMvxViewDispatcher CreateViewDispatcher() + { + return new MesAvnViewDispatcher(_uiThreadDispatcher, Presenter); + } - // Register themes - Mvx.IoCProvider.LazyConstructAndRegisterSingleton(); + protected virtual void RegisterPresenter(IMvxIoCProvider iocProvider) + { + ValidateArguments(iocProvider); - // try to setup culture info - String code = Properties.Settings.Default.LanguageCode; + var presenter = Presenter; + iocProvider.RegisterSingleton(presenter); + iocProvider.RegisterSingleton(presenter); + } - if (!String.IsNullOrWhiteSpace(code)) + protected override IMvxNameMapping CreateViewToViewModelNaming() + { + return new MvxPostfixAwareViewToViewModelNameMapping("View", "Control"); + } + + protected override void InitializeFirstChance(IMvxIoCProvider iocProvider) + { + RegisterPresenter(iocProvider); + base.InitializeFirstChance(iocProvider); + } + + protected override void InitializeLastChance(IMvxIoCProvider iocProvider) + { + InitializeBindingBuilder(iocProvider); + base.InitializeLastChance(iocProvider); + } + + protected virtual void InitializeBindingBuilder(IMvxIoCProvider iocProvider) + { + RegisterBindingBuilderCallbacks(iocProvider); + var bindingBuilder = CreateBindingBuilder(); + bindingBuilder.DoRegistration(); + } + + protected virtual void RegisterBindingBuilderCallbacks(IMvxIoCProvider iocProvider) + { + ValidateArguments(iocProvider); + + iocProvider.CallbackWhenRegistered(FillValueConverters); + iocProvider.CallbackWhenRegistered(FillTargetFactories); + iocProvider.CallbackWhenRegistered(FillBindingNames); + } + + protected virtual void FillBindingNames(IMvxBindingNameRegistry registry) + { + // this base class does nothing + } + + protected virtual void FillValueConverters(IMvxValueConverterRegistry registry) + { + registry.Fill(ValueConverterAssemblies); + registry.Fill(ValueConverterHolders); + } + + protected virtual void FillTargetFactories(IMvxTargetBindingFactoryRegistry registry) + { + // this base class does nothing + } + + protected virtual List ValueConverterHolders => new List(); + + protected virtual IEnumerable ValueConverterAssemblies + { + get { - CultureInfo culture = CultureInfo.GetCultureInfo(code); - // If code == "en", force to use default resource (Resources.resx) - // See PO #243 -#warning fix translator depends - //if (!Translator.Cultures.Contains(culture)) - // culture = CultureInfo.InvariantCulture; - //Translator.Culture = culture; - Thread.CurrentThread.CurrentUICulture = culture; - Thread.CurrentThread.CurrentCulture = culture; + var toReturn = new List(); + toReturn.AddRange(GetViewModelAssemblies()); + toReturn.AddRange(GetViewAssemblies()); + return toReturn; } } - } - - ///// - ///// By default, we are configured to use MEF - ///// - //protected override void Configure() - //{ - // // Add all assemblies to AssemblySource (using a temporary DirectoryCatalog). - // var directoryCatalog = new DirectoryCatalog(@"./"); - // AssemblySource.Instance.AddRange( - // directoryCatalog.Parts - // .Select(part => ReflectionModelServices.GetPartType(part).Value.Assembly) - // .Where(assembly => !AssemblySource.Instance.Contains(assembly))); - - // // Prioritise the executable assembly. This allows the client project to override exports, including IShell. - // // The client project can override SelectAssemblies to choose which assemblies are prioritised. - // _priorityAssemblies = SelectAssemblies().ToList(); - // var priorityCatalog = new AggregateCatalog(_priorityAssemblies.Select(x => new AssemblyCatalog(x))); - // var priorityProvider = new CatalogExportProvider(priorityCatalog); - - // // Now get all other assemblies (excluding the priority assemblies). - // var mainCatalog = new AggregateCatalog( - // AssemblySource.Instance - // .Where(assembly => !_priorityAssemblies.Contains(assembly)) - // .Select(x => new AssemblyCatalog(x))); - // var mainProvider = new CatalogExportProvider(mainCatalog); - - // Container = new CompositionContainer(priorityProvider, mainProvider); - // priorityProvider.SourceProvider = Container; - // mainProvider.SourceProvider = Container; - - // var batch = new CompositionBatch(); - - // BindServices(batch); - // batch.AddExportedValue(mainCatalog); - - // Container.Compose(batch); - //} - - // protected virtual void BindServices(CompositionBatch batch) - // { - // batch.AddExportedValue(new WindowManager()); - // batch.AddExportedValue(new EventAggregator()); - // batch.AddExportedValue(Container); - // batch.AddExportedValue(this); - // } - - //protected override object GetInstance(Type serviceType, string key) - //{ - // string contract = string.IsNullOrEmpty(key) ? AttributedModelServices.GetContractName(serviceType) : key; - // var exports = Container.GetExports(contract); - - // if (exports.Any()) - // return exports.First().Value; - - // throw new Exception(string.Format("Could not locate any instances of contract {0}.", contract)); - //} - - //protected override IEnumerable GetAllInstances(Type serviceType) - //{ - // return Container.GetExportedValues(AttributedModelServices.GetContractName(serviceType)); - //} - - //protected override void BuildUp(object instance) - //{ - // Container.SatisfyImportsOnce(instance); - //} - - // protected override IEnumerable SelectAssemblies() - // { - // return new[] { Assembly.GetEntryAssembly() }; - // } - // } + + + protected virtual MvxBindingBuilder CreateBindingBuilder() + { + throw new NotImplementedException(); + //return new MvxWindowsBindingBuilder(); + } + } /// /// This is the main initializer for the kit. Call or over-ride this simualr to any other MvxWpfSetup setup diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj index 37d84a5d..bf6dd8f0 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj @@ -38,9 +38,7 @@ This uses AvalonDock and has an MVVM architecture based on MvvmCross. - - - + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/IMesAvaViewPresenter.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/IMesAvnViewPresenter.cs similarity index 58% rename from Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/IMesAvaViewPresenter.cs rename to Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/IMesAvnViewPresenter.cs index 0a3382f2..056e820c 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/IMesAvaViewPresenter.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/IMesAvnViewPresenter.cs @@ -2,5 +2,5 @@ namespace MinoriEditorShell.Platforms.Avalonia.Presenters { - public interface IMesAvaViewPresenter : IMvxViewPresenter {} + public interface IMesAvnViewPresenter : IMvxViewPresenter {} } \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvaViewPresenter.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs similarity index 86% rename from Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvaViewPresenter.cs rename to Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs index 402b52a2..38f00224 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvaViewPresenter.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs @@ -17,7 +17,7 @@ namespace MinoriEditorShell.Platforms.Avalonia.Presenters /// /// Main presenter that allows document and tools to naviage to MesDocumentController /// - public class MesAvaViewPresenter : MvxAttributeViewPresenter, IMesAvaViewPresenter + public class MesAvnViewPresenter : MvxAttributeViewPresenter, IMesAvnViewPresenter { private IMvxLog _log; @@ -25,10 +25,10 @@ public class MesAvaViewPresenter : MvxAttributeViewPresenter, IMesAvaViewPresent /// Main constructor for the presenter, this gets the main window. /// /// - public MesAvaViewPresenter(ContentControl mainWindow) : base(mainWindow) + public MesAvnViewPresenter(ContentControl mainWindow) : base(mainWindow) { IMvxLogProvider provider = Mvx.IoCProvider.Resolve(); - _log = provider.GetLogFor(); + _log = provider.GetLogFor(); _log.Trace("Setup: Creating Presenter"); // Setup main window as singleton @@ -43,31 +43,31 @@ public override MvxBasePresentationAttribute CreatePresentationAttribute(Type vi { if (viewType.IsSubclassOf(typeof(Window))) { - MvxLog.Instance.Trace($"PresentationAttribute not found for {viewType.Name}. " + + _log.Trace($"PresentationAttribute not found for {viewType.Name}. " + $"Assuming window presentation"); return new MvxWindowPresentationAttribute(); } - MvxLog.Instance.Trace($"PresentationAttribute not found for {viewType.Name}. " + + _log.Trace($"PresentationAttribute not found for {viewType.Name}. " + $"Assuming content presentation"); return new MvxContentPresentationAttribute(); } public override void RegisterAttributeTypes() { - AttributeTypesToActionsDictionary.Register( + AttributeTypesToActionsDictionary.Register( (viewType, attribute, request) => { - var view = WpfViewLoader.CreateView(request); - return ShowWindow(view, (MvxWindowPresentationAttribute)attribute, request); + var view = AvnViewLoader.CreateView(request); + return ShowWindow(view, (MesWindowPresentationAttribute)attribute, request); }, (viewModel, attribute) => CloseWindow(viewModel)); - AttributeTypesToActionsDictionary.Register( + AttributeTypesToActionsDictionary.Register( (viewType, attribute, request) => { - var view = WpfViewLoader.CreateView(request); - return ShowContentView(view, (MvxContentPresentationAttribute)attribute, request); + var view = AvnViewLoader.CreateView(request); + return ShowContentView(view, (MesContentPresentationAttribute)attribute, request); }, (viewModel, attribute) => CloseContentView(viewModel)); } diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnView.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnView.cs new file mode 100644 index 00000000..98c804be --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnView.cs @@ -0,0 +1,21 @@ +using MvvmCross.Binding.BindingContext; +using MvvmCross.ViewModels; +using MvvmCross.Views; +using System; +using System.Collections.Generic; +using System.Text; + +namespace MinoriEditorShell.Platforms.Avalonia.Views +{ + public interface IMesAvnView + : IMvxView, IMvxBindingContextOwner + { + } + + public interface IMvxWpfView + : IMesAvnView + , IMvxView where TViewModel : class, IMvxViewModel + { + MvxFluentBindingDescriptionSet, TViewModel> CreateBindingSet(); + } +} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnViewLoader.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnViewLoader.cs new file mode 100644 index 00000000..0b8d3d70 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnViewLoader.cs @@ -0,0 +1,6 @@ +namespace MinoriEditorShell.Platforms.Avalonia.Views +{ + public interface IMesAvnViewLoader + { + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnViewsContainer.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnViewsContainer.cs new file mode 100644 index 00000000..ff977f2a --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnViewsContainer.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace MinoriEditorShell.Platforms.Avalonia.Views +{ + class IMesAvnViewsContainer + { + } +} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesApplicatioin.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesApplication.cs similarity index 51% rename from Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesApplicatioin.cs rename to Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesApplication.cs index 994944c0..51d0c29b 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesApplicatioin.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesApplication.cs @@ -1,19 +1,14 @@ -using Avalonia; -using Avalonia.Controls.ApplicationLifetimes; -using Avalonia.Markup.Xaml; +using Avalonia; +using Avalonia.Threading; using MvvmCross; -using MvvmCross.IoC; -using MvvmCross.Logging; -using MvvmCross.Plugin; +using MvvmCross.Core; using MvvmCross.ViewModels; using System; using System.Collections.Generic; -using System.Reflection; -using System.Threading.Tasks; +using System.Text; namespace MinoriEditorShell.Platforms.Avalonia.Views { - ///This is a bridge between MvvmCross and Avalonia project public abstract class MesApplication : Application { public MesApplication() : base() @@ -23,9 +18,8 @@ public MesApplication() : base() public virtual void ApplicationInitialized() { - if (MainWindow == null) return; - - // MvxWpfSetupSingleton.EnsureSingletonAvailable(Dispatcher, MainWindow).EnsureInitialized(); + //if (MainWindow == null) return; + //MvxWpfSetupSingleton.EnsureSingletonAvailable(Dispatcher, MainWindow).EnsureInitialized(); RunAppStart(); } @@ -48,13 +42,13 @@ protected virtual void RegisterSetup() } } - // public class MvxApplication : MvxApplication - // where TMvxWpfSetup : MvxWpfSetup, new() - // where TApplication : class, IMvxApplication, new() - // { - // protected override void RegisterSetup() - // { - // this.RegisterSetupType(); - // } - // } -} \ No newline at end of file + public class MvxApplication : MvxApplication + where TMvxWpfSetup : MesAvnSetup, new() + where TApplication : class, IMvxApplication, new() + { + protected override void RegisterSetup() + { + this.RegisterSetupType(); + } + } +} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnUIThreadDispatcher.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnUIThreadDispatcher.cs new file mode 100644 index 00000000..df75322b --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnUIThreadDispatcher.cs @@ -0,0 +1,39 @@ +using Avalonia.Threading; +using MvvmCross.Base; +using System; +using System.Collections.Generic; +using System.Text; + +namespace MinoriEditorShell.Platforms.Avalonia.Views +{ + public class MesAvnUIThreadDispatcher + : MvxMainThreadAsyncDispatcher + { + private readonly Dispatcher _dispatcher; + + public MesAvnUIThreadDispatcher(Dispatcher dispatcher) + { + _dispatcher = dispatcher; + } + + public override bool IsOnMainThread => _dispatcher.CheckAccess(); + + public override bool RequestMainThreadAction(Action action, bool maskExceptions = true) + { + if (IsOnMainThread) + { + ExceptionMaskedAction(action, maskExceptions); + } + else + { + _dispatcher.InvokeAsync(() => + { + ExceptionMaskedAction(action, maskExceptions); + }); + } + + // TODO - why return bool at all? + return true; + } + } +} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnView.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnView.cs new file mode 100644 index 00000000..4db70719 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnView.cs @@ -0,0 +1,97 @@ +using Avalonia.Controls; +using Avalonia.Interactivity; +using MvvmCross; +using MvvmCross.Binding.BindingContext; +using MvvmCross.ViewModels; +using System; +using System.Collections.Generic; +using System.Text; + +namespace MinoriEditorShell.Platforms.Avalonia.Views +{ + public class MesAvnView : UserControl, IMesAvnView, IDisposable + { + private IMvxViewModel _viewModel; + private IMvxBindingContext _bindingContext; + + public IMvxViewModel ViewModel + { + get => _viewModel; + set + { + _viewModel = value; + DataContext = value; + BindingContext.DataContext = value; + } + } + + public IMvxBindingContext BindingContext + { + get + { + if (_bindingContext != null) + return _bindingContext; + + if (Mvx.IoCProvider != null) + this.CreateBindingContext(); + + return _bindingContext; + } + set => _bindingContext = value; + } + + public MesAvnView() + { + Unloaded += MvxWpfView_Unloaded; + Loaded += MvxWpfView_Loaded; + } + + private void MvxWpfView_Unloaded(object sender, RoutedEventArgs e) + { + ViewModel?.ViewDisappearing(); + ViewModel?.ViewDisappeared(); + ViewModel?.ViewDestroy(); + } + + private void MvxWpfView_Loaded(object sender, RoutedEventArgs e) + { + ViewModel?.ViewAppearing(); + ViewModel?.ViewAppeared(); + } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + ~MesAvnView() + { + Dispose(false); + } + + protected virtual void Dispose(bool disposing) + { + if (disposing) + { + Unloaded -= MvxWpfView_Unloaded; + Loaded -= MvxWpfView_Loaded; + } + } + } + + public class MesAvnView : MesAvnView, IMesAvnView + where TViewModel : class, IMvxViewModel + { + public new TViewModel ViewModel + { + get { return (TViewModel)base.ViewModel; } + set { base.ViewModel = value; } + } + + public MvxFluentBindingDescriptionSet, TViewModel> CreateBindingSet() + { + return this.CreateBindingSet, TViewModel>(); + } + } +} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnViewDispatcher.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnViewDispatcher.cs new file mode 100644 index 00000000..58ad1567 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnViewDispatcher.cs @@ -0,0 +1,34 @@ +using Avalonia.Threading; +using MinoriEditorShell.Platforms.Avalonia.Presenters; +using MvvmCross.ViewModels; +using MvvmCross.Views; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace MinoriEditorShell.Platforms.Avalonia.Views +{ + public class MesAvnViewDispatcher + : MesAvnUIThreadDispatcher, IMvxViewDispatcher + { + private readonly IMesAvnViewPresenter _presenter; + + public MesAvnViewDispatcher(Dispatcher dispatcher, IMesAvnViewPresenter presenter) + : base(dispatcher) + { + _presenter = presenter; + } + + public async Task ShowViewModel(MvxViewModelRequest request) + { + await ExecuteOnMainThreadAsync(() => _presenter.Show(request)); + return true; + } + + public async Task ChangePresentation(MvxPresentationHint hint) + { + await ExecuteOnMainThreadAsync(() => _presenter.ChangePresentation(hint)); + return true; + } + } +} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnViewsContainer.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnViewsContainer.cs new file mode 100644 index 00000000..4cd06b90 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnViewsContainer.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace MinoriEditorShell.Platforms.Avalonia.Views +{ + class MesAvnViewsContainer + { + } +} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesWindow.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesWindow.cs index 3cb922b2..aa141a27 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesWindow.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesWindow.cs @@ -1,4 +1,7 @@ // using MahApps.Metro.Controls; +using Avalonia; +using Avalonia.Controls; +using Avalonia.Interactivity; using MinoriEditorShell.Services; using MvvmCross; using MvvmCross.Binding.BindingContext; @@ -11,119 +14,228 @@ namespace MinoriEditorShell.Platforms.Avalonia.Views { -// public class MesWindow : MetroWindow, IMesWindow, IMvxWindow, IMvxWpfView -// { -// private IMvxViewModel _viewModel; -// private IMvxBindingContext _bindingContext; - -// public IMvxViewModel ViewModel -// { -// get => _viewModel; -// set -// { -// _viewModel = value; -// DataContext = value; -// BindingContext.DataContext = value; -// } -// } - -// public String Identifier { get; set; } - -// public IMvxBindingContext BindingContext -// { -// get -// { -// if (_bindingContext != null) -// { -// return _bindingContext; -// } - -// if (Mvx.IoCProvider != null) -// { -// this.CreateBindingContext(); -// } - -// return _bindingContext; -// } -// set => _bindingContext = value; -// } - -// public String DisplayName -// { -// get => Title; -// set => Title = value; -// } - -// public MesWindow() -// { -// Unloaded += MesWindow_Unloaded; -// Loaded += MesWindow_Loaded; -// Initialized += MesWindow_Initialized; -// } - -// private void MesWindow_Initialized(Object sender, EventArgs e) -// { -// if (this == Application.Current.MainWindow) -// { -// // Application startup -// (Application.Current as MvxApplication).ApplicationInitialized(); - -// // Init mes setup -// Mvx.IoCProvider.Resolve(); - -// #warning fix style -// //WindowCloseButtonStyle = Application.Current.Resources.MergedDictionaries -// //WindowCloseButtonStyle = "{DynamicResource MetroWindowButtonStyle}" -// //WindowMinButtonStyle = "{DynamicResource MetroWindowButtonStyle}" -// //WindowMaxButtonStyle = "{DynamicResource MetroWindowButtonStyle}" -// } -// } - -// private void MesWindow_Unloaded(Object sender, RoutedEventArgs e) -// { -// ViewModel?.ViewDisappearing(); -// ViewModel?.ViewDisappeared(); -// ViewModel?.ViewDestroy(); -// } - -// /// -// /// Load inital settings if possible -// /// -// /// -// /// -// private void MesWindow_Loaded(Object sender, RoutedEventArgs e) -// { -// String blueTheme = "MesBlueTheme"; - -// // Get main theme property if possible -// String themeName = Properties.Settings.Default.ThemeName; -// if (String.IsNullOrEmpty(themeName)) themeName = blueTheme; - -// // Set theme from name -// IMesThemeManager manager = Mvx.IoCProvider.Resolve(); -// IMesTheme theme = manager.Themes.FirstOrDefault(x => x.GetType().Name == themeName); - -// // Set to defualt if missing or error -// if (theme == null) theme = manager.Themes.First(x => x.GetType().Name == themeName); - -// manager.SetCurrentTheme(theme.Name); - -// ViewModel?.ViewAppearing(); -// ViewModel?.ViewAppeared(); -// } -// } - -// public class MesWindow : MesWindow, IMvxWpfView where TViewModel : class, IMvxViewModel -// { -// public new TViewModel ViewModel -// { -// get => (TViewModel)base.ViewModel; -// set => base.ViewModel = value; -// } - -// MvxFluentBindingDescriptionSet, TViewModel> IMvxWpfView.CreateBindingSet() -// { -// return this.CreateBindingSet, TViewModel>(); -// } -// } + public class MesWindow : Window, IMesWindow, IMesAvnView, IDisposable + { + private IMvxViewModel _viewModel; + private IMvxBindingContext _bindingContext; + private bool _unloaded = false; + + public IMvxViewModel ViewModel + { + get => _viewModel; + set + { + _viewModel = value; + DataContext = value; + BindingContext.DataContext = value; + } + } + + public string Identifier { get; set; } + + public IMvxBindingContext BindingContext + { + get + { + if (_bindingContext != null) + return _bindingContext; + + if (Mvx.IoCProvider != null) + this.CreateBindingContext(); + + return _bindingContext; + } + set => _bindingContext = value; + } + + public String DisplayName { get; set; } + + public MesWindow() + { + Closed += MvxWindow_Closed; + Unloaded += MvxWindow_Unloaded; + Loaded += MvxWindow_Loaded; + Initialized += MvxWindow_Initialized; + } + + private void MvxWindow_Initialized(object sender, EventArgs e) + { + if (this == Application.Current.MainWindow) + { + (Application.Current as MvxApplication).ApplicationInitialized(); + } + } + + private void MvxWindow_Closed(object sender, EventArgs e) => Unload(); + + private void MvxWindow_Unloaded(object sender, RoutedEventArgs e) => Unload(); + + private void MvxWindow_Loaded(object sender, RoutedEventArgs e) + { + ViewModel?.ViewAppearing(); + ViewModel?.ViewAppeared(); + } + + private void Unload() + { + if (!_unloaded) + { + ViewModel?.ViewDisappearing(); + ViewModel?.ViewDisappeared(); + ViewModel?.ViewDestroy(); + _unloaded = true; + } + } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + ~MesWindow() + { + Dispose(false); + } + + protected virtual void Dispose(bool disposing) + { + if (disposing) + { + Unloaded -= MvxWindow_Unloaded; + Loaded -= MvxWindow_Loaded; + Closed -= MvxWindow_Closed; + } + } + } + + public class MvxWindow : MesWindow, IMesAvnView + where TViewModel : class, IMvxViewModel + { + public new TViewModel ViewModel + { + get { return (TViewModel)base.ViewModel; } + set { base.ViewModel = value; } + } + + public MvxFluentBindingDescriptionSet, TViewModel> CreateBindingSet() + { + return this.CreateBindingSet, TViewModel>(); + } + } + // public class MesWindow : MetroWindow, IMesWindow, IMvxWindow, IMvxWpfView + // { + // private IMvxViewModel _viewModel; + // private IMvxBindingContext _bindingContext; + + // public IMvxViewModel ViewModel + // { + // get => _viewModel; + // set + // { + // _viewModel = value; + // DataContext = value; + // BindingContext.DataContext = value; + // } + // } + + // public String Identifier { get; set; } + + // public IMvxBindingContext BindingContext + // { + // get + // { + // if (_bindingContext != null) + // { + // return _bindingContext; + // } + + // if (Mvx.IoCProvider != null) + // { + // this.CreateBindingContext(); + // } + + // return _bindingContext; + // } + // set => _bindingContext = value; + // } + + // public String DisplayName + // { + // get => Title; + // set => Title = value; + // } + + // public MesWindow() + // { + // Unloaded += MesWindow_Unloaded; + // Loaded += MesWindow_Loaded; + // Initialized += MesWindow_Initialized; + // } + + // private void MesWindow_Initialized(Object sender, EventArgs e) + // { + // if (this == Application.Current.MainWindow) + // { + // // Application startup + // (Application.Current as MvxApplication).ApplicationInitialized(); + + // // Init mes setup + // Mvx.IoCProvider.Resolve(); + + // #warning fix style + // //WindowCloseButtonStyle = Application.Current.Resources.MergedDictionaries + // //WindowCloseButtonStyle = "{DynamicResource MetroWindowButtonStyle}" + // //WindowMinButtonStyle = "{DynamicResource MetroWindowButtonStyle}" + // //WindowMaxButtonStyle = "{DynamicResource MetroWindowButtonStyle}" + // } + // } + + // private void MesWindow_Unloaded(Object sender, RoutedEventArgs e) + // { + // ViewModel?.ViewDisappearing(); + // ViewModel?.ViewDisappeared(); + // ViewModel?.ViewDestroy(); + // } + + // /// + // /// Load inital settings if possible + // /// + // /// + // /// + // private void MesWindow_Loaded(Object sender, RoutedEventArgs e) + // { + // String blueTheme = "MesBlueTheme"; + + // // Get main theme property if possible + // String themeName = Properties.Settings.Default.ThemeName; + // if (String.IsNullOrEmpty(themeName)) themeName = blueTheme; + + // // Set theme from name + // IMesThemeManager manager = Mvx.IoCProvider.Resolve(); + // IMesTheme theme = manager.Themes.FirstOrDefault(x => x.GetType().Name == themeName); + + // // Set to defualt if missing or error + // if (theme == null) theme = manager.Themes.First(x => x.GetType().Name == themeName); + + // manager.SetCurrentTheme(theme.Name); + + // ViewModel?.ViewAppearing(); + // ViewModel?.ViewAppeared(); + // } + // } + + // public class MesWindow : MesWindow, IMvxWpfView where TViewModel : class, IMvxViewModel + // { + // public new TViewModel ViewModel + // { + // get => (TViewModel)base.ViewModel; + // set => base.ViewModel = value; + // } + + // MvxFluentBindingDescriptionSet, TViewModel> IMvxWpfView.CreateBindingSet() + // { + // return this.CreateBindingSet, TViewModel>(); + // } + // } } \ No newline at end of file From b715455b8b16f4eff245876e5c4a7b5f955e0da2 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sun, 21 Feb 2021 10:10:00 -0500 Subject: [PATCH 12/68] fix class name --- .../Core/MesWpfSetup.cs | 73 +------------------ ...WpfPresenter.cs => MesWpfViewPresenter.cs} | 6 +- 2 files changed, 4 insertions(+), 75 deletions(-) rename Modules/MinoriEditorShell.Platforms.Wpf/Presenters/{MesWpfPresenter.cs => MesWpfViewPresenter.cs} (94%) diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/Core/MesWpfSetup.cs b/Modules/MinoriEditorShell.Platforms.Wpf/Core/MesWpfSetup.cs index bdad0ab0..7716b949 100644 --- a/Modules/MinoriEditorShell.Platforms.Wpf/Core/MesWpfSetup.cs +++ b/Modules/MinoriEditorShell.Platforms.Wpf/Core/MesWpfSetup.cs @@ -37,7 +37,7 @@ namespace MinoriEditorShell.Platforms.Wpf protected override IMvxWpfViewPresenter CreateViewPresenter(ContentControl root) { // This handles main window. - return new MesWpfPresenter(root); + return new MesWpfViewPresenter(root); } /// @@ -124,75 +124,4 @@ public override void InitializePrimary() } } } - - ///// - ///// By default, we are configured to use MEF - ///// - //protected override void Configure() - //{ - // // Add all assemblies to AssemblySource (using a temporary DirectoryCatalog). - // var directoryCatalog = new DirectoryCatalog(@"./"); - // AssemblySource.Instance.AddRange( - // directoryCatalog.Parts - // .Select(part => ReflectionModelServices.GetPartType(part).Value.Assembly) - // .Where(assembly => !AssemblySource.Instance.Contains(assembly))); - - // // Prioritise the executable assembly. This allows the client project to override exports, including IShell. - // // The client project can override SelectAssemblies to choose which assemblies are prioritised. - // _priorityAssemblies = SelectAssemblies().ToList(); - // var priorityCatalog = new AggregateCatalog(_priorityAssemblies.Select(x => new AssemblyCatalog(x))); - // var priorityProvider = new CatalogExportProvider(priorityCatalog); - - // // Now get all other assemblies (excluding the priority assemblies). - // var mainCatalog = new AggregateCatalog( - // AssemblySource.Instance - // .Where(assembly => !_priorityAssemblies.Contains(assembly)) - // .Select(x => new AssemblyCatalog(x))); - // var mainProvider = new CatalogExportProvider(mainCatalog); - - // Container = new CompositionContainer(priorityProvider, mainProvider); - // priorityProvider.SourceProvider = Container; - // mainProvider.SourceProvider = Container; - - // var batch = new CompositionBatch(); - - // BindServices(batch); - // batch.AddExportedValue(mainCatalog); - - // Container.Compose(batch); - //} - - // protected virtual void BindServices(CompositionBatch batch) - // { - // batch.AddExportedValue(new WindowManager()); - // batch.AddExportedValue(new EventAggregator()); - // batch.AddExportedValue(Container); - // batch.AddExportedValue(this); - // } - - //protected override object GetInstance(Type serviceType, string key) - //{ - // string contract = string.IsNullOrEmpty(key) ? AttributedModelServices.GetContractName(serviceType) : key; - // var exports = Container.GetExports(contract); - - // if (exports.Any()) - // return exports.First().Value; - - // throw new Exception(string.Format("Could not locate any instances of contract {0}.", contract)); - //} - - //protected override IEnumerable GetAllInstances(Type serviceType) - //{ - // return Container.GetExportedValues(AttributedModelServices.GetContractName(serviceType)); - //} - - //protected override void BuildUp(object instance) - //{ - // Container.SatisfyImportsOnce(instance); - //} - - // protected override IEnumerable SelectAssemblies() - // { - // return new[] { Assembly.GetEntryAssembly() }; - // } } \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/Presenters/MesWpfPresenter.cs b/Modules/MinoriEditorShell.Platforms.Wpf/Presenters/MesWpfViewPresenter.cs similarity index 94% rename from Modules/MinoriEditorShell.Platforms.Wpf/Presenters/MesWpfPresenter.cs rename to Modules/MinoriEditorShell.Platforms.Wpf/Presenters/MesWpfViewPresenter.cs index f99a96a0..5a5a5e7a 100644 --- a/Modules/MinoriEditorShell.Platforms.Wpf/Presenters/MesWpfPresenter.cs +++ b/Modules/MinoriEditorShell.Platforms.Wpf/Presenters/MesWpfViewPresenter.cs @@ -16,7 +16,7 @@ namespace MinoriEditorShell.Platforms.Wpf.Presenters /// /// Main presenter that allows document and tools to naviage to MesDocumentController /// - public class MesWpfPresenter : MvxWpfViewPresenter + public class MesWpfViewPresenter : MvxWpfViewPresenter { private IMvxLog _log; @@ -24,10 +24,10 @@ public class MesWpfPresenter : MvxWpfViewPresenter /// Main constructor for the presenter, this gets the main window. /// /// - public MesWpfPresenter(ContentControl mainWindow) : base(mainWindow) + public MesWpfViewPresenter(ContentControl mainWindow) : base(mainWindow) { IMvxLogProvider provider = Mvx.IoCProvider.Resolve(); - _log = provider.GetLogFor(); + _log = provider.GetLogFor(); _log.Trace("Setup: Creating Presenter"); // Setup main window as singleton From 287f966e513280aa8fa0193c0ccf8b2008b470ef Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sun, 21 Feb 2021 10:25:46 -0500 Subject: [PATCH 13/68] update sonar --- .../minorieditorshell/CSharp/SonarLint.xml | 89 ----- .sonarlint/minorieditorshellcsharp.ruleset | 366 ------------------ .../MinoriDemo.Core/MinoriDemo.Core.csproj | 4 +- .../MinoriDemo.RibbonWPF.csproj | 17 +- .../MinoriDemo.RibbonWPF.ruleset | 5 + .../MinoriDemo.RibbonWpfCore.csproj | 4 +- .../MinoriDemo.WPF/MinoriDemo.WPF.csproj | 11 +- .../MinoriDemo.WPF/MinoriDemo.WPF.ruleset | 5 + .../MinoriDemo.WpfCore.csproj | 4 +- .../SimpleDemo.Core/SimpleDemo.Core.csproj | 4 +- .../SimpleDemo.Core/SimpleDemo.Core.ruleset | 5 + .../SimpleDemo.RibbonWPF.csproj | 12 +- .../SimpleDemo.RibbonWPF.ruleset | 5 + .../SimpleDemo.RibbonWpfCore.csproj | 4 +- .../SimpleDemo.WPF/SimpleDemo.WPF.csproj | 11 +- .../SimpleDemo.WPF/SimpleDemo.WPF.ruleset | 5 + .../SimpleDemo.WpfCore.csproj | 4 +- ...inoriEditorShell.Platforms.Avalonia.csproj | 6 +- .../MinoriEditorShell.Platforms.Wpf.csproj | 6 +- .../MinoriEditorShell.Ribbon.csproj | 4 +- ...orShell.VirtualCanvas.Platforms.Wpf.csproj | 4 +- .../MinoriEditorShell.VirtualCanvas.csproj | 5 +- .../MinoriEditorShell.csproj | 5 +- .../MinoriEditorShell.ruleset | 5 + 24 files changed, 86 insertions(+), 504 deletions(-) delete mode 100644 .sonarlint/minorieditorshell/CSharp/SonarLint.xml delete mode 100644 .sonarlint/minorieditorshellcsharp.ruleset create mode 100644 Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.ruleset create mode 100644 Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.ruleset create mode 100644 Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core.ruleset create mode 100644 Demos/SimpleDemo/SimpleDemo.RibbonWPF/SimpleDemo.RibbonWPF.ruleset create mode 100644 Demos/SimpleDemo/SimpleDemo.WPF/SimpleDemo.WPF.ruleset create mode 100644 Modules/MinoriEditorShell/MinoriEditorShell.ruleset diff --git a/.sonarlint/minorieditorshell/CSharp/SonarLint.xml b/.sonarlint/minorieditorshell/CSharp/SonarLint.xml deleted file mode 100644 index 21acd70e..00000000 --- a/.sonarlint/minorieditorshell/CSharp/SonarLint.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - - - sonar.cs.analyzeGeneratedCode - false - - - sonar.cs.file.suffixes - .cs - - - sonar.cs.ignoreHeaderComments - true - - - sonar.cs.roslyn.ignoreIssues - false - - - - - S107 - - - max - 7 - - - - - S110 - - - max - 5 - - - - - S1479 - - - maximum - 30 - - - - - S2342 - - - flagsAttributeFormat - ^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?s$ - - - format - ^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?$ - - - - - S2436 - - - max - 2 - - - maxMethod - 3 - - - - - S3776 - - - propertyThreshold - 3 - - - threshold - 15 - - - - - \ No newline at end of file diff --git a/.sonarlint/minorieditorshellcsharp.ruleset b/.sonarlint/minorieditorshellcsharp.ruleset deleted file mode 100644 index 64d3f453..00000000 --- a/.sonarlint/minorieditorshellcsharp.ruleset +++ /dev/null @@ -1,366 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Demos/MinoriDemo/MinoriDemo.Core/MinoriDemo.Core.csproj b/Demos/MinoriDemo/MinoriDemo.Core/MinoriDemo.Core.csproj index b7b0611f..118cac46 100644 --- a/Demos/MinoriDemo/MinoriDemo.Core/MinoriDemo.Core.csproj +++ b/Demos/MinoriDemo/MinoriDemo.Core/MinoriDemo.Core.csproj @@ -2,7 +2,7 @@ netstandard2.0 - ..\..\..\.sonarlint\minorieditorshellcsharp.ruleset + ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset @@ -12,7 +12,7 @@ - + diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.csproj b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.csproj index f45f11aa..69136def 100644 --- a/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.csproj +++ b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.csproj @@ -14,7 +14,7 @@ 4 true true - ..\..\..\.sonarlint\minorieditorshellcsharp.ruleset + ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset AnyCPU @@ -25,7 +25,7 @@ DEBUG;TRACE prompt 4 - ..\..\..\.sonarlint\minorieditorshellcsharp.ruleset + ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset AnyCPU @@ -35,7 +35,7 @@ TRACE prompt 4 - ..\..\..\.sonarlint\minorieditorshellcsharp.ruleset + ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset @@ -138,6 +138,9 @@ + + torisankitsune_minorieditorshell2csharp.ruleset + @@ -192,12 +195,12 @@ - - SonarLint.xml - + - + + SonarLint.xml + \ No newline at end of file diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.ruleset b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.ruleset new file mode 100644 index 00000000..b327e534 --- /dev/null +++ b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.ruleset @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/MinoriDemo.RibbonWpfCore.csproj b/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/MinoriDemo.RibbonWpfCore.csproj index c72c6c04..ee85488e 100644 --- a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/MinoriDemo.RibbonWpfCore.csproj +++ b/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/MinoriDemo.RibbonWpfCore.csproj @@ -5,7 +5,7 @@ netcoreapp3.1 false true - ..\..\..\.sonarlint\minorieditorshellcsharp.ruleset + ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset @@ -13,7 +13,7 @@ - + diff --git a/Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.csproj b/Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.csproj index a688baa8..ff076a96 100644 --- a/Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.csproj +++ b/Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.csproj @@ -14,7 +14,7 @@ 4 true true - ..\..\..\.sonarlint\minorieditorshellcsharp.ruleset + ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset AnyCPU @@ -25,7 +25,7 @@ DEBUG;TRACE prompt 4 - ..\..\..\.sonarlint\minorieditorshellcsharp.ruleset + ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset AnyCPU @@ -35,7 +35,7 @@ TRACE prompt 4 - ..\..\..\.sonarlint\minorieditorshellcsharp.ruleset + ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset @@ -99,6 +99,9 @@ minorieditorshellcsharp.ruleset + + torisankitsune_minorieditorshell2csharp.ruleset + SettingsSingleFileGenerator Settings.Designer.cs @@ -140,7 +143,7 @@ - + SonarLint.xml diff --git a/Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.ruleset b/Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.ruleset new file mode 100644 index 00000000..b327e534 --- /dev/null +++ b/Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.ruleset @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Demos/MinoriDemo/MinoriDemo.WpfCore/MinoriDemo.WpfCore.csproj b/Demos/MinoriDemo/MinoriDemo.WpfCore/MinoriDemo.WpfCore.csproj index f02ef02a..b79ed68f 100644 --- a/Demos/MinoriDemo/MinoriDemo.WpfCore/MinoriDemo.WpfCore.csproj +++ b/Demos/MinoriDemo/MinoriDemo.WpfCore/MinoriDemo.WpfCore.csproj @@ -5,11 +5,11 @@ netcoreapp3.1 false true - ..\..\..\.sonarlint\minorieditorshellcsharp.ruleset + ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset - + diff --git a/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core.csproj b/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core.csproj index 248dfa60..1c65fbd8 100644 --- a/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core.csproj +++ b/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core.csproj @@ -2,11 +2,11 @@ netstandard2.0 - ..\..\..\.sonarlint\minorieditorshellcsharp.ruleset + ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset - + diff --git a/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core.ruleset b/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core.ruleset new file mode 100644 index 00000000..b327e534 --- /dev/null +++ b/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core.ruleset @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Demos/SimpleDemo/SimpleDemo.RibbonWPF/SimpleDemo.RibbonWPF.csproj b/Demos/SimpleDemo/SimpleDemo.RibbonWPF/SimpleDemo.RibbonWPF.csproj index 1a1e8445..27821e09 100644 --- a/Demos/SimpleDemo/SimpleDemo.RibbonWPF/SimpleDemo.RibbonWPF.csproj +++ b/Demos/SimpleDemo/SimpleDemo.RibbonWPF/SimpleDemo.RibbonWPF.csproj @@ -14,7 +14,7 @@ 4 true true - ..\..\..\.sonarlint\minorieditorshellcsharp.ruleset + ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset AnyCPU @@ -25,7 +25,7 @@ DEBUG;TRACE prompt 4 - ..\..\..\.sonarlint\minorieditorshellcsharp.ruleset + ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset AnyCPU @@ -35,7 +35,7 @@ TRACE prompt 4 - ..\..\..\.sonarlint\minorieditorshellcsharp.ruleset + ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset @@ -103,8 +103,8 @@ ResXFileCodeGenerator Resources.Designer.cs - - minorieditorshellcsharp.ruleset + + torisankitsune_minorieditorshell2csharp.ruleset SettingsSingleFileGenerator @@ -146,7 +146,7 @@ - + SonarLint.xml diff --git a/Demos/SimpleDemo/SimpleDemo.RibbonWPF/SimpleDemo.RibbonWPF.ruleset b/Demos/SimpleDemo/SimpleDemo.RibbonWPF/SimpleDemo.RibbonWPF.ruleset new file mode 100644 index 00000000..b327e534 --- /dev/null +++ b/Demos/SimpleDemo/SimpleDemo.RibbonWPF/SimpleDemo.RibbonWPF.ruleset @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Demos/SimpleDemo/SimpleDemo.RibbonWpfCore/SimpleDemo.RibbonWpfCore.csproj b/Demos/SimpleDemo/SimpleDemo.RibbonWpfCore/SimpleDemo.RibbonWpfCore.csproj index e4845d87..e3eb10c5 100644 --- a/Demos/SimpleDemo/SimpleDemo.RibbonWpfCore/SimpleDemo.RibbonWpfCore.csproj +++ b/Demos/SimpleDemo/SimpleDemo.RibbonWpfCore/SimpleDemo.RibbonWpfCore.csproj @@ -5,11 +5,11 @@ netcoreapp3.1 false true - ..\..\..\.sonarlint\minorieditorshellcsharp.ruleset + ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset - + diff --git a/Demos/SimpleDemo/SimpleDemo.WPF/SimpleDemo.WPF.csproj b/Demos/SimpleDemo/SimpleDemo.WPF/SimpleDemo.WPF.csproj index 4db0d757..c4aaebf4 100644 --- a/Demos/SimpleDemo/SimpleDemo.WPF/SimpleDemo.WPF.csproj +++ b/Demos/SimpleDemo/SimpleDemo.WPF/SimpleDemo.WPF.csproj @@ -14,7 +14,7 @@ 4 true true - ..\..\..\.sonarlint\minorieditorshellcsharp.ruleset + ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset AnyCPU @@ -25,7 +25,7 @@ DEBUG;TRACE prompt 4 - ..\..\..\.sonarlint\minorieditorshellcsharp.ruleset + ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset AnyCPU @@ -35,7 +35,7 @@ TRACE prompt 4 - ..\..\..\.sonarlint\minorieditorshellcsharp.ruleset + ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset @@ -106,6 +106,9 @@ minorieditorshellcsharp.ruleset + + torisankitsune_minorieditorshell2csharp.ruleset + SettingsSingleFileGenerator Settings.Designer.cs @@ -139,7 +142,7 @@ - + SonarLint.xml diff --git a/Demos/SimpleDemo/SimpleDemo.WPF/SimpleDemo.WPF.ruleset b/Demos/SimpleDemo/SimpleDemo.WPF/SimpleDemo.WPF.ruleset new file mode 100644 index 00000000..b327e534 --- /dev/null +++ b/Demos/SimpleDemo/SimpleDemo.WPF/SimpleDemo.WPF.ruleset @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Demos/SimpleDemo/SimpleDemo.WpfCore/SimpleDemo.WpfCore.csproj b/Demos/SimpleDemo/SimpleDemo.WpfCore/SimpleDemo.WpfCore.csproj index 5518d1d8..826a9e03 100644 --- a/Demos/SimpleDemo/SimpleDemo.WpfCore/SimpleDemo.WpfCore.csproj +++ b/Demos/SimpleDemo/SimpleDemo.WpfCore/SimpleDemo.WpfCore.csproj @@ -5,11 +5,11 @@ netcoreapp3.1 false true - ..\..\..\.sonarlint\minorieditorshellcsharp.ruleset + ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset - + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj index bf6dd8f0..8f6430ad 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj @@ -15,7 +15,7 @@ This uses AvalonDock and has an MVVM architecture based on MvvmCross.Mark Kromis Library bin\MinoriEditorShell.Platforms.Avalonia.xml - ..\..\.sonarlint\minorieditorshellcsharp.ruleset + ..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset @@ -26,9 +26,9 @@ This uses AvalonDock and has an MVVM architecture based on MvvmCross. - + - + diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj b/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj index 2d0efe68..c9ce174e 100644 --- a/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj +++ b/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj @@ -16,7 +16,7 @@ This uses AvalonDock and has an MVVM architecture based on MvvmCross.Library bin\MinoriEditorShell.xml true - ..\..\.sonarlint\minorieditorshellcsharp.ruleset + ..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset @@ -27,9 +27,9 @@ This uses AvalonDock and has an MVVM architecture based on MvvmCross. - + - + diff --git a/Modules/MinoriEditorShell.Ribbon/MinoriEditorShell.Ribbon.csproj b/Modules/MinoriEditorShell.Ribbon/MinoriEditorShell.Ribbon.csproj index b3baaca4..22940b50 100644 --- a/Modules/MinoriEditorShell.Ribbon/MinoriEditorShell.Ribbon.csproj +++ b/Modules/MinoriEditorShell.Ribbon/MinoriEditorShell.Ribbon.csproj @@ -11,11 +11,11 @@ Git Ribbon Mahapp IDE true - ..\..\.sonarlint\minorieditorshellcsharp.ruleset + ..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset - + diff --git a/Modules/MinoriEditorShell.VirtualCanvas.Platforms.Wpf/MinoriEditorShell.VirtualCanvas.Platforms.Wpf.csproj b/Modules/MinoriEditorShell.VirtualCanvas.Platforms.Wpf/MinoriEditorShell.VirtualCanvas.Platforms.Wpf.csproj index 80696868..e2601d5c 100644 --- a/Modules/MinoriEditorShell.VirtualCanvas.Platforms.Wpf/MinoriEditorShell.VirtualCanvas.Platforms.Wpf.csproj +++ b/Modules/MinoriEditorShell.VirtualCanvas.Platforms.Wpf/MinoriEditorShell.VirtualCanvas.Platforms.Wpf.csproj @@ -13,11 +13,11 @@ true bin\MinoriEditorStudio.VirtualCanvas.xml true - ..\..\.sonarlint\minorieditorshellcsharp.ruleset + ..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset - + diff --git a/Modules/MinoriEditorShell.VirtualCanvas/MinoriEditorShell.VirtualCanvas.csproj b/Modules/MinoriEditorShell.VirtualCanvas/MinoriEditorShell.VirtualCanvas.csproj index 489ede27..c9d33bf4 100644 --- a/Modules/MinoriEditorShell.VirtualCanvas/MinoriEditorShell.VirtualCanvas.csproj +++ b/Modules/MinoriEditorShell.VirtualCanvas/MinoriEditorShell.VirtualCanvas.csproj @@ -12,15 +12,14 @@ IDE VirtualCanvas Module true bin\MinoriEditorStudio.VirtualCanvas.xml - ..\..\.sonarlint\minorieditorshellcsharp.ruleset + ..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset - + - all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Modules/MinoriEditorShell/MinoriEditorShell.csproj b/Modules/MinoriEditorShell/MinoriEditorShell.csproj index fa8e21b2..445539f7 100644 --- a/Modules/MinoriEditorShell/MinoriEditorShell.csproj +++ b/Modules/MinoriEditorShell/MinoriEditorShell.csproj @@ -14,15 +14,14 @@ This uses AvalonDock and has an MVVM architecture based on MvvmCross.Mark Kromis Mark Kromis bin\MinoriEditorShell.xml - ..\..\.sonarlint\minorieditorshellcsharp.ruleset + ..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset - + - all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Modules/MinoriEditorShell/MinoriEditorShell.ruleset b/Modules/MinoriEditorShell/MinoriEditorShell.ruleset new file mode 100644 index 00000000..0c70e0f7 --- /dev/null +++ b/Modules/MinoriEditorShell/MinoriEditorShell.ruleset @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file From 13ff213511e24a0fcecc246ba985a07ff1ad436d Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sun, 21 Feb 2021 10:56:01 -0500 Subject: [PATCH 14/68] more fixes --- .../MesBinding/MesMvvmCrossBindingCreator.cs | 13 +- .../Binding/MesBindingCreator.cs | 9 +- .../Binding/MesWindowsBindingBuilder.cs | 3 - .../MesWindowsPropertyBindingExtensions.cs | 8 +- .../AvnWindowsBindingCreator.cs | 16 +- .../Core/MesAvnSetup.cs | 178 ++++++++---------- .../Views/IMesAvnView.cs | 4 +- 7 files changed, 113 insertions(+), 118 deletions(-) diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/MesMvvmCrossBindingCreator.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/MesMvvmCrossBindingCreator.cs index 560df9ab..766718fa 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/MesMvvmCrossBindingCreator.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/MesMvvmCrossBindingCreator.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Avalonia; using MvvmCross.Binding; using MvvmCross.Binding.Bindings; @@ -8,7 +9,7 @@ namespace MinoriEditorShell.Platforms.Avalonia.Binding.MesBinding { public class MesMvvmCrossBindingCreator : MesBindingCreator { - protected override void ApplyBindings(FrameworkElement attachedObject, + protected override void ApplyBindings(StyledElement attachedObject, IEnumerable bindingDescriptions) { var binder = MvxBindingSingletonCache.Instance.Binder; @@ -17,7 +18,7 @@ protected override void ApplyBindings(FrameworkElement attachedObject, RegisterBindingsForUpdates(attachedObject, bindings); } - private void RegisterBindingsForUpdates(FrameworkElement attachedObject, + private void RegisterBindingsForUpdates(AvaloniaObject attachedObject, IEnumerable bindings) { if (bindings == null) @@ -30,7 +31,7 @@ private void RegisterBindingsForUpdates(FrameworkElement attachedObject, } } - private IList GetOrCreateBindingsList(FrameworkElement attachedObject) + private IList GetOrCreateBindingsList(AvaloniaObject attachedObject) { var existing = attachedObject.GetValue(BindingsListProperty) as IList; if (existing != null) @@ -75,7 +76,7 @@ private IList GetOrCreateBindingsList(FrameworkElement at public static readonly DependencyProperty DataContextWatcherProperty = DependencyProperty.Register( "DataContextWatcher", typeof(object), - typeof(FrameworkElement), + typeof(AvaloniaObject), new PropertyMetadata(null, DataContext_Changed)); public static object GetDataContextWatcher(DependencyObject d) @@ -91,7 +92,7 @@ public static void SetDataContextWatcher(DependencyObject d, string value) public static readonly DependencyProperty BindingsListProperty = DependencyProperty.Register( "BindingsList", typeof(IList), - typeof(FrameworkElement), + typeof(AvaloniaObject), new PropertyMetadata(null)); public static IList GetBindingsList(DependencyObject d) @@ -106,7 +107,7 @@ public static void SetBindingsList(DependencyObject d, string value) private static void DataContext_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e) { - var frameworkElement = d as FrameworkElement; + var frameworkElement = d as AvaloniaObject; var bindings = frameworkElement?.GetValue(BindingsListProperty) as IList; if (bindings == null) diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBindingCreator.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBindingCreator.cs index 6a51c3b6..cf200a92 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBindingCreator.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBindingCreator.cs @@ -3,6 +3,8 @@ using System.Windows; using MvvmCross.Logging; using MvvmCross.Binding.Bindings; +using Avalonia; +using MvvmCross; namespace MinoriEditorShell.Platforms.Avalonia.Binding { @@ -11,10 +13,11 @@ public abstract class MesBindingCreator : IMesBindingCreator public void CreateBindings(object sender, DependencyPropertyChangedEventArgs args, Func> parseBindingDescriptions) { - var attachedObject = sender as FrameworkElement; + var attachedObject = sender as StyledElement; if (attachedObject == null) { - MvxLog.Instance.Warn("Null attached FrameworkElement seen in Bi.nd binding"); + IMvxLog _log = Mvx.IoCProvider.Resolve().GetLogFor(); + _log.Warn("Null attached StyledElement seen in Bi.nd binding"); return; } @@ -29,7 +32,7 @@ public void CreateBindings(object sender, DependencyPropertyChangedEventArgs arg ApplyBindings(attachedObject, bindingDescriptions); } - protected abstract void ApplyBindings(FrameworkElement attachedObject, + protected abstract void ApplyBindings(StyledElement attachedObject, IEnumerable bindingDescriptions); } } diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsBindingBuilder.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsBindingBuilder.cs index ccf75bdf..27a5c794 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsBindingBuilder.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsBindingBuilder.cs @@ -5,9 +5,6 @@ using MvvmCross.Binding.Binders; using MvvmCross.Binding.Bindings.Target.Construction; using MvvmCross.Binding.Combiners; -using MvvmCross.Platforms.Wpf.Binding.MvxBinding; -using MvvmCross.Platforms.Wpf.Binding.MvxBinding.Target; -using MvvmCross.Platforms.Wpf.Binding.WindowsBinding; namespace MinoriEditorShell.Platforms.Avalonia.Binding { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsPropertyBindingExtensions.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsPropertyBindingExtensions.cs index 898df8f3..9f94ae3f 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsPropertyBindingExtensions.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsPropertyBindingExtensions.cs @@ -1,14 +1,16 @@ +using Avalonia; + namespace MinoriEditorShell.Platforms.Avalonia.Binding { public static class MesWindowsPropertyBindingExtensions { - public static string BindVisible(this FrameworkElement frameworkElement) + public static string BindVisible(this AvaloniaObject frameworkElement) => MesWindowsPropertyBinding.FrameworkElement_Visible; - public static string BindCollapsed(this FrameworkElement frameworkElement) + public static string BindCollapsed(this AvaloniaObject frameworkElement) => MesWindowsPropertyBinding.FrameworkElement_Collapsed; - public static string BindHidden(this FrameworkElement frameworkElement) + public static string BindHidden(this AvaloniaObject frameworkElement) => MesWindowsPropertyBinding.FrameworkElement_Hidden; } } diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/WindowsBinding/AvnWindowsBindingCreator.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/WindowsBinding/AvnWindowsBindingCreator.cs index fb76db55..5d6abd03 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/WindowsBinding/AvnWindowsBindingCreator.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/WindowsBinding/AvnWindowsBindingCreator.cs @@ -10,31 +10,34 @@ using Avalonia.Data.Core; using Avalonia.Data.Converters; using MinoriEditorShell.Platforms.Avalonia.Converters; +using Avalonia; +using MvvmCross; namespace MinoriEditorShell.Platforms.Avalonia.Binding.WindowsBinding { public class AvnWindowsBindingCreator : MesBindingCreator { protected virtual void ApplyBinding(MvxBindingDescription bindingDescription, Type actualType, - FrameworkElement attachedObject) + StyledElement attachedObject) { + IMvxLog log = Mvx.IoCProvider.Resolve().GetLogFor(); DependencyProperty dependencyProperty = actualType.FindDependencyProperty(bindingDescription.TargetName); if (dependencyProperty == null) { - MvxLog.Instance.Warn("Dependency property not found for {0}", bindingDescription.TargetName); + log.Warn("Dependency property not found for {0}", bindingDescription.TargetName); return; } var property = actualType.FindActualProperty(bindingDescription.TargetName); if (property == null) { - MvxLog.Instance.Warn("Property not returned {0} - may cause issues", bindingDescription.TargetName); + log.Warn("Property not returned {0} - may cause issues", bindingDescription.TargetName); } var sourceStep = bindingDescription.Source as MvxPathSourceStepDescription; if (sourceStep == null) { - MvxLog.Instance.Warn("Binding description for {0} is not a simple path - Windows Binding cannot cope with this", bindingDescription.TargetName); + log.Warn("Binding description for {0} is not a simple path - Windows Binding cannot cope with this", bindingDescription.TargetName); return; } @@ -49,7 +52,7 @@ protected virtual void ApplyBinding(MvxBindingDescription bindingDescription, Ty BindingOperations.SetBinding(attachedObject, dependencyProperty, newBinding); } - protected override void ApplyBindings(FrameworkElement attachedObject, + protected override void ApplyBindings(StyledElement attachedObject, IEnumerable bindingDescriptions) { var actualType = attachedObject.GetType(); @@ -92,7 +95,8 @@ protected static BindingMode ConvertMode(MvxBindingMode mode, Type propertyType) return BindingMode.OneTime; case MvxBindingMode.OneWayToSource: - MvxLog.Instance.Warn("WinPhone doesn't support OneWayToSource"); + IMvxLog log = Mvx.IoCProvider.Resolve().GetLogFor(); + log.Warn("WinPhone doesn't support OneWayToSource"); return BindingMode.TwoWay; default: diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs index 0d65e326..0fa41ad3 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs @@ -43,6 +43,33 @@ public abstract class MesAvnSetup : MvxSetup, IMvxAvnSetup private IMesAvnViewPresenter _presenter; private ContentControl _root; private Dispatcher _uiThreadDispatcher; + protected IMesAvnViewPresenter Presenter + { + get + { + _presenter = CreateViewPresenter(_root); + return _presenter; + } + } + + protected virtual IEnumerable ValueConverterAssemblies + { + get + { + var toReturn = new List(); + toReturn.AddRange(GetViewModelAssemblies()); + toReturn.AddRange(GetViewAssemblies()); + return toReturn; + } + } + + protected virtual List ValueConverterHolders => new List(); + + public override IEnumerable GetViewAssemblies() + { + return base.GetViewAssemblies().Union(new[] { Assembly.GetEntryAssembly() }); + } + /// /// Sets up initial connected types and setup /// @@ -97,12 +124,6 @@ public void PlatformInitialize(Dispatcher uiThreadDispatcher, ContentControl roo _uiThreadDispatcher = uiThreadDispatcher; _root = root; } - - public override IEnumerable GetViewAssemblies() - { - return base.GetViewAssemblies().Union(new[] { Assembly.GetEntryAssembly() }); - } - /// /// Creates the app. /// @@ -122,18 +143,15 @@ protected override IMvxApplication CreateApp() //return new TApplication(); } - protected sealed override IMvxViewsContainer CreateViewsContainer(IMvxIoCProvider iocProvider) + protected virtual IMesAvnViewsContainer CreateAvnViewsContainer() { - ValidateArguments(iocProvider); - - var toReturn = CreateAvnViewsContainer(); - iocProvider.RegisterSingleton(toReturn); - return toReturn; + return new MesAvnViewsContainer(); } - protected virtual IMesAvnViewsContainer CreateAvnViewsContainer() + protected virtual MvxBindingBuilder CreateBindingBuilder() { - return new MesAvnViewsContainer(); + throw new NotImplementedException(); + //return new MvxWindowsBindingBuilder(); } /// @@ -147,81 +165,78 @@ protected override IMvxPluginManager CreatePluginManager() return manager; } + protected override IMvxViewDispatcher CreateViewDispatcher() + { + return new MesAvnViewDispatcher(_uiThreadDispatcher, Presenter); + } + /// /// Creates the inital view for the setup /// /// Control of the main windows for wpf /// - protected override IMvxViewPresenter CreateViewPresenter(ContentControl root) + protected virtual IMesAvnViewPresenter CreateViewPresenter(ContentControl root) { - // This handles main window. return new MesAvnViewPresenter(root); } - /// - /// Sets up the dictionary that connects the viewmodel to the view. - /// - /// - protected override IDictionary InitializeLookupDictionary() - { - IDictionary container = base.InitializeLookupDictionary(); - container.Add(typeof(MesSettingsManagerViewModel), typeof(MesSettingsView)); - container.Add(typeof(MesGeneralSettingsViewModel), typeof(MesGeneralSettingsView)); - return container; - } + protected IMvxViewsContainer CreateViewsContainer(IMvxIoCProvider iocProvider) + { + ValidateArguments(iocProvider); - protected IMesAvnViewPresenter Presenter + var toReturn = CreateAvnViewsContainer(); + iocProvider.RegisterSingleton(toReturn); + return toReturn; + } + protected override IMvxNameMapping CreateViewToViewModelNaming() { - get - { - _presenter = CreateViewPresenter(_root); - return _presenter; - } + return new MvxPostfixAwareViewToViewModelNameMapping("View", "Control"); } - protected virtual IMesAvnViewPresenter CreateViewPresenter(ContentControl root) + protected virtual void FillBindingNames(IMvxBindingNameRegistry registry) { - return new MesAvnViewPresenter(root); + // this base class does nothing } - protected override IMvxViewDispatcher CreateViewDispatcher() + protected virtual void FillTargetFactories(IMvxTargetBindingFactoryRegistry registry) { - return new MesAvnViewDispatcher(_uiThreadDispatcher, Presenter); + // this base class does nothing } - protected virtual void RegisterPresenter(IMvxIoCProvider iocProvider) + protected virtual void FillValueConverters(IMvxValueConverterRegistry registry) { - ValidateArguments(iocProvider); - - var presenter = Presenter; - iocProvider.RegisterSingleton(presenter); - iocProvider.RegisterSingleton(presenter); + registry.Fill(ValueConverterAssemblies); + registry.Fill(ValueConverterHolders); } - protected override IMvxNameMapping CreateViewToViewModelNaming() + protected virtual void InitializeBindingBuilder(IMvxIoCProvider iocProvider) { - return new MvxPostfixAwareViewToViewModelNameMapping("View", "Control"); + RegisterBindingBuilderCallbacks(iocProvider); + var bindingBuilder = CreateBindingBuilder(); + bindingBuilder.DoRegistration(); } - protected override void InitializeFirstChance(IMvxIoCProvider iocProvider) + protected void InitializeFirstChance(IMvxIoCProvider iocProvider) { RegisterPresenter(iocProvider); - base.InitializeFirstChance(iocProvider); } - protected override void InitializeLastChance(IMvxIoCProvider iocProvider) + protected void InitializeLastChance(IMvxIoCProvider iocProvider) { InitializeBindingBuilder(iocProvider); - base.InitializeLastChance(iocProvider); } - protected virtual void InitializeBindingBuilder(IMvxIoCProvider iocProvider) + /// + /// Sets up the dictionary that connects the viewmodel to the view. + /// + /// + protected override IDictionary InitializeLookupDictionary() { - RegisterBindingBuilderCallbacks(iocProvider); - var bindingBuilder = CreateBindingBuilder(); - bindingBuilder.DoRegistration(); + IDictionary container = base.InitializeLookupDictionary(); + container.Add(typeof(MesSettingsManagerViewModel), typeof(MesSettingsView)); + container.Add(typeof(MesGeneralSettingsViewModel), typeof(MesGeneralSettingsView)); + return container; } - protected virtual void RegisterBindingBuilderCallbacks(IMvxIoCProvider iocProvider) { ValidateArguments(iocProvider); @@ -231,40 +246,13 @@ protected virtual void RegisterBindingBuilderCallbacks(IMvxIoCProvider iocProvid iocProvider.CallbackWhenRegistered(FillBindingNames); } - protected virtual void FillBindingNames(IMvxBindingNameRegistry registry) - { - // this base class does nothing - } - - protected virtual void FillValueConverters(IMvxValueConverterRegistry registry) - { - registry.Fill(ValueConverterAssemblies); - registry.Fill(ValueConverterHolders); - } - - protected virtual void FillTargetFactories(IMvxTargetBindingFactoryRegistry registry) - { - // this base class does nothing - } - - protected virtual List ValueConverterHolders => new List(); - - protected virtual IEnumerable ValueConverterAssemblies + protected virtual void RegisterPresenter(IMvxIoCProvider iocProvider) { - get - { - var toReturn = new List(); - toReturn.AddRange(GetViewModelAssemblies()); - toReturn.AddRange(GetViewAssemblies()); - return toReturn; - } - } - + ValidateArguments(iocProvider); - protected virtual MvxBindingBuilder CreateBindingBuilder() - { - throw new NotImplementedException(); - //return new MvxWindowsBindingBuilder(); + var presenter = Presenter; + iocProvider.RegisterSingleton(presenter); + iocProvider.RegisterSingleton(presenter); } } @@ -272,13 +260,13 @@ protected virtual MvxBindingBuilder CreateBindingBuilder() /// This is the main initializer for the kit. Call or over-ride this simualr to any other MvxWpfSetup setup /// /// - // public class MesAvaSetup : MvxAvaSetup where TApplication : class, IMvxApplication, new() - // { - // protected override IMvxApplication CreateApp() => Mvx.IoCProvider.IoCConstruct(); - - // public override IEnumerable GetViewModelAssemblies() - // { - // return new[] { typeof(TApplication).GetTypeInfo().Assembly }; - // } - // } + public class MesAvnSetup : MesAvnSetup where TApplication : class, IMvxApplication, new() + { + public override IEnumerable GetViewModelAssemblies() + { + return new[] { typeof(TApplication).GetTypeInfo().Assembly }; + } + + protected override IMvxApplication CreateApp() => Mvx.IoCProvider.IoCConstruct(); + } } \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnView.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnView.cs index 98c804be..fe675a8f 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnView.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnView.cs @@ -12,10 +12,10 @@ public interface IMesAvnView { } - public interface IMvxWpfView + public interface IMesAvnView : IMesAvnView , IMvxView where TViewModel : class, IMvxViewModel { - MvxFluentBindingDescriptionSet, TViewModel> CreateBindingSet(); + MvxFluentBindingDescriptionSet, TViewModel> CreateBindingSet(); } } From 928306fa7d510c37ab5bf6c2823debd3214e9c23 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sun, 21 Feb 2021 19:34:41 -0500 Subject: [PATCH 15/68] Reset simple demo project, ignore some items so it compiles. --- .editorconfig | 5 +- .../SimpleDemo/SimpleDemo.Avalonia/App.axaml | 7 ++ .../{App.xaml.cs => App.axaml.cs} | 9 +- Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml | 11 --- .../{MainWindow.xaml => MainWindow.axaml} | 0 ...MainWindow.xaml.cs => MainWindow.axaml.cs} | 5 +- .../SimpleDemo/SimpleDemo.Avalonia/Program.cs | 5 +- .../SimpleDemo/SimpleDemo.Avalonia/Readme.md | 18 ---- .../SimpleDemo.Avalonia.csproj | 20 ++--- .../SimpleDemo.Avalonia/nuget.config | 7 +- MinoriEditorShell.sln | 7 ++ .../Binding/IMesBindingCreator.cs | 8 +- .../Binding/Import.cs | 4 +- .../Binding/MesBindingCreator.cs | 36 ++++---- .../Binding/MesDesignTimeChecker.cs | 1 + .../Core/MesAvnSetup.cs | 18 ++-- ...inoriEditorShell.Platforms.Avalonia.csproj | 19 +++++ .../Presenters/MesAvnViewPresenter.cs | 44 +++++----- .../Views/IMesAvnViewsContainer.cs | 9 +- .../Views/MesApplication.cs | 2 +- .../Views/MesAvnView.cs | 10 ++- .../Views/MesAvnViewsContainer.cs | 49 ++++++++++- .../Views/MesWindow.cs | 85 +++++++++---------- 23 files changed, 216 insertions(+), 163 deletions(-) create mode 100644 Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml rename Demos/SimpleDemo/SimpleDemo.Avalonia/{App.xaml.cs => App.axaml.cs} (72%) delete mode 100644 Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml rename Demos/SimpleDemo/SimpleDemo.Avalonia/{MainWindow.xaml => MainWindow.axaml} (100%) rename Demos/SimpleDemo/SimpleDemo.Avalonia/{MainWindow.xaml.cs => MainWindow.axaml.cs} (86%) delete mode 100644 Demos/SimpleDemo/SimpleDemo.Avalonia/Readme.md diff --git a/.editorconfig b/.editorconfig index 73cfb445..0d920fb0 100644 --- a/.editorconfig +++ b/.editorconfig @@ -87,7 +87,7 @@ csharp_style_conditional_delegate_call = true:suggestion csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async # Code-block preferences -csharp_prefer_braces = true:suggestion +csharp_prefer_braces = true:none # Expression-level preferences csharp_prefer_simple_default_expression = true:suggestion @@ -144,3 +144,6 @@ csharp_space_between_square_brackets = false csharp_preserve_single_line_blocks = true csharp_preserve_single_line_statements = true + +# IDE0011: Add braces +dotnet_diagnostic.IDE0011.severity = none diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml new file mode 100644 index 00000000..bbaecec2 --- /dev/null +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml @@ -0,0 +1,7 @@ + + + + + diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml.cs b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml.cs similarity index 72% rename from Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml.cs rename to Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml.cs index abd980e1..75a7355e 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml.cs +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml.cs @@ -1,19 +1,16 @@ using Avalonia; using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Markup.Xaml; -using MinoriEditorShell.Platforms.Avalonia.Views; namespace SimpleDemo.Avalonia { - public class App : MesApplication + public class App : Application { public override void Initialize() { AvaloniaXamlLoader.Load(this); } - protected override void RegisterSetup() { } //this.RegisterSetupType>(); - public override void OnFrameworkInitializationCompleted() { if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) @@ -23,5 +20,5 @@ public override void OnFrameworkInitializationCompleted() base.OnFrameworkInitializationCompleted(); } - } -} \ No newline at end of file + } +} diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml deleted file mode 100644 index 2d9d3162..00000000 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/App.xaml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/MainWindow.xaml b/Demos/SimpleDemo/SimpleDemo.Avalonia/MainWindow.axaml similarity index 100% rename from Demos/SimpleDemo/SimpleDemo.Avalonia/MainWindow.xaml rename to Demos/SimpleDemo/SimpleDemo.Avalonia/MainWindow.axaml diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/MainWindow.xaml.cs b/Demos/SimpleDemo/SimpleDemo.Avalonia/MainWindow.axaml.cs similarity index 86% rename from Demos/SimpleDemo/SimpleDemo.Avalonia/MainWindow.xaml.cs rename to Demos/SimpleDemo/SimpleDemo.Avalonia/MainWindow.axaml.cs index 7ecff1a6..6205cb2d 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/MainWindow.xaml.cs +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/MainWindow.axaml.cs @@ -9,6 +9,9 @@ public class MainWindow : Window public MainWindow() { InitializeComponent(); +#if DEBUG + this.AttachDevTools(); +#endif } private void InitializeComponent() @@ -16,4 +19,4 @@ private void InitializeComponent() AvaloniaXamlLoader.Load(this); } } -} \ No newline at end of file +} diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/Program.cs b/Demos/SimpleDemo/SimpleDemo.Avalonia/Program.cs index b541cf40..7105f84f 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/Program.cs +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/Program.cs @@ -1,8 +1,7 @@ -using System; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.ApplicationLifetimes; -using Avalonia.Logging.Serilog; +using System; namespace SimpleDemo.Avalonia { @@ -18,6 +17,6 @@ public static void Main(string[] args) => BuildAvaloniaApp() public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure() .UsePlatformDetect() - .LogToDebug(); + .LogToTrace(); } } diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/Readme.md b/Demos/SimpleDemo/SimpleDemo.Avalonia/Readme.md deleted file mode 100644 index afbc5686..00000000 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/Readme.md +++ /dev/null @@ -1,18 +0,0 @@ -# Introduction - -This is an attempt to get MvvmCross and Avalonia to play nice togeather. - -## Creation steps -Since we need to create our own MvvmCross.Platforms.Wpf -to Avalonui bridge, we will prefix the bridge with ava. -This is not using the ReactUI helper since we are using -MvvmCross. - -1. `dotnet new avalonia.app -o SimpleDemo.Avalonia` -1. Change the `App` class to use MesApplication from - `MinoriEditorShell.Platforms.Avalonuia` - 1. Add `xmlns:mes="clr-namespace:MinoriEditorShell.Platforms.Avalonia;assembly=MinoriEditorShell.Platforms.Avalonia"` - 2. Change `Application` to `mes:MesApplication` - 3. update `App.xmal.cs` - - \ No newline at end of file diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj b/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj index c2129b01..7dbbfdf2 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj @@ -1,21 +1,11 @@ WinExe - netcoreapp3.1 + net5.0 - - %(Filename) - - - Designer - - - - - - - - - + + + + diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/nuget.config b/Demos/SimpleDemo/SimpleDemo.Avalonia/nuget.config index 7c07e225..6c273ab3 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/nuget.config +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/nuget.config @@ -1,6 +1,11 @@ + + + - \ No newline at end of file + diff --git a/MinoriEditorShell.sln b/MinoriEditorShell.sln index 0b1e110f..e703fa40 100644 --- a/MinoriEditorShell.sln +++ b/MinoriEditorShell.sln @@ -67,6 +67,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MinoriEditorShell.RibbonTes EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MinoriEditorShell.Platforms.Avalonia", "Modules\MinoriEditorShell.Platforms.Avalonia\MinoriEditorShell.Platforms.Avalonia.csproj", "{C8944E3A-2D90-41D7-B16A-360CE60235A4}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleDemo.Avalonia", "Demos\SimpleDemo\SimpleDemo.Avalonia\SimpleDemo.Avalonia.csproj", "{AA7C540B-522B-474F-9866-860B6E251739}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -145,6 +147,10 @@ Global {C8944E3A-2D90-41D7-B16A-360CE60235A4}.Debug|Any CPU.Build.0 = Debug|Any CPU {C8944E3A-2D90-41D7-B16A-360CE60235A4}.Release|Any CPU.ActiveCfg = Release|Any CPU {C8944E3A-2D90-41D7-B16A-360CE60235A4}.Release|Any CPU.Build.0 = Release|Any CPU + {AA7C540B-522B-474F-9866-860B6E251739}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AA7C540B-522B-474F-9866-860B6E251739}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AA7C540B-522B-474F-9866-860B6E251739}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AA7C540B-522B-474F-9866-860B6E251739}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -171,6 +177,7 @@ Global {DE4AECF4-649F-45C0-B260-419F68EB5707} = {748FD7C1-877B-451D-809A-68E032C39B34} {7A48AD22-69BF-49A7-8988-E163F779997E} = {D96C6D53-E9ED-4E32-9856-B858A63C9D9E} {C8944E3A-2D90-41D7-B16A-360CE60235A4} = {417CE623-3714-4105-8A2F-4C1A7DB61AA7} + {AA7C540B-522B-474F-9866-860B6E251739} = {F8E17C87-3554-4E81-9FB6-0BC0939EDA6B} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C4DE08D7-0160-4FCF-876A-904438A56A8A} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/IMesBindingCreator.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/IMesBindingCreator.cs index bcb461e0..a658739c 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/IMesBindingCreator.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/IMesBindingCreator.cs @@ -7,9 +7,9 @@ namespace MinoriEditorShell.Platforms.Avalonia.Binding { public interface IMesBindingCreator { - void CreateBindings( - object sender, - DependencyPropertyChangedEventArgs args, - Func> parseBindingDescriptions); + //void CreateBindings( + // object sender, + // DependencyPropertyChangedEventArgs args, + // Func> parseBindingDescriptions); } } diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/Import.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/Import.cs index 914d7108..9f593315 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/Import.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/Import.cs @@ -4,6 +4,7 @@ using MvvmCross.IoC; using MvvmCross.Binding.Combiners; using MvvmCross; +using System; namespace MinoriEditorShell.Platforms.Avalonia.Binding { @@ -11,7 +12,8 @@ public class Import { static Import() { - MesDesignTimeChecker.Check(); + //MesDesignTimeChecker.Check(); + throw new NotImplementedException(); } private object _from; diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBindingCreator.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBindingCreator.cs index cf200a92..cfa79c48 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBindingCreator.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBindingCreator.cs @@ -10,27 +10,27 @@ namespace MinoriEditorShell.Platforms.Avalonia.Binding { public abstract class MesBindingCreator : IMesBindingCreator { - public void CreateBindings(object sender, DependencyPropertyChangedEventArgs args, - Func> parseBindingDescriptions) - { - var attachedObject = sender as StyledElement; - if (attachedObject == null) - { - IMvxLog _log = Mvx.IoCProvider.Resolve().GetLogFor(); - _log.Warn("Null attached StyledElement seen in Bi.nd binding"); - return; - } + //public void CreateBindings(object sender, DependencyPropertyChangedEventArgs args, + // Func> parseBindingDescriptions) + //{ + // var attachedObject = sender as StyledElement; + // if (attachedObject == null) + // { + // IMvxLog _log = Mvx.IoCProvider.Resolve().GetLogFor(); + // _log.Warn("Null attached StyledElement seen in Bi.nd binding"); + // return; + // } - var text = args.NewValue as string; - if (string.IsNullOrEmpty(text)) - return; + // var text = args.NewValue as string; + // if (string.IsNullOrEmpty(text)) + // return; - var bindingDescriptions = parseBindingDescriptions(text); - if (bindingDescriptions == null) - return; + // var bindingDescriptions = parseBindingDescriptions(text); + // if (bindingDescriptions == null) + // return; - ApplyBindings(attachedObject, bindingDescriptions); - } + // ApplyBindings(attachedObject, bindingDescriptions); + //} protected abstract void ApplyBindings(StyledElement attachedObject, IEnumerable bindingDescriptions); diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesDesignTimeChecker.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesDesignTimeChecker.cs index 5aeaeec9..8ed33fc1 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesDesignTimeChecker.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesDesignTimeChecker.cs @@ -1,3 +1,4 @@ +using MvvmCross; using MvvmCross.Binding.Parse.Binding; namespace MinoriEditorShell.Platforms.Avalonia.Binding diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs index 0fa41ad3..4e803e3f 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs @@ -1,12 +1,9 @@ -using Avalonia; using Avalonia.Controls; using MinoriEditorShell.Messages; using MinoriEditorShell.Modules.Services; using MinoriEditorShell.Platforms.Avalonia.Presenters; using MinoriEditorShell.Platforms.Avalonia.Views; using MinoriEditorShell.Platforms.Avalonia.Services; -using MinoriEditorShell.Platforms.Avalonia.ViewModels; -using MinoriEditorShell.Platforms.Avalonia.Views; using MinoriEditorShell.Services; using MinoriEditorShell.ViewModels; using MvvmCross; @@ -56,7 +53,7 @@ protected virtual IEnumerable ValueConverterAssemblies { get { - var toReturn = new List(); + List toReturn = new List(); toReturn.AddRange(GetViewModelAssemblies()); toReturn.AddRange(GetViewAssemblies()); return toReturn; @@ -180,11 +177,11 @@ protected virtual IMesAvnViewPresenter CreateViewPresenter(ContentControl root) return new MesAvnViewPresenter(root); } - protected IMvxViewsContainer CreateViewsContainer(IMvxIoCProvider iocProvider) + protected virtual IMvxViewsContainer CreateViewsContainer(IMvxIoCProvider iocProvider) { - ValidateArguments(iocProvider); + if (iocProvider is null) throw new ArgumentNullException(nameof(iocProvider)); - var toReturn = CreateAvnViewsContainer(); + IMesAvnViewsContainer toReturn = CreateAvnViewsContainer(); iocProvider.RegisterSingleton(toReturn); return toReturn; } @@ -239,7 +236,7 @@ protected override IDictionary InitializeLookupDictionary() } protected virtual void RegisterBindingBuilderCallbacks(IMvxIoCProvider iocProvider) { - ValidateArguments(iocProvider); + if (iocProvider is null) throw new ArgumentNullException(nameof(iocProvider)); iocProvider.CallbackWhenRegistered(FillValueConverters); iocProvider.CallbackWhenRegistered(FillTargetFactories); @@ -248,7 +245,7 @@ protected virtual void RegisterBindingBuilderCallbacks(IMvxIoCProvider iocProvid protected virtual void RegisterPresenter(IMvxIoCProvider iocProvider) { - ValidateArguments(iocProvider); + if (iocProvider is null) throw new ArgumentNullException(nameof(iocProvider)); var presenter = Presenter; iocProvider.RegisterSingleton(presenter); @@ -267,6 +264,9 @@ public override IEnumerable GetViewModelAssemblies() return new[] { typeof(TApplication).GetTypeInfo().Assembly }; } + + protected override IMvxApplication CreateApp() => Mvx.IoCProvider.IoCConstruct(); + protected override IMvxViewsContainer CreateViewsContainer() => base.CreateViewsContainer(Mvx.IoCProvider); } } \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj index 8f6430ad..97b349a3 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj @@ -25,6 +25,20 @@ This uses AvalonDock and has an MVVM architecture based on MvvmCross. + + + + + + + + + + + + + + @@ -44,4 +58,9 @@ This uses AvalonDock and has an MVVM architecture based on MvvmCross. + + + + + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs index 38f00224..f7f1d9c4 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs @@ -25,7 +25,7 @@ public class MesAvnViewPresenter : MvxAttributeViewPresenter, IMesAvnViewPresent /// Main constructor for the presenter, this gets the main window. /// /// - public MesAvnViewPresenter(ContentControl mainWindow) : base(mainWindow) + public MesAvnViewPresenter(ContentControl mainWindow) : base() { IMvxLogProvider provider = Mvx.IoCProvider.Resolve(); _log = provider.GetLogFor(); @@ -43,33 +43,32 @@ public override MvxBasePresentationAttribute CreatePresentationAttribute(Type vi { if (viewType.IsSubclassOf(typeof(Window))) { - _log.Trace($"PresentationAttribute not found for {viewType.Name}. " + - $"Assuming window presentation"); - return new MvxWindowPresentationAttribute(); + _log.Trace($"PresentationAttribute not found for {viewType.Name}. Assuming window presentation"); + return new MesWindowPresentationAttribute(); } - _log.Trace($"PresentationAttribute not found for {viewType.Name}. " + - $"Assuming content presentation"); - return new MvxContentPresentationAttribute(); + _log.Trace($"PresentationAttribute not found for {viewType.Name}. Assuming content presentation"); + return new MesContentPresentationAttribute(); } public override void RegisterAttributeTypes() { - AttributeTypesToActionsDictionary.Register( - (viewType, attribute, request) => - { - var view = AvnViewLoader.CreateView(request); - return ShowWindow(view, (MesWindowPresentationAttribute)attribute, request); - }, - (viewModel, attribute) => CloseWindow(viewModel)); + throw new NotImplementedException(); + //AttributeTypesToActionsDictionary.Register( + // (viewType, attribute, request) => + // { + // var view = AvnViewLoader.CreateView(request); + // return ShowWindow(view, (MesWindowPresentationAttribute)attribute, request); + // }, + // (viewModel, attribute) => CloseWindow(viewModel)); - AttributeTypesToActionsDictionary.Register( - (viewType, attribute, request) => - { - var view = AvnViewLoader.CreateView(request); - return ShowContentView(view, (MesContentPresentationAttribute)attribute, request); - }, - (viewModel, attribute) => CloseContentView(viewModel)); + //AttributeTypesToActionsDictionary.Register( + // (viewType, attribute, request) => + // { + // var view = AvnViewLoader.CreateView(request); + // return ShowContentView(view, (MesContentPresentationAttribute)attribute, request); + // }, + // (viewModel, attribute) => CloseContentView(viewModel)); } /// @@ -116,7 +115,8 @@ protected async Task ShowContentView( default: _log.Trace($"Passing to parent {view.ViewModel.ToString()}"); - return await base.ShowContentView(element, attribute, request); + //return await base.ShowContentView(element, attribute, request); + throw new NotImplementedException(); } } catch (Exception exception) diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnViewsContainer.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnViewsContainer.cs index ff977f2a..87802bec 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnViewsContainer.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnViewsContainer.cs @@ -1,10 +1,15 @@ -using System; +using Avalonia; +using MvvmCross.ViewModels; +using MvvmCross.Views; +using System; using System.Collections.Generic; using System.Text; namespace MinoriEditorShell.Platforms.Avalonia.Views { - class IMesAvnViewsContainer + public interface IMesAvnViewsContainer : IMvxViewsContainer, IMesAvnViewLoader { + StyledElement CreateView(MvxViewModelRequest request); + StyledElement CreateView(Type viewType); } } diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesApplication.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesApplication.cs index 51d0c29b..b9ef6206 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesApplication.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesApplication.cs @@ -42,7 +42,7 @@ protected virtual void RegisterSetup() } } - public class MvxApplication : MvxApplication + public class MesApplication : MesApplication where TMvxWpfSetup : MesAvnSetup, new() where TApplication : class, IMvxApplication, new() { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnView.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnView.cs index 4db70719..82abd55a 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnView.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnView.cs @@ -42,8 +42,9 @@ public IMvxBindingContext BindingContext public MesAvnView() { - Unloaded += MvxWpfView_Unloaded; - Loaded += MvxWpfView_Loaded; +#warning fix MesAvnView ctor + //Unloaded += MvxWpfView_Unloaded; + //Loaded += MvxWpfView_Loaded; } private void MvxWpfView_Unloaded(object sender, RoutedEventArgs e) @@ -74,8 +75,9 @@ protected virtual void Dispose(bool disposing) { if (disposing) { - Unloaded -= MvxWpfView_Unloaded; - Loaded -= MvxWpfView_Loaded; +#warning fix MesAvnView Dispose + //Unloaded -= MvxWpfView_Unloaded; + //Loaded -= MvxWpfView_Loaded; } } } diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnViewsContainer.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnViewsContainer.cs index 4cd06b90..9a991bdf 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnViewsContainer.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnViewsContainer.cs @@ -1,10 +1,55 @@ -using System; +using Avalonia; +using MvvmCross; +using MvvmCross.Exceptions; +using MvvmCross.ViewModels; +using MvvmCross.Views; +using System; using System.Collections.Generic; using System.Text; namespace MinoriEditorShell.Platforms.Avalonia.Views { - class MesAvnViewsContainer + public class MesAvnViewsContainer + : MvxViewsContainer + , IMesAvnViewsContainer { + public virtual StyledElement CreateView(MvxViewModelRequest request) + { + var viewType = GetViewType(request.ViewModelType); + if (viewType == null) + throw new MvxException("View Type not found for " + request.ViewModelType); + + var wpfView = CreateView(viewType) as IMesAvnView; + + if (request is MvxViewModelInstanceRequest instanceRequest) + { + wpfView.ViewModel = instanceRequest.ViewModelInstance; + } + else + { + var viewModelLoader = Mvx.IoCProvider.Resolve(); + wpfView.ViewModel = viewModelLoader.LoadViewModel(request, null); + } + + return wpfView as StyledElement; + } + + public StyledElement CreateView(Type viewType) + { + var viewObject = Activator.CreateInstance(viewType); + if (viewObject == null) + throw new MvxException("View not loaded for " + viewType); + + var wpfView = viewObject as IMesAvnView; + if (wpfView == null) + throw new MvxException("Loaded View does not have IMvxWpfView interface " + viewType); + + var viewControl = viewObject as StyledElement; + if (viewControl == null) + throw new MvxException("Loaded View is not a FrameworkElement " + viewType); + + return viewControl; + } } } + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesWindow.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesWindow.cs index aa141a27..a951cb9c 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesWindow.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesWindow.cs @@ -16,22 +16,20 @@ namespace MinoriEditorShell.Platforms.Avalonia.Views { public class MesWindow : Window, IMesWindow, IMesAvnView, IDisposable { - private IMvxViewModel _viewModel; private IMvxBindingContext _bindingContext; private bool _unloaded = false; - - public IMvxViewModel ViewModel + private IMvxViewModel _viewModel; + public MesWindow() { - get => _viewModel; - set - { - _viewModel = value; - DataContext = value; - BindingContext.DataContext = value; - } + Closed += MvxWindow_Closed; + Opened += MvxWindow_Opened; + Initialized += MvxWindow_Initialized; } - public string Identifier { get; set; } + ~MesWindow() + { + Dispose(false); + } public IMvxBindingContext BindingContext { @@ -50,32 +48,51 @@ public IMvxBindingContext BindingContext public String DisplayName { get; set; } - public MesWindow() + public string Identifier { get; set; } + + public IMvxViewModel ViewModel { - Closed += MvxWindow_Closed; - Unloaded += MvxWindow_Unloaded; - Loaded += MvxWindow_Loaded; - Initialized += MvxWindow_Initialized; + get => _viewModel; + set + { + _viewModel = value; + DataContext = value; + BindingContext.DataContext = value; + } + } + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); } - private void MvxWindow_Initialized(object sender, EventArgs e) + protected virtual void Dispose(bool disposing) { - if (this == Application.Current.MainWindow) + if (disposing) { - (Application.Current as MvxApplication).ApplicationInitialized(); + Opened -= MvxWindow_Opened; + Closed -= MvxWindow_Closed; } } private void MvxWindow_Closed(object sender, EventArgs e) => Unload(); - private void MvxWindow_Unloaded(object sender, RoutedEventArgs e) => Unload(); + private void MvxWindow_Initialized(object sender, EventArgs e) + { +#warning Fix MesWindow AVN Init + //if (this == Application.Current.MainWindow) + //{ + // (Application.Current as MvxApplication).ApplicationInitialized(); + //} + } - private void MvxWindow_Loaded(object sender, RoutedEventArgs e) + + private void MvxWindow_Opened(Object sender, EventArgs e) { ViewModel?.ViewAppearing(); ViewModel?.ViewAppeared(); } - + private void MvxWindow_Unloaded(object sender, RoutedEventArgs e) => Unload(); private void Unload() { if (!_unloaded) @@ -86,27 +103,6 @@ private void Unload() _unloaded = true; } } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - ~MesWindow() - { - Dispose(false); - } - - protected virtual void Dispose(bool disposing) - { - if (disposing) - { - Unloaded -= MvxWindow_Unloaded; - Loaded -= MvxWindow_Loaded; - Closed -= MvxWindow_Closed; - } - } } public class MvxWindow : MesWindow, IMesAvnView @@ -120,7 +116,8 @@ public class MvxWindow : MesWindow, IMesAvnView public MvxFluentBindingDescriptionSet, TViewModel> CreateBindingSet() { - return this.CreateBindingSet, TViewModel>(); + //return this.CreateBindingSet, TViewModel>(); + throw new NotImplementedException(); } } // public class MesWindow : MetroWindow, IMesWindow, IMvxWindow, IMvxWpfView From de2d88f3f19e53bf0fecb0ecd96a07e20a73cba1 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Mon, 22 Feb 2021 21:00:46 -0500 Subject: [PATCH 16/68] add app setup --- Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml | 8 +++++--- Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml.cs | 6 +++++- .../SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj | 8 ++++++++ Demos/SimpleDemo/SimpleDemo.Avalonia/nuget.config | 11 ----------- 4 files changed, 18 insertions(+), 15 deletions(-) delete mode 100644 Demos/SimpleDemo/SimpleDemo.Avalonia/nuget.config diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml index bbaecec2..36199cd5 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml @@ -1,6 +1,8 @@ - + diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml.cs b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml.cs index 75a7355e..81c73753 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml.cs +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml.cs @@ -1,15 +1,19 @@ using Avalonia; using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Markup.Xaml; +using MinoriEditorShell.Platforms.Avalonia; +using MinoriEditorShell.Platforms.Avalonia.Views; +using MvvmCross.Core; namespace SimpleDemo.Avalonia { - public class App : Application + public class App : MesApplication { public override void Initialize() { AvaloniaXamlLoader.Load(this); } + protected override void RegisterSetup() => this.RegisterSetupType>(); public override void OnFrameworkInitializationCompleted() { diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj b/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj index 7dbbfdf2..41396960 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj @@ -2,10 +2,18 @@ WinExe net5.0 + ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset + + + + + + + diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/nuget.config b/Demos/SimpleDemo/SimpleDemo.Avalonia/nuget.config deleted file mode 100644 index 6c273ab3..00000000 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/nuget.config +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - From 278416f982a22f00c11ecbbf81f0bf32c9a0d636 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Mon, 22 Feb 2021 21:01:12 -0500 Subject: [PATCH 17/68] nuget update --- .../MinoriEditorShell.Platforms.Wpf.csproj | 4 ++-- .../MinoriEditorShell.Platforms.WpfTests.csproj | 2 +- .../MinoriEditorShell.RibbonTests.csproj | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj b/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj index c9ce174e..56f01c58 100644 --- a/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj +++ b/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj @@ -44,8 +44,8 @@ This uses AvalonDock and has an MVVM architecture based on MvvmCross. - - + + diff --git a/Tests/MinoriEditorShell.Platforms.WpfTests/MinoriEditorShell.Platforms.WpfTests.csproj b/Tests/MinoriEditorShell.Platforms.WpfTests/MinoriEditorShell.Platforms.WpfTests.csproj index 50a1dc29..3844529e 100644 --- a/Tests/MinoriEditorShell.Platforms.WpfTests/MinoriEditorShell.Platforms.WpfTests.csproj +++ b/Tests/MinoriEditorShell.Platforms.WpfTests/MinoriEditorShell.Platforms.WpfTests.csproj @@ -15,7 +15,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Tests/MinoriEditorShell.RibbonTests/MinoriEditorShell.RibbonTests.csproj b/Tests/MinoriEditorShell.RibbonTests/MinoriEditorShell.RibbonTests.csproj index 1162e84f..d1fd2178 100644 --- a/Tests/MinoriEditorShell.RibbonTests/MinoriEditorShell.RibbonTests.csproj +++ b/Tests/MinoriEditorShell.RibbonTests/MinoriEditorShell.RibbonTests.csproj @@ -15,7 +15,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive From 87799413a6995c4e2ef795b508c2658ca2b92805 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Mon, 22 Feb 2021 21:47:08 -0500 Subject: [PATCH 18/68] sample setup of mainview --- .../SimpleDemo/SimpleDemo.Avalonia/App.axaml | 6 ++--- .../SimpleDemo.Avalonia/Views/MainView.axaml | 26 +++++++++++++++++++ .../Views/MainView.axaml.cs | 20 ++++++++++++++ .../SimpleDemo.WPF/SimpleDemo.WPF.csproj | 3 --- .../SimpleDemo.WpfCore.csproj | 4 +-- 5 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 Demos/SimpleDemo/SimpleDemo.Avalonia/Views/MainView.axaml create mode 100644 Demos/SimpleDemo/SimpleDemo.Avalonia/Views/MainView.axaml.cs diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml index 36199cd5..2a721687 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml @@ -1,9 +1,9 @@ - - + diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/Views/MainView.axaml b/Demos/SimpleDemo/SimpleDemo.Avalonia/Views/MainView.axaml new file mode 100644 index 00000000..58d0ecbf --- /dev/null +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/Views/MainView.axaml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/Views/MainView.axaml.cs b/Demos/SimpleDemo/SimpleDemo.Avalonia/Views/MainView.axaml.cs new file mode 100644 index 00000000..0103cf7d --- /dev/null +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/Views/MainView.axaml.cs @@ -0,0 +1,20 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; +using MinoriEditorShell.Platforms.Avalonia.Views; + +namespace SimpleDemo.Avalonia.Views +{ + public class MainView : MesAvnView + { + public MainView() + { + InitializeComponent(); + } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } + } +} diff --git a/Demos/SimpleDemo/SimpleDemo.WPF/SimpleDemo.WPF.csproj b/Demos/SimpleDemo/SimpleDemo.WPF/SimpleDemo.WPF.csproj index c4aaebf4..aa8234d5 100644 --- a/Demos/SimpleDemo/SimpleDemo.WPF/SimpleDemo.WPF.csproj +++ b/Demos/SimpleDemo/SimpleDemo.WPF/SimpleDemo.WPF.csproj @@ -103,9 +103,6 @@ ResXFileCodeGenerator Resources.Designer.cs - - minorieditorshellcsharp.ruleset - torisankitsune_minorieditorshell2csharp.ruleset diff --git a/Demos/SimpleDemo/SimpleDemo.WpfCore/SimpleDemo.WpfCore.csproj b/Demos/SimpleDemo/SimpleDemo.WpfCore/SimpleDemo.WpfCore.csproj index 826a9e03..ba1d5c11 100644 --- a/Demos/SimpleDemo/SimpleDemo.WpfCore/SimpleDemo.WpfCore.csproj +++ b/Demos/SimpleDemo/SimpleDemo.WpfCore/SimpleDemo.WpfCore.csproj @@ -1,8 +1,8 @@ - + Exe - netcoreapp3.1 + net5.0-windows false true ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset From 28252b6297a6448b1ff7ed944f2b48e391d8647f Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Fri, 12 Mar 2021 22:05:54 -0500 Subject: [PATCH 19/68] sonar lint update --- .sonarlint/MinoriEditorShell.slconfig | 2 +- .sonarlint/torisankitsune_minorieditorshell2csharp.ruleset | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.sonarlint/MinoriEditorShell.slconfig b/.sonarlint/MinoriEditorShell.slconfig index 94f7c454..5d7651c6 100644 --- a/.sonarlint/MinoriEditorShell.slconfig +++ b/.sonarlint/MinoriEditorShell.slconfig @@ -9,7 +9,7 @@ "Profiles": { "CSharp": { "ProfileKey": "AXfBiG4ncmi_3V30EHaZ", - "ProfileTimestamp": "2021-02-15T09:35:56Z" + "ProfileTimestamp": "2021-03-03T08:15:39Z" } } } \ No newline at end of file diff --git a/.sonarlint/torisankitsune_minorieditorshell2csharp.ruleset b/.sonarlint/torisankitsune_minorieditorshell2csharp.ruleset index 607decdc..c09d91fd 100644 --- a/.sonarlint/torisankitsune_minorieditorshell2csharp.ruleset +++ b/.sonarlint/torisankitsune_minorieditorshell2csharp.ruleset @@ -359,6 +359,7 @@ + From ee90badcb92a6de6616883b749c19b008fd90cc1 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Fri, 12 Mar 2021 22:31:20 -0500 Subject: [PATCH 20/68] more attempt at displaying content --- .../SimpleDemo.Avalonia/App.axaml.cs | 5 +- .../Core/MesAvnSetup.cs | 8 +- .../Presenters/MesAvnViewPresenter.cs | 218 ++++++++++++++++-- .../Views/IMesAvnView.cs | 7 +- .../Views/IMesAvnViewLoader.cs | 10 +- .../Views/IMesAvnViewsContainer.cs | 4 +- .../Views/MesAvnViewsContainer.cs | 19 +- .../MinoriEditorShell/Services/IMesWindow.cs | 1 + 8 files changed, 222 insertions(+), 50 deletions(-) diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml.cs b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml.cs index 81c73753..0395f2e4 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml.cs +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml.cs @@ -9,10 +9,7 @@ namespace SimpleDemo.Avalonia { public class App : MesApplication { - public override void Initialize() - { - AvaloniaXamlLoader.Load(this); - } + public override void Initialize() => AvaloniaXamlLoader.Load(this); protected override void RegisterSetup() => this.RegisterSetupType>(); public override void OnFrameworkInitializationCompleted() diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs index 4e803e3f..0a7a1af7 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs @@ -259,13 +259,7 @@ protected virtual void RegisterPresenter(IMvxIoCProvider iocProvider) /// public class MesAvnSetup : MesAvnSetup where TApplication : class, IMvxApplication, new() { - public override IEnumerable GetViewModelAssemblies() - { - return new[] { typeof(TApplication).GetTypeInfo().Assembly }; - } - - - + public override IEnumerable GetViewModelAssemblies() => new[] { typeof(TApplication).GetTypeInfo().Assembly }; protected override IMvxApplication CreateApp() => Mvx.IoCProvider.IoCConstruct(); protected override IMvxViewsContainer CreateViewsContainer() => base.CreateViewsContainer(Mvx.IoCProvider); } diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs index f7f1d9c4..adc3aa8e 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs @@ -1,5 +1,6 @@ using Avalonia.Controls; using MinoriEditorShell.Platforms.Avalonia.Presenters.Attributes; +using MinoriEditorShell.Platforms.Avalonia.Views; using MinoriEditorShell.Services; using MvvmCross; using MvvmCross.Exceptions; @@ -9,6 +10,8 @@ using MvvmCross.ViewModels; using MvvmCross.Views; using System; +using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using System.Windows; @@ -19,26 +22,73 @@ namespace MinoriEditorShell.Platforms.Avalonia.Presenters /// public class MesAvnViewPresenter : MvxAttributeViewPresenter, IMesAvnViewPresenter { + private Dictionary> _frameworkElementsDictionary; private IMvxLog _log; + private IMesAvnViewLoader _wpfViewLoader; + /// /// Main constructor for the presenter, this gets the main window. /// /// - public MesAvnViewPresenter(ContentControl mainWindow) : base() + public MesAvnViewPresenter(ContentControl contentControl) : base() { + if (contentControl is Window window) + window.Closed += Window_Closed; + + FrameworkElementsDictionary.Add(contentControl, new Stack()); + IMvxLogProvider provider = Mvx.IoCProvider.Resolve(); _log = provider.GetLogFor(); _log.Trace("Setup: Creating Presenter"); // Setup main window as singleton - if (mainWindow is IMesWindow mesWindow) + if (contentControl is IMesWindow mesWindow) { _log.Trace("Setting IMesWindow to main window"); Mvx.IoCProvider.RegisterSingleton(mesWindow); } } + + protected MesAvnViewPresenter() + { + } + + protected Dictionary> FrameworkElementsDictionary + { + get + { + if (_frameworkElementsDictionary == null) + _frameworkElementsDictionary = new Dictionary>(); + return _frameworkElementsDictionary; + } + } + + protected IMesAvnViewLoader AvnViewLoader + { + get + { + if (_wpfViewLoader == null) + _wpfViewLoader = Mvx.IoCProvider.Resolve(); + return _wpfViewLoader; + } + } + + public override async Task Close(IMvxViewModel toClose) + { + // toClose is window + if (FrameworkElementsDictionary.Any(i => (i.Key as IMesAvnView)?.ViewModel == toClose) && await CloseWindow(toClose)) + return true; + + // toClose is content + if (FrameworkElementsDictionary.Any(i => i.Value.Any() && (i.Value.Peek() as IMesAvnView)?.ViewModel == toClose) && await CloseContentView(toClose)) + return true; + + _log.Warn($"Could not close ViewModel type {toClose.GetType().Name}"); + return false; + } + public override MvxBasePresentationAttribute CreatePresentationAttribute(Type viewModelType, Type viewType) { if (viewType.IsSubclassOf(typeof(Window))) @@ -51,26 +101,96 @@ public override MvxBasePresentationAttribute CreatePresentationAttribute(Type vi return new MesContentPresentationAttribute(); } + public override MvxBasePresentationAttribute GetOverridePresentationAttribute(MvxViewModelRequest request, Type viewType) + { + if (viewType?.GetInterface(nameof(IMvxOverridePresentationAttribute)) != null) + { + var viewInstance = AvnViewLoader.CreateView(viewType) as IDisposable; + using (viewInstance) + { + MvxBasePresentationAttribute presentationAttribute = null; + if (viewInstance is IMvxOverridePresentationAttribute overrideInstance) + presentationAttribute = overrideInstance.PresentationAttribute(request); + + if (presentationAttribute == null) + { + _log.Warn("Override PresentationAttribute null. Falling back to existing attribute."); + } + else + { + if (presentationAttribute.ViewType == null) + presentationAttribute.ViewType = viewType; + + if (presentationAttribute.ViewModelType == null) + presentationAttribute.ViewModelType = request.ViewModelType; + + return presentationAttribute; + } + } + } + + return null; + } + public override void RegisterAttributeTypes() { - throw new NotImplementedException(); - //AttributeTypesToActionsDictionary.Register( - // (viewType, attribute, request) => - // { - // var view = AvnViewLoader.CreateView(request); - // return ShowWindow(view, (MesWindowPresentationAttribute)attribute, request); - // }, - // (viewModel, attribute) => CloseWindow(viewModel)); - - //AttributeTypesToActionsDictionary.Register( - // (viewType, attribute, request) => - // { - // var view = AvnViewLoader.CreateView(request); - // return ShowContentView(view, (MesContentPresentationAttribute)attribute, request); - // }, - // (viewModel, attribute) => CloseContentView(viewModel)); + AttributeTypesToActionsDictionary.Register( + (viewType, attribute, request) => + { + var view = AvnViewLoader.CreateView(request); + return ShowWindow(view, (MesWindowPresentationAttribute)attribute, request); + }, + (viewModel, attribute) => CloseWindow(viewModel)); + + AttributeTypesToActionsDictionary.Register( + (viewType, attribute, request) => + { + var view = AvnViewLoader.CreateView(request); + return ShowContentView(view, (MesContentPresentationAttribute)attribute, request); + }, + (viewModel, attribute) => CloseContentView(viewModel)); } - + + protected virtual Task CloseContentView(IMvxViewModel toClose) + { + var item = FrameworkElementsDictionary.FirstOrDefault(i => i.Value.Any() && (i.Value.Peek() as IMesAvnView)?.ViewModel == toClose); + var contentControl = item.Key; + var elements = item.Value; + + if (elements.Any()) + elements.Pop(); // Pop closing view + + if (elements.Any()) + { + contentControl.Content = elements.Peek(); + return Task.FromResult(true); + } + + // Close window if no contents + if (contentControl is Window window) + { + FrameworkElementsDictionary.Remove(window); + window.Close(); + return Task.FromResult(true); + } + + return Task.FromResult(false); + } + + protected virtual Task CloseWindow(IMvxViewModel toClose) + { + var item = FrameworkElementsDictionary.FirstOrDefault(i => (i.Key as IMesAvnView)?.ViewModel == toClose); + var contentControl = item.Key; + if (contentControl is Window window) + { + FrameworkElementsDictionary.Remove(window); + window.Close(); + return Task.FromResult(true); + } + + return Task.FromResult(false); + } + /// /// This gets called when navigation to view model happens. /// Depending on what the type is, will define where the class goes. @@ -114,9 +234,16 @@ protected async Task ShowContentView( return true; default: - _log.Trace($"Passing to parent {view.ViewModel.ToString()}"); - //return await base.ShowContentView(element, attribute, request); - throw new NotImplementedException(); + _log.Trace($"Passing to parent {view.ViewModel}"); + var contentControl = FrameworkElementsDictionary.Keys.FirstOrDefault(w => (w as MesWindow)?.Identifier == attribute.WindowIdentifier) + ?? FrameworkElementsDictionary.Keys.Last(); + + if (!attribute.StackNavigation && FrameworkElementsDictionary[contentControl].Any()) + FrameworkElementsDictionary[contentControl].Pop(); // Close previous view + + FrameworkElementsDictionary[contentControl].Push((Control)element); + contentControl.Content = element; + return true; } } catch (Exception exception) @@ -130,5 +257,52 @@ protected async Task ShowContentView( throw; } } + + protected virtual Task ShowWindow(IMesAvnView element, MesWindowPresentationAttribute attribute, MvxViewModelRequest request) + { + Window window; + if (element is IMesWindow mvxWindow) + { + window = (Window)element; + mvxWindow.Identifier = attribute.Identifier ?? element.GetType().Name; + } + else if (element is Window normalWindow) + { + // Accept normal Window class + window = normalWindow; + } + else + { + // Wrap in window + window = new MesWindow + { + Identifier = attribute.Identifier ?? element.GetType().Name + }; + } + window.Closed += Window_Closed; + FrameworkElementsDictionary.Add(window, new Stack()); + + if (!(element is Window)) + { + FrameworkElementsDictionary[window].Push((Control)element); + window.Content = element; + } + + if (attribute.Modal) + throw new NotImplementedException(); + //window.ShowDialog(); + else + window.Show(); + return Task.FromResult(true); + } + + private void Window_Closed(object sender, EventArgs e) + { + var window = sender as Window; + window.Closed -= Window_Closed; + + if (FrameworkElementsDictionary.ContainsKey(window)) + FrameworkElementsDictionary.Remove(window); + } } } \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnView.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnView.cs index fe675a8f..998cda85 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnView.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnView.cs @@ -1,4 +1,6 @@ -using MvvmCross.Binding.BindingContext; +using Avalonia; +using Avalonia.Controls; +using MvvmCross.Binding.BindingContext; using MvvmCross.ViewModels; using MvvmCross.Views; using System; @@ -7,8 +9,7 @@ namespace MinoriEditorShell.Platforms.Avalonia.Views { - public interface IMesAvnView - : IMvxView, IMvxBindingContextOwner + public interface IMesAvnView : IMvxView, IMvxBindingContextOwner, IControl, IStyledElement { } diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnViewLoader.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnViewLoader.cs index 0b8d3d70..b2c4cf9f 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnViewLoader.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnViewLoader.cs @@ -1,6 +1,14 @@ -namespace MinoriEditorShell.Platforms.Avalonia.Views +using Avalonia; +using Avalonia.Controls; +using MvvmCross.ViewModels; +using MvvmCross.Views; +using System; + +namespace MinoriEditorShell.Platforms.Avalonia.Views { public interface IMesAvnViewLoader { + IMesAvnView CreateView(MvxViewModelRequest request); + IMesAvnView CreateView(Type viewType); } } \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnViewsContainer.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnViewsContainer.cs index 87802bec..5d6c027a 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnViewsContainer.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/IMesAvnViewsContainer.cs @@ -9,7 +9,7 @@ namespace MinoriEditorShell.Platforms.Avalonia.Views { public interface IMesAvnViewsContainer : IMvxViewsContainer, IMesAvnViewLoader { - StyledElement CreateView(MvxViewModelRequest request); - StyledElement CreateView(Type viewType); + IMesAvnView CreateView(MvxViewModelRequest request); + IMesAvnView CreateView(Type viewType); } } diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnViewsContainer.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnViewsContainer.cs index 9a991bdf..8117996f 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnViewsContainer.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnViewsContainer.cs @@ -13,13 +13,13 @@ public class MesAvnViewsContainer : MvxViewsContainer , IMesAvnViewsContainer { - public virtual StyledElement CreateView(MvxViewModelRequest request) + public virtual IMesAvnView CreateView(MvxViewModelRequest request) { var viewType = GetViewType(request.ViewModelType); if (viewType == null) throw new MvxException("View Type not found for " + request.ViewModelType); - var wpfView = CreateView(viewType) as IMesAvnView; + IMesAvnView wpfView = CreateView(viewType) as IMesAvnView; if (request is MvxViewModelInstanceRequest instanceRequest) { @@ -31,24 +31,21 @@ public virtual StyledElement CreateView(MvxViewModelRequest request) wpfView.ViewModel = viewModelLoader.LoadViewModel(request, null); } - return wpfView as StyledElement; + return wpfView; } - public StyledElement CreateView(Type viewType) + public IMesAvnView CreateView(Type viewType) { var viewObject = Activator.CreateInstance(viewType); if (viewObject == null) throw new MvxException("View not loaded for " + viewType); - var wpfView = viewObject as IMesAvnView; - if (wpfView == null) + if (!(viewObject is IMesAvnView wpfView)) throw new MvxException("Loaded View does not have IMvxWpfView interface " + viewType); - var viewControl = viewObject as StyledElement; - if (viewControl == null) - throw new MvxException("Loaded View is not a FrameworkElement " + viewType); - - return viewControl; + return !(viewObject is IStyledElement viewControl) + ? throw new MvxException("Loaded View is not a FrameworkElement " + viewType) + : wpfView; } } } diff --git a/Modules/MinoriEditorShell/Services/IMesWindow.cs b/Modules/MinoriEditorShell/Services/IMesWindow.cs index 0d69848e..6a0b09ec 100644 --- a/Modules/MinoriEditorShell/Services/IMesWindow.cs +++ b/Modules/MinoriEditorShell/Services/IMesWindow.cs @@ -6,5 +6,6 @@ public interface IMesWindow { String DisplayName { get; set; } String Title { get; set; } + String Identifier { get; set; } } } \ No newline at end of file From fb3d44ebea8efcfd2c1dffc6f31b8328d1abbb00 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sat, 13 Mar 2021 19:36:05 -0500 Subject: [PATCH 21/68] nuget updates --- Demos/MinoriDemo/MinoriDemo.Core/MinoriDemo.Core.csproj | 2 +- .../MinoriEditorShell.Platforms.Avalonia.csproj | 2 +- .../Presenters/MesAvnViewPresenter.cs | 2 +- .../MinoriEditorShell.Platforms.Wpf.csproj | 4 ++-- Modules/MinoriEditorShell/MinoriEditorShell.csproj | 2 +- .../MinoriEditorShell.Platforms.WpfTests.csproj | 8 ++++---- .../MinoriEditorShell.RibbonTests.csproj | 8 ++++---- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Demos/MinoriDemo/MinoriDemo.Core/MinoriDemo.Core.csproj b/Demos/MinoriDemo/MinoriDemo.Core/MinoriDemo.Core.csproj index 118cac46..51be7a19 100644 --- a/Demos/MinoriDemo/MinoriDemo.Core/MinoriDemo.Core.csproj +++ b/Demos/MinoriDemo/MinoriDemo.Core/MinoriDemo.Core.csproj @@ -22,7 +22,7 @@ - + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj index 97b349a3..58e5e087 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj @@ -56,7 +56,7 @@ This uses AvalonDock and has an MVVM architecture based on MvvmCross. - + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs index adc3aa8e..40cacd1a 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs @@ -30,7 +30,7 @@ public class MesAvnViewPresenter : MvxAttributeViewPresenter, IMesAvnViewPresent /// /// Main constructor for the presenter, this gets the main window. /// - /// + /// public MesAvnViewPresenter(ContentControl contentControl) : base() { if (contentControl is Window window) diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj b/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj index 56f01c58..f4feb57f 100644 --- a/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj +++ b/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj @@ -42,11 +42,11 @@ This uses AvalonDock and has an MVVM architecture based on MvvmCross. - + - + diff --git a/Modules/MinoriEditorShell/MinoriEditorShell.csproj b/Modules/MinoriEditorShell/MinoriEditorShell.csproj index 445539f7..2aa669ed 100644 --- a/Modules/MinoriEditorShell/MinoriEditorShell.csproj +++ b/Modules/MinoriEditorShell/MinoriEditorShell.csproj @@ -32,7 +32,7 @@ This uses AvalonDock and has an MVVM architecture based on MvvmCross. - + diff --git a/Tests/MinoriEditorShell.Platforms.WpfTests/MinoriEditorShell.Platforms.WpfTests.csproj b/Tests/MinoriEditorShell.Platforms.WpfTests/MinoriEditorShell.Platforms.WpfTests.csproj index 3844529e..12ba4ec1 100644 --- a/Tests/MinoriEditorShell.Platforms.WpfTests/MinoriEditorShell.Platforms.WpfTests.csproj +++ b/Tests/MinoriEditorShell.Platforms.WpfTests/MinoriEditorShell.Platforms.WpfTests.csproj @@ -11,10 +11,10 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Tests/MinoriEditorShell.RibbonTests/MinoriEditorShell.RibbonTests.csproj b/Tests/MinoriEditorShell.RibbonTests/MinoriEditorShell.RibbonTests.csproj index d1fd2178..8ec60f37 100644 --- a/Tests/MinoriEditorShell.RibbonTests/MinoriEditorShell.RibbonTests.csproj +++ b/Tests/MinoriEditorShell.RibbonTests/MinoriEditorShell.RibbonTests.csproj @@ -11,10 +11,10 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive From 06ea30196dd9ebdbc61eb75ca37c7a44fd94a4e6 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sat, 13 Mar 2021 20:38:05 -0500 Subject: [PATCH 22/68] upgrade assistant --- .../MinoriDemo.RibbonWPF.csproj | 161 ++---------------- .../MinoriDemo.WPF/MinoriDemo.WPF.csproj | 136 ++------------- .../SimpleDemo.RibbonWPF.csproj | 141 ++------------- .../SimpleDemo.WPF/SimpleDemo.WPF.csproj | 133 ++------------- ...inoriEditorShell.Platforms.WpfTests.csproj | 2 +- .../MinoriEditorShell.RibbonTests.csproj | 2 +- 6 files changed, 48 insertions(+), 527 deletions(-) diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.csproj b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.csproj index 69136def..b69bf999 100644 --- a/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.csproj +++ b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.csproj @@ -1,70 +1,16 @@ - - - + - Debug - AnyCPU - {9D695910-476E-4156-8AEE-4F2DDBE984FD} + net461 WinExe - MinoriDemo.RibbonWPF - MinoriDemo.RibbonWPF - v4.6.1 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - true - true - ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset + false + true + true - - - - - - - - - - 4.0 - - - - - - - - App.xaml.cs - App.xaml - DataClasses\ThemeItem.cs - - MainWindow.xaml.cs - MainWindow.xaml - Modules\Themes\CyberTheme.cs @@ -77,62 +23,8 @@ Setup.cs - - Views\MainView.xaml.cs - MainView.xaml - - - Views\ThemeEditorView.xaml.cs - ThemeEditorView.xaml - - - Views\ToolSampleView.xaml.cs - ToolSampleView.xaml - - - Views\VirtualCanvasView.xaml.cs - VirtualCanvasView.xaml - - - App.xaml - MSBuild:Compile - Designer - - - MainWindow.xaml - MSBuild:Compile - Designer - - - Modules\Themes\CyberTheme.xaml - MSBuild:Compile - Designer - - - Views\MainView.xaml - MSBuild:Compile - Designer - - - Views\ThemeEditorView.xaml - MSBuild:Compile - Designer - - - Views\ToolSampleView.xaml - MSBuild:Compile - Designer - - - Views\VirtualCanvasView.xaml - MSBuild:Compile - Designer - - - Code - minorieditorshellcsharp.ruleset @@ -141,55 +33,29 @@ torisankitsune_minorieditorshell2csharp.ruleset - - - {79572320-e719-4053-a12a-9d74e111fc5e} - MinoriEditorShell.Platforms.Wpf - - - {ed2e6a4c-fe20-4cb8-953e-880c1ee31ae6} - MinoriEditorShell.Ribbon - - - {acd61563-7365-4287-8fe8-6b0c38c5e8e3} - MinoriEditorShell.VirtualCanvas.Platforms.Wpf - - - {B8BA7A12-25B1-445D-93B8-D0F34226D053} - MinoriEditorShell.VirtualCanvas - - - {320b6932-9c96-4a1c-a2fc-f393516ae13f} - MinoriEditorShell - - - {E2733B2F-5C55-4C2E-879F-1495C5E11A4B} - MinoriDemo.Core - + + + + + + 1.6.2 - - 8.0.3 - 5.5.1 runtime; build; native; contentfiles; analyzers; buildtransitive all - - 7.1.2 - - - 7.1.2 - + 7.1.2 + 1.1.1 @@ -202,5 +68,4 @@ SonarLint.xml - \ No newline at end of file diff --git a/Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.csproj b/Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.csproj index ff076a96..75561e85 100644 --- a/Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.csproj +++ b/Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.csproj @@ -1,136 +1,26 @@ - - - + - Debug - AnyCPU - {0CF393F5-88BF-435F-A294-1C118F67AD3F} + net461 WinExe - MinoriDemo.WPF - MinoriDemo.WPF - v4.6.1 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - true - true ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset + false + true + true - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset - - - - - - - - - - - - 4.0 - - - - - - - MSBuild:Compile - Designer - - - MainView.xaml - - - MSBuild:Compile - Designer - - - App.xaml - Code - - - MainWindow.xaml - Code - - - Designer - MSBuild:Compile - - - - - Code - - - True - True - Resources.resx - - - True - Settings.settings - True - - - ResXFileCodeGenerator - Resources.Designer.cs - minorieditorshellcsharp.ruleset torisankitsune_minorieditorshell2csharp.ruleset - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - - {79572320-e719-4053-a12a-9d74e111fc5e} - MinoriEditorShell.Platforms.Wpf - - - {acd61563-7365-4287-8fe8-6b0c38c5e8e3} - MinoriEditorShell.VirtualCanvas.Platforms.Wpf - - - {b8ba7a12-25b1-445d-93b8-d0f34226d053} - MinoriEditorShell.VirtualCanvas - - - {320b6932-9c96-4a1c-a2fc-f393516ae13f} - MinoriEditorShell - - - {e2733b2f-5c55-4c2e-879f-1495c5e11a4b} - MinoriDemo.Core - + + + + + @@ -138,14 +28,12 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - - 7.1.2 - + + SonarLint.xml - \ No newline at end of file diff --git a/Demos/SimpleDemo/SimpleDemo.RibbonWPF/SimpleDemo.RibbonWPF.csproj b/Demos/SimpleDemo/SimpleDemo.RibbonWPF/SimpleDemo.RibbonWPF.csproj index 27821e09..d8bf6764 100644 --- a/Demos/SimpleDemo/SimpleDemo.RibbonWPF/SimpleDemo.RibbonWPF.csproj +++ b/Demos/SimpleDemo/SimpleDemo.RibbonWPF/SimpleDemo.RibbonWPF.csproj @@ -1,154 +1,35 @@ - - - + - Debug - AnyCPU - {4179EC7D-789B-4570-91F9-A5D56251A6EE} + net461 WinExe - SimpleDemo.RibbonWPF - SimpleDemo.RibbonWPF - v4.6.1 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - true - true - ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset + false + true + true - - - - - - - - - - 4.0 - - - - - - - - MSBuild:Compile - Designer - - - MainView.xaml - - - TipView.xaml - - - MSBuild:Compile - Designer - - - App.xaml - Code - - - MainWindow.xaml - Code - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - - - Code - - - True - True - Resources.resx - - - True - Settings.settings - True - - - ResXFileCodeGenerator - Resources.Designer.cs - torisankitsune_minorieditorshell2csharp.ruleset - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - - {79572320-e719-4053-a12a-9d74e111fc5e} - MinoriEditorShell.Platforms.Wpf - - - {ed2e6a4c-fe20-4cb8-953e-880c1ee31ae6} - MinoriEditorShell.Ribbon - - - {320b6932-9c96-4a1c-a2fc-f393516ae13f} - MinoriEditorShell - - - {1be23c45-838b-47e7-8437-90493cbea59a} - SimpleDemo.Core - + + + + - - 8.0.3 - 5.5.1 runtime; build; native; contentfiles; analyzers; buildtransitive all - - 7.1.2 - + + SonarLint.xml - \ No newline at end of file diff --git a/Demos/SimpleDemo/SimpleDemo.WPF/SimpleDemo.WPF.csproj b/Demos/SimpleDemo/SimpleDemo.WPF/SimpleDemo.WPF.csproj index aa8234d5..6e68d713 100644 --- a/Demos/SimpleDemo/SimpleDemo.WPF/SimpleDemo.WPF.csproj +++ b/Demos/SimpleDemo/SimpleDemo.WPF/SimpleDemo.WPF.csproj @@ -1,132 +1,21 @@ - - - + - Debug - AnyCPU - {1C1AD720-523F-4144-8BA3-1E86461BC019} + net461 WinExe - SimpleDemo.WPF - SimpleDemo.WPF - v4.6.1 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - true - true ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset + false + true + true - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset - - - - - - - - - - - - 4.0 - - - - - - - MSBuild:Compile - Designer - - - MainView.xaml - - - TipView.xaml - - - MSBuild:Compile - Designer - - - App.xaml - Code - - - MainWindow.xaml - Code - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - - - Code - - - True - True - Resources.resx - - - True - Settings.settings - True - - - ResXFileCodeGenerator - Resources.Designer.cs - torisankitsune_minorieditorshell2csharp.ruleset - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - - {79572320-e719-4053-a12a-9d74e111fc5e} - MinoriEditorShell.Platforms.Wpf - - - {320b6932-9c96-4a1c-a2fc-f393516ae13f} - MinoriEditorShell - - - {1be23c45-838b-47e7-8437-90493cbea59a} - SimpleDemo.Core - + + + @@ -134,14 +23,12 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - - 7.1.2 - + + SonarLint.xml - \ No newline at end of file diff --git a/Tests/MinoriEditorShell.Platforms.WpfTests/MinoriEditorShell.Platforms.WpfTests.csproj b/Tests/MinoriEditorShell.Platforms.WpfTests/MinoriEditorShell.Platforms.WpfTests.csproj index 12ba4ec1..15df8a5f 100644 --- a/Tests/MinoriEditorShell.Platforms.WpfTests/MinoriEditorShell.Platforms.WpfTests.csproj +++ b/Tests/MinoriEditorShell.Platforms.WpfTests/MinoriEditorShell.Platforms.WpfTests.csproj @@ -1,7 +1,7 @@  - net461;netcoreapp3.1 + net461;netcoreapp3.1;net5.0-windows false diff --git a/Tests/MinoriEditorShell.RibbonTests/MinoriEditorShell.RibbonTests.csproj b/Tests/MinoriEditorShell.RibbonTests/MinoriEditorShell.RibbonTests.csproj index 8ec60f37..ac8e506b 100644 --- a/Tests/MinoriEditorShell.RibbonTests/MinoriEditorShell.RibbonTests.csproj +++ b/Tests/MinoriEditorShell.RibbonTests/MinoriEditorShell.RibbonTests.csproj @@ -1,7 +1,7 @@  - net461;netcoreapp3.1 + net461;netcoreapp3.1;net5.0 false From 681d911ffcfc21dbb7dbba4e522559b57926b406 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sat, 13 Mar 2021 20:40:18 -0500 Subject: [PATCH 23/68] update ribbon target --- .../MinoriEditorShell.RibbonTests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/MinoriEditorShell.RibbonTests/MinoriEditorShell.RibbonTests.csproj b/Tests/MinoriEditorShell.RibbonTests/MinoriEditorShell.RibbonTests.csproj index ac8e506b..865a2eb3 100644 --- a/Tests/MinoriEditorShell.RibbonTests/MinoriEditorShell.RibbonTests.csproj +++ b/Tests/MinoriEditorShell.RibbonTests/MinoriEditorShell.RibbonTests.csproj @@ -1,7 +1,7 @@  - net461;netcoreapp3.1;net5.0 + net461;netcoreapp3.1;net5.0-windows false From f2ac7aff7cf55355462d5acafc89b78b9e0a9503 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sat, 13 Mar 2021 21:19:20 -0500 Subject: [PATCH 24/68] removed *core projects for net5 --- .../MinoriDemo.RibbonWPF/App.config | 6 --- .../App.xaml | 0 .../App.xaml.cs | 0 .../DataClasses/ThemeItem.cs | 0 .../MainWindow.xaml | 0 .../MainWindow.xaml.cs | 0 .../MinoriDemo.RibbonWPF.csproj | 38 +++---------- .../MinoriDemo.RibbonWPF.ruleset | 5 -- .../Modules/Themes/CyberTheme.cs | 0 .../Modules/Themes/CyberTheme.xaml | 0 .../Modules/Themes/ThemeHelper.cs | 0 .../Modules/VirtualCanvas/Models/TestShape.cs | 0 .../Properties/AssemblyInfo.cs | 51 ------------------ .../Setup.cs | 0 .../Views/MainView.xaml | 0 .../Views/MainView.xaml.cs | 0 .../Views/ThemeEditorView.xaml | 0 .../Views/ThemeEditorView.xaml.cs | 0 .../Views/ToolSampleView.xaml | 0 .../Views/ToolSampleView.xaml.cs | 0 .../Views/VirtualCanvasView.xaml | 0 .../Views/VirtualCanvasView.xaml.cs | 0 .../MinoriDemo.RibbonWpfCore/AssemblyInfo.cs | 35 ------------ .../MinoriDemo.RibbonWpfCore.csproj | 40 -------------- .../Resources/Splash.png | Bin 24971 -> 0 bytes .../MinoriDemo.WPF/MinoriDemo.WPF.csproj | 12 +---- .../MinoriDemo.WPF/MinoriDemo.WPF.ruleset | 5 -- Demos/MinoriDemo/MinoriDemo.WpfCore/App.xaml | 10 ---- .../MinoriDemo/MinoriDemo.WpfCore/App.xaml.cs | 14 ----- .../MinoriDemo.WpfCore/AssemblyInfo.cs | 35 ------------ .../MinoriDemo.WpfCore/MainWindow.xaml | 14 ----- .../MinoriDemo.WpfCore/MainWindow.xaml.cs | 13 ----- .../MinoriDemo.WpfCore.csproj | 29 ---------- .../MinoriDemo.WpfCore/Views/MainView.xaml | 22 -------- .../MinoriDemo.WpfCore/Views/MainView.xaml.cs | 12 ----- .../SimpleDemo.RibbonWPF.csproj | 9 +--- .../SimpleDemo.RibbonWPF.ruleset | 5 -- .../SimpleDemo.RibbonWpfCore/App.xaml | 15 ------ .../SimpleDemo.RibbonWpfCore/App.xaml.cs | 14 ----- .../SimpleDemo.RibbonWpfCore/AssemblyInfo.cs | 35 ------------ .../SimpleDemo.RibbonWpfCore/MainWindow.xaml | 13 ----- .../MainWindow.xaml.cs | 18 ------- .../SimpleDemo.RibbonWpfCore.csproj | 28 ---------- .../Views/MainView.xaml | 24 --------- .../Views/MainView.xaml.cs | 12 ----- .../Views/TipView.xaml | 24 --------- .../Views/TipView.xaml.cs | 12 ----- .../SimpleDemo.WPF/SimpleDemo.WPF.csproj | 9 +--- .../SimpleDemo.WPF/SimpleDemo.WPF.ruleset | 5 -- Demos/SimpleDemo/SimpleDemo.WpfCore/App.xaml | 10 ---- .../SimpleDemo/SimpleDemo.WpfCore/App.xaml.cs | 14 ----- .../SimpleDemo.WpfCore/AssemblyInfo.cs | 35 ------------ .../SimpleDemo.WpfCore/MainWindow.xaml | 13 ----- .../SimpleDemo.WpfCore/MainWindow.xaml.cs | 15 ------ .../SimpleDemo.WpfCore.csproj | 28 ---------- .../SimpleDemo.WpfCore/Views/MainView.xaml | 29 ---------- .../SimpleDemo.WpfCore/Views/MainView.xaml.cs | 15 ------ .../SimpleDemo.WpfCore/Views/TipView.xaml | 24 --------- .../SimpleDemo.WpfCore/Views/TipView.xaml.cs | 15 ------ MinoriEditorShell.sln | 36 ++----------- .../MinoriEditorShell.Platforms.Wpf.csproj | 2 +- ...orShell.VirtualCanvas.Platforms.Wpf.csproj | 2 +- 62 files changed, 20 insertions(+), 782 deletions(-) delete mode 100644 Demos/MinoriDemo/MinoriDemo.RibbonWPF/App.config rename Demos/MinoriDemo/{MinoriDemo.RibbonWpfCore => MinoriDemo.RibbonWPF}/App.xaml (100%) rename Demos/MinoriDemo/{MinoriDemo.RibbonWpfCore => MinoriDemo.RibbonWPF}/App.xaml.cs (100%) rename Demos/MinoriDemo/{MinoriDemo.RibbonWpfCore => MinoriDemo.RibbonWPF}/DataClasses/ThemeItem.cs (100%) rename Demos/MinoriDemo/{MinoriDemo.RibbonWpfCore => MinoriDemo.RibbonWPF}/MainWindow.xaml (100%) rename Demos/MinoriDemo/{MinoriDemo.RibbonWpfCore => MinoriDemo.RibbonWPF}/MainWindow.xaml.cs (100%) delete mode 100644 Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.ruleset rename Demos/MinoriDemo/{MinoriDemo.RibbonWpfCore => MinoriDemo.RibbonWPF}/Modules/Themes/CyberTheme.cs (100%) rename Demos/MinoriDemo/{MinoriDemo.RibbonWpfCore => MinoriDemo.RibbonWPF}/Modules/Themes/CyberTheme.xaml (100%) rename Demos/MinoriDemo/{MinoriDemo.RibbonWpfCore => MinoriDemo.RibbonWPF}/Modules/Themes/ThemeHelper.cs (100%) rename Demos/MinoriDemo/{MinoriDemo.RibbonWpfCore => MinoriDemo.RibbonWPF}/Modules/VirtualCanvas/Models/TestShape.cs (100%) delete mode 100644 Demos/MinoriDemo/MinoriDemo.RibbonWPF/Properties/AssemblyInfo.cs rename Demos/MinoriDemo/{MinoriDemo.RibbonWpfCore => MinoriDemo.RibbonWPF}/Setup.cs (100%) rename Demos/MinoriDemo/{MinoriDemo.RibbonWpfCore => MinoriDemo.RibbonWPF}/Views/MainView.xaml (100%) rename Demos/MinoriDemo/{MinoriDemo.RibbonWpfCore => MinoriDemo.RibbonWPF}/Views/MainView.xaml.cs (100%) rename Demos/MinoriDemo/{MinoriDemo.RibbonWpfCore => MinoriDemo.RibbonWPF}/Views/ThemeEditorView.xaml (100%) rename Demos/MinoriDemo/{MinoriDemo.RibbonWpfCore => MinoriDemo.RibbonWPF}/Views/ThemeEditorView.xaml.cs (100%) rename Demos/MinoriDemo/{MinoriDemo.RibbonWpfCore => MinoriDemo.RibbonWPF}/Views/ToolSampleView.xaml (100%) rename Demos/MinoriDemo/{MinoriDemo.RibbonWpfCore => MinoriDemo.RibbonWPF}/Views/ToolSampleView.xaml.cs (100%) rename Demos/MinoriDemo/{MinoriDemo.RibbonWpfCore => MinoriDemo.RibbonWPF}/Views/VirtualCanvasView.xaml (100%) rename Demos/MinoriDemo/{MinoriDemo.RibbonWpfCore => MinoriDemo.RibbonWPF}/Views/VirtualCanvasView.xaml.cs (100%) delete mode 100644 Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/AssemblyInfo.cs delete mode 100644 Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/MinoriDemo.RibbonWpfCore.csproj delete mode 100644 Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Resources/Splash.png delete mode 100644 Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.ruleset delete mode 100644 Demos/MinoriDemo/MinoriDemo.WpfCore/App.xaml delete mode 100644 Demos/MinoriDemo/MinoriDemo.WpfCore/App.xaml.cs delete mode 100644 Demos/MinoriDemo/MinoriDemo.WpfCore/AssemblyInfo.cs delete mode 100644 Demos/MinoriDemo/MinoriDemo.WpfCore/MainWindow.xaml delete mode 100644 Demos/MinoriDemo/MinoriDemo.WpfCore/MainWindow.xaml.cs delete mode 100644 Demos/MinoriDemo/MinoriDemo.WpfCore/MinoriDemo.WpfCore.csproj delete mode 100644 Demos/MinoriDemo/MinoriDemo.WpfCore/Views/MainView.xaml delete mode 100644 Demos/MinoriDemo/MinoriDemo.WpfCore/Views/MainView.xaml.cs delete mode 100644 Demos/SimpleDemo/SimpleDemo.RibbonWPF/SimpleDemo.RibbonWPF.ruleset delete mode 100644 Demos/SimpleDemo/SimpleDemo.RibbonWpfCore/App.xaml delete mode 100644 Demos/SimpleDemo/SimpleDemo.RibbonWpfCore/App.xaml.cs delete mode 100644 Demos/SimpleDemo/SimpleDemo.RibbonWpfCore/AssemblyInfo.cs delete mode 100644 Demos/SimpleDemo/SimpleDemo.RibbonWpfCore/MainWindow.xaml delete mode 100644 Demos/SimpleDemo/SimpleDemo.RibbonWpfCore/MainWindow.xaml.cs delete mode 100644 Demos/SimpleDemo/SimpleDemo.RibbonWpfCore/SimpleDemo.RibbonWpfCore.csproj delete mode 100644 Demos/SimpleDemo/SimpleDemo.RibbonWpfCore/Views/MainView.xaml delete mode 100644 Demos/SimpleDemo/SimpleDemo.RibbonWpfCore/Views/MainView.xaml.cs delete mode 100644 Demos/SimpleDemo/SimpleDemo.RibbonWpfCore/Views/TipView.xaml delete mode 100644 Demos/SimpleDemo/SimpleDemo.RibbonWpfCore/Views/TipView.xaml.cs delete mode 100644 Demos/SimpleDemo/SimpleDemo.WPF/SimpleDemo.WPF.ruleset delete mode 100644 Demos/SimpleDemo/SimpleDemo.WpfCore/App.xaml delete mode 100644 Demos/SimpleDemo/SimpleDemo.WpfCore/App.xaml.cs delete mode 100644 Demos/SimpleDemo/SimpleDemo.WpfCore/AssemblyInfo.cs delete mode 100644 Demos/SimpleDemo/SimpleDemo.WpfCore/MainWindow.xaml delete mode 100644 Demos/SimpleDemo/SimpleDemo.WpfCore/MainWindow.xaml.cs delete mode 100644 Demos/SimpleDemo/SimpleDemo.WpfCore/SimpleDemo.WpfCore.csproj delete mode 100644 Demos/SimpleDemo/SimpleDemo.WpfCore/Views/MainView.xaml delete mode 100644 Demos/SimpleDemo/SimpleDemo.WpfCore/Views/MainView.xaml.cs delete mode 100644 Demos/SimpleDemo/SimpleDemo.WpfCore/Views/TipView.xaml delete mode 100644 Demos/SimpleDemo/SimpleDemo.WpfCore/Views/TipView.xaml.cs diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWPF/App.config b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/App.config deleted file mode 100644 index 5534e287..00000000 --- a/Demos/MinoriDemo/MinoriDemo.RibbonWPF/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/App.xaml b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/App.xaml similarity index 100% rename from Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/App.xaml rename to Demos/MinoriDemo/MinoriDemo.RibbonWPF/App.xaml diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/App.xaml.cs b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/App.xaml.cs similarity index 100% rename from Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/App.xaml.cs rename to Demos/MinoriDemo/MinoriDemo.RibbonWPF/App.xaml.cs diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/DataClasses/ThemeItem.cs b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/DataClasses/ThemeItem.cs similarity index 100% rename from Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/DataClasses/ThemeItem.cs rename to Demos/MinoriDemo/MinoriDemo.RibbonWPF/DataClasses/ThemeItem.cs diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/MainWindow.xaml b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MainWindow.xaml similarity index 100% rename from Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/MainWindow.xaml rename to Demos/MinoriDemo/MinoriDemo.RibbonWPF/MainWindow.xaml diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/MainWindow.xaml.cs b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MainWindow.xaml.cs similarity index 100% rename from Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/MainWindow.xaml.cs rename to Demos/MinoriDemo/MinoriDemo.RibbonWPF/MainWindow.xaml.cs diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.csproj b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.csproj index b69bf999..14bfa520 100644 --- a/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.csproj +++ b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.csproj @@ -1,38 +1,13 @@  - net461 + net5.0-windows WinExe ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset - false true true - - DataClasses\ThemeItem.cs - - - Modules\Themes\CyberTheme.cs - - - Modules\Themes\ThemeHelper.cs - - - Modules\VirtualCanvas\Models\TestShape.cs - - - Setup.cs - - - - - minorieditorshellcsharp.ruleset - - - - - torisankitsune_minorieditorshell2csharp.ruleset - + @@ -60,12 +35,15 @@ 1.1.1 - - - SonarLint.xml + + + + + + \ No newline at end of file diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.ruleset b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.ruleset deleted file mode 100644 index b327e534..00000000 --- a/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.ruleset +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Modules/Themes/CyberTheme.cs b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/Modules/Themes/CyberTheme.cs similarity index 100% rename from Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Modules/Themes/CyberTheme.cs rename to Demos/MinoriDemo/MinoriDemo.RibbonWPF/Modules/Themes/CyberTheme.cs diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Modules/Themes/CyberTheme.xaml b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/Modules/Themes/CyberTheme.xaml similarity index 100% rename from Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Modules/Themes/CyberTheme.xaml rename to Demos/MinoriDemo/MinoriDemo.RibbonWPF/Modules/Themes/CyberTheme.xaml diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Modules/Themes/ThemeHelper.cs b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/Modules/Themes/ThemeHelper.cs similarity index 100% rename from Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Modules/Themes/ThemeHelper.cs rename to Demos/MinoriDemo/MinoriDemo.RibbonWPF/Modules/Themes/ThemeHelper.cs diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Modules/VirtualCanvas/Models/TestShape.cs b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/Modules/VirtualCanvas/Models/TestShape.cs similarity index 100% rename from Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Modules/VirtualCanvas/Models/TestShape.cs rename to Demos/MinoriDemo/MinoriDemo.RibbonWPF/Modules/VirtualCanvas/Models/TestShape.cs diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWPF/Properties/AssemblyInfo.cs b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/Properties/AssemblyInfo.cs deleted file mode 100644 index 91dac924..00000000 --- a/Demos/MinoriDemo/MinoriDemo.RibbonWPF/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; -using System.Windows; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("MinoriDemo.RibbonWPF")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("MinoriDemo.RibbonWPF")] -[assembly: AssemblyCopyright("Copyright © 2019")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -//In order to begin building localizable applications, set -//CultureYouAreCodingWith in your .csproj file -//inside a . For example, if you are using US english -//in your source files, set the to en-US. Then uncomment -//the NeutralResourceLanguage attribute below. Update the "en-US" in -//the line below to match the UICulture setting in the project file. - -//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Setup.cs b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/Setup.cs similarity index 100% rename from Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Setup.cs rename to Demos/MinoriDemo/MinoriDemo.RibbonWPF/Setup.cs diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/MainView.xaml b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/Views/MainView.xaml similarity index 100% rename from Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/MainView.xaml rename to Demos/MinoriDemo/MinoriDemo.RibbonWPF/Views/MainView.xaml diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/MainView.xaml.cs b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/Views/MainView.xaml.cs similarity index 100% rename from Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/MainView.xaml.cs rename to Demos/MinoriDemo/MinoriDemo.RibbonWPF/Views/MainView.xaml.cs diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/ThemeEditorView.xaml b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/Views/ThemeEditorView.xaml similarity index 100% rename from Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/ThemeEditorView.xaml rename to Demos/MinoriDemo/MinoriDemo.RibbonWPF/Views/ThemeEditorView.xaml diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/ThemeEditorView.xaml.cs b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/Views/ThemeEditorView.xaml.cs similarity index 100% rename from Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/ThemeEditorView.xaml.cs rename to Demos/MinoriDemo/MinoriDemo.RibbonWPF/Views/ThemeEditorView.xaml.cs diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/ToolSampleView.xaml b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/Views/ToolSampleView.xaml similarity index 100% rename from Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/ToolSampleView.xaml rename to Demos/MinoriDemo/MinoriDemo.RibbonWPF/Views/ToolSampleView.xaml diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/ToolSampleView.xaml.cs b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/Views/ToolSampleView.xaml.cs similarity index 100% rename from Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/ToolSampleView.xaml.cs rename to Demos/MinoriDemo/MinoriDemo.RibbonWPF/Views/ToolSampleView.xaml.cs diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/VirtualCanvasView.xaml b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/Views/VirtualCanvasView.xaml similarity index 100% rename from Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/VirtualCanvasView.xaml rename to Demos/MinoriDemo/MinoriDemo.RibbonWPF/Views/VirtualCanvasView.xaml diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/VirtualCanvasView.xaml.cs b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/Views/VirtualCanvasView.xaml.cs similarity index 100% rename from Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/VirtualCanvasView.xaml.cs rename to Demos/MinoriDemo/MinoriDemo.RibbonWPF/Views/VirtualCanvasView.xaml.cs diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/AssemblyInfo.cs b/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/AssemblyInfo.cs deleted file mode 100644 index 41b0c858..00000000 --- a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Windows; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SimpleDemo.WPF")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SimpleDemo.WPF")] -[assembly: AssemblyCopyright("Copyright © 2019")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/MinoriDemo.RibbonWpfCore.csproj b/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/MinoriDemo.RibbonWpfCore.csproj deleted file mode 100644 index ee85488e..00000000 --- a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/MinoriDemo.RibbonWpfCore.csproj +++ /dev/null @@ -1,40 +0,0 @@ - - - - WinExe - netcoreapp3.1 - false - true - ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset - - - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Resources/Splash.png b/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Resources/Splash.png deleted file mode 100644 index 4167b397d8c3d4d9606efc176eca8216caaae917..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 24971 zcmdSBWmr^y^et{63|&&vB_a(1QiGJJbV&{fh^RC}4MQm1h@^CgbW0E2jdUX*GxPuh z49z`!f6sk$-~XTgy)WiD3~*x3XP>>-UVE(x)l^p|CU`_}=guAC*RK?{@7%e21iUms zxWI2-8%H<;o4ZhLW%)a$!wj3i8yssnHMu)?DxwK5%^v{o@f}|oLhsyR47z>Yg=ABH zy>rK$<+Y-mu7~OFBK-GzJsA4x0WrZ7zx>R{Aq4lHM!tY5zj&c^@9|&GHx}}yeKr(o zt9@1x?^As#g1OiwkVy<`*+O9ih?gNxUMaGLJqdCCr1|k~Jt3bnrLOM3;YRSdjMPBo zNp+zcy71~EN~p0AyHt%dftDntY`SK5GD3yFt~;gbfJzsXGbe32X)L zDvl}uTYMHjCV3F6>K*bUGI@~sy^zdcU`zP|M<#$wKIsnI#_i5HWOAgy_VJhhk9Tdw zMN3;Auj!zbg9w=5mj}p$8sI8G1ChjHGnupHeDtbUz7KiBGG)(a)`k?K!A7RHA7Q;a zj9C0*dbx!XjFF0+>S*hS1Hz&M`C4P4PUeT=Dey16vP_;w6-X{p@PhP0b5y?$b3vy5 zh}U+W?NqVno=CE_UH$BY18^Gx);o4(>ssn}=H12J7u|1qrH^9>&e@}7rlj}xbB5eB z<`J;_pEW{?RC@mf<_hiGa@I!bGkUon zENjaI`xo) z*yNHudwrG$@4Y&j$OBi;+ExuEM~cmTv_hY+scEm4>{ziJz)yV zrwJ|Tp0X}XHUeWn3@+K$&r$-RH=8}X^;#qKTn%KtP=B%4m@**Hf{;KXFv%h#(p6_; ziOmxx?u)KU|M1~dF8+?7ak)V{|Jp@2W9UjCjabIbB`T$AShDDBOTT5V7}8i1a`8CD zwo-jmzt}+NxbI-~LKapYa!%@du37abj5vi@eCFMjcn3R^CrD?XsQGHwA#wW0jPn3r z3JQ#^Uw7penLi_gq(@_BEW-Jcxxh~LxV3HAJlU&H&>_+3XVw|sZkYHouUx~b4{8VH z>Bq&^qK$hEHqc(y;Acf|OFoBt_+4mq%wX??GKkvyTy|!HKZ#L!=3hxyHgDA z3r_!YY0?+7BmCLh(r&X>i66F0YSYh$1}`_1Wj{AxETY9|ATC2q%Lb_3|{$bba}14W{zIBzzRtfe62FPAK%W%^q!zz+W80mHao zdn~`1G=cY>G7kla^Ib@2Ya3f^&XB=WnoP( zcchlj)VZ&GnD5bkX;zWFK8Oy__eH~(ZJ50F+X|Mi#fe6Y9h#~K^We3+XE$kwLW@!;D$U*A^t7FZ zy6kCykKlDkO{X|E_I>|W;05HW>7ws5J_dCt+y0h@$=6VEiM zL~oxCV(~b)DEU#&v4e#73=Y7PXGKQ+=mDupQkr$?pewhDfe)F@_CV+v5YfhASRbUj zD1*ifUx~}I6@m4K|2}@G1cggT{dBHyqA61YtwRf)naKSlJj2IT`O*M3J7D^@ ze+iC;Op#jOArX-f>o4xomLa)^%{&}6rLduVJVBSlqhHF~opn(_AV~_z z&V`F(#|MA9%O^cpJvvNmK|DnBxbi~|e7xCre9=wV>-Gf+_5f5)G5QIBR$Ok^-~nmi zw?8EwW(Ckq;r{L9oh2)iaJk5bUYL|++r7HAC|4+|eG&0-{O%iK!yvN9u>gjtdcjbF zdV9|K051BFRT{s(`*g`& z1~M?Uqfjy-`zvBb1m?{Ndne$_s>7C3IK3J`0C`K<0g=BFSkqno8=36N{% zn*-+cHh%g2@F5rDiZ{ZQM7`&xt9$6Fp12nvb0+|B2@<-#jvTG#U07lq4JkOY(FiM~ zLx!*58z($2TBI(U`+Kuk4^{c&2IPwGL_K#xgPGdjQ_7K=Q-`p`JpL|iYV-a=rak5z z0Zd?O*hvu)bl#Zdw&F_uV0!?zdF}A&8zuzU<6mW))QEvhrNb%v?w!N`qtbcWj~J7f zd;gW#KzsB^_1n@kh(nv#I07Uq1qr5W_| z{cj)BOTj-;SOiKYw+UBU{%(4`*b_0-ej}y&^Q_A>iR%XZVfhD51mzrvSarz)MNq@@ zsKsVmkZ__83!CE50r;dMI=&#BUon$OgBi;d4e~f?%!Ln+Ji~FyztVEr{T)gBBdA>K z8v@kbZebDDnSN2TIq5d7z^p5GG)LMU(M;wYGtl%8X?+-?#=9RzarBrnLUUV#n8zDx2-9y};?_lj@<;#yuk`g${5#Z!`FH(K%O-|#O7g}H9qSHk0OZD5k&rRS7Uao7UhMZADNzN zH9ekhd-MhNY?6|WI-ro`%gwRbjb1=;&0SpY`+xTu(WXl_d3WbtY}St>9uqYj7kP5t zn*tXFvXH;_Wim z2SK_e?1fq_q%#)v`WY-EK-bA@RleAy$lOd|`Xzk#tc-E)WBAf!k$&O=VGOmbyZ3o@ zBlWI3Uv)j{|?;If!dF6DYp-F917p9>6&ZcBU&$ckxbU>3_LAH3> zzK}%-drYbgZQZia_6=i4#nu7njuZPT^JyzyGPW7pH1xwd-S9j|{jP3KE}?=y4fnnM zKmo5T#rsQFd+y@Q*ZaZY-z4{3R`%rbcR9b^T%&K6ypD31?Et7Y5`RJ=m2#K6bX^r2 zenP2d0o$ubQLpu!Wq7QHcD-QvvNtI=+R~2ge7k8X8zfJRg_rSPmF&f8fa}kCmBHG> z;aRUkirk0aS@M$EVM{i%_PnQlD^hsqF-bW+lL2^F^@i@xdw+JzW9BV+U>)4pb^Qzt@AFC_@kM1W{S=etXrdY z4#c&TVs@*WlC?jG2zH$Z=X{t1*|V6Ii=amN<GWhU~a(VB!H{1 znoIUIOt4lI^&J~9&h=Gtlzudn@h%6OwDS^+6Yaz9Y3{sKZE3f3$qsAUbV-3@%8XM* zjK--;=?5v4n+XGI7tnF5H{_=e$aeu#W+Z~%k z-O13ed#H~6P@p_0Z?SZ4i^}o}g^Jsz8yS?hLt|(a84%3Wib08%ESyN`>e4nr$iH_B zE1L%hHMog$ALo#M^I<$2M|)GJoO4p~^?6)rGMND(dyl6V?B1_eCOo)CN=IFnB^(MX zw#Q_7XW9w_bNz5+J%v8&rxn+wqWnl3B$}hL&&;vucT??RQ`hpTamK-HSk31u&05JJ zInvbv4do$M&5R2Tj(%_T!8B6#F>DsrOL}~PfDAt*`(@J=bCB})Rr#d$%ozdhC{$wy ziB#Oz-;E5B?zXM}>?TLKJ-Bi0{i!w5|B~KMuV14e+>Mh~VkpE~3VI(GnL#KL2GgeH zpbeNu&$y#9)!j|*Nlvf5B^`DOuxF$pdXgIigRLp**Foxxp1fVA2sgW$G_#A6+{#A+ zklltv=4dp7QXW6D)R35pl5@IvI^_u7b7T}-i}Z&&noM^!pWk*RKL}X%w+g2VvUlgO zh5Ai}XYpod@rQGE?hY|ktWwJp1Z4|Ojk*=C8V&j(#Z-5j1_pj9TrhOVJpMVt!m@DO z>?Ru;C;0I=c3DK1w&dIffQ|e-@<%NgiOc;CmBtcHM_IuyHqJSi{9TLkAI^@8j2da0 z88&SmZW+ny&R~e;htyZvCLk4Bd8xCO1<_6uxxS=WVSX91+|(Unr79uTF$Sxr zR%|q*w{c2SeemO##Y1;?BXbV`UKy~69u3>`i#-H-AeolYB3iPK=ev(*MaljL zFJm{o_L}V49QhvCN zUjU$0`HPU}LS^*vw7(nD@kV-6i`${}aa&m_;hfY|EAQz`pIm)E>ZbD>Zu}=isk*8s z(=I7)Qz$olM{7ILwyT#_I-6TeRET)h^Z1d)WXI#~_6wpXrf8E247Ly!;;jgUOyYe$tD-Hn#jZ77moA=FaQ3dH+1(YW3Digs@Hxe}7ozLHC3cno; z4;Onb5c6~#)P&Mue>I%($57uaVC5FleWi^fQV;N}qn&AJj5;{FwhYlQ7tu^95;t%U z?0&(W`Y8j3=8Auc>`a=5C=5XZHx7kEiSHJ(85Fcwhv;<_3^R}5WU<>Tsy{KxZ<1;$ ziQIa>Pj1e{XKA4sg0eBiBqNC(JUS#TqdcZCqfD;@+HdxLn74h**J5Q7Xa7`+IWqtK z-=gD+Wht4vr_}AgZD=%@-1$V;J!V}+7@Kd`2Nc3ei1=_B6f%SAsw0ycA4?xJ%#!B(r2lUE zq*|6kE==+{e@-?m>1Q3FzZ`t z;Y?wofL%J=#nA$}xWt#dv{ao1Qi+nE_WJ{q;q0u?+@NM9J%&8@yq2c{oikoC_rngJ zQG#_)r}*`nO*a3Mi$;ze%|bE_z~Y0TH&h1RZ8~oo2B@k_9?=s;HsJb@O`yQgkv_c9 z#PN0hfUeu__RB>5(UQb00Xd41Z$iNW)Vue#A#363hBOE3$XQTkPhc|Ro-}Mqeh>PZ zZ5xlA<3;;&f*kpby*3^BLonA?(`&n?)A^?x6kW7;7eQ}CSwQw_jm%0Pjc{5k`XT@`f!40qowBIBX!D*R<)ufeB6RM*nnR2E3AWE%_f8V(7 zBFQQEVnFv)4XEExNe20C|C+FMZ~rM6F(H(qd9cB`U0+k`ggrm!tzcj6Oi*srRCq5r zu>#(3znR21+Hbi=6OB1Ut$Ue}x)xL|UolNF15FNYC(EaAlt$GI{nDSr=ToiUEAtJ6 zY-P$O*1M!Ljc7d4KWL`EhvX&?m6M*zCDC%WM+P_2t@yuW12tHZDdh6F=z*Gs11$GD zVHo+{Lx!#614H@3rp}QjEy}Z?$m@5{1l?%e7Ymr}9?A)NXGT`3u?{MVlBC9-VFuF# zWPq-hC^Xr%*u#wcb1lFjOd>H4#g^(KKK&Snj3CC;D7GJw#op5@_T!f>B~p1&n5h1Z z3XM|HAI1NW24%KtylA6!@=|FZ%$Xi-t`TBVdobfSl~C`$b5P2J>U8{eM=~r#fi?nY z(G>hp78*{uDXEuCV7O%8utQX@IIHmJ@7FI`Tm5E z9I7kl?hRMigUF%!8b0L6L-ZyV36Fh7!BFHLBNnolWS!-ru;)zrlFA80cpEX_@&|f7 zl&=DM-pOXvyZAdyV~So?CjZVWRKwFMY_HeU@YJ1ft5=VBru8uB(N|6{qHj+(a*jrA zn1$3Q%3ShXKou8Se`*4?x3${GIBt(8=y(_bYWRu}H!K;>9jVcOejsLM&-mNBjqVOa z4h<9l(M{coN1Z855A+s1+7uzI`-(cOnTHGy@5#RT%zP~3^}DO7fQW4)AGILkV<34O zT*A^Hw^QTyJU1m1OFd*6UH29&1q0`Y;BE>>(z5h@Phy|DgZXt=($zVNdig~aI8^z8 z7zrY3t2Q;-EF~<3ZdSAdn|;8vYHtVt$bmU6eZF1=6kJo6!1A&E!SoIe{pt2nCsMMA@Z zzhW~xod0Qx}uYiiixTulFkOrV;sGA?3S=+5>63_?Fs*F8clC%cx^TG_%ukjEH#!iih2QA&rKGC#xIWG;V^x9N0`#darbNQW8=&2Xp zX-sS&@$4#H%@iUL>E1hak7wNp`lnKlVmei@wk0`h8WTTP$nbQb>-@M^m5#;%8 zJpV{hX*r%U4$t~$-MPqOLN1(klvfzZj+54-(%CqjN5HEw>l#nH-5~r@+5C=F=_l~Z z`$FhF?r2Zurw5~4w-K420H<=e!CHB0O9@6}X!_qBWZax(47DK8-b0NyE6mB*%jKK- z)YCuFVrJ6Vg;gsOLKtpdhSN*THMXVYY%~}=;q|*@?Psj|XRzo4ks$Wezg-7*oJS# zV`y&MVU6E8?vRGBGyXCO9XgZUKP0Qi(C7OT>#qiXqgylguWd?6&?W)OO>-9FZRhWs zIl9!qKn%ZV75~hKDb3{R^g0UH57HoJ^~0+)4ojSdnbf zFrTx3RsTcgX&uJA9c1!2{qvzQ&u$6fyk0YOVqBJSCTnrMDKh+|PdT9PQu`obp5FK2 z^X9KVLU@|JnvW1_Z!x{ix;hDGmL=Ai#PhaIu2r8W3l9T*4)`0NjeNXmAv>C7bYC+3 zK7QR2t6|?fOQMcTWMfPUKK=V)`Rat{I4O@Fw@9GrH|*wOY1(Ar5eFjG=menKk-HAQ z@G6b%il}>ZegDHGCNjFsWZiZ|DTz%xR$azojsiH{lZMu5dQrZg;88?~ANvT5>_wF< z&oPPfvZ}kO7((K(mwn&>y8s=@NLkJx#{T}-yBT!>Osg6g-1)H&a;A@6Q*Vx2uJwgp zYRL?xxy=#SgvRW_?NgfH?+=LqRHLqV><`9aTSnS6EjG| ze8jP6pYv8cuqM&Nx@Dz@w48f7S4g9zIa+0V#C9_>Rn#WMc<)TBs;`?TIdTqeF~dtp zdUZYZIbKkHbdi_W%5c2dOEFAeYS0-NUd0Pk{p7+JCPehg9|tB%(F1SAK{%y|X1=EHk3jMZis-RgrcUm8A?Qmz>)c4^mm-n4u37)AyUJF=Q~juDVYj~y?vbq9D# zMsNn8=WNRO)tCb<0FYRlCaXp8C@ix+q}GKdmJTw<=0Th<4M- zJ4kCr+$XYC4~VD#j|Quw+&E7%!JfN-7NM_-pH*yil=@|Z!CYQuLN%dmp`ee!H>5{b zq?R3(WG>n7`0CnXUe&dEA9%cxkCfNOBdXZ(ZN1C+^D)PI8^i68rtMKjsfLs4(pLdN z!bKRhmhHexo%T9SBH{FhdBvDfWAnvwDyMG0Ylgz$B@*zQ-Iob_|17a5OVK>T%5|DG z6^=G&6VF_J9i2*5JFopF%NLE!&6r!g^qm!c90ZSF=Dw-1A31L5&{I zszT$auFijnHx*29y_ftLbm4-EmpED(%+lYYweTEzZutfsr=!lz>Vy?o*=;9#To+NZ zWxM|~kJ60%sX4rd<^bc1%0mAIJGD46nI0GFmr%MK4+hTejm#|#W(hSmH@x)vw+q^x#UUl_IOm2|*SGx13ajmDb8o&zYPFJp7M*2OthNozIKo=$DE2q#mb<*v|RG=dq=KJ<%pA^2R6>CKq(BKpMaL ze5)G%7s2=zt^VpOZm11SkG=0bNFKuj7oxZ zIE#IdOvoUuy0L*oSrcg@$~*-6Y`?j#I@+miA56f8Wr zT}|ws?AAg0rqM;|a?%+4mLn-&^i{ExJ&C`4)8g8cTmFa*_EF$9FSDFOU{=CO#*L5c zJ)(BkZ`6e~UPICone>Q38nY;$`%_*AhS33fTQsF!z-V3zz8@w zPPDs!L+Rr}YugrD1s2ptVHeaZzXVLf~VQC!BRXV-fPC! zo?BO=u)#!RMNbN!INYM@O3e6~vCOBd9R;;l+mt0ck7}K44(8r>C91ZMm)B0l)j6-J ziBpktAr;eJ;kWHJO`BS=Fh8h?|4p)3B!FvU`bxcN#Am9?$G+JO{2VXEz+eE~R4;1= zzUrA5Od_J(b}nn#YZ&uI5=^27E(h#d4&*1q2`p71-*bo}a7T;=t?6B0N~MdLn7O?N z_v~9AR%n@}i6^E$KIjppfBSvK1(nN$>Qd3Y@!Brx;WSuWlZ@W-9$v58(^JB&<1ScQ z`;?bADUqJvEqJcveZDmF*Ql;^kLP%@=^n?L1dUAt-q&8?eI>|5j^IY|s{_X4CKq*| zDH*g82c4vE+4TrOyFJlYUfx*SdO>v9G|Gh&`(^4?cFiVcj(RQBrs&#Sjrr7`a_4*A zICZyL$$+R6Bdw56_Z>Ii2=?WhK7UT3yd|_9vGW4@QvHlA>fURS^e?|m{k92N zb=+It;-J3UNi#B?zf*qN?Y9HD51_fJ`m{j?-=tTUF(qZqpB2eu&HH69FtP&X-C6-_ zX^H0uH`V}LSN}4(*_+_IYnAgEY!neH#}k^Df=PP_qKHLIvW7RVZ%q5J!LtnHooT?U;+cqiU*-){P#7~Qn#pF%o^A>c44K-sLG%GHJ(?eK+zZu##>h@ z-OZT`o2;Zuu_kko+AA2RS(;mtwIc@k?WLyqf>bxDlW1jy`xdqq?p!QIG&13zaMazr|@uneph0O0f(FfmBXZiHyju|Y(T&o z;KTymP{Z=S6c}tv_AO<(LYW_u8^Bew~5l3WkXxkl3S%zrpf3aHB+) zC6>wL4Kg_XfjK~Ro#IPrFf&YFr9S?`uM~T2oJ7q7A_s@2_EP=9airRGdpLH>T^hR; zpE!1{T3>P{(IMxoOa)!#lYEgHR=ap*lA)b*Z&A`_rRgxiuFuoVxW~WbKvTw zoHxJAP~&=**^+0D`y$NxAp0VeN{f7t^P8&=;wtYl%JG5-ojUr4X)TMA*_X#y$D8e* zi2aH1`VUIY46b(&jl~=0kG}SF;c5AxTHbf4ZdyTQ^o*#~1$T)!kMN5xH0@TvBv~c_ zwsCleVLI-?+D2p#lX1cX5hc?(%45UMTiQk9{_xPtM?E)tXll|$*eB)NK<{%l;~4ye z>4dd2DL<*O>vA!ixWe%cW81KcdFQUeQ@q@?Tf_EJ5jOsIaOkSkwkx{Fq-k+;gUW@? z>;RgA2odzCOgaAJ4?3}(+1&$Vh`!`A&ipC%M#w6w+Lje!hbM*?@19GTq1G9cULKiG z)BYeV?LYzDjdlj!(8M=5AW0D{RUD2ZRegWBNvUmYtUDZhB!eqh|M2)=R_-?CCr6vUlM0FpE}KD7h3y6B;4 z-cVBdd*R(&n_px`|62>92)Vd;#H_G7Rc$kn^KfXhNI6aZvJw?qPs~iKz_fgR1|9xX z+IW3#@#WN5haR)2Zxo zHC%bS5`Tp;$m4;eNc?<&q%@htrJ>ElAJ6X z!F)>w;w<1%Qf1p<|8h#^U<#vRzv0?i<5$H=&|-^dp4F|p>5)Cxn%#IQ&*}hqZi>7J zH@#f_ZZ2yEYWPIZ{UQ={E71PI(N#^x-BnprxwGAT5vECA>WUfPMWYliYTcJz_4|ge z0gz}YR>_B#uVM%oc-}lP<6i#cWor+TqSKUcHsoWbHp=c(F=;G_M4uU#(B*Xz=wx0>aCd!k~`q4l&3~T*d#S343 zQzsKN<#pD_m0^-iaUQOJ4R681tqkdNJ~q#8$YZU2PpUZC{>u2b9rsO@0g2m62uB9G zp+lzrs=M+N;a&2ls85(ml^=(7*1XsyW4F(11#Ypu4{vDFoAa*d2j(B?+x@T=la57vxIoFaz~QwdoU4J9fYb#zrw zdA}`-G2)Z4}GT}_X6MmghY;Osm_@-M2?zeMH1ezd3D&9k7e; z0`NX&&lz*21scBve;o~p+zHgo`S-6Jo#?Y|`Mu+Fz#s7Z+qVlgxt|YBs{(lM$@6*y zC~5khDBq-Uhz|tr--!nV(6wh%qSJAf%3a znzwDZn?L8@n2Lbi^}5-0ZopD?uojz8lsTIpi+(FivL`1>vJg}Xjc2GOqt(4}+A2^Q z5~$>-8tx z_vGR44i$=d5*=R&kvSclChy%EW#h|*5s&Sh6J0yYix^VhI#BUwgC`6%CueKJVX15t?exczDM|jL z_>q(n=oP5!#m)}vMOX`ZYSE5R&bYWI(SB@7uQpY$?4LAziP9aF#~6{2XJ2pC_l5b$ zsf37jocfR!Q6}r(zyKE-mI53bp%Gz>AjzzJQxAtt&pr{ke_O+!6}>yC=&9RuK!;xW zc3XUN`GeJJ{+a1&;L=AqLhYzbWNG|v*6nKfFx%1?IfV7V(csYh*V3143}ug= zg}W{RCJ=QXg}u<<2aQo?>~|vRG<;uH9gFxNSEA^V`^@%A3178kto#a}%NnAXq^riG zq{LE4&130ZCqZ8%!{uUjPJj#)1JI}Pok-82p8n*M&m&H+9Xt4=c(exH^4q%+$6MwU z3T*4xE3i~?Hu12I{0}w5%Lu0mO^+^(&w%wTo}lL+x#*3Hj?X zFEc`<^v#_vYHnnEn3oYpU+&|+2^xRf^|lIqEqjyqej3xiPE_}yCfR#?eral_dfHSc z1MrC)uo&(s_$AFh80Kj+s93f38@6Fe$fwYLzT`et%11Znrl}LWZd_wsy}Lbb+{Uhr zlg2_qX=lK-QR03v+CiFFe|amO9~v;bK1804_+C$#4M)R`qnD%XaIQo$&QuMdrgSXwK)r!%fLVBpz5GGI(&HT%a{_g5?8>Q1h`Bq}nstKVZo_o$Gb)kia}h={ba({7XT* zN^Nm?&+CWP{^GI`qi|6MTKw<*ml?t8Uj`VkDa(kzn$;%~HTnLEQn;@p9b4CoOJtdk zgi6ncb-Skd8}iTQ0%@on7$a~~`UKyc%)!yZuH^EdHAVS7h4#0_w<97pG8_a!!?Zbp zq#Ol*^X+sBM1e4(i8kp?%hWGRP&SrFD^R;YHx_R&KV@pYvfxDm)Zz<{3NVs}yarf6 ziK;is;&rObHg?|k<`4|HILrZI3@LuPh|^!gDM62-%5~R{^P9W-u&xdW*sC4iYFq!F zKunQ+%;$n+L4d~4j0c zUUTM{#&tYY3Kc9iF+^^_HeJ_}$$-Sjwqbd1rT*$IxiNGYvpCv{PW0s0$uASsVgl-EJ(o{nX&7+q+ zfRkZ0(iFbv+6Cn@9f-d$5=#7Ie|3E;tISxx`}+z|p3s$Da;G?$cBZaS%7a#DLNiJ4 zlxd5d0E3ut_fPCU&g&+u0ZFVC&jd}&hSHF|0PJ-Y))XGE3FwEQNMtzY7w>gH!Z-P* zubKn;6Irp<-X}wE2W6~E9zUdTk-!sMkAeO@LrY`UA9VpqWENP5FJ$M|*BIFp4PXQ~ zYujbgq%9^l3rByCA5vNVMRlN$0C=S`2H5+madj!G=vdSzl_}t-5{dOVoqlINwi*Vd zE4-2r!m6@Q51Nn?uYxRTH_K>hUdH6w0ERulozZ-!A^ohY#Co{#_W?orQdqUBZAvl1 zBN6gOJN5mu#^1Zm^Y%&`eC)9+{J*`{BE`jS=Q@KezE_6>;V~@awh{q8c{(-Uc3lYUlf%vwl4;W0Lo4&R$)0Nf%& zDyE0uD@_JdVY!}L{UWuqzhLq_M#!MR`Q6sH6z$CikzbjA3G+|*T<%zd$Gy;{jZ=IF z>>E>?Do;6(V)2Gsbmy!A<;{lFQeDJv7W?(ur|bZ4%4|Mz0T8_oo+aP7rnm2;i=6as&Qj7Z{QRKMh;g6Oh?&?WWF^9^6#y{UG+e$s;YQLx*$jd)rRu zhwX8j(&mQxJW-Y!TjD$SPzJGVpF2~n?W>sU?;nzQASd5d#G&(ZqCS&Io@RbG$!`H5 zZE9#{8CSnfi_hg6#d&iM)jYjJT~_^J7*9%BZF+r#3udXZqC}w9#*iGNSCp(*Vr}o^ zm10-(L(2<4t|!8N!E;BnF-_~;QfemrP0GhFnqUW0_|7=LRx$X_hg9j4M=Or@Zo7@e z$Ah~iBO=oyCn4^8$UY@8k97g5f8Ra;Df%gS`0G&B0I~!D@}py%7(@6rpA}tlt`&{X zdOLD8oS*;RQ4_pbU$`PPu2bx_JzkAzJ!H_9js55Fd^%xgq4d9>e8}j)nZRXyi9aX( z{?;!HmiL_U6{AltWSp4sLL^udFMC98#u8ghe(|R|K(c?yt}`%rAN^U^Dx0^%raGt7 z+i(1ezHJ+U(R#=V9VKPE#c;CzU^t?HYLur8ke~7br{Pyak^)d%zdZW8as(f@E#` zERS$Q29LJ_x1~njPbYSL`5gHewSE~eyH0FC{GykRbFR>=nkO9wGN-t`Btfx?6&U3s zQY}_#`K?Kte@*_=M$$8CV%$vsVvU^&NO6T^n@7MG52F`u@HZ`3v^9|jcHwgb4Lev# zvr@7*etl0^{n#j$C}9Juyk~52BOi&$c595&a$Oa@Y4_Xt)~nJNpnrEY%w(K!Uy6eN z5p0ND722KuK}x;F`KaRdm5^0clKkkdkT3jvGp`JOia&x~c?*I?P1+RusekdP81V#5 z5XyUo>uygdsrhrM6x$UtFLy06)3QObx<*;=13-XWbW7S5BA*8l{ZSfJZDSnzM2-vD zgFuQ}^}nM9KJrA#0CvV8)IoYbxxUnA{GsCf#1|hu_aUj#<&M;QKv~M|w*Z|hTGwMn z@zeha!-I^UDs_gMQb{lsmkS&qL(vNaQFg`y>DxT|2^@UJHRl&y>C2oh5uhyR6=)e7 z2-yo;WCP9Vp-uwld}}6bI)v?B939`y=~{l?L$il~p3R$QrgQzy_V%@5*fiF<&sJg< z_(uunh?^W0d8-5J$}i7JZ(%U{jU-(z9dPZx^7)|_Ugb~zfx~I*7)vkM1-cp zGy%hi)<@6nDNBx!_72531BxE=;TTc^%b%q>G*c%=sQJLP(89|*eIJ?JR#BY`3$i07 zY#E&9h&6M~#DY);6Q5bDE)U_dQd0Mifr#PhZD>%i&oQm8JYd}(2n|>W4*1rHm+|WF zob9;UG`?hXd_Ly!fOFZ~)*f=UmV~4-$ozum0H0NTl9hYq8r@xFaWsHoDow9H8QX~- zG2D3>INIop1-L9Zebm&v?YQk&n7jNIU@}+7@qPu8!5HCZNLcxGSQfuF!YLgVk7l1V zruk4tcOC``Y!^Z1ioE~)@=}oef#C9pho<5)4`j7QY&Da-!Jgu1$BU%##~ZXr&oh9C z!dMF7cz;qQ365czQ0t8kXaabx%3G7zL)XvU+k)n*KcNcGC-Aw_xlxd`#%amkxc%dp%}5oh<;Mm z@xIj0zU+?8sanjdg$NX2Dl4b;OGjk|3kEti$`B$*D9zo9?i5#QZt?pjP|wk4*{9iH z*h3?xusi{&nOrwO-^4Yd034GpHr453|Fj6Mt%hw5)Asq*Fps%7 zR(+z!)zAv?$Kl9SAjlFxZYNa&*Prszro1*3m_MsaZvI39K3EIb<)Y28|{x&=O#5XLNfI^^rcdt?Uu}m+A=EmdHvd>|(dp>_5GW*ImpWOcDa9 z5CNltf#NSpm)D=aPn#ZP(}?0RIKG&@Fatq6yd*&|zV>bTE%}Xz`{pO%0?l;+bJp?{ z5bsf9A#7_Vd(`u6>HWt6f~FkY`~gbu8zfw2QHm~r<=fWuq%tu+ue(nZ`;K|!{)YZm z)x9`tFy_ZL6Ze){ca z9T|1ZCe9+$>8Le@5<_C+StPNH-H|wjo(!7zH;HQ#Tvof=S*sj|3WkLBXKAxp~cAa8NeEo zJl(YCI>db0#{A3yK0lwF6Af+{Ou@?kLpN-fBExt}KdQ@K9U*tBM))xYtO2**9|8T6 zKO$P?U232|JU|_l=vWJ6(`R^09`CpTE4u?e8neR_K`?uG>sOzR_^*?_HxfHtL)L!y z7?8qJ$ZeSPUUdohIQ{3gJF7OksHT%SM*CnJt?oaH?%hpuCk4Ll0gw~(k`LyjP$qKJ z0+Xva(G3Bw6+#s^X^m!WnOj$CRsG4FO$xmOqJlS+kd@crb_b!s63hhWUqd*5$C3$L z00D)!@`x4U|L?zUEi@2$0Qy2_oMxJ=6Tmt5OZu-8$n*&qy2;9Gc6$IVUbQN9Z-7?g zL&GcFAPE;GwM%mgPCbn4-1e>o#vt=EpkD`UgbgKT?lb1W$o&pdfyT~0aIMe(s_xAH zp^E>$pOO?ZmO^B!5V9mhmN2MP_ASPm$S!2e82d6pv{80S_8DbohLWu;LyWPnG0bE) zmSMQg^u2z#?&}}8@B63uY36a}e3tWhzuvFc^MuHMdGHrLwLke=hQDiTg#nkKdAK{5 z5yh@i=V|L)zAsm?lJ!cM)4`PgDCcR{Sc7>v)eCd!C+;OQN)0zra-8UK@B4)iFOK*{ zlR|OWN8ZuW=7#0k?B-h9=bKe&{hw&tCqY-fz^80e2BwEeUq0GnHAqVYd+N_$Otj0K zA9Dtk?`Za%S}vvKPmH2-u-oLEd&}a>=mI-po99v8Yb-s>o?4O%e@LY}w?A3P<#3$U5Ac1)6YDXb4zVdU>--wIc=Gd0WH@!dzNo0}}nj6NNA1wL}pL1t=Afjdu>$iRz7}%4z##p%g^bDI1 ziw8qZGNV?3fI`B=q2CpFeOv|deywRHLqgH!aWE1d&JI{N4t@@P}NOf6hm}{H*Eq!nL zCM!#O;&vHOAq^5Elt1$$Wp%nJ5max$$+y9GI;xfYOA75tM+G!36ZE{q-OPstqG}(F zO|XYK$3)DzzuAUBXJY2DHN}PY2$ECLqIi4~2BsH59aQvmEGrcqEC?l-+^V)5;}cb$ z3i0=+Q3yCF!b3AKq2`v-Dn`#4N}l1NtIyJ+Oyva}?2vm*>-3mDAsOIl>6JUMj54@BpU(mD2X@87)%lAuv;@t@$+Lh+J z!AXq22bQ4C(cI=>=-{b~0Y<@AXOVk!0>SUlcIN&-JM$axG1*rsNJ|~Pe34|kFy!<5 zuEHuS;u`Dm3yFaHkhquR6Y??SAv`|Qd7CWj)hBqIq(JhwJG77p&0`t~a7&nL6w9Ig zb2-oNe@)lPt!$&(c4}rLQLRX7)p@mmc3yX6v+wdLFL|J>R;PxNNd_E(3J>Y09z~$ z6Q6JuhYnWULcfFVg%M1}Uy~ef48jh2LdeCtndCxEcN0OMwDn3LT@42xb7zcLca#iQ zR)>6Y%BwRhsk78664Q@8qVKMvU*De03UcfFYM7`G#tVKgbz@p3fu7<9J zY&ACwj+7T}CvSs1^pM*e6OVElj4m-G3U*`~UjBHdUg^Vj(W^7dE{xZi`Oe~Z9d0b1 zV0z^-3Wva1oV!)(La7E3mVpg2)UG`@_yg(0!b64gI(={EfisbTVi#7lY9DuWfGa>O z$g^cbs#ej5B=j$`Ey!tSux1md*^EgGdE%=i9JLF|S6w8ZN=~_w3qgV(L|%fvF1ybL z8kR|o;ZPpgO&u9w@KIuBPu>N*s@K|6Q~Z*Q%(T*&>*#J;1<|e(S2TuJg`Rba6fDym z`qm_?@!V0c29O0}`YDv2h*$9;K6w;bOFm#$xTJUS>)$M!tS)rj!xmBtnUyQM^6?G5 zhcRwkR%3_1s=@{`CI|o46SH-BJ&MAVm=%9~`=V)@; zk9#-t!{YzQRW!Ue>9>oG@GojpWT!v8jjc-rVY+%>YB&rx>#$vUteN;};pg`>Sy$AI zM7^ieR91#t!^1ba;}hnr=N?+IQYX0{c9l0|XHc0rd@SwFabsVgSo~&Sh-kZWr9Ku1 zdh8;@(HmAYrgFOP8C^_q>? zXy-di61Gdciolo0eHUrTlj%Q8#4Q4`$h>dCyTR(H&9zWeB&vM0Z5X80XMr$Re;QdD zN?hKpIX9%a!pF}W++YvHQDgk{w}Kaa0Rypm)3$G8I2 zc36d$`ATpi?|L{N%efXedl+qT)x+(%*b~kGvzb6oipP$z{zY@fp`$`BFfq@YXi&73 z7HV$KgD_QS44z*Y!WSD(0w5Zte_rF2rc~Y<=fL z%KcO8mz5G(h{f2?+|0IK=sB+O^e?!ZBDT>Fa&`rNM2O5E(ONB!c2#~DO_APUw?|8( zH}+%dA)2weJ-6Poc@2soo?f+15|#toTGHlh`S_{&+*&}ZGkYbJ)K(poL@C9k+ksAU zyz1LYJTKa7 zJ^IsKCiXecyt-O}f%S253?ddZhjh$UPdu#`AFbv^N`giA17tMEL}6rgcbeq+mi7gl zi}rq4Oi(XBI@$Bxcq>S}+y!M8OBlN{cTFis$HkC;C<2R)#aIuC9)ptN^c z&-Zg_kITN66B5XfpAF?Gs5oLc(cxDe-@i0@{bcR~RPCZ(k0J9%dVZ2o3-oz&I_6n0 zg6TlDcH*K#{F^m-!yphlN)+rNXf@MjfsAPR26|!c?t~91>X?zwAY4hDfGs58R97dr zEub@@4?*mJ^YpciFsHn|KpaP&jGgL_+u+;_?yc`Z=_hg$;(Bjy>|F2T^PrkemBe+F z*@Fe6fAU@Wp*^L*OA6l76Bv(6WZU^re5{nYf$1?Xkoy3&BPE^g$(s8@;WX`Uj1%Fq znOzDf>mepYWQ)gNqOmOZvalG0y^6(IyA#_xhf9-`z<6Y%uHR{-WYrAqP1}(KzPjCp zj5YO9tFlD$W%RVllXDfk|ENeP@Tuat#1>If>{vKt;sm~ERx817Z75E6Ijkc9x0T>I zxD@VQCx4@5k&a#wW^E}i_8dHRBt=n`qM`f?1f%qQ z4lx9|5}-Ah>MVz3xXzWxVb|~*yGo)s%8_Idq@#cQ8eT5egH+G;7HW^~1!=bQ0k+JR z+SbY-?;&Bs?qF*?uP{@T3Gwsk7fu>Y9uj7&Ce}s7&smr-J2!N0H;>nV9<6^_v*pvS zik2npWSGd{5=Vj5;``)Wa`R*vG^fhGBaM-W*$tfjM7Hs>>1f9zz|I^`@_Uq{CQ8Y>EFge>5IFvP}Cv%7Ta+-g_WJj(C3pQA}J0lE3mW4#ypiZxy`Q_UbFdHAHa2uEDor<(fMpIG}T zGj>SlL|}QwPtca?#P?gPX_Y6I`ALj}sE>X*+D)7vw z-_Y;km9ru|sD=46X`4lj{=HyZtH8lLys?q4c%(u|Nl~Fs8auG6Qg1Hk#r#kwH%?^_ zgE3;7NpEtwp0&Sli`o&1{!Y)sx61E$lJD!b`^qldDZf-3jNI95bM;hpB0pqbDKeb9 z5NMpHs$V^G*Gd)1efg0bj9%CJNmD*N)mQxKEBHE3`mu+hK@#)d)q~#E8)1jUu*m~F zKwrpz+q|35>=p|6ZkmJfrFQ1qPV8^)veESW^#5J^3%LNuYj8K5kW47JJ48EE8??ii z!>)Ak3wy%@t@8sqXq?TIW86i(uX#Ps9K<5t`YsAuCw|iDupG1|mmH;e;ras5y;Wx} zu|A~ViF*)b8IhN{J18M#d+!~^$>m)BI8f}P7N`;0QWIB;5){q_o{bHv9_wMc{LJ)v=IB0B)1292TA#?$A1t>0yb7Bk5uBLTJX;%W-qQh}PlBi1b zcwpAbA>aA@6QsA8;@-)N478WSQqh`;FM*oDfEDPhHBrhJ=++o|mw&b(sB$b=z_kf!s)$P}n8{0#qklXESOR zy28^)8_|CMUf~QMx8mQGP`peG2j{Y1NFT<)de7_nRQ!~X{KKvv zFC4$u9Put?Dq!FNOQ@QMm2HW`uegeqyr6eFS%mZ6uDp`1&#eZ1Rad73PmA9D>@(g) z8af{vt6w*I$x)zIOi&q^wq>rY4VX1LjG_n74K02t5^O7F?msGy^b8)6?+_Re@N4C` z^3w|i^2`1mV7<;1YN*=?XcKy>#0#+r9!pJt0n@1q-gHPMcc}-q^SN>x!mP}+#AgLx z!Q0MRa!2LqoxSW1Yj4`e3uqeSHd_1XYN@(0@mIV=vaLzFQ-Y=SvRYPXb}*#bt0EJ3 zZ0Y8q-TUm?L8-s2%p8#hGWDN46}wE+7H>$C_O9DfU6$kabkySOqV=;YGS6%-t)!9i zxNIlu$*}o%mZ`R$jkMg7f29OCz(osRdzV(|gHyFr~juT(3 zolWreKIZd~JGT*~AOmCaB^sz0_9rILcU)^Zi8Bwltem_YZiG{$ILF-U=TmK7)EZR8 z-~sV=e8E|0-)g-RF!COv=&4*Y?Od$?{5wbZ!n-9#tkZOAVn^pLA&f>?_#t%YyZ()J z*nfR7+KFw~H7n4PrRX%(>w&j758&5)p`z|(f;GUWu^UowiETY0io?;2m_M2!x& z$yiCx_H8-cL#F|8j*d5)4;JeDL2~#md~j6~&k1=JKPxvXP`j^Uy$l|I-ZDCKG|Hie z`yXIXXFiQ>XyyD9L(iJ2CkanV#e2eXmO$rOM8JZT1R2a@gGkmF7`{B`6CY=N8e@#`P{P3IS+%uqqQX(r7zhjT+ol5k~b zKv?HG*|w?gh^~Jt$zLyAb^Vczx}Z<@^<>b=s(UkrLheeBzBpFSFjF5#1!aGM)!kwX zfPTV075ZPvS=`ZGBN6HIEh+y^!Hbm1e470`R~O9c0O43^JND%Ed_Vu4#v|p<-apG1 zzOnsb0!MmZ;?3R@cH9P-j!~7Hv~E`oQ?=^Q_eXDi+cJVyD%pC$KW^iUiXxr*&_s`l zu(7d83&Fm8`*>==qVvz-eE!61+6Kq+t|c-69Im6yu=B=3(URfRImjx^vY4ec(`W^= z+1mq@op=GDNju*FqQu#wLQ>9dJsM=PY#?<;__`zuRnMPAQ(6MbWB?h z{?A0J9w_Sty^VxP2^DP6GT^ngdd9s43ex^%umbadmYrs{2Q> zM3>Fv?*m{>dvn-CZAmaW1-;R?mj9rgVw%Gjj`E~Bx1>@2UO zv{&lr(8JB4+NSC~0AxpTieBsfG0VlS9(@%mLQ~s{X&C^tjrU0LGvk+axYv8O?7wWv<3<>3yT_Er)%t#Aj=_r<3&NDGA3?_w`F7I?Cu}NA;`qF< ztcoVlh8}An%Ioxz9}hERN4sGpO2B&T z#@JuJ>j%i-uj8aEH&j`XsS#5E(j{I%OD^R?+36gHcPTPgpi2{FuKt)r0fUil*L{R$ zCORSu3c4KCym`(qMOtx6&huPAi=@Zo3x;_3=uk}Ve=x!zUdi4bO4|J=_Teu(;% z?#I2?wqjP~bZB~XJu}g-{ly(d=6um-a~Pll8vh~jbUTN$_A|jBku!tIFbI}2j0nlu z=s=Qcx8x5*6JBxi00)IL@jlUAWVxcedv*z0w!E*0@qJfBb}H+mvv}T+ito8y@>Nq7 z?aL^iOxQfPK)Hv!;;3SoUG_DlRimSrDV9+t`%`q845JHgi;21`A&0~G&8j4d?;}{f z*EKKJO3{q;OrEmVOYw@yEsYD(@cbU|l3HPBi5NxOOHGhVAc3j{lU=9LxFlfQ=`47_ zvnhLxAWVm?vxxpb1cd+p03i+(U4T{Ve{=JdphUh>p&UBA8}WC2Ax~e(t0wfe2H)Qkr-G2mufX^bC6?Pqi~A%gq~h#h4^t1tQ1UuKw0oB0GUoeMY>`ggq}BgxWp zSZyhuzgGNJ_-$ac<~wwfHHHrUe2>eB8zZnO59jhVWhPtoN#RX*E&vRBX=Ui2j~m@m z38IU5(=g06I>7&#bJUQO&^uQ - net461 + net5.0-windows WinExe - ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset + false true true - - - minorieditorshellcsharp.ruleset - - - torisankitsune_minorieditorshell2csharp.ruleset - - diff --git a/Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.ruleset b/Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.ruleset deleted file mode 100644 index b327e534..00000000 --- a/Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.ruleset +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Demos/MinoriDemo/MinoriDemo.WpfCore/App.xaml b/Demos/MinoriDemo/MinoriDemo.WpfCore/App.xaml deleted file mode 100644 index 55644a02..00000000 --- a/Demos/MinoriDemo/MinoriDemo.WpfCore/App.xaml +++ /dev/null @@ -1,10 +0,0 @@ - - - - \ No newline at end of file diff --git a/Demos/MinoriDemo/MinoriDemo.WpfCore/App.xaml.cs b/Demos/MinoriDemo/MinoriDemo.WpfCore/App.xaml.cs deleted file mode 100644 index 3c8d6757..00000000 --- a/Demos/MinoriDemo/MinoriDemo.WpfCore/App.xaml.cs +++ /dev/null @@ -1,14 +0,0 @@ -using MinoriEditorShell.Platforms.Wpf; -using MvvmCross.Core; -using MvvmCross.Platforms.Wpf.Views; - -namespace MinoriDemo.WpfCore -{ - /// - /// Interaction logic for App.xaml - /// - public partial class App : MvxApplication - { - protected override void RegisterSetup() => this.RegisterSetupType>(); - } -} \ No newline at end of file diff --git a/Demos/MinoriDemo/MinoriDemo.WpfCore/AssemblyInfo.cs b/Demos/MinoriDemo/MinoriDemo.WpfCore/AssemblyInfo.cs deleted file mode 100644 index 41b0c858..00000000 --- a/Demos/MinoriDemo/MinoriDemo.WpfCore/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Windows; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SimpleDemo.WPF")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SimpleDemo.WPF")] -[assembly: AssemblyCopyright("Copyright © 2019")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/Demos/MinoriDemo/MinoriDemo.WpfCore/MainWindow.xaml b/Demos/MinoriDemo/MinoriDemo.WpfCore/MainWindow.xaml deleted file mode 100644 index 719c4c9d..00000000 --- a/Demos/MinoriDemo/MinoriDemo.WpfCore/MainWindow.xaml +++ /dev/null @@ -1,14 +0,0 @@ - - - - \ No newline at end of file diff --git a/Demos/MinoriDemo/MinoriDemo.WpfCore/MainWindow.xaml.cs b/Demos/MinoriDemo/MinoriDemo.WpfCore/MainWindow.xaml.cs deleted file mode 100644 index b8579e8f..00000000 --- a/Demos/MinoriDemo/MinoriDemo.WpfCore/MainWindow.xaml.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace MinoriDemo.WpfCore -{ - /// - /// Interaction logic for MainWindow.xaml - /// - public partial class MainWindow - { - public MainWindow() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/Demos/MinoriDemo/MinoriDemo.WpfCore/MinoriDemo.WpfCore.csproj b/Demos/MinoriDemo/MinoriDemo.WpfCore/MinoriDemo.WpfCore.csproj deleted file mode 100644 index b79ed68f..00000000 --- a/Demos/MinoriDemo/MinoriDemo.WpfCore/MinoriDemo.WpfCore.csproj +++ /dev/null @@ -1,29 +0,0 @@ - - - - WinExe - netcoreapp3.1 - false - true - ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - \ No newline at end of file diff --git a/Demos/MinoriDemo/MinoriDemo.WpfCore/Views/MainView.xaml b/Demos/MinoriDemo/MinoriDemo.WpfCore/Views/MainView.xaml deleted file mode 100644 index fa389e12..00000000 --- a/Demos/MinoriDemo/MinoriDemo.WpfCore/Views/MainView.xaml +++ /dev/null @@ -1,22 +0,0 @@ - - - - /// An instance of MvxApplication - protected override IMvxApplication CreateApp() + protected override IMvxApplication CreateApp(IMvxIoCProvider iocProvider) { - _messenger = Mvx.IoCProvider.Resolve(); + _messenger = iocProvider.Resolve(); Properties.Settings.Default.PropertyChanged += (s, e) => { MesSettingsChangedMessage message = new MesSettingsChangedMessage( @@ -155,9 +156,9 @@ protected virtual MvxBindingBuilder CreateBindingBuilder() /// Used to ensure plugins are loaded. /// /// returns base manager - protected override IMvxPluginManager CreatePluginManager() + protected override IMvxPluginManager CreatePluginManager(IMvxIoCProvider iocProvider) { - IMvxPluginManager manager = base.CreatePluginManager(); + IMvxPluginManager manager = base.CreatePluginManager(iocProvider); manager.EnsurePluginLoaded(); return manager; } @@ -177,7 +178,7 @@ protected virtual IMesAvnViewPresenter CreateViewPresenter(ContentControl root) return new MesAvnViewPresenter(root); } - protected virtual IMvxViewsContainer CreateViewsContainer(IMvxIoCProvider iocProvider) + protected override IMvxViewsContainer CreateViewsContainer(IMvxIoCProvider iocProvider) { if (iocProvider is null) throw new ArgumentNullException(nameof(iocProvider)); @@ -210,7 +211,7 @@ protected virtual void InitializeBindingBuilder(IMvxIoCProvider iocProvider) { RegisterBindingBuilderCallbacks(iocProvider); var bindingBuilder = CreateBindingBuilder(); - bindingBuilder.DoRegistration(); + bindingBuilder.DoRegistration(iocProvider); } protected void InitializeFirstChance(IMvxIoCProvider iocProvider) @@ -227,9 +228,9 @@ protected void InitializeLastChance(IMvxIoCProvider iocProvider) /// Sets up the dictionary that connects the viewmodel to the view. /// /// - protected override IDictionary InitializeLookupDictionary() + protected override IDictionary InitializeLookupDictionary(IMvxIoCProvider iocProvider) { - IDictionary container = base.InitializeLookupDictionary(); + IDictionary container = base.InitializeLookupDictionary(iocProvider); container.Add(typeof(MesSettingsManagerViewModel), typeof(MesSettingsView)); container.Add(typeof(MesGeneralSettingsViewModel), typeof(MesGeneralSettingsView)); return container; @@ -257,10 +258,10 @@ protected virtual void RegisterPresenter(IMvxIoCProvider iocProvider) /// This is the main initializer for the kit. Call or over-ride this simualr to any other MvxWpfSetup setup /// /// - public class MesAvnSetup : MesAvnSetup where TApplication : class, IMvxApplication, new() + public abstract class MesAvnSetup : MesAvnSetup where TApplication : class, IMvxApplication, new() { public override IEnumerable GetViewModelAssemblies() => new[] { typeof(TApplication).GetTypeInfo().Assembly }; - protected override IMvxApplication CreateApp() => Mvx.IoCProvider.IoCConstruct(); - protected override IMvxViewsContainer CreateViewsContainer() => base.CreateViewsContainer(Mvx.IoCProvider); + protected override IMvxApplication CreateApp(IMvxIoCProvider iocProvider) => iocProvider.IoCConstruct(); + protected override IMvxViewsContainer CreateViewsContainer(IMvxIoCProvider iocProvider) => base.CreateViewsContainer(iocProvider); } } \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs index 40cacd1a..016d82cd 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs @@ -1,4 +1,5 @@ using Avalonia.Controls; +using Microsoft.Extensions.Logging; using MinoriEditorShell.Platforms.Avalonia.Presenters.Attributes; using MinoriEditorShell.Platforms.Avalonia.Views; using MinoriEditorShell.Services; @@ -22,8 +23,8 @@ namespace MinoriEditorShell.Platforms.Avalonia.Presenters /// public class MesAvnViewPresenter : MvxAttributeViewPresenter, IMesAvnViewPresenter { + private static readonly ILogger _log = MvxLogHost.GetLog(); private Dictionary> _frameworkElementsDictionary; - private IMvxLog _log; private IMesAvnViewLoader _wpfViewLoader; diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesThemeManager.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesThemeManager.cs index d14b482c..3b930488 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesThemeManager.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Services/MesThemeManager.cs @@ -1,3 +1,4 @@ +using Microsoft.Extensions.Logging; using MinoriEditorShell.Extensions; using MinoriEditorShell.Messages; using MinoriEditorShell.Services; @@ -14,18 +15,17 @@ namespace MinoriEditorShell.Platforms.Avalonia.Services { public class MesThemeManager : IMesThemeManager { + private static readonly ILogger _log = MvxLogHost.GetLog(); // IOC private readonly IMvxMessenger _messenger; - private readonly IMvxLog _log; public IEnumerable Themes { get; private set; } public IMesTheme CurrentTheme { get; private set; } - public MesThemeManager(IMvxMessenger messenger, IMvxLogProvider provider) + public MesThemeManager(IMvxMessenger messenger) { - _log = provider.GetLogFor(); _messenger = messenger; Themes = Mvx.IoCProvider.GetAll(); @@ -77,7 +77,7 @@ public Boolean SetCurrentTheme(String name, Boolean applySetting) // appTheme.EndInit(); }); - _log.Info($"Theme set to {name}"); + _log.LogInformation($"Theme set to {name}"); // publish event _messenger.Publish(new MesThemeChangeMessage(this, CurrentTheme.Name)); @@ -92,7 +92,7 @@ public Boolean SetCurrentTheme(String name, Boolean applySetting) } catch (Exception e) { - _log.InfoException("Log Theme Setting", e); + _log.LogInformation(e, "Log Theme Setting"); return false; } } diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/Core/MesWpfSetup.cs b/Modules/MinoriEditorShell.Platforms.Wpf/Core/MesWpfSetup.cs index c721b492..dee1d9d3 100644 --- a/Modules/MinoriEditorShell.Platforms.Wpf/Core/MesWpfSetup.cs +++ b/Modules/MinoriEditorShell.Platforms.Wpf/Core/MesWpfSetup.cs @@ -38,7 +38,7 @@ public abstract class MesWpfSetup : MvxWpfSetup protected override IMvxWpfViewPresenter CreateViewPresenter(ContentControl root) { // This handles main window. - return new MesWpfViewPresenter(root); + return new MesWpfViewPresenter(root); } /// diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/Presenters/MesWpfViewPresenter.cs b/Modules/MinoriEditorShell.Platforms.Wpf/Presenters/MesWpfViewPresenter.cs index acc2920d..9ddfd0a1 100644 --- a/Modules/MinoriEditorShell.Platforms.Wpf/Presenters/MesWpfViewPresenter.cs +++ b/Modules/MinoriEditorShell.Platforms.Wpf/Presenters/MesWpfViewPresenter.cs @@ -17,18 +17,18 @@ namespace MinoriEditorShell.Platforms.Wpf.Presenters /// /// Main presenter that allows document and tools to naviage to MesDocumentController /// - public class MesWpfPresenter : MvxWpfViewPresenter + public class MesWpfViewPresenter : MvxWpfViewPresenter { - private readonly ILogger _log; + private readonly ILogger _log; /// /// Main constructor for the presenter, this gets the main window. /// /// - public MesWpfPresenter(ContentControl mainWindow) : base(mainWindow) + public MesWpfViewPresenter(ContentControl mainWindow) : base(mainWindow) { // New style logging can return nulls - _log = MvxLogHost.GetLog(); + _log = MvxLogHost.GetLog(); _log?.LogTrace("Setup: Creating Presenter"); // Setup main window as singleton From 2891656e5b7af9308e12f6ed015c41125cfd59dd Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sat, 31 Jul 2021 22:36:33 -0400 Subject: [PATCH 34/68] Fix logging --- .../SimpleDemo.Avalonia/App.axaml.cs | 2 +- Demos/SimpleDemo/SimpleDemo.Avalonia/Setup.cs | 11 +++++++ .../SimpleDemo.Avalonia.csproj | 2 ++ .../Presenters/MesAvnViewPresenter.cs | 29 ++++++++----------- 4 files changed, 26 insertions(+), 18 deletions(-) create mode 100644 Demos/SimpleDemo/SimpleDemo.Avalonia/Setup.cs diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml.cs b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml.cs index 0395f2e4..e3fae023 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml.cs +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml.cs @@ -10,7 +10,7 @@ namespace SimpleDemo.Avalonia public class App : MesApplication { public override void Initialize() => AvaloniaXamlLoader.Load(this); - protected override void RegisterSetup() => this.RegisterSetupType>(); + protected override void RegisterSetup() => this.RegisterSetupType(); public override void OnFrameworkInitializationCompleted() { diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/Setup.cs b/Demos/SimpleDemo/SimpleDemo.Avalonia/Setup.cs new file mode 100644 index 00000000..97246a2e --- /dev/null +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/Setup.cs @@ -0,0 +1,11 @@ +using Microsoft.Extensions.Logging; +using MinoriEditorShell.Platforms.Avalonia; + +namespace SimpleDemo.Avalonia +{ + internal class Setup : MesAvnSetup + { + protected override ILoggerFactory CreateLogFactory() => LoggerFactory.Create(b => b.SetMinimumLevel(0).AddSimpleConsole(o => o.SingleLine = true)); + protected override ILoggerProvider CreateLogProvider() => null; + } +} \ No newline at end of file diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj b/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj index 3b0e2eae..c55e805a 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj @@ -11,6 +11,8 @@ + + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs index 016d82cd..4fde17ca 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs @@ -39,14 +39,12 @@ public MesAvnViewPresenter(ContentControl contentControl) : base() FrameworkElementsDictionary.Add(contentControl, new Stack()); - IMvxLogProvider provider = Mvx.IoCProvider.Resolve(); - _log = provider.GetLogFor(); - _log.Trace("Setup: Creating Presenter"); + _log.LogTrace("Setup: Creating Presenter"); // Setup main window as singleton if (contentControl is IMesWindow mesWindow) { - _log.Trace("Setting IMesWindow to main window"); + _log.LogTrace("Setting IMesWindow to main window"); Mvx.IoCProvider.RegisterSingleton(mesWindow); } } @@ -86,7 +84,7 @@ public override async Task Close(IMvxViewModel toClose) if (FrameworkElementsDictionary.Any(i => i.Value.Any() && (i.Value.Peek() as IMesAvnView)?.ViewModel == toClose) && await CloseContentView(toClose)) return true; - _log.Warn($"Could not close ViewModel type {toClose.GetType().Name}"); + _log.LogWarning($"Could not close ViewModel type {toClose.GetType().Name}"); return false; } @@ -94,11 +92,11 @@ public override MvxBasePresentationAttribute CreatePresentationAttribute(Type vi { if (viewType.IsSubclassOf(typeof(Window))) { - _log.Trace($"PresentationAttribute not found for {viewType.Name}. Assuming window presentation"); + _log.LogTrace($"PresentationAttribute not found for {viewType.Name}. Assuming window presentation"); return new MesWindowPresentationAttribute(); } - _log.Trace($"PresentationAttribute not found for {viewType.Name}. Assuming content presentation"); + _log.LogTrace($"PresentationAttribute not found for {viewType.Name}. Assuming content presentation"); return new MesContentPresentationAttribute(); } @@ -115,7 +113,7 @@ public override MvxBasePresentationAttribute GetOverridePresentationAttribute(Mv if (presentationAttribute == null) { - _log.Warn("Override PresentationAttribute null. Falling back to existing attribute."); + _log.LogWarning("Override PresentationAttribute null. Falling back to existing attribute."); } else { @@ -221,7 +219,7 @@ protected async Task ShowContentView( // Add to manager model manager.Documents.Add(docViewModel); - _log.Trace($"Add {document} to IMesDocumentManager.Documents"); + _log.LogTrace($"Add {document} to IMesDocumentManager.Documents"); return true; case IMesTool tool: @@ -231,11 +229,11 @@ protected async Task ShowContentView( // Add to manager model manager.Tools.Add(toolViewModel); - _log.Trace($"Add {tool} to IDocumentManager.Tools"); + _log.LogTrace($"Add {tool} to IDocumentManager.Tools"); return true; default: - _log.Trace($"Passing to parent {view.ViewModel}"); + _log.LogTrace($"Passing to parent {view.ViewModel}"); var contentControl = FrameworkElementsDictionary.Keys.FirstOrDefault(w => (w as MesWindow)?.Identifier == attribute.WindowIdentifier) ?? FrameworkElementsDictionary.Keys.Last(); @@ -249,12 +247,9 @@ protected async Task ShowContentView( } catch (Exception exception) { - if (_log == null) - { - _log = Mvx.IoCProvider.Resolve(); - } - _log.ErrorException("Error seen during navigation request to {0} - error {1}", - exception, request.ViewModelType.Name, exception.ToLongString()); + + _log.LogError(exception, "Error seen during navigation request to {0} - error {1}", + request.ViewModelType.Name, exception.ToLongString()); throw; } } From 4d48b0f9b66e48a222f0b4e88f44387ff61dfbf4 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sat, 31 Jul 2021 22:51:49 -0400 Subject: [PATCH 35/68] Restore mainwindow --- .../MinoriDemo/MinoriDemo.RibbonWPF/MainWindow.xaml | 12 ++++++++++++ .../MinoriDemo.RibbonWpf/MainWindow.xaml.cs | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 Demos/MinoriDemo/MinoriDemo.RibbonWPF/MainWindow.xaml diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MainWindow.xaml b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MainWindow.xaml new file mode 100644 index 00000000..668aa875 --- /dev/null +++ b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MainWindow.xaml @@ -0,0 +1,12 @@ + + + + diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpf/MainWindow.xaml.cs b/Demos/MinoriDemo/MinoriDemo.RibbonWpf/MainWindow.xaml.cs index bcf91ef8..8187a5bc 100644 --- a/Demos/MinoriDemo/MinoriDemo.RibbonWpf/MainWindow.xaml.cs +++ b/Demos/MinoriDemo/MinoriDemo.RibbonWpf/MainWindow.xaml.cs @@ -1,4 +1,4 @@ -namespace MinoriDemo.RibbonWPF +namespace MinoriDemo.RibbonWPF { /// /// Interaction logic for MainWindow.xaml @@ -7,4 +7,4 @@ public partial class MainWindow { public MainWindow() => InitializeComponent(); } -} \ No newline at end of file +} From 6ca7aa13c042d4bf770967a2373df1784a92fb25 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sat, 31 Jul 2021 23:03:16 -0400 Subject: [PATCH 36/68] remove sonar --- .sonarlint/MinoriEditorShell.slconfig | 15 - .../CSharp/SonarLint.xml | 89 ----- ...ankitsune_minorieditorshell2csharp.ruleset | 372 ------------------ .../MinoriDemo.Core/MinoriDemo.Core.csproj | 4 - .../MinoriDemo.RibbonWPF.csproj | 4 - .../MinoriDemo.RibbonWpf.csproj | 4 - .../MinoriDemo.WPF/MinoriDemo.WPF.csproj | 4 - .../MinoriDemo.Wpf/MinoriDemo.Wpf.csproj | 4 - .../SimpleDemo.Avalonia.csproj | 3 - .../SimpleDemo.Core/SimpleDemo.Core.csproj | 4 - .../SimpleDemo.RibbonWPF.csproj | 4 - .../SimpleDemo.RibbonWpf.csproj | 4 - ...inoriEditorShell.Platforms.Avalonia.csproj | 4 - .../MinoriEditorShell.Platforms.Wpf.csproj | 4 - .../MinoriEditorShell.Ribbon.csproj | 4 - ...orShell.VirtualCanvas.Platforms.Wpf.csproj | 4 - .../MinoriEditorShell.VirtualCanvas.csproj | 4 - .../MinoriEditorShell.csproj | 4 - .../MinoriEditorShell.ruleset | 5 - 19 files changed, 540 deletions(-) delete mode 100644 .sonarlint/MinoriEditorShell.slconfig delete mode 100644 .sonarlint/torisankitsune_minorieditorshell2/CSharp/SonarLint.xml delete mode 100644 .sonarlint/torisankitsune_minorieditorshell2csharp.ruleset delete mode 100644 Modules/MinoriEditorShell/MinoriEditorShell.ruleset diff --git a/.sonarlint/MinoriEditorShell.slconfig b/.sonarlint/MinoriEditorShell.slconfig deleted file mode 100644 index 5d7651c6..00000000 --- a/.sonarlint/MinoriEditorShell.slconfig +++ /dev/null @@ -1,15 +0,0 @@ -{ - "ServerUri": "https://sonarcloud.io/", - "Organization": { - "Key": "torisankitsune-1", - "Name": "torisankitsune-1" - }, - "ProjectKey": "TorisanKitsune_MinoriEditorShell2", - "ProjectName": "MinoriEditorShell", - "Profiles": { - "CSharp": { - "ProfileKey": "AXfBiG4ncmi_3V30EHaZ", - "ProfileTimestamp": "2021-03-03T08:15:39Z" - } - } -} \ No newline at end of file diff --git a/.sonarlint/torisankitsune_minorieditorshell2/CSharp/SonarLint.xml b/.sonarlint/torisankitsune_minorieditorshell2/CSharp/SonarLint.xml deleted file mode 100644 index 21acd70e..00000000 --- a/.sonarlint/torisankitsune_minorieditorshell2/CSharp/SonarLint.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - - - sonar.cs.analyzeGeneratedCode - false - - - sonar.cs.file.suffixes - .cs - - - sonar.cs.ignoreHeaderComments - true - - - sonar.cs.roslyn.ignoreIssues - false - - - - - S107 - - - max - 7 - - - - - S110 - - - max - 5 - - - - - S1479 - - - maximum - 30 - - - - - S2342 - - - flagsAttributeFormat - ^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?s$ - - - format - ^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?$ - - - - - S2436 - - - max - 2 - - - maxMethod - 3 - - - - - S3776 - - - propertyThreshold - 3 - - - threshold - 15 - - - - - \ No newline at end of file diff --git a/.sonarlint/torisankitsune_minorieditorshell2csharp.ruleset b/.sonarlint/torisankitsune_minorieditorshell2csharp.ruleset deleted file mode 100644 index c09d91fd..00000000 --- a/.sonarlint/torisankitsune_minorieditorshell2csharp.ruleset +++ /dev/null @@ -1,372 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Demos/MinoriDemo/MinoriDemo.Core/MinoriDemo.Core.csproj b/Demos/MinoriDemo/MinoriDemo.Core/MinoriDemo.Core.csproj index f596f2de..eb3d96c2 100644 --- a/Demos/MinoriDemo/MinoriDemo.Core/MinoriDemo.Core.csproj +++ b/Demos/MinoriDemo/MinoriDemo.Core/MinoriDemo.Core.csproj @@ -11,10 +11,6 @@ - - - - all diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.csproj b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.csproj index 9cec42a7..49fbe740 100644 --- a/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.csproj +++ b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.csproj @@ -11,10 +11,6 @@ - - - - diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpf/MinoriDemo.RibbonWpf.csproj b/Demos/MinoriDemo/MinoriDemo.RibbonWpf/MinoriDemo.RibbonWpf.csproj index 9cec42a7..49fbe740 100644 --- a/Demos/MinoriDemo/MinoriDemo.RibbonWpf/MinoriDemo.RibbonWpf.csproj +++ b/Demos/MinoriDemo/MinoriDemo.RibbonWpf/MinoriDemo.RibbonWpf.csproj @@ -11,10 +11,6 @@ - - - - diff --git a/Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.csproj b/Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.csproj index 3e6fd5da..5531bd79 100644 --- a/Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.csproj +++ b/Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.csproj @@ -7,10 +7,6 @@ ..\..\..\.sonarlint\minorieditorshellcsharp.ruleset - - - - all diff --git a/Demos/MinoriDemo/MinoriDemo.Wpf/MinoriDemo.Wpf.csproj b/Demos/MinoriDemo/MinoriDemo.Wpf/MinoriDemo.Wpf.csproj index 3e6fd5da..5531bd79 100644 --- a/Demos/MinoriDemo/MinoriDemo.Wpf/MinoriDemo.Wpf.csproj +++ b/Demos/MinoriDemo/MinoriDemo.Wpf/MinoriDemo.Wpf.csproj @@ -7,10 +7,6 @@ ..\..\..\.sonarlint\minorieditorshellcsharp.ruleset - - - - all diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj b/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj index c55e805a..9f9972a3 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj @@ -4,9 +4,6 @@ net5.0 ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset - - - diff --git a/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core.csproj b/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core.csproj index 0fd16521..08a62217 100644 --- a/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core.csproj +++ b/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core.csproj @@ -5,10 +5,6 @@ ..\..\..\.sonarlint\minorieditorshellcsharp.ruleset - - - - all diff --git a/Demos/SimpleDemo/SimpleDemo.RibbonWPF/SimpleDemo.RibbonWPF.csproj b/Demos/SimpleDemo/SimpleDemo.RibbonWPF/SimpleDemo.RibbonWPF.csproj index eb29cbfc..4971fb61 100644 --- a/Demos/SimpleDemo/SimpleDemo.RibbonWPF/SimpleDemo.RibbonWPF.csproj +++ b/Demos/SimpleDemo/SimpleDemo.RibbonWPF/SimpleDemo.RibbonWPF.csproj @@ -7,10 +7,6 @@ ..\..\..\.sonarlint\minorieditorshellcsharp.ruleset - - - - all diff --git a/Demos/SimpleDemo/SimpleDemo.RibbonWpf/SimpleDemo.RibbonWpf.csproj b/Demos/SimpleDemo/SimpleDemo.RibbonWpf/SimpleDemo.RibbonWpf.csproj index eb29cbfc..4971fb61 100644 --- a/Demos/SimpleDemo/SimpleDemo.RibbonWpf/SimpleDemo.RibbonWpf.csproj +++ b/Demos/SimpleDemo/SimpleDemo.RibbonWpf/SimpleDemo.RibbonWpf.csproj @@ -7,10 +7,6 @@ ..\..\..\.sonarlint\minorieditorshellcsharp.ruleset - - - - all diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj index 5a8b59d1..80e64ddb 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj @@ -39,10 +39,6 @@ This uses AvalonDock and has an MVVM architecture based on MvvmCross. - - - - diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj b/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj index 959222bd..c1cce851 100644 --- a/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj +++ b/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj @@ -28,10 +28,6 @@ - - - - diff --git a/Modules/MinoriEditorShell.Ribbon/MinoriEditorShell.Ribbon.csproj b/Modules/MinoriEditorShell.Ribbon/MinoriEditorShell.Ribbon.csproj index 67fa8a91..64724e6f 100644 --- a/Modules/MinoriEditorShell.Ribbon/MinoriEditorShell.Ribbon.csproj +++ b/Modules/MinoriEditorShell.Ribbon/MinoriEditorShell.Ribbon.csproj @@ -14,10 +14,6 @@ ..\..\.sonarlint\minorieditorshellcsharp.ruleset - - - - diff --git a/Modules/MinoriEditorShell.VirtualCanvas.Platforms.Wpf/MinoriEditorShell.VirtualCanvas.Platforms.Wpf.csproj b/Modules/MinoriEditorShell.VirtualCanvas.Platforms.Wpf/MinoriEditorShell.VirtualCanvas.Platforms.Wpf.csproj index 57651bba..40bafba9 100644 --- a/Modules/MinoriEditorShell.VirtualCanvas.Platforms.Wpf/MinoriEditorShell.VirtualCanvas.Platforms.Wpf.csproj +++ b/Modules/MinoriEditorShell.VirtualCanvas.Platforms.Wpf/MinoriEditorShell.VirtualCanvas.Platforms.Wpf.csproj @@ -16,10 +16,6 @@ ..\..\.sonarlint\minorieditorshellcsharp.ruleset - - - - diff --git a/Modules/MinoriEditorShell.VirtualCanvas/MinoriEditorShell.VirtualCanvas.csproj b/Modules/MinoriEditorShell.VirtualCanvas/MinoriEditorShell.VirtualCanvas.csproj index 98b697c1..17916e9d 100644 --- a/Modules/MinoriEditorShell.VirtualCanvas/MinoriEditorShell.VirtualCanvas.csproj +++ b/Modules/MinoriEditorShell.VirtualCanvas/MinoriEditorShell.VirtualCanvas.csproj @@ -15,10 +15,6 @@ ..\..\.sonarlint\minorieditorshellcsharp.ruleset - - - - diff --git a/Modules/MinoriEditorShell/MinoriEditorShell.csproj b/Modules/MinoriEditorShell/MinoriEditorShell.csproj index 37dcfd83..0bfab857 100644 --- a/Modules/MinoriEditorShell/MinoriEditorShell.csproj +++ b/Modules/MinoriEditorShell/MinoriEditorShell.csproj @@ -19,10 +19,6 @@ ..\..\.sonarlint\minorieditorshellcsharp.ruleset - - - - diff --git a/Modules/MinoriEditorShell/MinoriEditorShell.ruleset b/Modules/MinoriEditorShell/MinoriEditorShell.ruleset deleted file mode 100644 index 0c70e0f7..00000000 --- a/Modules/MinoriEditorShell/MinoriEditorShell.ruleset +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file From d43a35246e3144ad0cbdf7bb024b599966dd5ff6 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sat, 31 Jul 2021 23:05:18 -0400 Subject: [PATCH 37/68] add sonar lint --- .sonarlint/MinoriEditorShell.slconfig | 15 + .../CSharp/SonarLint.xml | 89 +++++ ...ankitsune_minorieditorshell2csharp.ruleset | 365 ++++++++++++++++++ .../MinoriDemo.Core/MinoriDemo.Core.csproj | 6 +- .../MinoriDemo.Core/MinoriDemo.Core.ruleset | 5 + .../MinoriDemo.RibbonWPF.csproj | 6 +- .../MinoriDemo.RibbonWPF.ruleset | 5 + .../MinoriDemo.WPF/MinoriDemo.WPF.csproj | 6 +- .../MinoriDemo.WPF/MinoriDemo.WPF.ruleset | 5 + .../SimpleDemo.Avalonia.csproj | 5 +- .../SimpleDemo.Avalonia.ruleset | 5 + .../SimpleDemo.Core/SimpleDemo.Core-1.ruleset | 5 + .../SimpleDemo.Core/SimpleDemo.Core-2.ruleset | 5 + .../SimpleDemo.Core/SimpleDemo.Core-3.ruleset | 5 + .../SimpleDemo.Core/SimpleDemo.Core-4.ruleset | 5 + .../SimpleDemo.Core/SimpleDemo.Core.csproj | 6 +- .../SimpleDemo.RibbonWPF.csproj | 6 +- .../SimpleDemo.RibbonWPF.ruleset | 5 + .../SimpleDemo.WPF/SimpleDemo.WPF.csproj | 4 + ...inoriEditorShell.Platforms.Avalonia.csproj | 6 +- ...noriEditorShell.Platforms.Avalonia.ruleset | 5 + .../MinoriEditorShell.Platforms.Wpf.csproj | 6 +- .../MinoriEditorShell.Platforms.Wpf.ruleset | 5 + .../MinoriEditorShell.Ribbon.csproj | 6 +- .../MinoriEditorShell.Ribbon.ruleset | 5 + ...orShell.VirtualCanvas.Platforms.Wpf.csproj | 6 +- ...rShell.VirtualCanvas.Platforms.Wpf.ruleset | 5 + .../MinoriEditorShell.VirtualCanvas.csproj | 6 +- .../MinoriEditorShell.VirtualCanvas.ruleset | 5 + .../MinoriEditorShell.csproj | 6 +- .../MinoriEditorShell.ruleset | 5 + 31 files changed, 607 insertions(+), 12 deletions(-) create mode 100644 .sonarlint/MinoriEditorShell.slconfig create mode 100644 .sonarlint/torisankitsune_minorieditorshell2/CSharp/SonarLint.xml create mode 100644 .sonarlint/torisankitsune_minorieditorshell2csharp.ruleset create mode 100644 Demos/MinoriDemo/MinoriDemo.Core/MinoriDemo.Core.ruleset create mode 100644 Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.ruleset create mode 100644 Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.ruleset create mode 100644 Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.ruleset create mode 100644 Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-1.ruleset create mode 100644 Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-2.ruleset create mode 100644 Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-3.ruleset create mode 100644 Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-4.ruleset create mode 100644 Demos/SimpleDemo/SimpleDemo.RibbonWPF/SimpleDemo.RibbonWPF.ruleset create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.ruleset create mode 100644 Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.ruleset create mode 100644 Modules/MinoriEditorShell.Ribbon/MinoriEditorShell.Ribbon.ruleset create mode 100644 Modules/MinoriEditorShell.VirtualCanvas.Platforms.Wpf/MinoriEditorShell.VirtualCanvas.Platforms.Wpf.ruleset create mode 100644 Modules/MinoriEditorShell.VirtualCanvas/MinoriEditorShell.VirtualCanvas.ruleset create mode 100644 Modules/MinoriEditorShell/MinoriEditorShell.ruleset diff --git a/.sonarlint/MinoriEditorShell.slconfig b/.sonarlint/MinoriEditorShell.slconfig new file mode 100644 index 00000000..7c4155d6 --- /dev/null +++ b/.sonarlint/MinoriEditorShell.slconfig @@ -0,0 +1,15 @@ +{ + "ServerUri": "https://sonarcloud.io/", + "Organization": { + "Key": "torisankitsune-1", + "Name": "torisankitsune-1" + }, + "ProjectKey": "TorisanKitsune_MinoriEditorShell2", + "ProjectName": "MinoriEditorShell", + "Profiles": { + "CSharp": { + "ProfileKey": "AXfBiG4ncmi_3V30EHaZ", + "ProfileTimestamp": "2021-05-05T07:40:20Z" + } + } +} \ No newline at end of file diff --git a/.sonarlint/torisankitsune_minorieditorshell2/CSharp/SonarLint.xml b/.sonarlint/torisankitsune_minorieditorshell2/CSharp/SonarLint.xml new file mode 100644 index 00000000..21acd70e --- /dev/null +++ b/.sonarlint/torisankitsune_minorieditorshell2/CSharp/SonarLint.xml @@ -0,0 +1,89 @@ + + + + + sonar.cs.analyzeGeneratedCode + false + + + sonar.cs.file.suffixes + .cs + + + sonar.cs.ignoreHeaderComments + true + + + sonar.cs.roslyn.ignoreIssues + false + + + + + S107 + + + max + 7 + + + + + S110 + + + max + 5 + + + + + S1479 + + + maximum + 30 + + + + + S2342 + + + flagsAttributeFormat + ^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?s$ + + + format + ^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?$ + + + + + S2436 + + + max + 2 + + + maxMethod + 3 + + + + + S3776 + + + propertyThreshold + 3 + + + threshold + 15 + + + + + \ No newline at end of file diff --git a/.sonarlint/torisankitsune_minorieditorshell2csharp.ruleset b/.sonarlint/torisankitsune_minorieditorshell2csharp.ruleset new file mode 100644 index 00000000..b05496e5 --- /dev/null +++ b/.sonarlint/torisankitsune_minorieditorshell2csharp.ruleset @@ -0,0 +1,365 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Demos/MinoriDemo/MinoriDemo.Core/MinoriDemo.Core.csproj b/Demos/MinoriDemo/MinoriDemo.Core/MinoriDemo.Core.csproj index eb3d96c2..1bb0ba4e 100644 --- a/Demos/MinoriDemo/MinoriDemo.Core/MinoriDemo.Core.csproj +++ b/Demos/MinoriDemo/MinoriDemo.Core/MinoriDemo.Core.csproj @@ -2,7 +2,7 @@ netstandard2.0 - ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset + MinoriDemo.Core.ruleset @@ -11,6 +11,10 @@ + + + + all diff --git a/Demos/MinoriDemo/MinoriDemo.Core/MinoriDemo.Core.ruleset b/Demos/MinoriDemo/MinoriDemo.Core/MinoriDemo.Core.ruleset new file mode 100644 index 00000000..8c64bbf2 --- /dev/null +++ b/Demos/MinoriDemo/MinoriDemo.Core/MinoriDemo.Core.ruleset @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.csproj b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.csproj index 49fbe740..9bd8012c 100644 --- a/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.csproj +++ b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.csproj @@ -4,13 +4,17 @@ WinExe net5.0-windows true - ..\..\..\.sonarlint\minorieditorshellcsharp.ruleset + MinoriDemo.RibbonWPF.ruleset + + + + diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.ruleset b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.ruleset new file mode 100644 index 00000000..b327e534 --- /dev/null +++ b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/MinoriDemo.RibbonWPF.ruleset @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.csproj b/Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.csproj index 5531bd79..381b66c7 100644 --- a/Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.csproj +++ b/Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.csproj @@ -4,9 +4,13 @@ WinExe net5.0-windows true - ..\..\..\.sonarlint\minorieditorshellcsharp.ruleset + MinoriDemo.WPF.ruleset + + + + all diff --git a/Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.ruleset b/Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.ruleset new file mode 100644 index 00000000..b327e534 --- /dev/null +++ b/Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.ruleset @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj b/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj index 9f9972a3..b7e7b1ae 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj @@ -2,8 +2,11 @@ WinExe net5.0 - ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset + SimpleDemo.Avalonia.ruleset + + + diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.ruleset b/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.ruleset new file mode 100644 index 00000000..8c64bbf2 --- /dev/null +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.ruleset @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-1.ruleset b/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-1.ruleset new file mode 100644 index 00000000..b327e534 --- /dev/null +++ b/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-1.ruleset @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-2.ruleset b/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-2.ruleset new file mode 100644 index 00000000..b327e534 --- /dev/null +++ b/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-2.ruleset @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-3.ruleset b/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-3.ruleset new file mode 100644 index 00000000..b327e534 --- /dev/null +++ b/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-3.ruleset @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-4.ruleset b/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-4.ruleset new file mode 100644 index 00000000..b327e534 --- /dev/null +++ b/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-4.ruleset @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core.csproj b/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core.csproj index 08a62217..655df1db 100644 --- a/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core.csproj +++ b/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core.csproj @@ -2,9 +2,13 @@ netstandard2.0 - ..\..\..\.sonarlint\minorieditorshellcsharp.ruleset + SimpleDemo.Core-4.ruleset + + + + all diff --git a/Demos/SimpleDemo/SimpleDemo.RibbonWPF/SimpleDemo.RibbonWPF.csproj b/Demos/SimpleDemo/SimpleDemo.RibbonWPF/SimpleDemo.RibbonWPF.csproj index 4971fb61..e4b3f81c 100644 --- a/Demos/SimpleDemo/SimpleDemo.RibbonWPF/SimpleDemo.RibbonWPF.csproj +++ b/Demos/SimpleDemo/SimpleDemo.RibbonWPF/SimpleDemo.RibbonWPF.csproj @@ -4,9 +4,13 @@ WinExe net5.0-windows true - ..\..\..\.sonarlint\minorieditorshellcsharp.ruleset + SimpleDemo.RibbonWPF.ruleset + + + + all diff --git a/Demos/SimpleDemo/SimpleDemo.RibbonWPF/SimpleDemo.RibbonWPF.ruleset b/Demos/SimpleDemo/SimpleDemo.RibbonWPF/SimpleDemo.RibbonWPF.ruleset new file mode 100644 index 00000000..b327e534 --- /dev/null +++ b/Demos/SimpleDemo/SimpleDemo.RibbonWPF/SimpleDemo.RibbonWPF.ruleset @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Demos/SimpleDemo/SimpleDemo.WPF/SimpleDemo.WPF.csproj b/Demos/SimpleDemo/SimpleDemo.WPF/SimpleDemo.WPF.csproj index 33aa23b5..a8e629f9 100644 --- a/Demos/SimpleDemo/SimpleDemo.WPF/SimpleDemo.WPF.csproj +++ b/Demos/SimpleDemo/SimpleDemo.WPF/SimpleDemo.WPF.csproj @@ -5,7 +5,11 @@ true + ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset + + + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj index 80e64ddb..e7d75878 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj @@ -15,7 +15,7 @@ This uses AvalonDock and has an MVVM architecture based on MvvmCross.Mark Kromis Library bin\MinoriEditorShell.Platforms.Avalonia.xml - ..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset + MinoriEditorShell.Platforms.Avalonia.ruleset @@ -39,6 +39,10 @@ This uses AvalonDock and has an MVVM architecture based on MvvmCross. + + + + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.ruleset b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.ruleset new file mode 100644 index 00000000..9eb18db0 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.ruleset @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj b/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj index c1cce851..8c3e25f0 100644 --- a/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj +++ b/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj @@ -18,7 +18,7 @@ Library bin\MinoriEditorShell.xml true - ..\..\.sonarlint\minorieditorshellcsharp.ruleset + MinoriEditorShell.Platforms.Wpf.ruleset @@ -28,6 +28,10 @@ + + + + diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.ruleset b/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.ruleset new file mode 100644 index 00000000..0c70e0f7 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.ruleset @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Ribbon/MinoriEditorShell.Ribbon.csproj b/Modules/MinoriEditorShell.Ribbon/MinoriEditorShell.Ribbon.csproj index 64724e6f..bac20302 100644 --- a/Modules/MinoriEditorShell.Ribbon/MinoriEditorShell.Ribbon.csproj +++ b/Modules/MinoriEditorShell.Ribbon/MinoriEditorShell.Ribbon.csproj @@ -11,9 +11,13 @@ Git Ribbon Mahapp IDE true - ..\..\.sonarlint\minorieditorshellcsharp.ruleset + MinoriEditorShell.Ribbon.ruleset + + + + diff --git a/Modules/MinoriEditorShell.Ribbon/MinoriEditorShell.Ribbon.ruleset b/Modules/MinoriEditorShell.Ribbon/MinoriEditorShell.Ribbon.ruleset new file mode 100644 index 00000000..0c70e0f7 --- /dev/null +++ b/Modules/MinoriEditorShell.Ribbon/MinoriEditorShell.Ribbon.ruleset @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Modules/MinoriEditorShell.VirtualCanvas.Platforms.Wpf/MinoriEditorShell.VirtualCanvas.Platforms.Wpf.csproj b/Modules/MinoriEditorShell.VirtualCanvas.Platforms.Wpf/MinoriEditorShell.VirtualCanvas.Platforms.Wpf.csproj index 40bafba9..9252e01c 100644 --- a/Modules/MinoriEditorShell.VirtualCanvas.Platforms.Wpf/MinoriEditorShell.VirtualCanvas.Platforms.Wpf.csproj +++ b/Modules/MinoriEditorShell.VirtualCanvas.Platforms.Wpf/MinoriEditorShell.VirtualCanvas.Platforms.Wpf.csproj @@ -13,9 +13,13 @@ true bin\MinoriEditorStudio.VirtualCanvas.xml true - ..\..\.sonarlint\minorieditorshellcsharp.ruleset + MinoriEditorShell.VirtualCanvas.Platforms.Wpf.ruleset + + + + diff --git a/Modules/MinoriEditorShell.VirtualCanvas.Platforms.Wpf/MinoriEditorShell.VirtualCanvas.Platforms.Wpf.ruleset b/Modules/MinoriEditorShell.VirtualCanvas.Platforms.Wpf/MinoriEditorShell.VirtualCanvas.Platforms.Wpf.ruleset new file mode 100644 index 00000000..0c70e0f7 --- /dev/null +++ b/Modules/MinoriEditorShell.VirtualCanvas.Platforms.Wpf/MinoriEditorShell.VirtualCanvas.Platforms.Wpf.ruleset @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Modules/MinoriEditorShell.VirtualCanvas/MinoriEditorShell.VirtualCanvas.csproj b/Modules/MinoriEditorShell.VirtualCanvas/MinoriEditorShell.VirtualCanvas.csproj index 17916e9d..5b4cb368 100644 --- a/Modules/MinoriEditorShell.VirtualCanvas/MinoriEditorShell.VirtualCanvas.csproj +++ b/Modules/MinoriEditorShell.VirtualCanvas/MinoriEditorShell.VirtualCanvas.csproj @@ -12,9 +12,13 @@ IDE VirtualCanvas Module true bin\MinoriEditorStudio.VirtualCanvas.xml - ..\..\.sonarlint\minorieditorshellcsharp.ruleset + MinoriEditorShell.VirtualCanvas.ruleset + + + + diff --git a/Modules/MinoriEditorShell.VirtualCanvas/MinoriEditorShell.VirtualCanvas.ruleset b/Modules/MinoriEditorShell.VirtualCanvas/MinoriEditorShell.VirtualCanvas.ruleset new file mode 100644 index 00000000..0c70e0f7 --- /dev/null +++ b/Modules/MinoriEditorShell.VirtualCanvas/MinoriEditorShell.VirtualCanvas.ruleset @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Modules/MinoriEditorShell/MinoriEditorShell.csproj b/Modules/MinoriEditorShell/MinoriEditorShell.csproj index 0bfab857..ac9095a6 100644 --- a/Modules/MinoriEditorShell/MinoriEditorShell.csproj +++ b/Modules/MinoriEditorShell/MinoriEditorShell.csproj @@ -16,9 +16,13 @@ Mark Kromis Mark Kromis bin\MinoriEditorShell.xml - ..\..\.sonarlint\minorieditorshellcsharp.ruleset + MinoriEditorShell.ruleset + + + + diff --git a/Modules/MinoriEditorShell/MinoriEditorShell.ruleset b/Modules/MinoriEditorShell/MinoriEditorShell.ruleset new file mode 100644 index 00000000..0c70e0f7 --- /dev/null +++ b/Modules/MinoriEditorShell/MinoriEditorShell.ruleset @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file From 6b92c8b10a64f29ec9f85a50e47ddbde0d050533 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sat, 31 Jul 2021 23:05:31 -0400 Subject: [PATCH 38/68] Add sonar --- .../MinoriDemo.RibbonWpf/MinoriDemo.RibbonWpf.csproj | 6 +++++- Demos/MinoriDemo/MinoriDemo.Wpf/MinoriDemo.Wpf.csproj | 6 +++++- .../SimpleDemo.RibbonWpf/SimpleDemo.RibbonWpf.csproj | 6 +++++- Demos/SimpleDemo/SimpleDemo.Wpf/SimpleDemo.Wpf.csproj | 4 ++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpf/MinoriDemo.RibbonWpf.csproj b/Demos/MinoriDemo/MinoriDemo.RibbonWpf/MinoriDemo.RibbonWpf.csproj index 49fbe740..9bd8012c 100644 --- a/Demos/MinoriDemo/MinoriDemo.RibbonWpf/MinoriDemo.RibbonWpf.csproj +++ b/Demos/MinoriDemo/MinoriDemo.RibbonWpf/MinoriDemo.RibbonWpf.csproj @@ -4,13 +4,17 @@ WinExe net5.0-windows true - ..\..\..\.sonarlint\minorieditorshellcsharp.ruleset + MinoriDemo.RibbonWPF.ruleset + + + + diff --git a/Demos/MinoriDemo/MinoriDemo.Wpf/MinoriDemo.Wpf.csproj b/Demos/MinoriDemo/MinoriDemo.Wpf/MinoriDemo.Wpf.csproj index 5531bd79..381b66c7 100644 --- a/Demos/MinoriDemo/MinoriDemo.Wpf/MinoriDemo.Wpf.csproj +++ b/Demos/MinoriDemo/MinoriDemo.Wpf/MinoriDemo.Wpf.csproj @@ -4,9 +4,13 @@ WinExe net5.0-windows true - ..\..\..\.sonarlint\minorieditorshellcsharp.ruleset + MinoriDemo.WPF.ruleset + + + + all diff --git a/Demos/SimpleDemo/SimpleDemo.RibbonWpf/SimpleDemo.RibbonWpf.csproj b/Demos/SimpleDemo/SimpleDemo.RibbonWpf/SimpleDemo.RibbonWpf.csproj index 4971fb61..e4b3f81c 100644 --- a/Demos/SimpleDemo/SimpleDemo.RibbonWpf/SimpleDemo.RibbonWpf.csproj +++ b/Demos/SimpleDemo/SimpleDemo.RibbonWpf/SimpleDemo.RibbonWpf.csproj @@ -4,9 +4,13 @@ WinExe net5.0-windows true - ..\..\..\.sonarlint\minorieditorshellcsharp.ruleset + SimpleDemo.RibbonWPF.ruleset + + + + all diff --git a/Demos/SimpleDemo/SimpleDemo.Wpf/SimpleDemo.Wpf.csproj b/Demos/SimpleDemo/SimpleDemo.Wpf/SimpleDemo.Wpf.csproj index 33aa23b5..a8e629f9 100644 --- a/Demos/SimpleDemo/SimpleDemo.Wpf/SimpleDemo.Wpf.csproj +++ b/Demos/SimpleDemo/SimpleDemo.Wpf/SimpleDemo.Wpf.csproj @@ -5,7 +5,11 @@ true + ..\..\..\.sonarlint\torisankitsune_minorieditorshell2csharp.ruleset + + + From 8bbb06dc7a68bcbaf9d3c6923d7aacef16772188 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sat, 14 Aug 2021 21:18:38 -0400 Subject: [PATCH 39/68] fix sonarlint --- .../CSharp/SonarLint.xml | 89 +++++ ...sankitsune_minorieditorshellcsharp.ruleset | 365 ++++++++++++++++++ .vscode/launch.json | 19 - .vscode/tasks.json | 42 -- .../SimpleDemo.Avalonia.csproj | 4 +- .../SimpleDemo.Avalonia.ruleset | 3 +- .../SimpleDemo.WPF/SimpleDemo.WPF.csproj | 3 +- .../SimpleDemo.Wpf/SimpleDemo.Wpf.csproj | 3 +- ...inoriEditorShell.Platforms.Avalonia.csproj | 4 +- ...noriEditorShell.Platforms.Avalonia.ruleset | 3 +- 10 files changed, 462 insertions(+), 73 deletions(-) create mode 100644 .sonarlint/torisankitsune_minorieditorshell/CSharp/SonarLint.xml create mode 100644 .sonarlint/torisankitsune_minorieditorshellcsharp.ruleset delete mode 100644 .vscode/launch.json delete mode 100644 .vscode/tasks.json diff --git a/.sonarlint/torisankitsune_minorieditorshell/CSharp/SonarLint.xml b/.sonarlint/torisankitsune_minorieditorshell/CSharp/SonarLint.xml new file mode 100644 index 00000000..21acd70e --- /dev/null +++ b/.sonarlint/torisankitsune_minorieditorshell/CSharp/SonarLint.xml @@ -0,0 +1,89 @@ + + + + + sonar.cs.analyzeGeneratedCode + false + + + sonar.cs.file.suffixes + .cs + + + sonar.cs.ignoreHeaderComments + true + + + sonar.cs.roslyn.ignoreIssues + false + + + + + S107 + + + max + 7 + + + + + S110 + + + max + 5 + + + + + S1479 + + + maximum + 30 + + + + + S2342 + + + flagsAttributeFormat + ^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?s$ + + + format + ^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?$ + + + + + S2436 + + + max + 2 + + + maxMethod + 3 + + + + + S3776 + + + propertyThreshold + 3 + + + threshold + 15 + + + + + \ No newline at end of file diff --git a/.sonarlint/torisankitsune_minorieditorshellcsharp.ruleset b/.sonarlint/torisankitsune_minorieditorshellcsharp.ruleset new file mode 100644 index 00000000..f9145a58 --- /dev/null +++ b/.sonarlint/torisankitsune_minorieditorshellcsharp.ruleset @@ -0,0 +1,365 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index ec435ed0..00000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": ".NET Core Launch (SimpleDemo.Avalonia)", - "type": "coreclr", - "request": "launch", - "preLaunchTask": "build", - "program": "${workspaceFolder}/Demos/SimpleDemo/SimpleDemo.Avalonia/bin/Debug/netcoreapp3.1/SimpleDemo.Avalonia.dll", - "args": [], - "cwd": "${workspaceFolder}", - "stopAtEntry": false, - "console": "internalConsole" - } - ] -} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index 5f7c8584..00000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - // See https://go.microsoft.com/fwlink/?LinkId=733558 - // for the documentation about the tasks.json format - "version": "2.0.0", - "tasks": [ - { - "label": "build", - "command": "dotnet", - "type": "shell", - "args": [ - "build", - "MinoriEditorShell-Avalonia.sln", - "/property:GenerateFullPaths=true", - "/consoleloggerparameters:NoSummary" - ], - "group": "build", - "presentation": { - "reveal": "silent" - }, - "problemMatcher": "$msCompile" - }, - { - "label": "test", - "command": "dotnet", - "type": "shell", - "args": [ - "test", - "MinoriEditorShell-Avalonia.sln", - "/property:GenerateFullPaths=true", - "/consoleloggerparameters:NoSummary" - ], - "group": { - "kind": "test", - "isDefault": true - }, - "presentation": { - "reveal": "silent" - }, - "problemMatcher": "$msCompile" - } - ] -} \ No newline at end of file diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj b/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj index b7e7b1ae..b3bf2979 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj @@ -2,10 +2,10 @@ WinExe net5.0 - SimpleDemo.Avalonia.ruleset + ..\..\..\.sonarlint\torisankitsune_minorieditorshellcsharp.ruleset - + diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.ruleset b/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.ruleset index 8c64bbf2..913e6bd2 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.ruleset +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.ruleset @@ -1,5 +1,4 @@  - - + \ No newline at end of file diff --git a/Demos/SimpleDemo/SimpleDemo.WPF/SimpleDemo.WPF.csproj b/Demos/SimpleDemo/SimpleDemo.WPF/SimpleDemo.WPF.csproj index 40735f09..a6e5cabd 100644 --- a/Demos/SimpleDemo/SimpleDemo.WPF/SimpleDemo.WPF.csproj +++ b/Demos/SimpleDemo/SimpleDemo.WPF/SimpleDemo.WPF.csproj @@ -5,14 +5,13 @@ true - ..\..\..\.sonarlint\torisankitsune_minorieditorshellcsharp.ruleset false false false + ..\..\..\.sonarlint\torisankitsune_minorieditorshellcsharp.ruleset - diff --git a/Demos/SimpleDemo/SimpleDemo.Wpf/SimpleDemo.Wpf.csproj b/Demos/SimpleDemo/SimpleDemo.Wpf/SimpleDemo.Wpf.csproj index 40735f09..a6e5cabd 100644 --- a/Demos/SimpleDemo/SimpleDemo.Wpf/SimpleDemo.Wpf.csproj +++ b/Demos/SimpleDemo/SimpleDemo.Wpf/SimpleDemo.Wpf.csproj @@ -5,14 +5,13 @@ true - ..\..\..\.sonarlint\torisankitsune_minorieditorshellcsharp.ruleset false false false + ..\..\..\.sonarlint\torisankitsune_minorieditorshellcsharp.ruleset - diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj index e7d75878..336b1e23 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj @@ -15,7 +15,7 @@ This uses AvalonDock and has an MVVM architecture based on MvvmCross.Mark Kromis Library bin\MinoriEditorShell.Platforms.Avalonia.xml - MinoriEditorShell.Platforms.Avalonia.ruleset + ..\..\.sonarlint\torisankitsune_minorieditorshellcsharp.ruleset @@ -40,7 +40,7 @@ This uses AvalonDock and has an MVVM architecture based on MvvmCross. - + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.ruleset b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.ruleset index 9eb18db0..2b9a1a05 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.ruleset +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.ruleset @@ -1,5 +1,4 @@  - - + \ No newline at end of file From 19f2a9cc7f94b739c79d0b69a38da33461a57313 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sat, 14 Aug 2021 21:50:36 -0400 Subject: [PATCH 40/68] update nuget --- .../SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj | 4 ++++ .../MinoriEditorShell.Platforms.Avalonia.csproj | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj b/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj index b3bf2979..10017d5f 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj @@ -11,6 +11,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj index 336b1e23..f9445ee0 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj @@ -45,13 +45,13 @@ This uses AvalonDock and has an MVVM architecture based on MvvmCross. - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + From 03ed690342cd67d43f89f5e2b9c6cb55b978d19d Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sun, 15 Aug 2021 22:15:57 -0400 Subject: [PATCH 41/68] Fix setup class init --- .../SimpleDemo.Avalonia/App.axaml.cs | 2 + .../SimpleDemo/SimpleDemo.Avalonia/Program.cs | 10 ++-- Demos/SimpleDemo/SimpleDemo.Avalonia/Setup.cs | 2 +- .../SimpleDemo.Avalonia.csproj | 1 + .../SimpleDemo.Avalonia/Views/MainView.axaml | 11 ++++ .../Views/MainView.axaml.cs | 2 +- .../Binding/MesWindowsAssemblyCache.cs | 14 ++++- .../Core/MvxAvnSetupSingleton.cs | 42 +++++++++++++++ .../Views/MesApplication.cs | 36 +++++++------ .../Views/MesWindow.cs | 53 ++++++++++++++----- 10 files changed, 137 insertions(+), 36 deletions(-) create mode 100644 Demos/SimpleDemo/SimpleDemo.Avalonia/Views/MainView.axaml create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Core/MvxAvnSetupSingleton.cs diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml.cs b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml.cs index e3fae023..b75115e6 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml.cs +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml.cs @@ -4,6 +4,7 @@ using MinoriEditorShell.Platforms.Avalonia; using MinoriEditorShell.Platforms.Avalonia.Views; using MvvmCross.Core; +using System.Diagnostics; namespace SimpleDemo.Avalonia { @@ -14,6 +15,7 @@ public class App : MesApplication public override void OnFrameworkInitializationCompleted() { + Debug.WriteLine("InitTest"); if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { desktop.MainWindow = new MainWindow(); diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/Program.cs b/Demos/SimpleDemo/SimpleDemo.Avalonia/Program.cs index 7105f84f..c1726508 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/Program.cs +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/Program.cs @@ -5,13 +5,17 @@ namespace SimpleDemo.Avalonia { - class Program + /// + /// This is autogenerated from the VS Studio tool. + /// + internal static class Program { // Initialization code. Don't use any Avalonia, third-party APIs or any // SynchronizationContext-reliant code before AppMain is called: things aren't initialized // yet and stuff might break. - public static void Main(string[] args) => BuildAvaloniaApp() - .StartWithClassicDesktopLifetime(args); + public static void Main(string[] args) + => BuildAvaloniaApp() + .StartWithClassicDesktopLifetime(args); // Avalonia configuration, don't remove; also used by visual designer. public static AppBuilder BuildAvaloniaApp() diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/Setup.cs b/Demos/SimpleDemo/SimpleDemo.Avalonia/Setup.cs index 97246a2e..adaa3ae5 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/Setup.cs +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/Setup.cs @@ -5,7 +5,7 @@ namespace SimpleDemo.Avalonia { internal class Setup : MesAvnSetup { - protected override ILoggerFactory CreateLogFactory() => LoggerFactory.Create(b => b.SetMinimumLevel(0).AddSimpleConsole(o => o.SingleLine = true)); + protected override ILoggerFactory CreateLogFactory() => LoggerFactory.Create(b => b.SetMinimumLevel(0).AddDebug()); protected override ILoggerProvider CreateLogProvider() => null; } } \ No newline at end of file diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj b/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj index 10017d5f..020b54ce 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj @@ -17,6 +17,7 @@ + diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/Views/MainView.axaml b/Demos/SimpleDemo/SimpleDemo.Avalonia/Views/MainView.axaml new file mode 100644 index 00000000..a7ee266b --- /dev/null +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/Views/MainView.axaml @@ -0,0 +1,11 @@ + + Welcome to MainView + diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/Views/MainView.axaml.cs b/Demos/SimpleDemo/SimpleDemo.Avalonia/Views/MainView.axaml.cs index 0103cf7d..3f92e9ff 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/Views/MainView.axaml.cs +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/Views/MainView.axaml.cs @@ -5,7 +5,7 @@ namespace SimpleDemo.Avalonia.Views { - public class MainView : MesAvnView + public partial class MainView : MesAvnView { public MainView() { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsAssemblyCache.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsAssemblyCache.cs index 721fb894..c1285d14 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsAssemblyCache.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsAssemblyCache.cs @@ -5,26 +5,38 @@ namespace MinoriEditorShell.Platforms.Avalonia.Binding { + /// + /// Assembly cache setup + /// public class MesWindowsAssemblyCache : MvxSingleton , IMesWindowsAssemblyCache { + /// + /// Helper to make sure class is init properly + /// public static void EnsureInitialized() { if (Instance != null) return; - var instance = new MesWindowsAssemblyCache(); + MesWindowsAssemblyCache instance = new MesWindowsAssemblyCache(); if (Instance != instance) throw new MvxException("Error initialising MvxWindowsAssemblyCache"); } + /// + /// Setups assbembly cache + /// public MesWindowsAssemblyCache() { Assemblies = new List(); } + /// + /// Gets assembly cache + /// public IList Assemblies { get; } } } diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MvxAvnSetupSingleton.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MvxAvnSetupSingleton.cs new file mode 100644 index 00000000..f177886d --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MvxAvnSetupSingleton.cs @@ -0,0 +1,42 @@ +using Avalonia.Controls; +using Avalonia.Threading; +using MinoriEditorShell.Platforms.Avalonia.Presenters; +using MvvmCross.Core; +using System; +using System.Collections.Generic; +using System.Text; + +namespace MinoriEditorShell.Platforms.Avalonia.Core +{ + /// + /// Setup utilities + /// + public class MvxAvnSetupSingleton : MvxSetupSingleton + { + /// + /// Helper to ensure seup is only done once + /// + /// + /// + /// + public static MvxAvnSetupSingleton EnsureSingletonAvailable(Dispatcher uiThreadDispatcher, IMesAvnViewPresenter presenter) + { + MvxAvnSetupSingleton instance = EnsureSingletonAvailable(); + instance.PlatformSetup()?.PlatformInitialize(uiThreadDispatcher, presenter); + return instance; + } + + /// + /// Helper to make sure setup is only done once. + /// + /// + /// + /// + public static MvxAvnSetupSingleton EnsureSingletonAvailable(Dispatcher uiThreadDispatcher, ContentControl root) + { + MvxAvnSetupSingleton instance = EnsureSingletonAvailable(); + instance.PlatformSetup()?.PlatformInitialize(uiThreadDispatcher, root); + return instance; + } + } +} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesApplication.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesApplication.cs index 84ce2241..d3f40df3 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesApplication.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesApplication.cs @@ -10,21 +10,19 @@ namespace MinoriEditorShell.Platforms.Avalonia.Views { + /// + /// Main application helper to help setup IoC + /// public abstract class MesApplication : Application { - public MesApplication() : base() - { - RegisterSetup(); - } + + /// + /// Main application class interface + /// + protected MesApplication() : base() => RegisterSetup(); public virtual void ApplicationInitialized() { - if (Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) - { - if (desktop.MainWindow == null) return; - //MvxWpfSetupSingleton.EnsureSingletonAvailable(this.Dispatcher, desktop.MainWindow).EnsureInitialized(); - } - RunAppStart(); } @@ -41,18 +39,22 @@ protected virtual object GetAppStartHint(object hint = null) return hint; } - protected virtual void RegisterSetup() - { - } + protected abstract void RegisterSetup(); } + /// + /// This is an Generics helper for MesApplication for + /// + /// + /// public class MesApplication : MesApplication where TMvxWpfSetup : MesAvnSetup, new() where TApplication : class, IMvxApplication, new() { - protected override void RegisterSetup() - { - this.RegisterSetupType(); - } + + /// + /// Register setup based on template + /// + protected override void RegisterSetup() => this.RegisterSetupType(); } } diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesWindow.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesWindow.cs index 2296c4f0..65c79799 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesWindow.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesWindow.cs @@ -1,12 +1,12 @@ -// using MahApps.Metro.Controls; -using Avalonia; +using Avalonia; using Avalonia.Controls; using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Interactivity; +using Avalonia.Threading; +using MinoriEditorShell.Platforms.Avalonia.Core; using MinoriEditorShell.Services; using MvvmCross; using MvvmCross.Binding.BindingContext; -// using MvvmCross.Platforms.Wpf.Views; using MvvmCross.ViewModels; using System; using System.Linq; @@ -15,11 +15,19 @@ namespace MinoriEditorShell.Platforms.Avalonia.Views { + /// + /// MesWindow is a interface for windows based views. + /// This will give extra properties to access extra properties such as titlebar. + /// public class MesWindow : Window, IMesWindow, IMesAvnView, IDisposable { private IMvxBindingContext _bindingContext; - private bool _unloaded = false; + private Boolean _unloaded = false; private IMvxViewModel _viewModel; + + /// + /// Basic constructor for window views. + /// public MesWindow() { Closed += MvxWindow_Closed; @@ -27,11 +35,17 @@ public MesWindow() Initialized += MvxWindow_Initialized; } + /// + /// basic dtor for window class + /// ~MesWindow() { Dispose(false); } + /// + /// Gets a binding context + /// public IMvxBindingContext BindingContext { get @@ -47,10 +61,19 @@ public IMvxBindingContext BindingContext set => _bindingContext = value; } + /// + /// Title of the window, Legacy use. + /// public String DisplayName { get; set; } - public string Identifier { get; set; } + /// + /// Unique identifier for window + /// + public String Identifier { get; set; } + /// + /// Sets the view model + /// public IMvxViewModel ViewModel { get => _viewModel; @@ -61,12 +84,20 @@ public IMvxViewModel ViewModel BindingContext.DataContext = value; } } + + /// + /// Dispose current object + /// public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } + /// + /// Dispose pattern + /// + /// protected virtual void Dispose(bool disposing) { if (disposing) @@ -76,17 +107,13 @@ protected virtual void Dispose(bool disposing) } } + private void MvxWindow_Closed(object sender, EventArgs e) => Unload(); private void MvxWindow_Initialized(object sender, EventArgs e) { - //if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) - //{ - //if (this == desktop.MainWindow) - //{ - (Application.Current as MesApplication).ApplicationInitialized(); - //} - //} + MvxAvnSetupSingleton.EnsureSingletonAvailable(Dispatcher.UIThread, this).EnsureInitialized(); + (Application.Current as MesApplication).ApplicationInitialized(); } @@ -95,7 +122,7 @@ private void MvxWindow_Opened(Object sender, EventArgs e) ViewModel?.ViewAppearing(); ViewModel?.ViewAppeared(); } - private void MvxWindow_Unloaded(object sender, RoutedEventArgs e) => Unload(); + private void Unload() { if (!_unloaded) From c5352563e772ef5faff35781f8684c08a0eee3aa Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sun, 15 Aug 2021 22:30:48 -0400 Subject: [PATCH 42/68] add tip view --- .../SimpleDemo.Avalonia/MainWindow.axaml.cs | 7 +++---- .../SimpleDemo.Avalonia.csproj | 1 + .../SimpleDemo.Avalonia/Views/MainView.axaml.cs | 14 ++++---------- .../SimpleDemo.Avalonia/Views/TipView.axaml | 8 ++++++++ .../SimpleDemo.Avalonia/Views/TipView.axaml.cs | 15 +++++++++++++++ .../Core/MesAvnSetup.cs | 11 +++++++++++ 6 files changed, 42 insertions(+), 14 deletions(-) create mode 100644 Demos/SimpleDemo/SimpleDemo.Avalonia/Views/TipView.axaml create mode 100644 Demos/SimpleDemo/SimpleDemo.Avalonia/Views/TipView.axaml.cs diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/MainWindow.axaml.cs b/Demos/SimpleDemo/SimpleDemo.Avalonia/MainWindow.axaml.cs index 45ddc38c..cc4dc4e6 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/MainWindow.axaml.cs +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/MainWindow.axaml.cs @@ -1,10 +1,12 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; +using MinoriEditorShell.Platforms.Avalonia.Presenters.Attributes; using MinoriEditorShell.Platforms.Avalonia.Views; namespace SimpleDemo.Avalonia { + [MesWindowPresentation] public class MainWindow : MesWindow { public MainWindow() @@ -15,9 +17,6 @@ public MainWindow() #endif } - private void InitializeComponent() - { - AvaloniaXamlLoader.Load(this); - } + private void InitializeComponent() => AvaloniaXamlLoader.Load(this); } } diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj b/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj index 020b54ce..cf433cc7 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj @@ -18,6 +18,7 @@ + diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/Views/MainView.axaml.cs b/Demos/SimpleDemo/SimpleDemo.Avalonia/Views/MainView.axaml.cs index 3f92e9ff..ccdf3d83 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/Views/MainView.axaml.cs +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/Views/MainView.axaml.cs @@ -1,20 +1,14 @@ -using Avalonia; -using Avalonia.Controls; using Avalonia.Markup.Xaml; +using MinoriEditorShell.Platforms.Avalonia.Presenters.Attributes; using MinoriEditorShell.Platforms.Avalonia.Views; namespace SimpleDemo.Avalonia.Views { + [MesContentPresentation] public partial class MainView : MesAvnView { - public MainView() - { - InitializeComponent(); - } + public MainView() => InitializeComponent(); - private void InitializeComponent() - { - AvaloniaXamlLoader.Load(this); - } + private void InitializeComponent() => AvaloniaXamlLoader.Load(this); } } diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/Views/TipView.axaml b/Demos/SimpleDemo/SimpleDemo.Avalonia/Views/TipView.axaml new file mode 100644 index 00000000..b2c76664 --- /dev/null +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/Views/TipView.axaml @@ -0,0 +1,8 @@ + + Welcome to Avalonia! + diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/Views/TipView.axaml.cs b/Demos/SimpleDemo/SimpleDemo.Avalonia/Views/TipView.axaml.cs new file mode 100644 index 00000000..3decf0b4 --- /dev/null +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/Views/TipView.axaml.cs @@ -0,0 +1,15 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; +using MinoriEditorShell.Platforms.Avalonia.Presenters.Attributes; + +namespace SimpleDemo.Avalonia.Views +{ + [MesContentPresentation] + public partial class TipView : UserControl + { + public TipView() => InitializeComponent(); + + private void InitializeComponent() => AvaloniaXamlLoader.Load(this); + } +} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs index 51935e5c..0c7f4bd7 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs @@ -111,17 +111,28 @@ public override void LoadPlugins(IMvxPluginManager pluginManager) pluginManager.EnsurePluginLoaded(); } + /// + /// Setup class based on presenter + /// + /// + /// public void PlatformInitialize(Dispatcher uiThreadDispatcher, IMesAvnViewPresenter presenter) { _uiThreadDispatcher = uiThreadDispatcher; _presenter = presenter; } + /// + /// Setup presenter based on content + /// + /// + /// public void PlatformInitialize(Dispatcher uiThreadDispatcher, ContentControl root) { _uiThreadDispatcher = uiThreadDispatcher; _root = root; } + /// /// Creates the app. /// From f672aaecead0c43421c34f28e2990b252fa7ec8e Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sun, 15 Aug 2021 22:42:14 -0400 Subject: [PATCH 43/68] remove extra ruleset --- Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-1.ruleset | 5 ----- Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-2.ruleset | 5 ----- Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-3.ruleset | 5 ----- Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-4.ruleset | 5 ----- 4 files changed, 20 deletions(-) delete mode 100644 Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-1.ruleset delete mode 100644 Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-2.ruleset delete mode 100644 Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-3.ruleset delete mode 100644 Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-4.ruleset diff --git a/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-1.ruleset b/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-1.ruleset deleted file mode 100644 index b327e534..00000000 --- a/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-1.ruleset +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-2.ruleset b/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-2.ruleset deleted file mode 100644 index b327e534..00000000 --- a/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-2.ruleset +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-3.ruleset b/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-3.ruleset deleted file mode 100644 index b327e534..00000000 --- a/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-3.ruleset +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-4.ruleset b/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-4.ruleset deleted file mode 100644 index b327e534..00000000 --- a/Demos/SimpleDemo/SimpleDemo.Core/SimpleDemo.Core-4.ruleset +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file From 36a3d248c8c414d823d23a2a8cc6faa541b91f06 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sat, 21 Aug 2021 19:22:17 -0400 Subject: [PATCH 44/68] add comments to view model --- .../Views/MesAvnView.cs | 62 ++++++++++++++----- 1 file changed, 46 insertions(+), 16 deletions(-) diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnView.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnView.cs index 82abd55a..6529899f 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnView.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnView.cs @@ -1,4 +1,5 @@ -using Avalonia.Controls; +using Avalonia; +using Avalonia.Controls; using Avalonia.Interactivity; using MvvmCross; using MvvmCross.Binding.BindingContext; @@ -9,11 +10,17 @@ namespace MinoriEditorShell.Platforms.Avalonia.Views { + /// + /// Mes Avalonia helper class + /// public class MesAvnView : UserControl, IMesAvnView, IDisposable { private IMvxViewModel _viewModel; private IMvxBindingContext _bindingContext; + /// + /// Interface to view model. + /// public IMvxViewModel ViewModel { get => _viewModel; @@ -25,6 +32,9 @@ public IMvxViewModel ViewModel } } + /// + /// Get binding context + /// public IMvxBindingContext BindingContext { get @@ -40,60 +50,80 @@ public IMvxBindingContext BindingContext set => _bindingContext = value; } + /// + /// Default constructor for class + /// public MesAvnView() { -#warning fix MesAvnView ctor - //Unloaded += MvxWpfView_Unloaded; - //Loaded += MvxWpfView_Loaded; + DetachedFromVisualTree += MvxWpfView_Unloaded; + AttachedToVisualTree += MvxWpfView_Loaded; } - private void MvxWpfView_Unloaded(object sender, RoutedEventArgs e) + private void MvxWpfView_Unloaded(Object sender, VisualTreeAttachmentEventArgs e) { ViewModel?.ViewDisappearing(); ViewModel?.ViewDisappeared(); ViewModel?.ViewDestroy(); } - private void MvxWpfView_Loaded(object sender, RoutedEventArgs e) - { + private void MvxWpfView_Loaded(Object sender, VisualTreeAttachmentEventArgs e) + { ViewModel?.ViewAppearing(); ViewModel?.ViewAppeared(); } + /// + /// Standard dispose pattern. + /// public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } + /// + /// deconstructor + /// ~MesAvnView() { Dispose(false); } + /// + /// Standard disposable pattern + /// + /// protected virtual void Dispose(bool disposing) { if (disposing) { -#warning fix MesAvnView Dispose - //Unloaded -= MvxWpfView_Unloaded; - //Loaded -= MvxWpfView_Loaded; + DetachedFromVisualTree -= MvxWpfView_Unloaded; + AttachedToVisualTree -= MvxWpfView_Loaded; } } } + /// + /// Helper class for + /// + /// public class MesAvnView : MesAvnView, IMesAvnView where TViewModel : class, IMvxViewModel { + /// + /// View model interface + /// public new TViewModel ViewModel { - get { return (TViewModel)base.ViewModel; } - set { base.ViewModel = value; } + get => (TViewModel)base.ViewModel; + set => base.ViewModel = value; } - public MvxFluentBindingDescriptionSet, TViewModel> CreateBindingSet() - { - return this.CreateBindingSet, TViewModel>(); - } + /// + /// Helper to create binding set + /// + /// + public MvxFluentBindingDescriptionSet, TViewModel> CreateBindingSet() => + this.CreateBindingSet, TViewModel>(); } } From 858eb89948222af6a527d1b49bc4879f8ad56c3c Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sat, 21 Aug 2021 19:30:11 -0400 Subject: [PATCH 45/68] nuget updates --- .../SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj | 10 +++------- .../MinoriEditorShell.Platforms.Avalonia.csproj | 8 ++------ .../Views/MesAvnView.cs | 2 +- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj b/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj index cf433cc7..b6e236e7 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj @@ -8,13 +8,9 @@ - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + + + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj index f9445ee0..62f42629 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj @@ -46,12 +46,8 @@ This uses AvalonDock and has an MVVM architecture based on MvvmCross. - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnView.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnView.cs index 6529899f..be81b00a 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnView.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesAvnView.cs @@ -93,7 +93,7 @@ public void Dispose() /// Standard disposable pattern /// /// - protected virtual void Dispose(bool disposing) + protected virtual void Dispose(Boolean disposing) { if (disposing) { From f34fb577a1827d56fe85a4cb600106540aa1fc0b Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sat, 21 Aug 2021 21:27:37 -0400 Subject: [PATCH 46/68] add skipped files, adpat first pass for avalonaia --- .../Binding/Bi.n.d.cs | 48 +++--- .../Binding/La.n.g.cs | 46 +++--- .../MesBinding/MesMvvmCrossBindingCreator.cs | 142 +++++++++--------- .../MesWindowsTargetBindingFactoryRegistry.cs | 3 +- .../MesDependencyPropertyTargetBinding.cs | 76 +++++----- .../Target/MesVisibleTargetBinding.cs | 9 +- .../MesDependencyPropertyExtensions.cs | 5 +- .../Binding/MesDesignTimeChecker.cs | 24 +-- .../Binding/MesWindowsBindingBuilder.cs | 42 +++--- .../AvnWindowsBindingCreator.cs | 37 ++--- .../Core/MesAvnSetup.cs | 4 +- ...inoriEditorShell.Platforms.Avalonia.csproj | 103 ++++++------- 12 files changed, 282 insertions(+), 257 deletions(-) diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/Bi.n.d.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/Bi.n.d.cs index 9cef3f67..1a7f3ca5 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/Bi.n.d.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/Bi.n.d.cs @@ -5,6 +5,8 @@ using MvvmCross.Binding; using MvvmCross.Binding.Bindings; using MvvmCross; +using Avalonia; +using System; namespace MinoriEditorShell.Platforms.Avalonia.Binding { @@ -18,24 +20,27 @@ static Bi() } // ReSharper disable InconsistentNaming - public static readonly DependencyProperty ndProperty = - // ReSharper restore InconsistentNaming - DependencyProperty.RegisterAttached("nd", - typeof(string), - typeof(Bi), - new PropertyMetadata(null, CallBackWhenndIsChanged)); +#warning fix ndProperty + //public static readonly AvaloniaProperty ndProperty = + // // ReSharper restore InconsistentNaming + // AvaloniaProperty.RegisterAttached("nd", + // typeof(string), + // typeof(Bi), + // new AvaloniaProperty(null, CallBackWhenndIsChanged)); - public static string Getnd(DependencyObject obj) + public static string Getnd(AvaloniaProperty obj) { - return obj.GetValue(ndProperty) as string; + //return obj.GetValue(ndProperty) as string; + throw new NotImplementedException(); } - public static void Setnd( - DependencyObject obj, - string value) - { - obj.SetValue(ndProperty, value); - } +#warning fix Setnd + //public static void Setnd( + // StyledProperty obj, + // string value) + //{ + // obj.SetValue(ndProperty, value); + //} private static IMesBindingCreator _bindingCreator; @@ -61,19 +66,22 @@ private static IMesBindingCreator ResolveBindingCreator() private static void CallBackWhenndIsChanged( object sender, - DependencyPropertyChangedEventArgs args) + object args) + //StyledPropertyChangedEventArgs args) { - var bindingCreator = BindingCreator; + //var bindingCreator = BindingCreator; - bindingCreator?.CreateBindings(sender, args, ParseBindingDescriptions); + //bindingCreator?.CreateBindings(sender, args, ParseBindingDescriptions); + throw new NotImplementedException(); } private static IEnumerable ParseBindingDescriptions(string bindingText) { - if (MvxSingleton.Instance == null) - return null; + throw new NotImplementedException(); + //if (MvxSingleton.Instance == null) + // return null; - return MvxSingleton.Instance.BindingDescriptionParser.Parse(bindingText); + //return MvxSingleton.Instance.BindingDescriptionParser.Parse(bindingText); } } } diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/La.n.g.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/La.n.g.cs index ee160e51..e8f5423d 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/La.n.g.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/La.n.g.cs @@ -5,6 +5,8 @@ using MvvmCross.Base; using MvvmCross.Binding; using MvvmCross.Core; +using Avalonia; +using MvvmCross; namespace MinoriEditorShell.Platforms.Avalonia.Binding { @@ -18,23 +20,26 @@ static La() } // ReSharper disable InconsistentNaming - public static readonly DependencyProperty ngProperty = - // ReSharper restore InconsistentNaming - DependencyProperty.RegisterAttached("ng", - typeof(string), - typeof(La), - new PropertyMetadata(null, CallBackWhenngIsChanged)); +#warning fix ngProperty + //public static readonly AvaloniaProperty ngProperty = + // // ReSharper restore InconsistentNaming + // AvaloniaProperty.RegisterAttached("ng", + // typeof(string), + // typeof(La), + // new AvaloniaPropertyMetadata()); //null, CallBackWhenngIsChanged)); - public static string Getng(DependencyObject obj) + public static string Getng(AvaloniaObject obj) { - return obj.GetValue(ngProperty) as string; + //return obj.GetValue(ngProperty) as string; + throw new NotImplementedException(); } public static void Setng( - DependencyObject obj, + AvaloniaObject obj, string value) { - obj.SetValue(ngProperty, value); + //obj.SetValue(ngProperty, value); + throw new NotImplementedException(); } private static IMesBindingCreator _bindingCreator; @@ -48,17 +53,18 @@ private static IMesBindingCreator BindingCreator } } - private static void CallBackWhenngIsChanged( - object sender, - DependencyPropertyChangedEventArgs args) - { - // bindingCreator may be null in the designer currently - var bindingCreator = BindingCreator; - if (bindingCreator == null) - return; +#warning fix CallBackWhenngIsChanged + //private static void CallBackWhenngIsChanged( + // object sender, + // DependencyPropertyChangedEventArgs args) + //{ + // // bindingCreator may be null in the designer currently + // var bindingCreator = BindingCreator; + // if (bindingCreator == null) + // return; - bindingCreator.CreateBindings(sender, args, ParseBindingDescriptions); - } + // bindingCreator.CreateBindings(sender, args, ParseBindingDescriptions); + //} private static IEnumerable ParseBindingDescriptions(string languageText) { diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/MesMvvmCrossBindingCreator.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/MesMvvmCrossBindingCreator.cs index 766718fa..c24530a3 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/MesMvvmCrossBindingCreator.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/MesMvvmCrossBindingCreator.cs @@ -33,90 +33,98 @@ private void RegisterBindingsForUpdates(AvaloniaObject attachedObject, private IList GetOrCreateBindingsList(AvaloniaObject attachedObject) { - var existing = attachedObject.GetValue(BindingsListProperty) as IList; - if (existing != null) - return existing; - - // attach the list - var newList = new List(); - attachedObject.SetValue(BindingsListProperty, newList); - - // create a binding watcher for the list - var binding = new System.Windows.Data.Binding(); - bool attached = false; - Action attachAction = () => - { - if (attached) - return; - BindingOperations.SetBinding(attachedObject, DataContextWatcherProperty, binding); - attached = true; - }; - - Action detachAction = () => - { - if (!attached) - return; - - BindingOperations.ClearBinding(attachedObject, DataContextWatcherProperty); - attached = false; - }; - attachAction(); - attachedObject.Loaded += (o, args) => - { - attachAction(); - }; - attachedObject.Unloaded += (o, args) => - { - detachAction(); - }; - - return newList; + //var existing = attachedObject.GetValue(BindingsListProperty) as IList; + //if (existing != null) + // return existing; + + //// attach the list + //var newList = new List(); + //attachedObject.SetValue(BindingsListProperty, newList); + + //// create a binding watcher for the list + //var binding = new System.Windows.Data.Binding(); + //bool attached = false; + //Action attachAction = () => + //{ + // if (attached) + // return; + // BindingOperations.SetBinding(attachedObject, DataContextWatcherProperty, binding); + // attached = true; + //}; + + //Action detachAction = () => + //{ + // if (!attached) + // return; + + // BindingOperations.ClearBinding(attachedObject, DataContextWatcherProperty); + // attached = false; + //}; + //attachAction(); + //attachedObject.Loaded += (o, args) => + //{ + // attachAction(); + //}; + //attachedObject.Unloaded += (o, args) => + //{ + // detachAction(); + //}; + + //return newList; + throw new NotImplementedException(); } - public static readonly DependencyProperty DataContextWatcherProperty = DependencyProperty.Register( - "DataContextWatcher", - typeof(object), - typeof(AvaloniaObject), - new PropertyMetadata(null, DataContext_Changed)); +#warning fix DataContextWatcherProperty + //public static readonly AvaloniaProperty DataContextWatcherProperty = AvaloniaProperty.Register( + // "DataContextWatcher", + // typeof(object), + // typeof(AvaloniaObject), + // new AvaloniaPropertyMetadata(null, DataContext_Changed)); - public static object GetDataContextWatcher(DependencyObject d) + public static object GetDataContextWatcher(AvaloniaProperty d) { - return d.GetValue(DataContextWatcherProperty); + //return d.GetValue(DataContextWatcherProperty); + throw new NotImplementedException(); } - public static void SetDataContextWatcher(DependencyObject d, string value) + public static void SetDataContextWatcher(AvaloniaProperty d, string value) { - d.SetValue(DataContextWatcherProperty, value); + //d.SetValue(DataContextWatcherProperty, value); + throw new NotImplementedException(); } - public static readonly DependencyProperty BindingsListProperty = DependencyProperty.Register( - "BindingsList", - typeof(IList), - typeof(AvaloniaObject), - new PropertyMetadata(null)); +#warning fix BindingsListProperty + //public static readonly AvaloniaProperty BindingsListProperty = AvaloniaProperty.Register( + // "BindingsList", + // typeof(IList), + // typeof(AvaloniaObject), + // new AvaloniaPropertyMetadata(null)); - public static IList GetBindingsList(DependencyObject d) + public static IList GetBindingsList(AvaloniaProperty d) { - return d.GetValue(BindingsListProperty) as IList; + //return d.GetValue(BindingsListProperty) as IList; + throw new NotImplementedException(); } - public static void SetBindingsList(DependencyObject d, string value) + public static void SetBindingsList(AvaloniaProperty d, string value) { - d.SetValue(BindingsListProperty, value); + //d.SetValue(BindingsListProperty, value); + throw new NotImplementedException(); } - private static void DataContext_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - var frameworkElement = d as AvaloniaObject; +#warning fix DataContext_Changed + //private static void DataContext_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e) + //{ + // var frameworkElement = d as AvaloniaObject; - var bindings = frameworkElement?.GetValue(BindingsListProperty) as IList; - if (bindings == null) - return; + // var bindings = frameworkElement?.GetValue(BindingsListProperty) as IList; + // if (bindings == null) + // return; - foreach (var binding in bindings) - { - binding.DataContext = e.NewValue; - } - } + // foreach (var binding in bindings) + // { + // binding.DataContext = e.NewValue; + // } + //} } } diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/MesWindowsTargetBindingFactoryRegistry.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/MesWindowsTargetBindingFactoryRegistry.cs index 47fa3344..55d59750 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/MesWindowsTargetBindingFactoryRegistry.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/MesWindowsTargetBindingFactoryRegistry.cs @@ -1,3 +1,4 @@ +using MinoriEditorShell.Platforms.Avalonia.Binding.MesBinding.Target; using MvvmCross.Binding; using MvvmCross.Binding.Bindings.Target; using MvvmCross.Binding.Bindings.Target.Construction; @@ -44,7 +45,7 @@ private static bool TryCreatePropertyDependencyBasedBinding(object target, strin var actualProperty = target.GetType().FindActualProperty(targetName); var actualPropertyType = actualProperty?.PropertyType ?? typeof(object); - binding = new MvxDependencyPropertyTargetBinding(target, targetName, dependencyProperty, actualPropertyType); + binding = new MesDependencyPropertyTargetBinding(target, targetName, dependencyProperty, actualPropertyType); return true; } } diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/Target/MesDependencyPropertyTargetBinding.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/Target/MesDependencyPropertyTargetBinding.cs index 2c8b25c9..7e64f493 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/Target/MesDependencyPropertyTargetBinding.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/Target/MesDependencyPropertyTargetBinding.cs @@ -1,5 +1,6 @@ using System; using System.ComponentModel; +using Avalonia; using MvvmCross.Binding; using MvvmCross.Binding.Bindings.Target; using MvvmCross.Binding.Extensions; @@ -9,11 +10,11 @@ namespace MinoriEditorShell.Platforms.Avalonia.Binding.MesBinding.Target public class MesDependencyPropertyTargetBinding : MvxConvertingTargetBinding { private readonly string _targetName; - private readonly DependencyProperty _targetDependencyProperty; + private readonly AvaloniaProperty _targetDependencyProperty; private readonly Type _actualPropertyType; private readonly TypeConverter _typeConverter; - public MesDependencyPropertyTargetBinding(object target, string targetName, DependencyProperty targetDependencyProperty, Type actualPropertyType) + public MesDependencyPropertyTargetBinding(object target, string targetName, AvaloniaProperty targetDependencyProperty, Type actualPropertyType) : base(target) { _targetDependencyProperty = targetDependencyProperty; @@ -25,26 +26,29 @@ public MesDependencyPropertyTargetBinding(object target, string targetName, Depe // problems with WP7 not doing the auto-conversion // see some of my angst in http://stackoverflow.com/questions/16752242/how-does-xaml-create-the-string-to-bitmapimage-value-conversion-when-binding-to/16753488#16753488 // Note: if we discover other issues here, then we should make a more flexible solution - if (_actualPropertyType == typeof(ImageSource)) - { - _defaultBindingMode = MvxBindingMode.OneWay; - } + +#warning TODO: fix ImageSource + //if (_actualPropertyType == typeof(ImageSource)) + //{ + // _defaultBindingMode = MvxBindingMode.OneWay; + //} } public override void SubscribeToEvents() { - var frameworkElement = Target as FrameworkElement; - if (frameworkElement == null) - return; - var listenerBinding = new System.Windows.Data.Binding(_targetName) - { Source = frameworkElement }; - - var attachedProperty = DependencyProperty.RegisterAttached( - "ListenAttached" + _targetName + Guid.NewGuid().ToString("N") - , typeof(object) - , typeof(FrameworkElement) - , new PropertyMetadata(null, (s, e) => FireValueChanged(e.NewValue))); - frameworkElement.SetBinding(attachedProperty, listenerBinding); + //var frameworkElement = Target as FrameworkElement; + //if (frameworkElement == null) + // return; + //var listenerBinding = new System.Windows.Data.Binding(_targetName) + //{ Source = frameworkElement }; + + //var attachedProperty = DependencyProperty.RegisterAttached( + // "ListenAttached" + _targetName + Guid.NewGuid().ToString("N") + // , typeof(object) + // , typeof(FrameworkElement) + // , new PropertyMetadata(null, (s, e) => FireValueChanged(e.NewValue))); + //frameworkElement.SetBinding(attachedProperty, listenerBinding); + throw new NotImplementedException(); } public override Type TargetType => _actualPropertyType; @@ -54,27 +58,29 @@ public override void SubscribeToEvents() protected virtual object GetValueByReflection() { - var target = Target as FrameworkElement; - if (target == null) - { - MvxBindingLog.Warning("Weak Target is null in {0} - skipping Get", GetType().Name); - return null; - } - - return target.GetValue(_targetDependencyProperty); + throw new NotImplementedException(); + //var target = Target as FrameworkElement; + //if (target == null) + //{ + // MvxBindingLog.Warning("Weak Target is null in {0} - skipping Get", GetType().Name); + // return null; + //} + + //return target.GetValue(_targetDependencyProperty); } protected override void SetValueImpl(object target, object value) { - MvxBindingLog.Trace("Receiving setValue to " + (value ?? "")); - var frameworkElement = target as FrameworkElement; - if (frameworkElement == null) - { - MvxBindingLog.Warning("Weak Target is null in {0} - skipping set", GetType().Name); - return; - } - - frameworkElement.SetValue(_targetDependencyProperty, value); + throw new NotImplementedException(); + //MvxBindingLog.Trace("Receiving setValue to " + (value ?? "")); + //var frameworkElement = target as FrameworkElement; + //if (frameworkElement == null) + //{ + // MvxBindingLog.Warning("Weak Target is null in {0} - skipping set", GetType().Name); + // return; + //} + + //frameworkElement.SetValue(_targetDependencyProperty, value); } protected override object MakeSafeValue(object value) diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/Target/MesVisibleTargetBinding.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/Target/MesVisibleTargetBinding.cs index bd97a321..49d8f4f4 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/Target/MesVisibleTargetBinding.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesBinding/Target/MesVisibleTargetBinding.cs @@ -1,13 +1,16 @@ -using System; +using Avalonia; +using Avalonia.Controls; using MvvmCross.Binding; +using System; namespace MinoriEditorShell.Platforms.Avalonia.Binding.MesBinding.Target { public class MesVisibleTargetBinding : MesDependencyPropertyTargetBinding { public MesVisibleTargetBinding(object target) - : base(target, "Visibility", UIElement.VisibilityProperty, typeof(Visibility)) + : base(target, "Visibility", Visual.IsVisibleProperty, typeof(StyledProperty)) { + } public override MvxBindingMode DefaultMode => MvxBindingMode.OneWay; @@ -19,7 +22,7 @@ public override void SetValue(object value) if (value == null) value = false; var boolValue = (bool)value; - base.SetValue(boolValue ? Visibility.Visible : Visibility.Collapsed); + base.SetValue(boolValue);// ? Visibility.Visible : Visibility.Collapsed); } } } diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesDependencyPropertyExtensions.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesDependencyPropertyExtensions.cs index 2fbe9005..e0cb1d58 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesDependencyPropertyExtensions.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesDependencyPropertyExtensions.cs @@ -1,3 +1,4 @@ +using Avalonia; using System; using System.ComponentModel; using System.Linq; @@ -54,14 +55,14 @@ public static FieldInfo FindDependencyPropertyInfo(this Type type, string depend return null; } - public static DependencyProperty FindDependencyProperty(this Type type, string name) + public static AvaloniaProperty FindDependencyProperty(this Type type, string name) { if (string.IsNullOrEmpty(name)) return null; var propertyInfo = FindDependencyPropertyInfo(type, name); - return propertyInfo?.GetValue(null) as DependencyProperty; + return propertyInfo?.GetValue(null) as AvaloniaProperty; } private static bool EnsureIsDependencyPropertyName(ref string dependencyPropertyName) diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesDesignTimeChecker.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesDesignTimeChecker.cs index 8ed33fc1..ff42270e 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesDesignTimeChecker.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesDesignTimeChecker.cs @@ -1,5 +1,6 @@ using MvvmCross; using MvvmCross.Binding.Parse.Binding; +using System; namespace MinoriEditorShell.Platforms.Avalonia.Binding { @@ -9,20 +10,21 @@ public static class MesDesignTimeChecker public static void Check() { - if (_checked) - return; + //if (_checked) + // return; - _checked = true; - if (!MvxDesignTimeHelper.IsInDesignTime) - return; + //_checked = true; + //if (!MvxDesignTimeHelper.IsInDesignTime) + // return; - MvxDesignTimeHelper.Initialize(); + //MvxDesignTimeHelper.Initialize(); - if (!Mvx.IoCProvider.CanResolve()) - { - var builder = new MesWindowsBindingBuilder(MesWindowsBindingBuilder.BindingType.MvvmCross); - builder.DoRegistration(); - } + //if (!Mvx.IoCProvider.CanResolve()) + //{ + // var builder = new MesWindowsBindingBuilder(MesWindowsBindingBuilder.BindingType.MvvmCross); + // builder.DoRegistration(); + //} + throw new NotImplementedException(); } } } diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsBindingBuilder.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsBindingBuilder.cs index 27a5c794..ee95871e 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsBindingBuilder.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsBindingBuilder.cs @@ -5,6 +5,9 @@ using MvvmCross.Binding.Binders; using MvvmCross.Binding.Bindings.Target.Construction; using MvvmCross.Binding.Combiners; +using MvvmCross.IoC; +using MinoriEditorShell.Platforms.Avalonia.Binding.MesBinding; +using MvvmCross; namespace MinoriEditorShell.Platforms.Avalonia.Binding { @@ -24,13 +27,13 @@ public MesWindowsBindingBuilder( _bindingType = bindingType; } - public override void DoRegistration() + public override void DoRegistration(IMvxIoCProvider iocProvider) { - base.DoRegistration(); + base.DoRegistration(iocProvider); InitializeBindingCreator(); } - protected override void RegisterBindingFactories() + protected override void RegisterBindingFactories(IMvxIoCProvider iocProvider) { switch (_bindingType) { @@ -39,7 +42,7 @@ protected override void RegisterBindingFactories() break; case BindingType.MvvmCross: - base.RegisterBindingFactories(); + base.RegisterBindingFactories(iocProvider); break; default: @@ -55,7 +58,7 @@ protected override IMvxTargetBindingFactoryRegistry CreateTargetBindingRegistry( return base.CreateTargetBindingRegistry(); case BindingType.MvvmCross: - return new MvxWindowsTargetBindingFactoryRegistry(); + return new MesWindowsTargetBindingFactoryRegistry(); default: throw new ArgumentOutOfRangeException(); @@ -72,11 +75,11 @@ protected virtual IMesBindingCreator CreateBindingCreator() { switch (_bindingType) { - case BindingType.Windows: - return new MvxWindowsBindingCreator(); + //case BindingType.Windows: + // return new MvxWindowsBindingCreator(); - case BindingType.MvvmCross: - return new MvxMvvmCrossBindingCreator(); + //case BindingType.MvvmCross: + // return new MvxMvvmCrossBindingCreator(); default: throw new ArgumentOutOfRangeException(); @@ -111,19 +114,20 @@ protected override void FillValueCombiners(IMvxValueCombinerRegistry registry) protected override void FillTargetFactories(IMvxTargetBindingFactoryRegistry registry) { - registry.RegisterCustomBindingFactory( - MesWindowsPropertyBinding.FrameworkElement_Visible, - view => new MvxVisibleTargetBinding(view)); + throw new NotImplementedException(); + //registry.RegisterCustomBindingFactory( + // MesWindowsPropertyBinding.FrameworkElement_Visible, + // view => new MvxVisibleTargetBinding(view)); - registry.RegisterCustomBindingFactory( - MesWindowsPropertyBinding.FrameworkElement_Collapsed, - view => new MvxCollapsedTargetBinding(view)); + //registry.RegisterCustomBindingFactory( + // MesWindowsPropertyBinding.FrameworkElement_Collapsed, + // view => new MvxCollapsedTargetBinding(view)); - registry.RegisterCustomBindingFactory( - MesWindowsPropertyBinding.FrameworkElement_Hidden, - view => new MvxCollapsedTargetBinding(view)); + //registry.RegisterCustomBindingFactory( + // MesWindowsPropertyBinding.FrameworkElement_Hidden, + // view => new MvxCollapsedTargetBinding(view)); - base.FillTargetFactories(registry); + //base.FillTargetFactories(registry); } } } diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/WindowsBinding/AvnWindowsBindingCreator.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/WindowsBinding/AvnWindowsBindingCreator.cs index 5d6abd03..d9f8999d 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/WindowsBinding/AvnWindowsBindingCreator.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/WindowsBinding/AvnWindowsBindingCreator.cs @@ -12,6 +12,7 @@ using MinoriEditorShell.Platforms.Avalonia.Converters; using Avalonia; using MvvmCross; +using Microsoft.Extensions.Logging; namespace MinoriEditorShell.Platforms.Avalonia.Binding.WindowsBinding { @@ -20,36 +21,37 @@ public class AvnWindowsBindingCreator : MesBindingCreator protected virtual void ApplyBinding(MvxBindingDescription bindingDescription, Type actualType, StyledElement attachedObject) { - IMvxLog log = Mvx.IoCProvider.Resolve().GetLogFor(); - DependencyProperty dependencyProperty = actualType.FindDependencyProperty(bindingDescription.TargetName); + ILogger log = MvxLogHost.GetLog(); + AvaloniaProperty dependencyProperty = actualType.FindDependencyProperty(bindingDescription.TargetName); if (dependencyProperty == null) { - log.Warn("Dependency property not found for {0}", bindingDescription.TargetName); + log.LogWarning("Dependency property not found for {0}", bindingDescription.TargetName); return; } var property = actualType.FindActualProperty(bindingDescription.TargetName); if (property == null) { - log.Warn("Property not returned {0} - may cause issues", bindingDescription.TargetName); + log.LogWarning("Property not returned {0} - may cause issues", bindingDescription.TargetName); } var sourceStep = bindingDescription.Source as MvxPathSourceStepDescription; if (sourceStep == null) { - log.Warn("Binding description for {0} is not a simple path - Windows Binding cannot cope with this", bindingDescription.TargetName); + log.LogWarning("Binding description for {0} is not a simple path - Windows Binding cannot cope with this", bindingDescription.TargetName); return; } - var newBinding = new System.Windows.Data.Binding - { - Path = new PropertyPath(sourceStep.SourcePropertyPath), - Mode = ConvertMode(bindingDescription.Mode, property?.PropertyType ?? typeof(object)), - Converter = GetConverter(sourceStep.Converter), - ConverterParameter = sourceStep.ConverterParameter, - }; + throw new NotImplementedException(); + //var newBinding = new + //{ + // Path = new PropertyPath(sourceStep.SourcePropertyPath), + // Mode = ConvertMode(bindingDescription.Mode, property?.PropertyType ?? typeof(object)), + // Converter = GetConverter(sourceStep.Converter), + // ConverterParameter = sourceStep.ConverterParameter, + //}; - BindingOperations.SetBinding(attachedObject, dependencyProperty, newBinding); + //BindingOperations.Apply(attachedObject, dependencyProperty, newBinding); } protected override void ApplyBindings(StyledElement attachedObject, @@ -80,8 +82,9 @@ protected static BindingMode ConvertMode(MvxBindingMode mode, Type propertyType) // problems with WP7 not doing the auto-conversion // see some of my angst in http://stackoverflow.com/questions/16752242/how-does-xaml-create-the-string-to-bitmapimage-value-conversion-when-binding-to/16753488#16753488 // Note: if we discover other issues here, then we should make a more flexible solution - if (propertyType == typeof(ImageSource)) - return BindingMode.OneWay; +#warning fix ImageSource + //if (propertyType == typeof(ImageSource)) + // return BindingMode.OneWay; return BindingMode.TwoWay; @@ -95,8 +98,8 @@ protected static BindingMode ConvertMode(MvxBindingMode mode, Type propertyType) return BindingMode.OneTime; case MvxBindingMode.OneWayToSource: - IMvxLog log = Mvx.IoCProvider.Resolve().GetLogFor(); - log.Warn("WinPhone doesn't support OneWayToSource"); + ILogger log = MvxLogHost.GetLog(); + log.LogWarning("WinPhone doesn't support OneWayToSource"); return BindingMode.TwoWay; default: diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs index 0c7f4bd7..f640060f 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs @@ -27,6 +27,7 @@ using MvvmCross.Binding.Bindings.Target.Construction; using MvvmCross.Binding.Binders; using Microsoft.Extensions.Logging; +using MinoriEditorShell.Platforms.Avalonia.Binding; // Portions of this was barrowed from MvvmCross. namespace MinoriEditorShell.Platforms.Avalonia @@ -159,8 +160,7 @@ protected virtual IMesAvnViewsContainer CreateAvnViewsContainer() protected virtual MvxBindingBuilder CreateBindingBuilder() { - throw new NotImplementedException(); - //return new MvxWindowsBindingBuilder(); + return new MesWindowsBindingBuilder(); } /// diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj index 62f42629..947f68c2 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj @@ -1,62 +1,45 @@  - - - netstandard2.0 - MinoriEditorStudio is an application shell similar in concept to the Visual Studio Shell. -This uses AvalonDock and has an MVVM architecture based on MvvmCross. - Copyright 2019 - https://github.com/TorisanKitsune/MinoriEditorShell - https://github.com/TorisanKitsune/MinoriEditorShell - - git - .net40 netcoreapp AvaloniaUI MvvmCross AvalonDock Visual Studio IDE Shell - true - Mark Kromis - Mark Kromis - Library - bin\MinoriEditorShell.Platforms.Avalonia.xml - ..\..\.sonarlint\torisankitsune_minorieditorshellcsharp.ruleset - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + netstandard2.0 + + MinoriEditorStudio is an application shell similar in concept to the Visual Studio Shell. + This uses AvalonDock and has an MVVM architecture based on MvvmCross. + + Copyright 2019 + https://github.com/TorisanKitsune/MinoriEditorShell + https://github.com/TorisanKitsune/MinoriEditorShell + + git + .net40 netcoreapp AvaloniaUI MvvmCross AvalonDock Visual Studio IDE Shell + true + Mark Kromis + Mark Kromis + Library + bin\MinoriEditorShell.Platforms.Avalonia.xml + ..\..\.sonarlint\torisankitsune_minorieditorshellcsharp.ruleset + + + + + + + + + + + + + + + + + + + + + + + + From a442268653adcff834fb460d5a59e93a631efd36 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sat, 21 Aug 2021 22:01:10 -0400 Subject: [PATCH 47/68] Initial mainview works --- .../Binding/MesWindowsBindingBuilder.cs | 10 +++++----- .../Core/MesAvnSetup.cs | 6 ++++-- .../Views/MesWindow.cs | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsBindingBuilder.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsBindingBuilder.cs index ee95871e..006fd8b8 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsBindingBuilder.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Binding/MesWindowsBindingBuilder.cs @@ -76,10 +76,10 @@ protected virtual IMesBindingCreator CreateBindingCreator() switch (_bindingType) { //case BindingType.Windows: - // return new MvxWindowsBindingCreator(); + // return new MesWindowsBindingCreator(); - //case BindingType.MvvmCross: - // return new MvxMvvmCrossBindingCreator(); + case BindingType.MvvmCross: + return new MesMvvmCrossBindingCreator(); default: throw new ArgumentOutOfRangeException(); @@ -114,7 +114,7 @@ protected override void FillValueCombiners(IMvxValueCombinerRegistry registry) protected override void FillTargetFactories(IMvxTargetBindingFactoryRegistry registry) { - throw new NotImplementedException(); +#warning fix FillTargetFactories //registry.RegisterCustomBindingFactory( // MesWindowsPropertyBinding.FrameworkElement_Visible, // view => new MvxVisibleTargetBinding(view)); @@ -127,7 +127,7 @@ protected override void FillTargetFactories(IMvxTargetBindingFactoryRegistry reg // MesWindowsPropertyBinding.FrameworkElement_Hidden, // view => new MvxCollapsedTargetBinding(view)); - //base.FillTargetFactories(registry); + base.FillTargetFactories(registry); } } } diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs index f640060f..44b127bb 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs @@ -225,14 +225,16 @@ protected virtual void InitializeBindingBuilder(IMvxIoCProvider iocProvider) bindingBuilder.DoRegistration(iocProvider); } - protected void InitializeFirstChance(IMvxIoCProvider iocProvider) + protected override void InitializeFirstChance(IMvxIoCProvider iocProvider) { RegisterPresenter(iocProvider); + base.InitializeFirstChance(iocProvider); } - protected void InitializeLastChance(IMvxIoCProvider iocProvider) + protected override void InitializeLastChance(IMvxIoCProvider iocProvider) { InitializeBindingBuilder(iocProvider); + base.InitializeLastChance(iocProvider); } /// diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesWindow.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesWindow.cs index 65c79799..2c7f56d6 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesWindow.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesWindow.cs @@ -168,7 +168,7 @@ public MvxFluentBindingDescriptionSet, TViewModel> Creat // public String Identifier { get; set; } - // public IMvxBindingContext BindingContext + // public BindingContext // { // get // { From 7035748089d0923101227608a483a31634cfcf69 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sat, 21 Aug 2021 22:19:41 -0400 Subject: [PATCH 48/68] update demo copy --- CreateArtifacts.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/CreateArtifacts.ps1 b/CreateArtifacts.ps1 index 0c7b9f0b..cf8bc51b 100644 --- a/CreateArtifacts.ps1 +++ b/CreateArtifacts.ps1 @@ -19,6 +19,7 @@ foreach ($nupkg in $nupkgs) { #mkdir Artifacts\$basedir\Demos cp Demos\SimpleDemo\SimpleDemo.WPF\bin\Release\net5.0-windows Artifacts\$basedir\Demos\SimpleDemo.WPF -Recurse cp Demos\SimpleDemo\SimpleDemo.RibbonWPF\bin\Release\net5.0-windows Artifacts\$basedir\Demos\SimpleDemo.RibbonWPF -Recurse +cp Demos\SimpleDemo\SimpleDemo.Avalonia\bin\Release\net5.0-windows Artifacts\$basedir\Demos\SimpleDemo.Avalonia -Recurse cp Demos\MinoriDemo\MinoriDemo.WPF\bin\Release\net5.0-windows Artifacts\$basedir\Demos\MinoriDemo.WPF -Recurse cp Demos\MinoriDemo\MinoriDemo.RibbonWPF\bin\Release\net5.0-windows Artifacts\$basedir\Demos\MinoriDemo.RibbonWPF -Recurse From b7bc71154ee4bc99fddd6b525a505981402772ef Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sat, 21 Aug 2021 22:42:25 -0400 Subject: [PATCH 49/68] fix path --- CreateArtifacts.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CreateArtifacts.ps1 b/CreateArtifacts.ps1 index cf8bc51b..5c84f493 100644 --- a/CreateArtifacts.ps1 +++ b/CreateArtifacts.ps1 @@ -19,7 +19,7 @@ foreach ($nupkg in $nupkgs) { #mkdir Artifacts\$basedir\Demos cp Demos\SimpleDemo\SimpleDemo.WPF\bin\Release\net5.0-windows Artifacts\$basedir\Demos\SimpleDemo.WPF -Recurse cp Demos\SimpleDemo\SimpleDemo.RibbonWPF\bin\Release\net5.0-windows Artifacts\$basedir\Demos\SimpleDemo.RibbonWPF -Recurse -cp Demos\SimpleDemo\SimpleDemo.Avalonia\bin\Release\net5.0-windows Artifacts\$basedir\Demos\SimpleDemo.Avalonia -Recurse +cp Demos\SimpleDemo\SimpleDemo.Avalonia\bin\Release\net5.0 Artifacts\$basedir\Demos\SimpleDemo.Avalonia -Recurse cp Demos\MinoriDemo\MinoriDemo.WPF\bin\Release\net5.0-windows Artifacts\$basedir\Demos\MinoriDemo.WPF -Recurse cp Demos\MinoriDemo\MinoriDemo.RibbonWPF\bin\Release\net5.0-windows Artifacts\$basedir\Demos\MinoriDemo.RibbonWPF -Recurse From dff7fd347132f32778e5e8d348d67c872d887c5a Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sun, 22 Aug 2021 16:25:25 -0400 Subject: [PATCH 50/68] fix statusbar for simple demo --- Demos/SimpleDemo/SimpleDemo.RibbonWPF/Views/MainView.xaml | 2 +- Demos/SimpleDemo/SimpleDemo.WPF/Views/MainView.xaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Demos/SimpleDemo/SimpleDemo.RibbonWPF/Views/MainView.xaml b/Demos/SimpleDemo/SimpleDemo.RibbonWPF/Views/MainView.xaml index 8829532f..5c1af20d 100644 --- a/Demos/SimpleDemo/SimpleDemo.RibbonWPF/Views/MainView.xaml +++ b/Demos/SimpleDemo/SimpleDemo.RibbonWPF/Views/MainView.xaml @@ -18,7 +18,7 @@ - + \ No newline at end of file diff --git a/Demos/SimpleDemo/SimpleDemo.WPF/Views/MainView.xaml b/Demos/SimpleDemo/SimpleDemo.WPF/Views/MainView.xaml index 4a999091..2908f4f9 100644 --- a/Demos/SimpleDemo/SimpleDemo.WPF/Views/MainView.xaml +++ b/Demos/SimpleDemo/SimpleDemo.WPF/Views/MainView.xaml @@ -23,7 +23,7 @@ - + \ No newline at end of file From 544d7049210fa083e39f69b98b7fe268c460d522 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sun, 22 Aug 2021 16:26:55 -0400 Subject: [PATCH 51/68] remove code warnings --- .github/workflows/build.yml | 6 +++--- .../Controls/MesClippingHwndHost.cs | 1 - .../MinoriEditorShell.Platforms.Avalonia.csproj | 1 + .../Presenters/IMesAvnViewPresenter.cs | 3 +++ .../Presenters/MesAvnViewPresenter.cs | 7 ++++--- .../Themes/MesBlueTheme.cs | 4 +++- .../Themes/MesDarkTheme.cs | 4 +++- .../Themes/MesLightTheme.cs | 4 +++- .../Views/MesApplication.cs | 2 -- .../Views/MesWindow.cs | 2 -- 10 files changed, 20 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f4a98eee..dec4ef97 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -83,9 +83,9 @@ jobs: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} # Needed to get PR information, if any SONAR_TOKEN: ${{secrets.SONAR_TOKEN}} shell: powershell - run: > - .\.sonar\scanner\dotnet-sonarscanner - begin /k:"TorisanKitsune_MinoriEditorShell" /o:"torisankitsune" + run: > + .\.sonar\scanner\dotnet-sonarscanner + begin /k:"TorisanKitsune_MinoriEditorShell" /o:"torisankitsune" /d:sonar.login="${{secrets.SONAR_TOKEN}}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths=**/coverage.opencover.xml /v:${{steps.gitversion.outputs.semVer}} diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesClippingHwndHost.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesClippingHwndHost.cs index acf32c13..3f4acdda 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesClippingHwndHost.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesClippingHwndHost.cs @@ -1,4 +1,3 @@ -using MinoriEditorShell.Platforms.Avalonia.Win32; using System; using System.Collections; using System.Runtime.InteropServices; diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj index 947f68c2..c2bbbcd3 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj @@ -35,6 +35,7 @@ + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/IMesAvnViewPresenter.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/IMesAvnViewPresenter.cs index 056e820c..bccaab25 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/IMesAvnViewPresenter.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/IMesAvnViewPresenter.cs @@ -2,5 +2,8 @@ namespace MinoriEditorShell.Platforms.Avalonia.Presenters { + /// + /// Avalonia specific view presenter + /// public interface IMesAvnViewPresenter : IMvxViewPresenter {} } \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs index 4fde17ca..d2784d43 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs @@ -49,7 +49,9 @@ public MesAvnViewPresenter(ContentControl contentControl) : base() } } - + /// + /// View presenter that helpds dock control + /// protected MesAvnViewPresenter() { } @@ -234,7 +236,7 @@ protected async Task ShowContentView( default: _log.LogTrace($"Passing to parent {view.ViewModel}"); - var contentControl = FrameworkElementsDictionary.Keys.FirstOrDefault(w => (w as MesWindow)?.Identifier == attribute.WindowIdentifier) + ContentControl contentControl = FrameworkElementsDictionary.Keys.FirstOrDefault(w => (w as MesWindow)?.Identifier == attribute.WindowIdentifier) ?? FrameworkElementsDictionary.Keys.Last(); if (!attribute.StackNavigation && FrameworkElementsDictionary[contentControl].Any()) @@ -247,7 +249,6 @@ protected async Task ShowContentView( } catch (Exception exception) { - _log.LogError(exception, "Error seen during navigation request to {0} - error {1}", request.ViewModelType.Name, exception.ToLongString()); throw; diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesBlueTheme.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesBlueTheme.cs index aa5c848b..18547e0f 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesBlueTheme.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesBlueTheme.cs @@ -15,6 +15,8 @@ public class MesBlueTheme : MesThemeBase /// /// Blue theme constructor /// - public MesBlueTheme() : base() => Add(new Uri("pack://application:,,,/MinoriEditorShell.Platforms.Avalonia;component/Themes/BlueTheme.xaml")); + public MesBlueTheme() : base() + { } + //=> Add(new Uri("pack://application:,,,/MinoriEditorShell.Platforms.Avalonia;component/Themes/BlueTheme.xaml")); } } \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesDarkTheme.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesDarkTheme.cs index 737311fc..be96a998 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesDarkTheme.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesDarkTheme.cs @@ -15,6 +15,8 @@ public class MesDarkTheme : MesThemeBase /// /// Constructor for theme /// - public MesDarkTheme() => Add(new Uri("pack://application:,,,/MinoriEditorShell.Platforms.Avalonia;component/Themes/DarkTheme.xaml")); + public MesDarkTheme() + { } + //=> Add(new Uri("pack://application:,,,/MinoriEditorShell.Platforms.Avalonia;component/Themes/DarkTheme.xaml")); } } \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesLightTheme.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesLightTheme.cs index dcd251de..1ee2017f 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesLightTheme.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Themes/MesLightTheme.cs @@ -15,6 +15,8 @@ public class MesLightTheme : MesThemeBase /// /// Light theme constructor /// - public MesLightTheme() : base() => Add(new Uri("pack://application:,,,/MinoriEditorShell.Platforms.Wpf;component/Themes/LightTheme.xaml")); + public MesLightTheme() : base() + { } + //=> Add(new Uri("pack://application:,,,/MinoriEditorShell.Platforms.Wpf;component/Themes/LightTheme.xaml")); } } \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesApplication.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesApplication.cs index d3f40df3..7a7b074c 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesApplication.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesApplication.cs @@ -15,7 +15,6 @@ namespace MinoriEditorShell.Platforms.Avalonia.Views /// public abstract class MesApplication : Application { - /// /// Main application class interface /// @@ -51,7 +50,6 @@ public class MesApplication : MesApplication where TMvxWpfSetup : MesAvnSetup, new() where TApplication : class, IMvxApplication, new() { - /// /// Register setup based on template /// diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesWindow.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesWindow.cs index 2c7f56d6..7bf2c4a0 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesWindow.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesWindow.cs @@ -107,7 +107,6 @@ protected virtual void Dispose(bool disposing) } } - private void MvxWindow_Closed(object sender, EventArgs e) => Unload(); private void MvxWindow_Initialized(object sender, EventArgs e) @@ -116,7 +115,6 @@ private void MvxWindow_Initialized(object sender, EventArgs e) (Application.Current as MesApplication).ApplicationInitialized(); } - private void MvxWindow_Opened(Object sender, EventArgs e) { ViewModel?.ViewAppearing(); From b496678a67a249e1fb479e469abf87d1ce5c4947 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sun, 22 Aug 2021 16:27:41 -0400 Subject: [PATCH 52/68] remove un-used classes --- .../Behaviors/CustomGlowWindowBehavior.cs | 111 --- ...MesBindableTreeViewSelectedItemBehavior.cs | 194 ------ .../Behaviors/MesKeyboardFocusBehavior.cs | 17 - .../Behaviors/MesWindowOptionsBehavior.cs | 101 --- .../Controls/MesHwndMouse.cs | 22 - .../Controls/MesHwndMouseEventArgs.cs | 110 --- .../Controls/MesHwndMouseState.cs | 48 -- .../Controls/MesHwndWrapper.cs | 631 ------------------ .../Win32/NativeMethods.cs | 208 ------ .../Behaviors/CustomGlowWindowBehavior.cs | 111 --- ...MesBindableTreeViewSelectedItemBehavior.cs | 194 ------ .../Behaviors/MesKeyboardFocusBehavior.cs | 17 - .../Behaviors/MesWindowOptionsBehavior.cs | 101 --- .../Controls/MesClippingHwndHost.cs | 90 --- .../Controls/MesHwndMouse.cs | 22 - .../Controls/MesHwndMouseEventArgs.cs | 110 --- .../Controls/MesHwndMouseState.cs | 48 -- .../Controls/MesHwndWrapper.cs | 631 ------------------ .../Views/MesMainWindowView.xaml | 1 - .../Win32/NativeMethods.cs | 208 ------ 20 files changed, 2975 deletions(-) delete mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/CustomGlowWindowBehavior.cs delete mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesBindableTreeViewSelectedItemBehavior.cs delete mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesKeyboardFocusBehavior.cs delete mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesWindowOptionsBehavior.cs delete mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouse.cs delete mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouseEventArgs.cs delete mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouseState.cs delete mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndWrapper.cs delete mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Win32/NativeMethods.cs delete mode 100644 Modules/MinoriEditorShell.Platforms.Wpf/Behaviors/CustomGlowWindowBehavior.cs delete mode 100644 Modules/MinoriEditorShell.Platforms.Wpf/Behaviors/MesBindableTreeViewSelectedItemBehavior.cs delete mode 100644 Modules/MinoriEditorShell.Platforms.Wpf/Behaviors/MesKeyboardFocusBehavior.cs delete mode 100644 Modules/MinoriEditorShell.Platforms.Wpf/Behaviors/MesWindowOptionsBehavior.cs delete mode 100644 Modules/MinoriEditorShell.Platforms.Wpf/Controls/MesClippingHwndHost.cs delete mode 100644 Modules/MinoriEditorShell.Platforms.Wpf/Controls/MesHwndMouse.cs delete mode 100644 Modules/MinoriEditorShell.Platforms.Wpf/Controls/MesHwndMouseEventArgs.cs delete mode 100644 Modules/MinoriEditorShell.Platforms.Wpf/Controls/MesHwndMouseState.cs delete mode 100644 Modules/MinoriEditorShell.Platforms.Wpf/Controls/MesHwndWrapper.cs delete mode 100644 Modules/MinoriEditorShell.Platforms.Wpf/Win32/NativeMethods.cs diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/CustomGlowWindowBehavior.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/CustomGlowWindowBehavior.cs deleted file mode 100644 index 00890f2b..00000000 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/CustomGlowWindowBehavior.cs +++ /dev/null @@ -1,111 +0,0 @@ -//namespace MinoriEditorShell.Platforms.Avalonia.Behaviors -//{ -// Copied from MahApp's GlowWindowBehavior, because that one has a bug if GlowBrush is set in a style, rather than directly. -//public class CustomGlowWindowBehavior : Behavior -//{ -// //private GlowWindow left; -// //private GlowWindow right; -// //private GlowWindow top; -// //private GlowWindow bottom; - -// //protected override void OnAttached() -// //{ -// // base.OnAttached(); -// // this.AssociatedObject.Loaded += new RoutedEventHandler(this.AssociatedObjectOnLoaded); -// //} - -// //private void AssociatedObjectOnLoaded(object sender, RoutedEventArgs routedEventArgs) -// //{ -// // MetroWindow metroWindow = this.AssociatedObject as MetroWindow; -// // if (metroWindow != null && (metroWindow.UseNoneWindowStyle/* || metroWindow.GlowBrush == null*/)) -// // return; -// // this.left = new GlowWindow(this.AssociatedObject, GlowDirection.Left); -// // this.right = new GlowWindow(this.AssociatedObject, GlowDirection.Right); -// // this.top = new GlowWindow(this.AssociatedObject, GlowDirection.Top); -// // this.bottom = new GlowWindow(this.AssociatedObject, GlowDirection.Bottom); -// // this.Show(); -// // this.Update(); - -// // metroWindow.LocationChanged += (s, e) => this.Update(); -// // metroWindow.SizeChanged += (s, e) => this.Update(); - -// // if (metroWindow == null || !metroWindow.WindowTransitionsEnabled) -// // { -// // this.SetOpacityTo(1.0); -// // } -// // else -// // { -// // this.StartOpacityStoryboard(); -// // this.AssociatedObject.IsVisibleChanged += new DependencyPropertyChangedEventHandler(this.AssociatedObjectIsVisibleChanged); -// // this.AssociatedObject.Closing += (CancelEventHandler) ((o, args) => -// // { -// // if (args.Cancel) -// // return; -// // this.AssociatedObject.IsVisibleChanged -= new DependencyPropertyChangedEventHandler(this.AssociatedObjectIsVisibleChanged); -// // }); -// // } -// //} - -// //private void AssociatedObjectIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) -// //{ -// // if (!this.AssociatedObject.IsVisible) -// // this.SetOpacityTo(0.0); -// // else -// // this.StartOpacityStoryboard(); -// //} - -// ///// -// ///// Updates all glow windows (visible, hidden, collapsed) -// ///// -// ///// -// //private void Update() -// //{ -// // if (this.left == null || this.right == null || (this.top == null || this.bottom == null)) -// // return; -// // this.left.Update(); -// // this.right.Update(); -// // this.top.Update(); -// // this.bottom.Update(); -// //} - -// ///// -// ///// Sets the opacity to all glow windows -// ///// -// ///// -// //private void SetOpacityTo(double newOpacity) -// //{ -// // if (this.left == null || this.right == null || (this.top == null || this.bottom == null)) -// // return; -// // this.left.Opacity = newOpacity; -// // this.right.Opacity = newOpacity; -// // this.top.Opacity = newOpacity; -// // this.bottom.Opacity = newOpacity; -// //} - -// ///// -// ///// Starts the opacity storyboard 0 -> 1 -// ///// -// ///// -// //private void StartOpacityStoryboard() -// //{ -// // if (this.left == null || this.left.OpacityStoryboard == null || (this.right == null || this.right.OpacityStoryboard == null) || (this.top == null || this.top.OpacityStoryboard == null || (this.bottom == null || this.bottom.OpacityStoryboard == null))) -// // return; -// // this.left.BeginStoryboard(this.left.OpacityStoryboard); -// // this.right.BeginStoryboard(this.right.OpacityStoryboard); -// // this.top.BeginStoryboard(this.top.OpacityStoryboard); -// // this.bottom.BeginStoryboard(this.bottom.OpacityStoryboard); -// //} - -// ///// -// ///// Shows all glow windows -// ///// -// ///// -// //private void Show() -// //{ -// // this.left.Show(); -// // this.right.Show(); -// // this.top.Show(); -// // this.bottom.Show(); -// //} -//} -//} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesBindableTreeViewSelectedItemBehavior.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesBindableTreeViewSelectedItemBehavior.cs deleted file mode 100644 index 3aad14e7..00000000 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesBindableTreeViewSelectedItemBehavior.cs +++ /dev/null @@ -1,194 +0,0 @@ -namespace MinoriEditorShell.Platforms.Avalonia.Behaviors -{ - // From http://stackoverflow.com/a/20636049/208817 - // public class MesBindableTreeViewSelectedItemBehavior : Behavior - // { - // #region SelectedItem Property - - // public object SelectedItem - // { - // get { return GetValue(SelectedItemProperty); } - // set { SetValue(SelectedItemProperty, value); } - // } - - // public static readonly DependencyProperty SelectedItemProperty = DependencyProperty.Register( - // "SelectedItem", typeof(object), typeof(MesBindableTreeViewSelectedItemBehavior), - // new UIPropertyMetadata(null, OnSelectedItemChanged)); - - // private static void OnSelectedItemChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) - // { - // Action selectTreeViewItem = tvi2 => - // { - // if (tvi2 != null) - // { - // tvi2.IsSelected = true; - // tvi2.Focus(); - // } - // }; - - // var tvi = e.NewValue as TreeViewItem; - - // if (tvi == null) - // { - // var tree = ((MesBindableTreeViewSelectedItemBehavior) sender).AssociatedObject; - // if (tree == null) - // return; - - // if (!tree.IsLoaded) - // { - // RoutedEventHandler handler = null; - // handler = (sender2, e2) => - // { - // tvi = GetTreeViewItem(tree, e.NewValue); - // selectTreeViewItem(tvi); - // tree.Loaded -= handler; - // }; - // tree.Loaded += handler; - - // return; - // } - // tvi = GetTreeViewItem(tree, e.NewValue); - // } - - // selectTreeViewItem(tvi); - // } - - // #endregion - - // #region Private - - // private void OnTreeViewSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs e) - // { - // SelectedItem = e.NewValue; - // } - - // private static TreeViewItem GetTreeViewItem(ItemsControl container, object item) - // { - // if (container != null) - // { - // if (container.DataContext == item) - // { - // return container as TreeViewItem; - // } - - // // Expand the current container - // if (container is TreeViewItem && !((TreeViewItem) container).IsExpanded) - // { - // container.SetValue(TreeViewItem.IsExpandedProperty, true); - // } - - // // Try to generate the ItemsPresenter and the ItemsPanel. - // // by calling ApplyTemplate. Note that in the - // // virtualizing case even if the item is marked - // // expanded we still need to do this step in order to - // // regenerate the visuals because they may have been virtualized away. - - // container.ApplyTemplate(); - // var itemsPresenter = - // (ItemsPresenter) container.Template.FindName("ItemsHost", container); - // if (itemsPresenter != null) - // { - // itemsPresenter.ApplyTemplate(); - // } - // else - // { - // // The Tree template has not named the ItemsPresenter, - // // so walk the descendents and find the child. - // itemsPresenter = FindVisualChild(container); - // if (itemsPresenter == null) - // { - // container.UpdateLayout(); - // itemsPresenter = FindVisualChild(container); - // } - // } - - // var itemsHostPanel = (Panel) VisualTreeHelper.GetChild(itemsPresenter, 0); - - // // Ensure that the generator for this panel has been created. - //#pragma warning disable 168 - // var children = itemsHostPanel.Children; - //#pragma warning restore 168 - - // for (int i = 0, count = container.Items.Count; i < count; i++) - // { - // var subContainer = (TreeViewItem) container.ItemContainerGenerator. - // ContainerFromIndex(i); - // if (subContainer == null) - // { - // continue; - // } - - // subContainer.BringIntoView(); - - // // Search the next level for the object. - // var resultContainer = GetTreeViewItem(subContainer, item); - // if (resultContainer != null) - // { - // return resultContainer; - // } - // else - // { - // // The object is not under this TreeViewItem - // // so collapse it. - // //subContainer.IsExpanded = false; - // } - // } - // } - - // return null; - // } - - // /// - // /// Search for an element of a certain type in the visual tree. - // /// - // /// The type of element to find. - // /// The parent element. - // /// - // private static T FindVisualChild(Visual visual) where T : Visual - // { - // for (int i = 0; i < VisualTreeHelper.GetChildrenCount(visual); i++) - // { - // Visual child = (Visual) VisualTreeHelper.GetChild(visual, i); - // if (child != null) - // { - // T correctlyTyped = child as T; - // if (correctlyTyped != null) - // { - // return correctlyTyped; - // } - - // T descendent = FindVisualChild(child); - // if (descendent != null) - // { - // return descendent; - // } - // } - // } - - // return null; - // } - - // #endregion - - // #region Protected - - // protected override void OnAttached() - // { - // base.OnAttached(); - - // AssociatedObject.SelectedItemChanged += OnTreeViewSelectedItemChanged; - // } - - // protected override void OnDetaching() - // { - // base.OnDetaching(); - - // if (AssociatedObject != null) - // { - // AssociatedObject.SelectedItemChanged -= OnTreeViewSelectedItemChanged; - // } - // } - - // #endregion - // } -} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesKeyboardFocusBehavior.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesKeyboardFocusBehavior.cs deleted file mode 100644 index 4bd65d80..00000000 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesKeyboardFocusBehavior.cs +++ /dev/null @@ -1,17 +0,0 @@ -//using System.Windows.Interactivity; - -namespace MinoriEditorShell.Platforms.Avalonia.Behaviors -{ - //public class MesKeyboardFocusBehavior : Behavior - //{ - // protected override void OnAttached() - // { - // if (!AssociatedObject.IsLoaded) - // AssociatedObject.Loaded += (sender, e) => { Keyboard.Focus(AssociatedObject); }; - // else - // Keyboard.Focus(AssociatedObject); - - // base.OnAttached(); - // } - //} -} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesWindowOptionsBehavior.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesWindowOptionsBehavior.cs deleted file mode 100644 index a43a6f1b..00000000 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Behaviors/MesWindowOptionsBehavior.cs +++ /dev/null @@ -1,101 +0,0 @@ -//using System.Windows.Interactivity; - -namespace MinoriEditorShell.Platforms.Avalonia.Behaviors -{ - //public class MesWindowOptionsBehavior : Behavior - //{ - // public static readonly DependencyProperty ShowIconProperty = DependencyProperty.Register( - // "ShowIcon", typeof(Boolean), typeof(MesWindowOptionsBehavior), - // new PropertyMetadata(true, OnWindowOptionChanged)); - - // public Boolean ShowIcon - // { - // get => (Boolean)GetValue(ShowIconProperty); - // set => SetValue(ShowIconProperty, value); - // } - - // public static readonly DependencyProperty ShowMinimizeBoxProperty = DependencyProperty.Register( - // "ShowMinimizeBox", typeof(Boolean), typeof(MesWindowOptionsBehavior), - // new PropertyMetadata(true, OnWindowOptionChanged)); - - // public Boolean ShowMinimizeBox - // { - // get => (Boolean)GetValue(ShowMinimizeBoxProperty); - // set => SetValue(ShowMinimizeBoxProperty, value); - // } - - // public static readonly DependencyProperty ShowMaximizeBoxProperty = DependencyProperty.Register( - // "ShowMaximizeBox", typeof(Boolean), typeof(MesWindowOptionsBehavior), - // new PropertyMetadata(true, OnWindowOptionChanged)); - - // public Boolean ShowMaximizeBox - // { - // get => (Boolean)GetValue(ShowMaximizeBoxProperty); - // set => SetValue(ShowMaximizeBoxProperty, value); - // } - - // private static void OnWindowOptionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => ((MesWindowOptionsBehavior)d).UpdateWindowStyle(); - - // private void UpdateWindowStyle() - // { - // if (AssociatedObject == null) - // { - // return; - // } - - // IntPtr handle = new WindowInteropHelper(AssociatedObject).Handle; - - // Int32 windowStyle = NativeMethods.GetWindowLong(handle, NativeMethods.GWL_STYLE); - - // if (ShowMinimizeBox) - // { - // windowStyle |= NativeMethods.WS_MINIMIZEBOX; - // } - // else - // { - // windowStyle &= ~NativeMethods.WS_MINIMIZEBOX; - // } - - // if (ShowMaximizeBox) - // { - // windowStyle |= NativeMethods.WS_MAXIMIZEBOX; - // } - // else - // { - // windowStyle &= ~NativeMethods.WS_MAXIMIZEBOX; - // } - - // NativeMethods.SetWindowLong(handle, NativeMethods.GWL_STYLE, windowStyle); - - // if (ShowIcon) - // { - // // TODO - // } - // else - // { - // Int32 exWindowStyle = NativeMethods.GetWindowLong(handle, NativeMethods.GWL_EXSTYLE); - // NativeMethods.SetWindowLong(handle, NativeMethods.GWL_EXSTYLE, - // exWindowStyle | NativeMethods.WS_EX_DLGMODALFRAME); - - // NativeMethods.SetWindowPos(handle, IntPtr.Zero, 0, 0, 0, 0, - // NativeMethods.SWP_NOMOVE | NativeMethods.SWP_NOSIZE | NativeMethods.SWP_NOZORDER | NativeMethods.SWP_FRAMECHANGED); - - // NativeMethods.SendMessage(handle, NativeMethods.WM_SETICON, IntPtr.Zero, IntPtr.Zero); - // } - // } - - // protected override void OnAttached() - // { - // AssociatedObject.SourceInitialized += OnSourceInitialized; - // base.OnAttached(); - // } - - // protected override void OnDetaching() - // { - // AssociatedObject.SourceInitialized -= OnSourceInitialized; - // base.OnDetaching(); - // } - - // private void OnSourceInitialized(Object sender, EventArgs e) => UpdateWindowStyle(); - //} -} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouse.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouse.cs deleted file mode 100644 index 1767d6be..00000000 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouse.cs +++ /dev/null @@ -1,22 +0,0 @@ -using MinoriEditorShell.Platforms.Avalonia.Win32; -using System; -using System.Windows; - -namespace MinoriEditorShell.Platforms.Avalonia.Controls -{ - public static class MesHwndMouse - { - // public static Point GetCursorPosition() - // { - // NativeMethods.NativePoint point = new NativeMethods.NativePoint(); - // NativeMethods.GetCursorPos(ref point); - // return new Point(point.X, point.Y); - // } - - // public static void SetCursorPosition(Point point) => NativeMethods.SetCursorPos((Int32)point.X, (Int32)point.Y); - - // public static void ShowCursor() => NativeMethods.ShowCursor(true); - - // public static void HideCursor() => NativeMethods.ShowCursor(false); - } -} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouseEventArgs.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouseEventArgs.cs deleted file mode 100644 index 34c26a99..00000000 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouseEventArgs.cs +++ /dev/null @@ -1,110 +0,0 @@ -#region File Description - -//----------------------------------------------------------------------------- -// Copyright 2011, Nick Gravelyn. -// Licensed under the terms of the Ms-PL: -// http://www.microsoft.com/opensource/licenses.mspx#Ms-PL -//----------------------------------------------------------------------------- - -#endregion File Description - -using System; -using System.Windows; -using System.Windows.Input; - -namespace MinoriEditorShell.Platforms.Avalonia.Controls -{ - // public class MesHwndMouseEventArgs : EventArgs - // { - // /// - // /// Gets the state of the left mouse button. - // /// - // public MouseButtonState LeftButton { get; private set; } - - // /// - // /// Gets the state of the right mouse button. - // /// - // public MouseButtonState RightButton { get; private set; } - - // /// - // /// Gets the state of the middle mouse button. - // /// - // public MouseButtonState MiddleButton { get; private set; } - - // /// - // /// Gets the state of the first extra mouse button. - // /// - // public MouseButtonState X1Button { get; private set; } - - // /// - // /// Gets the state of the second extra mouse button. - // /// - // public MouseButtonState X2Button { get; private set; } - - // /// - // /// Gets the button that was double clicked. - // /// - // public MouseButton? DoubleClickButton { get; private set; } - - // /// - // /// Gets the mouse wheel delta. - // /// - // public int WheelDelta { get; private set; } - - // /// - // /// Gets the horizontal mouse wheel delta. - // /// - // public int HorizontalWheelDelta { get; private set; } - - // /// - // /// Gets the position of the mouse in screen coordinates. - // /// - // public Point ScreenPosition { get; private set; } - - // /// - // /// Calculates the position of the mouse relative to a particular element. - // /// - // public Point GetPosition(UIElement relativeTo) - // { - // return relativeTo.PointFromScreen(ScreenPosition); - // } - - // /// - // /// Initializes a new HwndMouseEventArgs. - // /// - // /// The state from which to initialize the properties. - // public MesHwndMouseEventArgs(MesHwndMouseState state) - // { - // LeftButton = state.LeftButton; - // RightButton = state.RightButton; - // MiddleButton = state.MiddleButton; - // X1Button = state.X1Button; - // X2Button = state.X2Button; - // ScreenPosition = state.ScreenPosition; - // } - - // /// - // /// Initializes a new HwndMouseEventArgs. - // /// - // /// The state from which to initialize the properties. - // /// The mouse wheel rotation delta. - // /// The horizontal mouse wheel delta. - // public MesHwndMouseEventArgs(MesHwndMouseState state, int mouseWheelDelta, int mouseHWheelDelta) - // : this(state) - // { - // WheelDelta = mouseWheelDelta; - // HorizontalWheelDelta = mouseHWheelDelta; - // } - - // /// - // /// Initializes a new HwndMouseEventArgs. - // /// - // /// The state from which to initialize the properties. - // /// The button that was double clicked. - // public MesHwndMouseEventArgs(MesHwndMouseState state, MouseButton doubleClickButton) - // : this(state) - // { - // DoubleClickButton = doubleClickButton; - // } - // } -} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouseState.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouseState.cs deleted file mode 100644 index 608d13b6..00000000 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndMouseState.cs +++ /dev/null @@ -1,48 +0,0 @@ -#region File Description - -//----------------------------------------------------------------------------- -// Copyright 2011, Nick Gravelyn. -// Licensed under the terms of the Ms-PL: -// http://www.microsoft.com/opensource/licenses.mspx#Ms-PL -//----------------------------------------------------------------------------- - -#endregion File Description - -using System.Windows; -using System.Windows.Input; - -namespace MinoriEditorShell.Platforms.Avalonia.Controls -{ - public class MesHwndMouseState - { - // /// - // /// The current state of the left mouse button. - // /// - // public MouseButtonState LeftButton; - - // /// - // /// The current state of the right mouse button. - // /// - // public MouseButtonState RightButton; - - // /// - // /// The current state of the middle mouse button. - // /// - // public MouseButtonState MiddleButton; - - // /// - // /// The current state of the first extra mouse button. - // /// - // public MouseButtonState X1Button; - - // /// - // /// The current state of the second extra mouse button. - // /// - // public MouseButtonState X2Button; - - // /// - // /// The current position of the mouse in screen coordinates. - // /// - // public Point ScreenPosition; - } -} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndWrapper.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndWrapper.cs deleted file mode 100644 index ef68da59..00000000 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesHwndWrapper.cs +++ /dev/null @@ -1,631 +0,0 @@ -#region File Description - -//----------------------------------------------------------------------------- -// Copyright 2011, Nick Gravelyn. -// Licensed under the terms of the Ms-PL: -// http://www.microsoft.com/opensource/licenses.mspx#Ms-PL -//----------------------------------------------------------------------------- - -#endregion File Description - -using MinoriEditorShell.Platforms.Avalonia.Win32; -using System; -using System.Linq; -using System.Runtime.InteropServices; -using System.Windows; -using System.Windows.Input; -//using System.Windows.Interop; -//using System.Windows.Media; - -namespace MinoriEditorShell.Platforms.Avalonia.Controls -{ - /// - /// A control that enables graphics rendering inside a WPF control through - /// the use of a hosted child Hwnd. - /// - // public abstract class MesHwndWrapper : HwndHost - // { - // #region Fields - - // // The name of our window class - // private const string WindowClass = "GraphicsDeviceControlHostWindowClass"; - - // // The HWND we present to when rendering - // private IntPtr _hWnd; - - // // For holding previous hWnd focus - // private IntPtr _hWndPrev; - - // // Track if the application has focus - // private bool _applicationHasFocus; - - // // Track if the mouse is in the window - // private bool _mouseInWindow; - - // // Track the previous mouse position - // private Point _previousPosition; - - // // Track the mouse state - // private readonly MesHwndMouseState _mouseState = new MesHwndMouseState(); - - // // Tracking whether we've "capture" the mouse - // private bool _isMouseCaptured; - - // #endregion Fields - - // #region Events - - // /// - // /// Invoked when the control receives a left mouse down message. - // /// - // public event EventHandler HwndLButtonDown; - - // /// - // /// Invoked when the control receives a left mouse up message. - // /// - // public event EventHandler HwndLButtonUp; - - // /// - // /// Invoked when the control receives a left mouse double click message. - // /// - // public event EventHandler HwndLButtonDblClick; - - // /// - // /// Invoked when the control receives a right mouse down message. - // /// - // public event EventHandler HwndRButtonDown; - - // /// - // /// Invoked when the control receives a right mouse up message. - // /// - // public event EventHandler HwndRButtonUp; - - // /// - // /// Invoked when the control receives a rigt mouse double click message. - // /// - // public event EventHandler HwndRButtonDblClick; - - // /// - // /// Invoked when the control receives a middle mouse down message. - // /// - // public event EventHandler HwndMButtonDown; - - // /// - // /// Invoked when the control receives a middle mouse up message. - // /// - // public event EventHandler HwndMButtonUp; - - // /// - // /// Invoked when the control receives a middle mouse double click message. - // /// - // public event EventHandler HwndMButtonDblClick; - - // /// - // /// Invoked when the control receives a mouse down message for the first extra button. - // /// - // public event EventHandler HwndX1ButtonDown; - - // /// - // /// Invoked when the control receives a mouse up message for the first extra button. - // /// - // public event EventHandler HwndX1ButtonUp; - - // /// - // /// Invoked when the control receives a double click message for the first extra mouse button. - // /// - // public event EventHandler HwndX1ButtonDblClick; - - // /// - // /// Invoked when the control receives a mouse down message for the second extra button. - // /// - // public event EventHandler HwndX2ButtonDown; - - // /// - // /// Invoked when the control receives a mouse up message for the second extra button. - // /// - // public event EventHandler HwndX2ButtonUp; - - // /// - // /// Invoked when the control receives a double click message for the first extra mouse button. - // /// - // public event EventHandler HwndX2ButtonDblClick; - - // /// - // /// Invoked when the control receives a mouse move message. - // /// - // public event EventHandler HwndMouseMove; - - // /// - // /// Invoked when the control first gets a mouse move message. - // /// - // public event EventHandler HwndMouseEnter; - - // /// - // /// Invoked when the control gets a mouse leave message. - // /// - // public event EventHandler HwndMouseLeave; - - // /// - // /// Invoked when the control recieves a mouse wheel delta. - // /// - // public event EventHandler HwndMouseWheel; - - // #endregion Events - - // #region Properties - - // public new bool IsMouseCaptured - // { - // get { return _isMouseCaptured; } - // } - - // #endregion Properties - - // #region Construction and Disposal - - // protected MesHwndWrapper() - // { - // // We must be notified of the application foreground status for our mouse input events - // Application.Current.Activated += OnApplicationActivated; - // Application.Current.Deactivated += OnApplicationDeactivated; - - // // We use the CompositionTarget.Rendering event to trigger the control to draw itself - // CompositionTarget.Rendering += OnCompositionTargetRendering; - - // // Check whether the application is active (it almost certainly is, at this point). - // if (Application.Current.Windows.Cast().Any(x => x.IsActive)) - // _applicationHasFocus = true; - // } - - // protected override void Dispose(bool disposing) - // { - // // Unhook all events. - // CompositionTarget.Rendering -= OnCompositionTargetRendering; - // if (Application.Current != null) - // { - // Application.Current.Activated -= OnApplicationActivated; - // Application.Current.Deactivated -= OnApplicationDeactivated; - // } - - // base.Dispose(disposing); - // } - - // #endregion Construction and Disposal - - // #region Public Methods - - // /// - // /// Captures the mouse, hiding it and trapping it inside the window bounds. - // /// - // /// - // /// This method is useful for tooling scenarios where you only care about the mouse deltas - // /// and want the user to be able to continue interacting with the window while they move - // /// the mouse. A good example of this is rotating an object based on the mouse deltas where - // /// through capturing you can spin and spin without having the cursor leave the window. - // /// - // public new void CaptureMouse() - // { - // // Don't do anything if the mouse is already captured - // if (_isMouseCaptured) - // return; - - // NativeMethods.SetCapture(_hWnd); - // _isMouseCaptured = true; - // } - - // /// - // /// Releases the capture of the mouse which makes it visible and allows it to leave the window bounds. - // /// - // public new void ReleaseMouseCapture() - // { - // // Don't do anything if the mouse is not captured - // if (!_isMouseCaptured) - // return; - - // NativeMethods.ReleaseCapture(); - // _isMouseCaptured = false; - // } - - // #endregion Public Methods - - // #region Graphics Device Control Implementation - - // private void OnCompositionTargetRendering(object sender, EventArgs e) - // { - // // Get the current width and height of the control - // var width = (int)ActualWidth; - // var height = (int)ActualHeight; - - // // If the control has no width or no height, skip drawing since it's not visible - // if (width < 1 || height < 1) - // return; - - // Render(_hWnd); - // } - - // protected abstract void Render(IntPtr windowHandle); - - // private void OnApplicationActivated(object sender, EventArgs e) - // { - // _applicationHasFocus = true; - // } - - // private void OnApplicationDeactivated(object sender, EventArgs e) - // { - // _applicationHasFocus = false; - // ResetMouseState(); - - // if (_mouseInWindow) - // { - // _mouseInWindow = false; - // RaiseHwndMouseLeave(new MesHwndMouseEventArgs(_mouseState)); - // } - - // ReleaseMouseCapture(); - // } - - // private void ResetMouseState() - // { - // // We need to invoke events for any buttons that were pressed - // bool fireL = _mouseState.LeftButton == MouseButtonState.Pressed; - // bool fireM = _mouseState.MiddleButton == MouseButtonState.Pressed; - // bool fireR = _mouseState.RightButton == MouseButtonState.Pressed; - // bool fireX1 = _mouseState.X1Button == MouseButtonState.Pressed; - // bool fireX2 = _mouseState.X2Button == MouseButtonState.Pressed; - - // // Update the state of all of the buttons - // _mouseState.LeftButton = MouseButtonState.Released; - // _mouseState.MiddleButton = MouseButtonState.Released; - // _mouseState.RightButton = MouseButtonState.Released; - // _mouseState.X1Button = MouseButtonState.Released; - // _mouseState.X2Button = MouseButtonState.Released; - - // // Fire any events - // var args = new MesHwndMouseEventArgs(_mouseState); - // if (fireL) - // RaiseHwndLButtonUp(args); - // if (fireM) - // RaiseHwndMButtonUp(args); - // if (fireR) - // RaiseHwndRButtonUp(args); - // if (fireX1) - // RaiseHwndX1ButtonUp(args); - // if (fireX2) - // RaiseHwndX2ButtonUp(args); - - // // The mouse is no longer considered to be in our window - // _mouseInWindow = false; - // } - - // #endregion Graphics Device Control Implementation - - // #region HWND Management - - // protected override HandleRef BuildWindowCore(HandleRef hwndParent) - // { - // // Create the host window as a child of the parent - // _hWnd = CreateHostWindow(hwndParent.Handle); - // return new HandleRef(this, _hWnd); - // } - - // protected override void DestroyWindowCore(HandleRef hwnd) - // { - // // Destroy the window and reset our hWnd value - // NativeMethods.DestroyWindow(hwnd.Handle); - // _hWnd = IntPtr.Zero; - // } - - // /// - // /// Creates the host window as a child of the parent window. - // /// - // private IntPtr CreateHostWindow(IntPtr hWndParent) - // { - // // Register our window class - // RegisterWindowClass(); - - // // Create the window - // return NativeMethods.CreateWindowEx(0, WindowClass, "", - // NativeMethods.WS_CHILD | NativeMethods.WS_VISIBLE, - // 0, 0, (int)Width, (int)Height, hWndParent, IntPtr.Zero, IntPtr.Zero, 0); - // } - - // /// - // /// Registers the window class. - // /// - // private void RegisterWindowClass() - // { - // var wndClass = new NativeMethods.WNDCLASSEX(); - // wndClass.cbSize = (uint)Marshal.SizeOf(wndClass); - // wndClass.hInstance = NativeMethods.GetModuleHandle(null); - // wndClass.lpfnWndProc = NativeMethods.DefaultWindowProc; - // wndClass.lpszClassName = WindowClass; - // wndClass.hCursor = NativeMethods.LoadCursor(IntPtr.Zero, NativeMethods.IDC_ARROW); - - // NativeMethods.RegisterClassEx(ref wndClass); - // } - - // #endregion HWND Management - - // #region WndProc Implementation - - // protected override IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) - // { - // switch (msg) - // { - // case NativeMethods.WM_MOUSEWHEEL: - // if (_mouseInWindow) - // { - // int delta = NativeMethods.GetWheelDeltaWParam(wParam.ToInt32()); - // RaiseHwndMouseWheel(new MesHwndMouseEventArgs(_mouseState, delta, 0)); - // } - // break; - - // case NativeMethods.WM_LBUTTONDOWN: - // _mouseState.LeftButton = MouseButtonState.Pressed; - // RaiseHwndLButtonDown(new MesHwndMouseEventArgs(_mouseState)); - // break; - - // case NativeMethods.WM_LBUTTONUP: - // _mouseState.LeftButton = MouseButtonState.Released; - // RaiseHwndLButtonUp(new MesHwndMouseEventArgs(_mouseState)); - // break; - - // case NativeMethods.WM_LBUTTONDBLCLK: - // RaiseHwndLButtonDblClick(new MesHwndMouseEventArgs(_mouseState, MouseButton.Left)); - // break; - - // case NativeMethods.WM_RBUTTONDOWN: - // _mouseState.RightButton = MouseButtonState.Pressed; - // RaiseHwndRButtonDown(new MesHwndMouseEventArgs(_mouseState)); - // break; - - // case NativeMethods.WM_RBUTTONUP: - // _mouseState.RightButton = MouseButtonState.Released; - // RaiseHwndRButtonUp(new MesHwndMouseEventArgs(_mouseState)); - // break; - - // case NativeMethods.WM_RBUTTONDBLCLK: - // RaiseHwndRButtonDblClick(new MesHwndMouseEventArgs(_mouseState, MouseButton.Right)); - // break; - - // case NativeMethods.WM_MBUTTONDOWN: - // _mouseState.MiddleButton = MouseButtonState.Pressed; - // RaiseHwndMButtonDown(new MesHwndMouseEventArgs(_mouseState)); - // break; - - // case NativeMethods.WM_MBUTTONUP: - // _mouseState.MiddleButton = MouseButtonState.Released; - // RaiseHwndMButtonUp(new MesHwndMouseEventArgs(_mouseState)); - // break; - - // case NativeMethods.WM_MBUTTONDBLCLK: - // RaiseHwndMButtonDblClick(new MesHwndMouseEventArgs(_mouseState, MouseButton.Middle)); - // break; - - // case NativeMethods.WM_XBUTTONDOWN: - // if (((int)wParam & NativeMethods.MK_XBUTTON1) != 0) - // { - // _mouseState.X1Button = MouseButtonState.Pressed; - // RaiseHwndX1ButtonDown(new MesHwndMouseEventArgs(_mouseState)); - // } - // else if (((int)wParam & NativeMethods.MK_XBUTTON2) != 0) - // { - // _mouseState.X2Button = MouseButtonState.Pressed; - // RaiseHwndX2ButtonDown(new MesHwndMouseEventArgs(_mouseState)); - // } - // break; - - // case NativeMethods.WM_XBUTTONUP: - // if (((int)wParam & NativeMethods.MK_XBUTTON1) != 0) - // { - // _mouseState.X1Button = MouseButtonState.Released; - // RaiseHwndX1ButtonUp(new MesHwndMouseEventArgs(_mouseState)); - // } - // else if (((int)wParam & NativeMethods.MK_XBUTTON2) != 0) - // { - // _mouseState.X2Button = MouseButtonState.Released; - // RaiseHwndX2ButtonUp(new MesHwndMouseEventArgs(_mouseState)); - // } - // break; - - // case NativeMethods.WM_XBUTTONDBLCLK: - // if (((int)wParam & NativeMethods.MK_XBUTTON1) != 0) - // RaiseHwndX1ButtonDblClick(new MesHwndMouseEventArgs(_mouseState, MouseButton.XButton1)); - // else if (((int)wParam & NativeMethods.MK_XBUTTON2) != 0) - // RaiseHwndX2ButtonDblClick(new MesHwndMouseEventArgs(_mouseState, MouseButton.XButton2)); - // break; - - // case NativeMethods.WM_MOUSEMOVE: - // // If the application isn't in focus, we don't handle this message - // if (!_applicationHasFocus) - // break; - - // // record the prevous and new position of the mouse - // _mouseState.ScreenPosition = PointToScreen(new Point( - // NativeMethods.GetXLParam((int)lParam), - // NativeMethods.GetYLParam((int)lParam))); - - // if (!_mouseInWindow) - // { - // _mouseInWindow = true; - - // RaiseHwndMouseEnter(new MesHwndMouseEventArgs(_mouseState)); - - // // Track the previously focused window, and set focus to this window. - // _hWndPrev = NativeMethods.GetFocus(); - // NativeMethods.SetFocus(_hWnd); - - // // send the track mouse event so that we get the WM_MOUSELEAVE message - // var tme = new NativeMethods.TRACKMOUSEEVENT - // { - // cbSize = Marshal.SizeOf(typeof(NativeMethods.TRACKMOUSEEVENT)), - // dwFlags = NativeMethods.TME_LEAVE, - // hWnd = hwnd - // }; - // NativeMethods.TrackMouseEvent(ref tme); - // } - - // if (_mouseState.ScreenPosition != _previousPosition) - // RaiseHwndMouseMove(new MesHwndMouseEventArgs(_mouseState)); - - // _previousPosition = _mouseState.ScreenPosition; - - // break; - - // case NativeMethods.WM_MOUSELEAVE: - - // // If we have capture, we ignore this message because we're just - // // going to reset the cursor position back into the window - // if (_isMouseCaptured) - // break; - - // // Reset the state which releases all buttons and - // // marks the mouse as not being in the window. - // ResetMouseState(); - - // RaiseHwndMouseLeave(new MesHwndMouseEventArgs(_mouseState)); - - // NativeMethods.SetFocus(_hWndPrev); - - // break; - // } - - // return base.WndProc(hwnd, msg, wParam, lParam, ref handled); - // } - - // protected virtual void RaiseHwndLButtonDown(MesHwndMouseEventArgs args) - // { - // var handler = HwndLButtonDown; - // if (handler != null) - // handler(this, args); - // } - - // protected virtual void RaiseHwndLButtonUp(MesHwndMouseEventArgs args) - // { - // var handler = HwndLButtonUp; - // if (handler != null) - // handler(this, args); - // } - - // protected virtual void RaiseHwndRButtonDown(MesHwndMouseEventArgs args) - // { - // var handler = HwndRButtonDown; - // if (handler != null) - // handler(this, args); - // } - - // protected virtual void RaiseHwndRButtonUp(MesHwndMouseEventArgs args) - // { - // var handler = HwndRButtonUp; - // if (handler != null) - // handler(this, args); - // } - - // protected virtual void RaiseHwndMButtonDown(MesHwndMouseEventArgs args) - // { - // var handler = HwndMButtonDown; - // if (handler != null) - // handler(this, args); - // } - - // protected virtual void RaiseHwndMButtonUp(MesHwndMouseEventArgs args) - // { - // var handler = HwndMButtonUp; - // if (handler != null) - // handler(this, args); - // } - - // protected virtual void RaiseHwndLButtonDblClick(MesHwndMouseEventArgs args) - // { - // var handler = HwndLButtonDblClick; - // if (handler != null) - // handler(this, args); - // } - - // protected virtual void RaiseHwndRButtonDblClick(MesHwndMouseEventArgs args) - // { - // var handler = HwndRButtonDblClick; - // if (handler != null) - // handler(this, args); - // } - - // protected virtual void RaiseHwndMButtonDblClick(MesHwndMouseEventArgs args) - // { - // var handler = HwndMButtonDblClick; - // if (handler != null) - // handler(this, args); - // } - - // protected virtual void RaiseHwndMouseEnter(MesHwndMouseEventArgs args) - // { - // var handler = HwndMouseEnter; - // if (handler != null) - // handler(this, args); - // } - - // protected virtual void RaiseHwndX1ButtonDown(MesHwndMouseEventArgs args) - // { - // var handler = HwndX1ButtonDown; - // if (handler != null) - // handler(this, args); - // } - - // protected virtual void RaiseHwndX1ButtonUp(MesHwndMouseEventArgs args) - // { - // var handler = HwndX1ButtonUp; - // if (handler != null) - // handler(this, args); - // } - - // protected virtual void RaiseHwndX2ButtonDown(MesHwndMouseEventArgs args) - // { - // var handler = HwndX2ButtonDown; - // if (handler != null) - // handler(this, args); - // } - - // protected virtual void RaiseHwndX2ButtonUp(MesHwndMouseEventArgs args) - // { - // var handler = HwndX2ButtonUp; - // if (handler != null) - // handler(this, args); - // } - - // protected virtual void RaiseHwndX1ButtonDblClick(MesHwndMouseEventArgs args) - // { - // var handler = HwndX1ButtonDblClick; - // if (handler != null) - // handler(this, args); - // } - - // protected virtual void RaiseHwndX2ButtonDblClick(MesHwndMouseEventArgs args) - // { - // var handler = HwndX2ButtonDblClick; - // if (handler != null) - // handler(this, args); - // } - - // protected virtual void RaiseHwndMouseLeave(MesHwndMouseEventArgs args) - // { - // var handler = HwndMouseLeave; - // if (handler != null) - // handler(this, args); - // } - - // protected virtual void RaiseHwndMouseMove(MesHwndMouseEventArgs args) - // { - // var handler = HwndMouseMove; - // if (handler != null) - // handler(this, args); - // } - - // protected virtual void RaiseHwndMouseWheel(MesHwndMouseEventArgs args) - // { - // var handler = HwndMouseWheel; - // if (handler != null) - // handler(this, args); - // } - - // #endregion WndProc Implementation - // } -} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Win32/NativeMethods.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Win32/NativeMethods.cs deleted file mode 100644 index d2c003a7..00000000 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Win32/NativeMethods.cs +++ /dev/null @@ -1,208 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace MinoriEditorShell.Platforms.Avalonia.Win32 -{ - internal static class NativeMethods - { - #region Constants - - public const int GWL_STYLE = -16; - public const int GWL_EXSTYLE = -20; - - public const int WS_MAXIMIZEBOX = 0x10000; - public const int WS_MINIMIZEBOX = 0x20000; - - public const int WS_EX_DLGMODALFRAME = 0x00000001; - - public const int SWP_NOSIZE = 0x0001; - public const int SWP_NOMOVE = 0x0002; - public const int SWP_NOZORDER = 0x0004; - public const int SWP_FRAMECHANGED = 0x0020; - - public const uint WM_SETICON = 0x0080; - - // Define the window styles we use - public const int WS_CHILD = 0x40000000; - - public const int WS_VISIBLE = 0x10000000; - - // Define the Windows messages we will handle - public const int WM_MOUSEMOVE = 0x0200; - - public const int WM_LBUTTONDOWN = 0x0201; - public const int WM_LBUTTONUP = 0x0202; - public const int WM_LBUTTONDBLCLK = 0x0203; - public const int WM_RBUTTONDOWN = 0x0204; - public const int WM_RBUTTONUP = 0x0205; - public const int WM_RBUTTONDBLCLK = 0x0206; - public const int WM_MBUTTONDOWN = 0x0207; - public const int WM_MBUTTONUP = 0x0208; - public const int WM_MBUTTONDBLCLK = 0x0209; - public const int WM_MOUSEWHEEL = 0x020A; - public const int WM_XBUTTONDOWN = 0x020B; - public const int WM_XBUTTONUP = 0x020C; - public const int WM_XBUTTONDBLCLK = 0x020D; - public const int WM_MOUSELEAVE = 0x02A3; - - // Define the values that let us differentiate between the two extra mouse buttons - public const int MK_XBUTTON1 = 0x020; - - public const int MK_XBUTTON2 = 0x040; - - // Define the cursor icons we use - public const int IDC_ARROW = 32512; - - // Define the TME_LEAVE value so we can register for WM_MOUSELEAVE messages - public const uint TME_LEAVE = 0x00000002; - - #endregion Constants - - #region Delegates and Structs - - public delegate IntPtr WndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam); - - public static readonly WndProc DefaultWindowProc = DefWindowProc; - - [StructLayout(LayoutKind.Sequential)] - public struct TRACKMOUSEEVENT - { - public int cbSize; - public uint dwFlags; - public IntPtr hWnd; - public uint dwHoverTime; - } - - [StructLayout(LayoutKind.Sequential)] - public struct WNDCLASSEX - { - public uint cbSize; - public uint style; - - [MarshalAs(UnmanagedType.FunctionPtr)] - public WndProc lpfnWndProc; - - public int cbClsExtra; - public int cbWndExtra; - public IntPtr hInstance; - public IntPtr hIcon; - public IntPtr hCursor; - public IntPtr hbrBackground; - public string lpszMenuName; - public string lpszClassName; - public IntPtr hIconSm; - } - - [StructLayout(LayoutKind.Sequential)] - public struct NativePoint - { - public int X; - public int Y; - } - - #endregion Delegates and Structs - - #region DllImports - - [DllImport("user32.dll")] - public extern static int GetWindowLong(IntPtr hwnd, int index); - - [DllImport("user32.dll")] - public extern static int SetWindowLong(IntPtr hwnd, int index, int value); - - [DllImport("user32.dll")] - public extern static bool SetWindowPos(IntPtr hwnd, IntPtr hwndInsertAfter, - int x, int y, int width, int height, uint flags); - - [DllImport("user32.dll")] - public static extern IntPtr SendMessage(IntPtr hwnd, uint msg, - IntPtr wParam, IntPtr lParam); - - [DllImport("user32.dll", EntryPoint = "CreateWindowEx", CharSet = CharSet.Auto)] - public static extern IntPtr CreateWindowEx( - int exStyle, - string className, - string windowName, - int style, - int x, int y, - int width, int height, - IntPtr hwndParent, - IntPtr hMenu, - IntPtr hInstance, - [MarshalAs(UnmanagedType.AsAny)] object pvParam); - - [DllImport("user32.dll", EntryPoint = "DestroyWindow", CharSet = CharSet.Auto)] - public static extern bool DestroyWindow(IntPtr hwnd); - - [DllImport("user32.dll")] - public static extern IntPtr DefWindowProc(IntPtr hWnd, uint uMsg, IntPtr wParam, IntPtr lParam); - - [DllImport("kernel32.dll")] - public static extern IntPtr GetModuleHandle(string module); - - [DllImport("user32.dll")] - public static extern IntPtr LoadCursor(IntPtr hInstance, int lpCursorName); - - [DllImport("user32.dll")] - public static extern int TrackMouseEvent(ref TRACKMOUSEEVENT lpEventTrack); - - [DllImport("user32.dll")] - [return: MarshalAs(UnmanagedType.U2)] - public static extern short RegisterClassEx([In] ref WNDCLASSEX lpwcx); - - [DllImport("user32.dll")] - public static extern int ScreenToClient(IntPtr hWnd, ref NativePoint pt); - - [DllImport("user32.dll")] - public static extern int SetFocus(IntPtr hWnd); - - [DllImport("user32.dll")] - public static extern IntPtr GetFocus(); - - [DllImport("user32.dll")] - public static extern IntPtr SetCapture(IntPtr hWnd); - - [DllImport("user32.dll")] - public static extern bool ReleaseCapture(); - - [DllImport("user32.dll")] - public static extern bool GetCursorPos(ref NativePoint point); - - [DllImport("user32.dll")] - public static extern bool SetCursorPos(int x, int y); - - [DllImport("user32.dll")] - public static extern int ShowCursor(bool bShow); - - #endregion DllImports - - #region Helpers - - public static int GetXLParam(int lParam) - { - return LowWord(lParam); - } - - public static int GetYLParam(int lParam) - { - return HighWord(lParam); - } - - public static int GetWheelDeltaWParam(int wParam) - { - return HighWord(wParam); - } - - public static int LowWord(int input) - { - return (short)(input & 0xffff); - } - - public static int HighWord(int input) - { - return (short)(input >> 16); - } - - #endregion Helpers - } -} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/Behaviors/CustomGlowWindowBehavior.cs b/Modules/MinoriEditorShell.Platforms.Wpf/Behaviors/CustomGlowWindowBehavior.cs deleted file mode 100644 index c41d1fae..00000000 --- a/Modules/MinoriEditorShell.Platforms.Wpf/Behaviors/CustomGlowWindowBehavior.cs +++ /dev/null @@ -1,111 +0,0 @@ -//namespace MinoriEditorShell.Platforms.Wpf.Behaviors -//{ -// Copied from MahApp's GlowWindowBehavior, because that one has a bug if GlowBrush is set in a style, rather than directly. -//public class CustomGlowWindowBehavior : Behavior -//{ -// //private GlowWindow left; -// //private GlowWindow right; -// //private GlowWindow top; -// //private GlowWindow bottom; - -// //protected override void OnAttached() -// //{ -// // base.OnAttached(); -// // this.AssociatedObject.Loaded += new RoutedEventHandler(this.AssociatedObjectOnLoaded); -// //} - -// //private void AssociatedObjectOnLoaded(object sender, RoutedEventArgs routedEventArgs) -// //{ -// // MetroWindow metroWindow = this.AssociatedObject as MetroWindow; -// // if (metroWindow != null && (metroWindow.UseNoneWindowStyle/* || metroWindow.GlowBrush == null*/)) -// // return; -// // this.left = new GlowWindow(this.AssociatedObject, GlowDirection.Left); -// // this.right = new GlowWindow(this.AssociatedObject, GlowDirection.Right); -// // this.top = new GlowWindow(this.AssociatedObject, GlowDirection.Top); -// // this.bottom = new GlowWindow(this.AssociatedObject, GlowDirection.Bottom); -// // this.Show(); -// // this.Update(); - -// // metroWindow.LocationChanged += (s, e) => this.Update(); -// // metroWindow.SizeChanged += (s, e) => this.Update(); - -// // if (metroWindow == null || !metroWindow.WindowTransitionsEnabled) -// // { -// // this.SetOpacityTo(1.0); -// // } -// // else -// // { -// // this.StartOpacityStoryboard(); -// // this.AssociatedObject.IsVisibleChanged += new DependencyPropertyChangedEventHandler(this.AssociatedObjectIsVisibleChanged); -// // this.AssociatedObject.Closing += (CancelEventHandler) ((o, args) => -// // { -// // if (args.Cancel) -// // return; -// // this.AssociatedObject.IsVisibleChanged -= new DependencyPropertyChangedEventHandler(this.AssociatedObjectIsVisibleChanged); -// // }); -// // } -// //} - -// //private void AssociatedObjectIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) -// //{ -// // if (!this.AssociatedObject.IsVisible) -// // this.SetOpacityTo(0.0); -// // else -// // this.StartOpacityStoryboard(); -// //} - -// ///// -// ///// Updates all glow windows (visible, hidden, collapsed) -// ///// -// ///// -// //private void Update() -// //{ -// // if (this.left == null || this.right == null || (this.top == null || this.bottom == null)) -// // return; -// // this.left.Update(); -// // this.right.Update(); -// // this.top.Update(); -// // this.bottom.Update(); -// //} - -// ///// -// ///// Sets the opacity to all glow windows -// ///// -// ///// -// //private void SetOpacityTo(double newOpacity) -// //{ -// // if (this.left == null || this.right == null || (this.top == null || this.bottom == null)) -// // return; -// // this.left.Opacity = newOpacity; -// // this.right.Opacity = newOpacity; -// // this.top.Opacity = newOpacity; -// // this.bottom.Opacity = newOpacity; -// //} - -// ///// -// ///// Starts the opacity storyboard 0 -> 1 -// ///// -// ///// -// //private void StartOpacityStoryboard() -// //{ -// // if (this.left == null || this.left.OpacityStoryboard == null || (this.right == null || this.right.OpacityStoryboard == null) || (this.top == null || this.top.OpacityStoryboard == null || (this.bottom == null || this.bottom.OpacityStoryboard == null))) -// // return; -// // this.left.BeginStoryboard(this.left.OpacityStoryboard); -// // this.right.BeginStoryboard(this.right.OpacityStoryboard); -// // this.top.BeginStoryboard(this.top.OpacityStoryboard); -// // this.bottom.BeginStoryboard(this.bottom.OpacityStoryboard); -// //} - -// ///// -// ///// Shows all glow windows -// ///// -// ///// -// //private void Show() -// //{ -// // this.left.Show(); -// // this.right.Show(); -// // this.top.Show(); -// // this.bottom.Show(); -// //} -//} -//} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/Behaviors/MesBindableTreeViewSelectedItemBehavior.cs b/Modules/MinoriEditorShell.Platforms.Wpf/Behaviors/MesBindableTreeViewSelectedItemBehavior.cs deleted file mode 100644 index b57be102..00000000 --- a/Modules/MinoriEditorShell.Platforms.Wpf/Behaviors/MesBindableTreeViewSelectedItemBehavior.cs +++ /dev/null @@ -1,194 +0,0 @@ -namespace MinoriEditorShell.Platforms.Wpf.Behaviors -{ - // From http://stackoverflow.com/a/20636049/208817 - // public class MesBindableTreeViewSelectedItemBehavior : Behavior - // { - // #region SelectedItem Property - - // public object SelectedItem - // { - // get { return GetValue(SelectedItemProperty); } - // set { SetValue(SelectedItemProperty, value); } - // } - - // public static readonly DependencyProperty SelectedItemProperty = DependencyProperty.Register( - // "SelectedItem", typeof(object), typeof(MesBindableTreeViewSelectedItemBehavior), - // new UIPropertyMetadata(null, OnSelectedItemChanged)); - - // private static void OnSelectedItemChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) - // { - // Action selectTreeViewItem = tvi2 => - // { - // if (tvi2 != null) - // { - // tvi2.IsSelected = true; - // tvi2.Focus(); - // } - // }; - - // var tvi = e.NewValue as TreeViewItem; - - // if (tvi == null) - // { - // var tree = ((MesBindableTreeViewSelectedItemBehavior) sender).AssociatedObject; - // if (tree == null) - // return; - - // if (!tree.IsLoaded) - // { - // RoutedEventHandler handler = null; - // handler = (sender2, e2) => - // { - // tvi = GetTreeViewItem(tree, e.NewValue); - // selectTreeViewItem(tvi); - // tree.Loaded -= handler; - // }; - // tree.Loaded += handler; - - // return; - // } - // tvi = GetTreeViewItem(tree, e.NewValue); - // } - - // selectTreeViewItem(tvi); - // } - - // #endregion - - // #region Private - - // private void OnTreeViewSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs e) - // { - // SelectedItem = e.NewValue; - // } - - // private static TreeViewItem GetTreeViewItem(ItemsControl container, object item) - // { - // if (container != null) - // { - // if (container.DataContext == item) - // { - // return container as TreeViewItem; - // } - - // // Expand the current container - // if (container is TreeViewItem && !((TreeViewItem) container).IsExpanded) - // { - // container.SetValue(TreeViewItem.IsExpandedProperty, true); - // } - - // // Try to generate the ItemsPresenter and the ItemsPanel. - // // by calling ApplyTemplate. Note that in the - // // virtualizing case even if the item is marked - // // expanded we still need to do this step in order to - // // regenerate the visuals because they may have been virtualized away. - - // container.ApplyTemplate(); - // var itemsPresenter = - // (ItemsPresenter) container.Template.FindName("ItemsHost", container); - // if (itemsPresenter != null) - // { - // itemsPresenter.ApplyTemplate(); - // } - // else - // { - // // The Tree template has not named the ItemsPresenter, - // // so walk the descendents and find the child. - // itemsPresenter = FindVisualChild(container); - // if (itemsPresenter == null) - // { - // container.UpdateLayout(); - // itemsPresenter = FindVisualChild(container); - // } - // } - - // var itemsHostPanel = (Panel) VisualTreeHelper.GetChild(itemsPresenter, 0); - - // // Ensure that the generator for this panel has been created. - //#pragma warning disable 168 - // var children = itemsHostPanel.Children; - //#pragma warning restore 168 - - // for (int i = 0, count = container.Items.Count; i < count; i++) - // { - // var subContainer = (TreeViewItem) container.ItemContainerGenerator. - // ContainerFromIndex(i); - // if (subContainer == null) - // { - // continue; - // } - - // subContainer.BringIntoView(); - - // // Search the next level for the object. - // var resultContainer = GetTreeViewItem(subContainer, item); - // if (resultContainer != null) - // { - // return resultContainer; - // } - // else - // { - // // The object is not under this TreeViewItem - // // so collapse it. - // //subContainer.IsExpanded = false; - // } - // } - // } - - // return null; - // } - - // /// - // /// Search for an element of a certain type in the visual tree. - // /// - // /// The type of element to find. - // /// The parent element. - // /// - // private static T FindVisualChild(Visual visual) where T : Visual - // { - // for (int i = 0; i < VisualTreeHelper.GetChildrenCount(visual); i++) - // { - // Visual child = (Visual) VisualTreeHelper.GetChild(visual, i); - // if (child != null) - // { - // T correctlyTyped = child as T; - // if (correctlyTyped != null) - // { - // return correctlyTyped; - // } - - // T descendent = FindVisualChild(child); - // if (descendent != null) - // { - // return descendent; - // } - // } - // } - - // return null; - // } - - // #endregion - - // #region Protected - - // protected override void OnAttached() - // { - // base.OnAttached(); - - // AssociatedObject.SelectedItemChanged += OnTreeViewSelectedItemChanged; - // } - - // protected override void OnDetaching() - // { - // base.OnDetaching(); - - // if (AssociatedObject != null) - // { - // AssociatedObject.SelectedItemChanged -= OnTreeViewSelectedItemChanged; - // } - // } - - // #endregion - // } -} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/Behaviors/MesKeyboardFocusBehavior.cs b/Modules/MinoriEditorShell.Platforms.Wpf/Behaviors/MesKeyboardFocusBehavior.cs deleted file mode 100644 index c6eebe76..00000000 --- a/Modules/MinoriEditorShell.Platforms.Wpf/Behaviors/MesKeyboardFocusBehavior.cs +++ /dev/null @@ -1,17 +0,0 @@ -//using System.Windows.Interactivity; - -namespace MinoriEditorShell.Platforms.Wpf.Behaviors -{ - //public class MesKeyboardFocusBehavior : Behavior - //{ - // protected override void OnAttached() - // { - // if (!AssociatedObject.IsLoaded) - // AssociatedObject.Loaded += (sender, e) => { Keyboard.Focus(AssociatedObject); }; - // else - // Keyboard.Focus(AssociatedObject); - - // base.OnAttached(); - // } - //} -} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/Behaviors/MesWindowOptionsBehavior.cs b/Modules/MinoriEditorShell.Platforms.Wpf/Behaviors/MesWindowOptionsBehavior.cs deleted file mode 100644 index 02df7cb9..00000000 --- a/Modules/MinoriEditorShell.Platforms.Wpf/Behaviors/MesWindowOptionsBehavior.cs +++ /dev/null @@ -1,101 +0,0 @@ -//using System.Windows.Interactivity; - -namespace MinoriEditorShell.Platforms.Wpf.Behaviors -{ - //public class MesWindowOptionsBehavior : Behavior - //{ - // public static readonly DependencyProperty ShowIconProperty = DependencyProperty.Register( - // "ShowIcon", typeof(Boolean), typeof(MesWindowOptionsBehavior), - // new PropertyMetadata(true, OnWindowOptionChanged)); - - // public Boolean ShowIcon - // { - // get => (Boolean)GetValue(ShowIconProperty); - // set => SetValue(ShowIconProperty, value); - // } - - // public static readonly DependencyProperty ShowMinimizeBoxProperty = DependencyProperty.Register( - // "ShowMinimizeBox", typeof(Boolean), typeof(MesWindowOptionsBehavior), - // new PropertyMetadata(true, OnWindowOptionChanged)); - - // public Boolean ShowMinimizeBox - // { - // get => (Boolean)GetValue(ShowMinimizeBoxProperty); - // set => SetValue(ShowMinimizeBoxProperty, value); - // } - - // public static readonly DependencyProperty ShowMaximizeBoxProperty = DependencyProperty.Register( - // "ShowMaximizeBox", typeof(Boolean), typeof(MesWindowOptionsBehavior), - // new PropertyMetadata(true, OnWindowOptionChanged)); - - // public Boolean ShowMaximizeBox - // { - // get => (Boolean)GetValue(ShowMaximizeBoxProperty); - // set => SetValue(ShowMaximizeBoxProperty, value); - // } - - // private static void OnWindowOptionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => ((MesWindowOptionsBehavior)d).UpdateWindowStyle(); - - // private void UpdateWindowStyle() - // { - // if (AssociatedObject == null) - // { - // return; - // } - - // IntPtr handle = new WindowInteropHelper(AssociatedObject).Handle; - - // Int32 windowStyle = NativeMethods.GetWindowLong(handle, NativeMethods.GWL_STYLE); - - // if (ShowMinimizeBox) - // { - // windowStyle |= NativeMethods.WS_MINIMIZEBOX; - // } - // else - // { - // windowStyle &= ~NativeMethods.WS_MINIMIZEBOX; - // } - - // if (ShowMaximizeBox) - // { - // windowStyle |= NativeMethods.WS_MAXIMIZEBOX; - // } - // else - // { - // windowStyle &= ~NativeMethods.WS_MAXIMIZEBOX; - // } - - // NativeMethods.SetWindowLong(handle, NativeMethods.GWL_STYLE, windowStyle); - - // if (ShowIcon) - // { - // // TODO - // } - // else - // { - // Int32 exWindowStyle = NativeMethods.GetWindowLong(handle, NativeMethods.GWL_EXSTYLE); - // NativeMethods.SetWindowLong(handle, NativeMethods.GWL_EXSTYLE, - // exWindowStyle | NativeMethods.WS_EX_DLGMODALFRAME); - - // NativeMethods.SetWindowPos(handle, IntPtr.Zero, 0, 0, 0, 0, - // NativeMethods.SWP_NOMOVE | NativeMethods.SWP_NOSIZE | NativeMethods.SWP_NOZORDER | NativeMethods.SWP_FRAMECHANGED); - - // NativeMethods.SendMessage(handle, NativeMethods.WM_SETICON, IntPtr.Zero, IntPtr.Zero); - // } - // } - - // protected override void OnAttached() - // { - // AssociatedObject.SourceInitialized += OnSourceInitialized; - // base.OnAttached(); - // } - - // protected override void OnDetaching() - // { - // AssociatedObject.SourceInitialized -= OnSourceInitialized; - // base.OnDetaching(); - // } - - // private void OnSourceInitialized(Object sender, EventArgs e) => UpdateWindowStyle(); - //} -} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/Controls/MesClippingHwndHost.cs b/Modules/MinoriEditorShell.Platforms.Wpf/Controls/MesClippingHwndHost.cs deleted file mode 100644 index fa65d6dc..00000000 --- a/Modules/MinoriEditorShell.Platforms.Wpf/Controls/MesClippingHwndHost.cs +++ /dev/null @@ -1,90 +0,0 @@ -using MinoriEditorShell.Platforms.Wpf.Win32; -using System; -using System.Collections; -using System.Runtime.InteropServices; -using System.Windows; -using System.Windows.Interop; -using System.Windows.Media; - -namespace MinoriEditorShell.Platforms.Wpf.Controls -{ - public class MesClippingHwndHost : HwndHost - { - private HwndSource _source; - - public static readonly DependencyProperty ContentProperty = DependencyProperty.Register( - "Content", typeof(Visual), typeof(MesClippingHwndHost), - new PropertyMetadata(OnContentChanged)); - - private static void OnContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - MesClippingHwndHost hwndHost = (MesClippingHwndHost)d; - - if (e.OldValue != null) - { - if (hwndHost._source != null) - { - hwndHost._source.RootVisual = null; - } - - hwndHost.RemoveLogicalChild(e.OldValue); - } - - if (e.NewValue != null) - { - hwndHost.AddLogicalChild(e.NewValue); - if (hwndHost._source != null) - { - hwndHost._source.RootVisual = (Visual)e.NewValue; - } - } - } - - public Visual Content - { - get => (Visual)GetValue(ContentProperty); - set => SetValue(ContentProperty, value); - } - - protected override IEnumerator LogicalChildren - { - get - { - if (Content != null) - { - yield return Content; - } - } - } - - protected override HandleRef BuildWindowCore(HandleRef hwndParent) - { - HwndSourceParameters param = new HwndSourceParameters("MinoriEditorStudioClippingHwndHost", (Int32)Width, (Int32)Height) - { - ParentWindow = hwndParent.Handle, - WindowStyle = NativeMethods.WS_VISIBLE | NativeMethods.WS_CHILD, - }; - - _source = new HwndSource(param) - { - RootVisual = Content - }; - - return new HandleRef(null, _source.Handle); - } - - protected override void DestroyWindowCore(HandleRef hwnd) - { - _source.Dispose(); - _source = null; - } - - protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) - { - // If we don't do this, HwndHost doesn't seem to pick up on all size changes. - UpdateWindowPos(); - - base.OnRenderSizeChanged(sizeInfo); - } - } -} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/Controls/MesHwndMouse.cs b/Modules/MinoriEditorShell.Platforms.Wpf/Controls/MesHwndMouse.cs deleted file mode 100644 index bb66d1b3..00000000 --- a/Modules/MinoriEditorShell.Platforms.Wpf/Controls/MesHwndMouse.cs +++ /dev/null @@ -1,22 +0,0 @@ -using MinoriEditorShell.Platforms.Wpf.Win32; -using System; -using System.Windows; - -namespace MinoriEditorShell.Platforms.Wpf.Controls -{ - public static class MesHwndMouse - { - public static Point GetCursorPosition() - { - NativeMethods.NativePoint point = new NativeMethods.NativePoint(); - NativeMethods.GetCursorPos(ref point); - return new Point(point.X, point.Y); - } - - public static void SetCursorPosition(Point point) => NativeMethods.SetCursorPos((Int32)point.X, (Int32)point.Y); - - public static void ShowCursor() => NativeMethods.ShowCursor(true); - - public static void HideCursor() => NativeMethods.ShowCursor(false); - } -} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/Controls/MesHwndMouseEventArgs.cs b/Modules/MinoriEditorShell.Platforms.Wpf/Controls/MesHwndMouseEventArgs.cs deleted file mode 100644 index 718d8060..00000000 --- a/Modules/MinoriEditorShell.Platforms.Wpf/Controls/MesHwndMouseEventArgs.cs +++ /dev/null @@ -1,110 +0,0 @@ -#region File Description - -//----------------------------------------------------------------------------- -// Copyright 2011, Nick Gravelyn. -// Licensed under the terms of the Ms-PL: -// http://www.microsoft.com/opensource/licenses.mspx#Ms-PL -//----------------------------------------------------------------------------- - -#endregion File Description - -using System; -using System.Windows; -using System.Windows.Input; - -namespace MinoriEditorShell.Platforms.Wpf.Controls -{ - public class MesHwndMouseEventArgs : EventArgs - { - /// - /// Gets the state of the left mouse button. - /// - public MouseButtonState LeftButton { get; private set; } - - /// - /// Gets the state of the right mouse button. - /// - public MouseButtonState RightButton { get; private set; } - - /// - /// Gets the state of the middle mouse button. - /// - public MouseButtonState MiddleButton { get; private set; } - - /// - /// Gets the state of the first extra mouse button. - /// - public MouseButtonState X1Button { get; private set; } - - /// - /// Gets the state of the second extra mouse button. - /// - public MouseButtonState X2Button { get; private set; } - - /// - /// Gets the button that was double clicked. - /// - public MouseButton? DoubleClickButton { get; private set; } - - /// - /// Gets the mouse wheel delta. - /// - public int WheelDelta { get; private set; } - - /// - /// Gets the horizontal mouse wheel delta. - /// - public int HorizontalWheelDelta { get; private set; } - - /// - /// Gets the position of the mouse in screen coordinates. - /// - public Point ScreenPosition { get; private set; } - - /// - /// Calculates the position of the mouse relative to a particular element. - /// - public Point GetPosition(UIElement relativeTo) - { - return relativeTo.PointFromScreen(ScreenPosition); - } - - /// - /// Initializes a new HwndMouseEventArgs. - /// - /// The state from which to initialize the properties. - public MesHwndMouseEventArgs(MesHwndMouseState state) - { - LeftButton = state.LeftButton; - RightButton = state.RightButton; - MiddleButton = state.MiddleButton; - X1Button = state.X1Button; - X2Button = state.X2Button; - ScreenPosition = state.ScreenPosition; - } - - /// - /// Initializes a new HwndMouseEventArgs. - /// - /// The state from which to initialize the properties. - /// The mouse wheel rotation delta. - /// The horizontal mouse wheel delta. - public MesHwndMouseEventArgs(MesHwndMouseState state, int mouseWheelDelta, int mouseHWheelDelta) - : this(state) - { - WheelDelta = mouseWheelDelta; - HorizontalWheelDelta = mouseHWheelDelta; - } - - /// - /// Initializes a new HwndMouseEventArgs. - /// - /// The state from which to initialize the properties. - /// The button that was double clicked. - public MesHwndMouseEventArgs(MesHwndMouseState state, MouseButton doubleClickButton) - : this(state) - { - DoubleClickButton = doubleClickButton; - } - } -} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/Controls/MesHwndMouseState.cs b/Modules/MinoriEditorShell.Platforms.Wpf/Controls/MesHwndMouseState.cs deleted file mode 100644 index 302466f2..00000000 --- a/Modules/MinoriEditorShell.Platforms.Wpf/Controls/MesHwndMouseState.cs +++ /dev/null @@ -1,48 +0,0 @@ -#region File Description - -//----------------------------------------------------------------------------- -// Copyright 2011, Nick Gravelyn. -// Licensed under the terms of the Ms-PL: -// http://www.microsoft.com/opensource/licenses.mspx#Ms-PL -//----------------------------------------------------------------------------- - -#endregion File Description - -using System.Windows; -using System.Windows.Input; - -namespace MinoriEditorShell.Platforms.Wpf.Controls -{ - public class MesHwndMouseState - { - /// - /// The current state of the left mouse button. - /// - public MouseButtonState LeftButton; - - /// - /// The current state of the right mouse button. - /// - public MouseButtonState RightButton; - - /// - /// The current state of the middle mouse button. - /// - public MouseButtonState MiddleButton; - - /// - /// The current state of the first extra mouse button. - /// - public MouseButtonState X1Button; - - /// - /// The current state of the second extra mouse button. - /// - public MouseButtonState X2Button; - - /// - /// The current position of the mouse in screen coordinates. - /// - public Point ScreenPosition; - } -} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/Controls/MesHwndWrapper.cs b/Modules/MinoriEditorShell.Platforms.Wpf/Controls/MesHwndWrapper.cs deleted file mode 100644 index ab202cb0..00000000 --- a/Modules/MinoriEditorShell.Platforms.Wpf/Controls/MesHwndWrapper.cs +++ /dev/null @@ -1,631 +0,0 @@ -#region File Description - -//----------------------------------------------------------------------------- -// Copyright 2011, Nick Gravelyn. -// Licensed under the terms of the Ms-PL: -// http://www.microsoft.com/opensource/licenses.mspx#Ms-PL -//----------------------------------------------------------------------------- - -#endregion File Description - -using MinoriEditorShell.Platforms.Wpf.Win32; -using System; -using System.Linq; -using System.Runtime.InteropServices; -using System.Windows; -using System.Windows.Input; -using System.Windows.Interop; -using System.Windows.Media; - -namespace MinoriEditorShell.Platforms.Wpf.Controls -{ - /// - /// A control that enables graphics rendering inside a WPF control through - /// the use of a hosted child Hwnd. - /// - public abstract class MesHwndWrapper : HwndHost - { - #region Fields - - // The name of our window class - private const string WindowClass = "GraphicsDeviceControlHostWindowClass"; - - // The HWND we present to when rendering - private IntPtr _hWnd; - - // For holding previous hWnd focus - private IntPtr _hWndPrev; - - // Track if the application has focus - private bool _applicationHasFocus; - - // Track if the mouse is in the window - private bool _mouseInWindow; - - // Track the previous mouse position - private Point _previousPosition; - - // Track the mouse state - private readonly MesHwndMouseState _mouseState = new MesHwndMouseState(); - - // Tracking whether we've "capture" the mouse - private bool _isMouseCaptured; - - #endregion Fields - - #region Events - - /// - /// Invoked when the control receives a left mouse down message. - /// - public event EventHandler HwndLButtonDown; - - /// - /// Invoked when the control receives a left mouse up message. - /// - public event EventHandler HwndLButtonUp; - - /// - /// Invoked when the control receives a left mouse double click message. - /// - public event EventHandler HwndLButtonDblClick; - - /// - /// Invoked when the control receives a right mouse down message. - /// - public event EventHandler HwndRButtonDown; - - /// - /// Invoked when the control receives a right mouse up message. - /// - public event EventHandler HwndRButtonUp; - - /// - /// Invoked when the control receives a rigt mouse double click message. - /// - public event EventHandler HwndRButtonDblClick; - - /// - /// Invoked when the control receives a middle mouse down message. - /// - public event EventHandler HwndMButtonDown; - - /// - /// Invoked when the control receives a middle mouse up message. - /// - public event EventHandler HwndMButtonUp; - - /// - /// Invoked when the control receives a middle mouse double click message. - /// - public event EventHandler HwndMButtonDblClick; - - /// - /// Invoked when the control receives a mouse down message for the first extra button. - /// - public event EventHandler HwndX1ButtonDown; - - /// - /// Invoked when the control receives a mouse up message for the first extra button. - /// - public event EventHandler HwndX1ButtonUp; - - /// - /// Invoked when the control receives a double click message for the first extra mouse button. - /// - public event EventHandler HwndX1ButtonDblClick; - - /// - /// Invoked when the control receives a mouse down message for the second extra button. - /// - public event EventHandler HwndX2ButtonDown; - - /// - /// Invoked when the control receives a mouse up message for the second extra button. - /// - public event EventHandler HwndX2ButtonUp; - - /// - /// Invoked when the control receives a double click message for the first extra mouse button. - /// - public event EventHandler HwndX2ButtonDblClick; - - /// - /// Invoked when the control receives a mouse move message. - /// - public event EventHandler HwndMouseMove; - - /// - /// Invoked when the control first gets a mouse move message. - /// - public event EventHandler HwndMouseEnter; - - /// - /// Invoked when the control gets a mouse leave message. - /// - public event EventHandler HwndMouseLeave; - - /// - /// Invoked when the control recieves a mouse wheel delta. - /// - public event EventHandler HwndMouseWheel; - - #endregion Events - - #region Properties - - public new bool IsMouseCaptured - { - get { return _isMouseCaptured; } - } - - #endregion Properties - - #region Construction and Disposal - - protected MesHwndWrapper() - { - // We must be notified of the application foreground status for our mouse input events - Application.Current.Activated += OnApplicationActivated; - Application.Current.Deactivated += OnApplicationDeactivated; - - // We use the CompositionTarget.Rendering event to trigger the control to draw itself - CompositionTarget.Rendering += OnCompositionTargetRendering; - - // Check whether the application is active (it almost certainly is, at this point). - if (Application.Current.Windows.Cast().Any(x => x.IsActive)) - _applicationHasFocus = true; - } - - protected override void Dispose(bool disposing) - { - // Unhook all events. - CompositionTarget.Rendering -= OnCompositionTargetRendering; - if (Application.Current != null) - { - Application.Current.Activated -= OnApplicationActivated; - Application.Current.Deactivated -= OnApplicationDeactivated; - } - - base.Dispose(disposing); - } - - #endregion Construction and Disposal - - #region Public Methods - - /// - /// Captures the mouse, hiding it and trapping it inside the window bounds. - /// - /// - /// This method is useful for tooling scenarios where you only care about the mouse deltas - /// and want the user to be able to continue interacting with the window while they move - /// the mouse. A good example of this is rotating an object based on the mouse deltas where - /// through capturing you can spin and spin without having the cursor leave the window. - /// - public new void CaptureMouse() - { - // Don't do anything if the mouse is already captured - if (_isMouseCaptured) - return; - - NativeMethods.SetCapture(_hWnd); - _isMouseCaptured = true; - } - - /// - /// Releases the capture of the mouse which makes it visible and allows it to leave the window bounds. - /// - public new void ReleaseMouseCapture() - { - // Don't do anything if the mouse is not captured - if (!_isMouseCaptured) - return; - - NativeMethods.ReleaseCapture(); - _isMouseCaptured = false; - } - - #endregion Public Methods - - #region Graphics Device Control Implementation - - private void OnCompositionTargetRendering(object sender, EventArgs e) - { - // Get the current width and height of the control - var width = (int)ActualWidth; - var height = (int)ActualHeight; - - // If the control has no width or no height, skip drawing since it's not visible - if (width < 1 || height < 1) - return; - - Render(_hWnd); - } - - protected abstract void Render(IntPtr windowHandle); - - private void OnApplicationActivated(object sender, EventArgs e) - { - _applicationHasFocus = true; - } - - private void OnApplicationDeactivated(object sender, EventArgs e) - { - _applicationHasFocus = false; - ResetMouseState(); - - if (_mouseInWindow) - { - _mouseInWindow = false; - RaiseHwndMouseLeave(new MesHwndMouseEventArgs(_mouseState)); - } - - ReleaseMouseCapture(); - } - - private void ResetMouseState() - { - // We need to invoke events for any buttons that were pressed - bool fireL = _mouseState.LeftButton == MouseButtonState.Pressed; - bool fireM = _mouseState.MiddleButton == MouseButtonState.Pressed; - bool fireR = _mouseState.RightButton == MouseButtonState.Pressed; - bool fireX1 = _mouseState.X1Button == MouseButtonState.Pressed; - bool fireX2 = _mouseState.X2Button == MouseButtonState.Pressed; - - // Update the state of all of the buttons - _mouseState.LeftButton = MouseButtonState.Released; - _mouseState.MiddleButton = MouseButtonState.Released; - _mouseState.RightButton = MouseButtonState.Released; - _mouseState.X1Button = MouseButtonState.Released; - _mouseState.X2Button = MouseButtonState.Released; - - // Fire any events - var args = new MesHwndMouseEventArgs(_mouseState); - if (fireL) - RaiseHwndLButtonUp(args); - if (fireM) - RaiseHwndMButtonUp(args); - if (fireR) - RaiseHwndRButtonUp(args); - if (fireX1) - RaiseHwndX1ButtonUp(args); - if (fireX2) - RaiseHwndX2ButtonUp(args); - - // The mouse is no longer considered to be in our window - _mouseInWindow = false; - } - - #endregion Graphics Device Control Implementation - - #region HWND Management - - protected override HandleRef BuildWindowCore(HandleRef hwndParent) - { - // Create the host window as a child of the parent - _hWnd = CreateHostWindow(hwndParent.Handle); - return new HandleRef(this, _hWnd); - } - - protected override void DestroyWindowCore(HandleRef hwnd) - { - // Destroy the window and reset our hWnd value - NativeMethods.DestroyWindow(hwnd.Handle); - _hWnd = IntPtr.Zero; - } - - /// - /// Creates the host window as a child of the parent window. - /// - private IntPtr CreateHostWindow(IntPtr hWndParent) - { - // Register our window class - RegisterWindowClass(); - - // Create the window - return NativeMethods.CreateWindowEx(0, WindowClass, "", - NativeMethods.WS_CHILD | NativeMethods.WS_VISIBLE, - 0, 0, (int)Width, (int)Height, hWndParent, IntPtr.Zero, IntPtr.Zero, 0); - } - - /// - /// Registers the window class. - /// - private void RegisterWindowClass() - { - var wndClass = new NativeMethods.WNDCLASSEX(); - wndClass.cbSize = (uint)Marshal.SizeOf(wndClass); - wndClass.hInstance = NativeMethods.GetModuleHandle(null); - wndClass.lpfnWndProc = NativeMethods.DefaultWindowProc; - wndClass.lpszClassName = WindowClass; - wndClass.hCursor = NativeMethods.LoadCursor(IntPtr.Zero, NativeMethods.IDC_ARROW); - - NativeMethods.RegisterClassEx(ref wndClass); - } - - #endregion HWND Management - - #region WndProc Implementation - - protected override IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) - { - switch (msg) - { - case NativeMethods.WM_MOUSEWHEEL: - if (_mouseInWindow) - { - int delta = NativeMethods.GetWheelDeltaWParam(wParam.ToInt32()); - RaiseHwndMouseWheel(new MesHwndMouseEventArgs(_mouseState, delta, 0)); - } - break; - - case NativeMethods.WM_LBUTTONDOWN: - _mouseState.LeftButton = MouseButtonState.Pressed; - RaiseHwndLButtonDown(new MesHwndMouseEventArgs(_mouseState)); - break; - - case NativeMethods.WM_LBUTTONUP: - _mouseState.LeftButton = MouseButtonState.Released; - RaiseHwndLButtonUp(new MesHwndMouseEventArgs(_mouseState)); - break; - - case NativeMethods.WM_LBUTTONDBLCLK: - RaiseHwndLButtonDblClick(new MesHwndMouseEventArgs(_mouseState, MouseButton.Left)); - break; - - case NativeMethods.WM_RBUTTONDOWN: - _mouseState.RightButton = MouseButtonState.Pressed; - RaiseHwndRButtonDown(new MesHwndMouseEventArgs(_mouseState)); - break; - - case NativeMethods.WM_RBUTTONUP: - _mouseState.RightButton = MouseButtonState.Released; - RaiseHwndRButtonUp(new MesHwndMouseEventArgs(_mouseState)); - break; - - case NativeMethods.WM_RBUTTONDBLCLK: - RaiseHwndRButtonDblClick(new MesHwndMouseEventArgs(_mouseState, MouseButton.Right)); - break; - - case NativeMethods.WM_MBUTTONDOWN: - _mouseState.MiddleButton = MouseButtonState.Pressed; - RaiseHwndMButtonDown(new MesHwndMouseEventArgs(_mouseState)); - break; - - case NativeMethods.WM_MBUTTONUP: - _mouseState.MiddleButton = MouseButtonState.Released; - RaiseHwndMButtonUp(new MesHwndMouseEventArgs(_mouseState)); - break; - - case NativeMethods.WM_MBUTTONDBLCLK: - RaiseHwndMButtonDblClick(new MesHwndMouseEventArgs(_mouseState, MouseButton.Middle)); - break; - - case NativeMethods.WM_XBUTTONDOWN: - if (((int)wParam & NativeMethods.MK_XBUTTON1) != 0) - { - _mouseState.X1Button = MouseButtonState.Pressed; - RaiseHwndX1ButtonDown(new MesHwndMouseEventArgs(_mouseState)); - } - else if (((int)wParam & NativeMethods.MK_XBUTTON2) != 0) - { - _mouseState.X2Button = MouseButtonState.Pressed; - RaiseHwndX2ButtonDown(new MesHwndMouseEventArgs(_mouseState)); - } - break; - - case NativeMethods.WM_XBUTTONUP: - if (((int)wParam & NativeMethods.MK_XBUTTON1) != 0) - { - _mouseState.X1Button = MouseButtonState.Released; - RaiseHwndX1ButtonUp(new MesHwndMouseEventArgs(_mouseState)); - } - else if (((int)wParam & NativeMethods.MK_XBUTTON2) != 0) - { - _mouseState.X2Button = MouseButtonState.Released; - RaiseHwndX2ButtonUp(new MesHwndMouseEventArgs(_mouseState)); - } - break; - - case NativeMethods.WM_XBUTTONDBLCLK: - if (((int)wParam & NativeMethods.MK_XBUTTON1) != 0) - RaiseHwndX1ButtonDblClick(new MesHwndMouseEventArgs(_mouseState, MouseButton.XButton1)); - else if (((int)wParam & NativeMethods.MK_XBUTTON2) != 0) - RaiseHwndX2ButtonDblClick(new MesHwndMouseEventArgs(_mouseState, MouseButton.XButton2)); - break; - - case NativeMethods.WM_MOUSEMOVE: - // If the application isn't in focus, we don't handle this message - if (!_applicationHasFocus) - break; - - // record the prevous and new position of the mouse - _mouseState.ScreenPosition = PointToScreen(new Point( - NativeMethods.GetXLParam((int)lParam), - NativeMethods.GetYLParam((int)lParam))); - - if (!_mouseInWindow) - { - _mouseInWindow = true; - - RaiseHwndMouseEnter(new MesHwndMouseEventArgs(_mouseState)); - - // Track the previously focused window, and set focus to this window. - _hWndPrev = NativeMethods.GetFocus(); - NativeMethods.SetFocus(_hWnd); - - // send the track mouse event so that we get the WM_MOUSELEAVE message - var tme = new NativeMethods.TRACKMOUSEEVENT - { - cbSize = Marshal.SizeOf(typeof(NativeMethods.TRACKMOUSEEVENT)), - dwFlags = NativeMethods.TME_LEAVE, - hWnd = hwnd - }; - NativeMethods.TrackMouseEvent(ref tme); - } - - if (_mouseState.ScreenPosition != _previousPosition) - RaiseHwndMouseMove(new MesHwndMouseEventArgs(_mouseState)); - - _previousPosition = _mouseState.ScreenPosition; - - break; - - case NativeMethods.WM_MOUSELEAVE: - - // If we have capture, we ignore this message because we're just - // going to reset the cursor position back into the window - if (_isMouseCaptured) - break; - - // Reset the state which releases all buttons and - // marks the mouse as not being in the window. - ResetMouseState(); - - RaiseHwndMouseLeave(new MesHwndMouseEventArgs(_mouseState)); - - NativeMethods.SetFocus(_hWndPrev); - - break; - } - - return base.WndProc(hwnd, msg, wParam, lParam, ref handled); - } - - protected virtual void RaiseHwndLButtonDown(MesHwndMouseEventArgs args) - { - var handler = HwndLButtonDown; - if (handler != null) - handler(this, args); - } - - protected virtual void RaiseHwndLButtonUp(MesHwndMouseEventArgs args) - { - var handler = HwndLButtonUp; - if (handler != null) - handler(this, args); - } - - protected virtual void RaiseHwndRButtonDown(MesHwndMouseEventArgs args) - { - var handler = HwndRButtonDown; - if (handler != null) - handler(this, args); - } - - protected virtual void RaiseHwndRButtonUp(MesHwndMouseEventArgs args) - { - var handler = HwndRButtonUp; - if (handler != null) - handler(this, args); - } - - protected virtual void RaiseHwndMButtonDown(MesHwndMouseEventArgs args) - { - var handler = HwndMButtonDown; - if (handler != null) - handler(this, args); - } - - protected virtual void RaiseHwndMButtonUp(MesHwndMouseEventArgs args) - { - var handler = HwndMButtonUp; - if (handler != null) - handler(this, args); - } - - protected virtual void RaiseHwndLButtonDblClick(MesHwndMouseEventArgs args) - { - var handler = HwndLButtonDblClick; - if (handler != null) - handler(this, args); - } - - protected virtual void RaiseHwndRButtonDblClick(MesHwndMouseEventArgs args) - { - var handler = HwndRButtonDblClick; - if (handler != null) - handler(this, args); - } - - protected virtual void RaiseHwndMButtonDblClick(MesHwndMouseEventArgs args) - { - var handler = HwndMButtonDblClick; - if (handler != null) - handler(this, args); - } - - protected virtual void RaiseHwndMouseEnter(MesHwndMouseEventArgs args) - { - var handler = HwndMouseEnter; - if (handler != null) - handler(this, args); - } - - protected virtual void RaiseHwndX1ButtonDown(MesHwndMouseEventArgs args) - { - var handler = HwndX1ButtonDown; - if (handler != null) - handler(this, args); - } - - protected virtual void RaiseHwndX1ButtonUp(MesHwndMouseEventArgs args) - { - var handler = HwndX1ButtonUp; - if (handler != null) - handler(this, args); - } - - protected virtual void RaiseHwndX2ButtonDown(MesHwndMouseEventArgs args) - { - var handler = HwndX2ButtonDown; - if (handler != null) - handler(this, args); - } - - protected virtual void RaiseHwndX2ButtonUp(MesHwndMouseEventArgs args) - { - var handler = HwndX2ButtonUp; - if (handler != null) - handler(this, args); - } - - protected virtual void RaiseHwndX1ButtonDblClick(MesHwndMouseEventArgs args) - { - var handler = HwndX1ButtonDblClick; - if (handler != null) - handler(this, args); - } - - protected virtual void RaiseHwndX2ButtonDblClick(MesHwndMouseEventArgs args) - { - var handler = HwndX2ButtonDblClick; - if (handler != null) - handler(this, args); - } - - protected virtual void RaiseHwndMouseLeave(MesHwndMouseEventArgs args) - { - var handler = HwndMouseLeave; - if (handler != null) - handler(this, args); - } - - protected virtual void RaiseHwndMouseMove(MesHwndMouseEventArgs args) - { - var handler = HwndMouseMove; - if (handler != null) - handler(this, args); - } - - protected virtual void RaiseHwndMouseWheel(MesHwndMouseEventArgs args) - { - var handler = HwndMouseWheel; - if (handler != null) - handler(this, args); - } - - #endregion WndProc Implementation - } -} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/Views/MesMainWindowView.xaml b/Modules/MinoriEditorShell.Platforms.Wpf/Views/MesMainWindowView.xaml index c8aea8a4..bcc29134 100644 --- a/Modules/MinoriEditorShell.Platforms.Wpf/Views/MesMainWindowView.xaml +++ b/Modules/MinoriEditorShell.Platforms.Wpf/Views/MesMainWindowView.xaml @@ -4,7 +4,6 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:behaviours="http://metro.mahapps.com/winfx/xaml/shared" - xmlns:behaviors="clr-namespace:MinoriEditorShell.Platforms.Wpf.Behaviors" Title="{Binding Title}" Icon="{Binding Icon}" Width="{Binding Width, Mode=TwoWay}" diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/Win32/NativeMethods.cs b/Modules/MinoriEditorShell.Platforms.Wpf/Win32/NativeMethods.cs deleted file mode 100644 index a1ee1b4c..00000000 --- a/Modules/MinoriEditorShell.Platforms.Wpf/Win32/NativeMethods.cs +++ /dev/null @@ -1,208 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace MinoriEditorShell.Platforms.Wpf.Win32 -{ - internal static class NativeMethods - { - #region Constants - - public const int GWL_STYLE = -16; - public const int GWL_EXSTYLE = -20; - - public const int WS_MAXIMIZEBOX = 0x10000; - public const int WS_MINIMIZEBOX = 0x20000; - - public const int WS_EX_DLGMODALFRAME = 0x00000001; - - public const int SWP_NOSIZE = 0x0001; - public const int SWP_NOMOVE = 0x0002; - public const int SWP_NOZORDER = 0x0004; - public const int SWP_FRAMECHANGED = 0x0020; - - public const uint WM_SETICON = 0x0080; - - // Define the window styles we use - public const int WS_CHILD = 0x40000000; - - public const int WS_VISIBLE = 0x10000000; - - // Define the Windows messages we will handle - public const int WM_MOUSEMOVE = 0x0200; - - public const int WM_LBUTTONDOWN = 0x0201; - public const int WM_LBUTTONUP = 0x0202; - public const int WM_LBUTTONDBLCLK = 0x0203; - public const int WM_RBUTTONDOWN = 0x0204; - public const int WM_RBUTTONUP = 0x0205; - public const int WM_RBUTTONDBLCLK = 0x0206; - public const int WM_MBUTTONDOWN = 0x0207; - public const int WM_MBUTTONUP = 0x0208; - public const int WM_MBUTTONDBLCLK = 0x0209; - public const int WM_MOUSEWHEEL = 0x020A; - public const int WM_XBUTTONDOWN = 0x020B; - public const int WM_XBUTTONUP = 0x020C; - public const int WM_XBUTTONDBLCLK = 0x020D; - public const int WM_MOUSELEAVE = 0x02A3; - - // Define the values that let us differentiate between the two extra mouse buttons - public const int MK_XBUTTON1 = 0x020; - - public const int MK_XBUTTON2 = 0x040; - - // Define the cursor icons we use - public const int IDC_ARROW = 32512; - - // Define the TME_LEAVE value so we can register for WM_MOUSELEAVE messages - public const uint TME_LEAVE = 0x00000002; - - #endregion Constants - - #region Delegates and Structs - - public delegate IntPtr WndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam); - - public static readonly WndProc DefaultWindowProc = DefWindowProc; - - [StructLayout(LayoutKind.Sequential)] - public struct TRACKMOUSEEVENT - { - public int cbSize; - public uint dwFlags; - public IntPtr hWnd; - public uint dwHoverTime; - } - - [StructLayout(LayoutKind.Sequential)] - public struct WNDCLASSEX - { - public uint cbSize; - public uint style; - - [MarshalAs(UnmanagedType.FunctionPtr)] - public WndProc lpfnWndProc; - - public int cbClsExtra; - public int cbWndExtra; - public IntPtr hInstance; - public IntPtr hIcon; - public IntPtr hCursor; - public IntPtr hbrBackground; - public string lpszMenuName; - public string lpszClassName; - public IntPtr hIconSm; - } - - [StructLayout(LayoutKind.Sequential)] - public struct NativePoint - { - public int X; - public int Y; - } - - #endregion Delegates and Structs - - #region DllImports - - [DllImport("user32.dll")] - public extern static int GetWindowLong(IntPtr hwnd, int index); - - [DllImport("user32.dll")] - public extern static int SetWindowLong(IntPtr hwnd, int index, int value); - - [DllImport("user32.dll")] - public extern static bool SetWindowPos(IntPtr hwnd, IntPtr hwndInsertAfter, - int x, int y, int width, int height, uint flags); - - [DllImport("user32.dll")] - public static extern IntPtr SendMessage(IntPtr hwnd, uint msg, - IntPtr wParam, IntPtr lParam); - - [DllImport("user32.dll", EntryPoint = "CreateWindowEx", CharSet = CharSet.Auto)] - public static extern IntPtr CreateWindowEx( - int exStyle, - string className, - string windowName, - int style, - int x, int y, - int width, int height, - IntPtr hwndParent, - IntPtr hMenu, - IntPtr hInstance, - [MarshalAs(UnmanagedType.AsAny)] object pvParam); - - [DllImport("user32.dll", EntryPoint = "DestroyWindow", CharSet = CharSet.Auto)] - public static extern bool DestroyWindow(IntPtr hwnd); - - [DllImport("user32.dll")] - public static extern IntPtr DefWindowProc(IntPtr hWnd, uint uMsg, IntPtr wParam, IntPtr lParam); - - [DllImport("kernel32.dll")] - public static extern IntPtr GetModuleHandle(string module); - - [DllImport("user32.dll")] - public static extern IntPtr LoadCursor(IntPtr hInstance, int lpCursorName); - - [DllImport("user32.dll")] - public static extern int TrackMouseEvent(ref TRACKMOUSEEVENT lpEventTrack); - - [DllImport("user32.dll")] - [return: MarshalAs(UnmanagedType.U2)] - public static extern short RegisterClassEx([In] ref WNDCLASSEX lpwcx); - - [DllImport("user32.dll")] - public static extern int ScreenToClient(IntPtr hWnd, ref NativePoint pt); - - [DllImport("user32.dll")] - public static extern int SetFocus(IntPtr hWnd); - - [DllImport("user32.dll")] - public static extern IntPtr GetFocus(); - - [DllImport("user32.dll")] - public static extern IntPtr SetCapture(IntPtr hWnd); - - [DllImport("user32.dll")] - public static extern bool ReleaseCapture(); - - [DllImport("user32.dll")] - public static extern bool GetCursorPos(ref NativePoint point); - - [DllImport("user32.dll")] - public static extern bool SetCursorPos(int x, int y); - - [DllImport("user32.dll")] - public static extern int ShowCursor(bool bShow); - - #endregion DllImports - - #region Helpers - - public static int GetXLParam(int lParam) - { - return LowWord(lParam); - } - - public static int GetYLParam(int lParam) - { - return HighWord(lParam); - } - - public static int GetWheelDeltaWParam(int wParam) - { - return HighWord(wParam); - } - - public static int LowWord(int input) - { - return (short)(input & 0xffff); - } - - public static int HighWord(int input) - { - return (short)(input >> 16); - } - - #endregion Helpers - } -} \ No newline at end of file From 68e9560a68b8d4dd4135c71e2fe283d254c344c7 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sun, 22 Aug 2021 17:13:39 -0400 Subject: [PATCH 53/68] MinoriDemo.WPF -> MinoriDemo.RibbonWpf --- CreateArtifacts.ps1 | 1 - .../ViewModels/MainViewModel.cs | 2 - .../App.xaml.cs | 0 .../Setup.cs | 2 +- .../Views/MainView.xaml | 0 .../Views/MainView.xaml.cs | 2 +- .../Views/VirtualCanvasView.xaml.cs | 2 + .../MinoriDemo.RibbonWpfCore/App.xaml | 16 - .../DataClasses/ThemeItem.cs | 63 --- .../MinoriDemo.RibbonWpfCore/MainWindow.xaml | 12 - .../MainWindow.xaml.cs | 10 - .../Modules/Themes/CyberTheme.cs | 18 - .../Modules/Themes/CyberTheme.xaml | 455 ------------------ .../Modules/Themes/ThemeHelper.cs | 105 ---- .../Modules/VirtualCanvas/Models/TestShape.cs | 249 ---------- .../Views/MainView.xaml.cs | 12 - .../Views/ThemeEditorView.xaml | 68 --- .../Views/ThemeEditorView.xaml.cs | 176 ------- .../Views/ToolSampleView.xaml | 44 -- .../Views/ToolSampleView.xaml.cs | 13 - .../Views/VirtualCanvasView.xaml | 18 - Demos/MinoriDemo/MinoriDemo.WPF/App.xaml | 10 - Demos/MinoriDemo/MinoriDemo.WPF/App.xaml.cs | 14 - .../MinoriDemo/MinoriDemo.WPF/MainWindow.xaml | 14 - .../MinoriDemo.WPF/MainWindow.xaml.cs | 13 - .../MinoriDemo.WPF/MinoriDemo.WPF.csproj | 24 - .../MinoriDemo.WPF/MinoriDemo.WPF.ruleset | 5 - .../MinoriDemo.WPF/MinoriDemo.Wpf.ruleset | 5 - .../MinoriDemo.WPF/Views/MainView.xaml | 22 - .../MinoriDemo.Wpf/MinoriDemo.Wpf.csproj | 24 - .../SimpleDemo.Avalonia/Views/MainView.axaml | 21 +- .../SimpleDemo.Avalonia/Views/TipView.axaml | 18 +- .../Views/TipView.axaml.cs | 3 +- MinoriEditorShell.sln | 7 - 34 files changed, 36 insertions(+), 1412 deletions(-) rename Demos/MinoriDemo/{MinoriDemo.RibbonWpfCore => MinoriDemo.RibbonWPF}/App.xaml.cs (100%) rename Demos/MinoriDemo/{MinoriDemo.Wpf => MinoriDemo.RibbonWPF}/Setup.cs (93%) rename Demos/MinoriDemo/{MinoriDemo.RibbonWpfCore => MinoriDemo.RibbonWPF}/Views/MainView.xaml (100%) rename Demos/MinoriDemo/{MinoriDemo.WPF => MinoriDemo.RibbonWPF}/Views/MainView.xaml.cs (89%) rename Demos/MinoriDemo/{MinoriDemo.RibbonWpfCore => MinoriDemo.RibbonWPF}/Views/VirtualCanvasView.xaml.cs (86%) delete mode 100644 Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/App.xaml delete mode 100644 Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/DataClasses/ThemeItem.cs delete mode 100644 Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/MainWindow.xaml delete mode 100644 Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/MainWindow.xaml.cs delete mode 100644 Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Modules/Themes/CyberTheme.cs delete mode 100644 Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Modules/Themes/CyberTheme.xaml delete mode 100644 Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Modules/Themes/ThemeHelper.cs delete mode 100644 Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Modules/VirtualCanvas/Models/TestShape.cs delete mode 100644 Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/MainView.xaml.cs delete mode 100644 Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/ThemeEditorView.xaml delete mode 100644 Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/ThemeEditorView.xaml.cs delete mode 100644 Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/ToolSampleView.xaml delete mode 100644 Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/ToolSampleView.xaml.cs delete mode 100644 Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/VirtualCanvasView.xaml delete mode 100644 Demos/MinoriDemo/MinoriDemo.WPF/App.xaml delete mode 100644 Demos/MinoriDemo/MinoriDemo.WPF/App.xaml.cs delete mode 100644 Demos/MinoriDemo/MinoriDemo.WPF/MainWindow.xaml delete mode 100644 Demos/MinoriDemo/MinoriDemo.WPF/MainWindow.xaml.cs delete mode 100644 Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.csproj delete mode 100644 Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.WPF.ruleset delete mode 100644 Demos/MinoriDemo/MinoriDemo.WPF/MinoriDemo.Wpf.ruleset delete mode 100644 Demos/MinoriDemo/MinoriDemo.WPF/Views/MainView.xaml delete mode 100644 Demos/MinoriDemo/MinoriDemo.Wpf/MinoriDemo.Wpf.csproj diff --git a/CreateArtifacts.ps1 b/CreateArtifacts.ps1 index 5c84f493..57200697 100644 --- a/CreateArtifacts.ps1 +++ b/CreateArtifacts.ps1 @@ -20,7 +20,6 @@ foreach ($nupkg in $nupkgs) { cp Demos\SimpleDemo\SimpleDemo.WPF\bin\Release\net5.0-windows Artifacts\$basedir\Demos\SimpleDemo.WPF -Recurse cp Demos\SimpleDemo\SimpleDemo.RibbonWPF\bin\Release\net5.0-windows Artifacts\$basedir\Demos\SimpleDemo.RibbonWPF -Recurse cp Demos\SimpleDemo\SimpleDemo.Avalonia\bin\Release\net5.0 Artifacts\$basedir\Demos\SimpleDemo.Avalonia -Recurse -cp Demos\MinoriDemo\MinoriDemo.WPF\bin\Release\net5.0-windows Artifacts\$basedir\Demos\MinoriDemo.WPF -Recurse cp Demos\MinoriDemo\MinoriDemo.RibbonWPF\bin\Release\net5.0-windows Artifacts\$basedir\Demos\MinoriDemo.RibbonWPF -Recurse # Compress folder into 7z file diff --git a/Demos/MinoriDemo/MinoriDemo.Core/ViewModels/MainViewModel.cs b/Demos/MinoriDemo/MinoriDemo.Core/ViewModels/MainViewModel.cs index 757e5ac9..f2a2c91e 100644 --- a/Demos/MinoriDemo/MinoriDemo.Core/ViewModels/MainViewModel.cs +++ b/Demos/MinoriDemo/MinoriDemo.Core/ViewModels/MainViewModel.cs @@ -1,8 +1,6 @@ -using Microsoft.Extensions.Logging; using MinoriEditorShell.Services; using MvvmCross; using MvvmCross.Commands; -using MvvmCross.Logging; using MvvmCross.Navigation; using MvvmCross.ViewModels; using System; diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/App.xaml.cs b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/App.xaml.cs similarity index 100% rename from Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/App.xaml.cs rename to Demos/MinoriDemo/MinoriDemo.RibbonWPF/App.xaml.cs diff --git a/Demos/MinoriDemo/MinoriDemo.Wpf/Setup.cs b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/Setup.cs similarity index 93% rename from Demos/MinoriDemo/MinoriDemo.Wpf/Setup.cs rename to Demos/MinoriDemo/MinoriDemo.RibbonWPF/Setup.cs index c013254e..5ef6c2ca 100644 --- a/Demos/MinoriDemo/MinoriDemo.Wpf/Setup.cs +++ b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/Setup.cs @@ -1,7 +1,7 @@ using Microsoft.Extensions.Logging; using MinoriEditorShell.Platforms.Wpf; -namespace MinoriDemo.WpfCore +namespace MinoriDemo.RibbonWPF { internal class Setup : MesWpfSetup { diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/MainView.xaml b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/Views/MainView.xaml similarity index 100% rename from Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/MainView.xaml rename to Demos/MinoriDemo/MinoriDemo.RibbonWPF/Views/MainView.xaml diff --git a/Demos/MinoriDemo/MinoriDemo.WPF/Views/MainView.xaml.cs b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/Views/MainView.xaml.cs similarity index 89% rename from Demos/MinoriDemo/MinoriDemo.WPF/Views/MainView.xaml.cs rename to Demos/MinoriDemo/MinoriDemo.RibbonWPF/Views/MainView.xaml.cs index 7373b133..1d7f6494 100644 --- a/Demos/MinoriDemo/MinoriDemo.WPF/Views/MainView.xaml.cs +++ b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/Views/MainView.xaml.cs @@ -1,7 +1,7 @@ using MvvmCross.Platforms.Wpf.Presenters.Attributes; using MvvmCross.Platforms.Wpf.Views; -namespace MinoriDemo.WpfCore.Views +namespace MinoriDemo.RibbonWPF.Views { /// /// Interaction logic for MainView.xaml diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/VirtualCanvasView.xaml.cs b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/Views/VirtualCanvasView.xaml.cs similarity index 86% rename from Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/VirtualCanvasView.xaml.cs rename to Demos/MinoriDemo/MinoriDemo.RibbonWPF/Views/VirtualCanvasView.xaml.cs index f552118f..596c27a7 100644 --- a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/VirtualCanvasView.xaml.cs +++ b/Demos/MinoriDemo/MinoriDemo.RibbonWPF/Views/VirtualCanvasView.xaml.cs @@ -1,10 +1,12 @@ using MinoriEditorShell.VirtualCanvas.Services; +using MvvmCross.Platforms.Wpf.Presenters.Attributes; namespace MinoriDemo.RibbonWPF.Views { /// /// Interaction logic for VirtualCanvasView.xaml /// + [MvxContentPresentation] public partial class VirtualCanvasView { public VirtualCanvasView() diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/App.xaml b/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/App.xaml deleted file mode 100644 index 5a0cae05..00000000 --- a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/App.xaml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/DataClasses/ThemeItem.cs b/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/DataClasses/ThemeItem.cs deleted file mode 100644 index d33218d2..00000000 --- a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/DataClasses/ThemeItem.cs +++ /dev/null @@ -1,63 +0,0 @@ -using MinoriDemo.RibbonWPF.Modules.Themes; -using MvvmCross; -using MvvmCross.Base; -using MvvmCross.ViewModels; -using System; -using System.Collections.Generic; -using System.Windows.Media; - -namespace MinoriDemo.RibbonWPF.DataClasses -{ - internal class ThemeItem : MvxNotifyPropertyChanged - { - private Color _color; - private String _key; - private Boolean _canEdit = false; - private String _modeText = "Edit"; - - public ThemeHelper ThemeHelper { get; set; } - - public String ModeText - { - get => _modeText; - set => SetProperty(ref _modeText, value); - } - - public Boolean CanEdit - { - get => _canEdit; - set - { - if (SetProperty(ref _canEdit, value)) - { - ModeText = value ? "Done" : "Edit"; - } - } - } - - public String Key - { - get => _key; - set => SetProperty(ref _key, value); - } - - public Color Color - { - get => _color; - set - { - _color = value; - - Mvx.IoCProvider.Resolve() - .ExecuteOnMainThreadAsync(() => - { - IDictionary brushes = ThemeHelper.GetBrushes(); - brushes[Key] = new SolidColorBrush(value); - ThemeHelper.SetBrushes(brushes); - }); - } - } - - public String OriginalKey { get; internal set; } - } -} \ No newline at end of file diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/MainWindow.xaml b/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/MainWindow.xaml deleted file mode 100644 index c28a2f14..00000000 --- a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/MainWindow.xaml +++ /dev/null @@ -1,12 +0,0 @@ - - - - \ No newline at end of file diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/MainWindow.xaml.cs b/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/MainWindow.xaml.cs deleted file mode 100644 index bcf91ef8..00000000 --- a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/MainWindow.xaml.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace MinoriDemo.RibbonWPF -{ - /// - /// Interaction logic for MainWindow.xaml - /// - public partial class MainWindow - { - public MainWindow() => InitializeComponent(); - } -} \ No newline at end of file diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Modules/Themes/CyberTheme.cs b/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Modules/Themes/CyberTheme.cs deleted file mode 100644 index 0487bd58..00000000 --- a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Modules/Themes/CyberTheme.cs +++ /dev/null @@ -1,18 +0,0 @@ -using MinoriEditorShell.Platforms.Wpf.Themes; -using System; - -namespace MinoriDemo.RibbonWPF.Modules.Themes -{ - internal class CyberTheme : MesThemeBase - { - /// - /// When doing this in your own project, try to localize if if necessary - /// - public override String Name => "CyberTheme"; - - public CyberTheme() : base() - { - Add(new Uri("pack://application:,,,/MinoriDemo.RibbonWPF;component/Modules/Themes/CyberTheme.xaml")); - } - } -} \ No newline at end of file diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Modules/Themes/CyberTheme.xaml b/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Modules/Themes/CyberTheme.xaml deleted file mode 100644 index 35673fc6..00000000 --- a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Modules/Themes/CyberTheme.xaml +++ /dev/null @@ -1,455 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Modules/Themes/ThemeHelper.cs b/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Modules/Themes/ThemeHelper.cs deleted file mode 100644 index 9a178e58..00000000 --- a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Modules/Themes/ThemeHelper.cs +++ /dev/null @@ -1,105 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows; -using System.Windows.Media; - -namespace MinoriDemo.RibbonWPF.Modules.Themes -{ - public class ThemeHelper - { - public ResourceDictionary GetAppDictionary() => Application.Current.Resources.MergedDictionaries[0]; - - public ResourceDictionary CurrentThemeDictionary { get; set; } - - /// - /// Gets all of the brushes in a dictionary format - /// - /// - public IDictionary GetBrushes() - { - SortedDictionary results = new SortedDictionary(); - - // Get theme dict - ResourceDictionary theme = CurrentThemeDictionary; - - // if theme is not selected yet, don't process - if (theme != null) - { - foreach (Object item in theme.Keys) - { - // Construct solid color brush - String newItem = item.ToString(); - Object current = theme[newItem]; - if (current is SolidColorBrush brush) - { - results[newItem] = brush; - } - } - } - return results; - } - - /// - /// Convert dictionary to resources - /// - /// - public void SetBrushes(IDictionary brushes) - { - ResourceDictionary appDict = GetAppDictionary(); - ResourceDictionary themeDict = CurrentThemeDictionary; - - // Reset visuals - // Setup app style - appDict.BeginInit(); - themeDict.Clear(); - - // Object type not known at this point - foreach (String key in brushes.Keys) - { - themeDict[key] = brushes[key]; - } - - appDict.EndInit(); - } - - public String ExportString() - { - ResourceDictionary theme = CurrentThemeDictionary; - if (theme == null) - { - throw new InvalidOperationException("CurrentThemeDictionary"); - } - - StringBuilder export = new StringBuilder(); - export.AppendLine(""); - - // Export dictionary - export.AppendLine(" "); - foreach (ResourceDictionary dictionary in theme.MergedDictionaries) - { - export.AppendLine($" "); - } - export.AppendLine(" "); - - // Export colors - export.AppendLine(" "); - IDictionary brushes = GetBrushes(); - foreach (String key in brushes.Keys) - { - export.AppendLine($" "); - } - export.AppendLine(" "); - - // End - export.AppendLine(""); - return export.ToString(); - } - } -} \ No newline at end of file diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Modules/VirtualCanvas/Models/TestShape.cs b/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Modules/VirtualCanvas/Models/TestShape.cs deleted file mode 100644 index 8970933a..00000000 --- a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Modules/VirtualCanvas/Models/TestShape.cs +++ /dev/null @@ -1,249 +0,0 @@ -using MinoriDemo.Core.Modules.VirtualCanvas.Models; -using MinoriEditorShell.VirtualCanvas.Services; -using System; -using System.Globalization; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Media; -using System.Windows.Shapes; -using RectangleF = System.Drawing.RectangleF; - -namespace MinoriDemo.RibbonWPF.Modules.VirtualCanvas.Models -{ - public class TestShape : ITestShape - { - private IMesVirtualCanvasControl _parent; - private Typeface _typeface; - private Double _fontSize; - private System.Drawing.Color baseColor; - private RectangleF _bounds; - private TestShapeType _shape; - private Point[] _points; - private LinearGradientBrush _fill; - private LinearGradientBrush _stroke; - - public event EventHandler BoundsChanged; - - public String Label { get; set; } - - public System.Drawing.Color BaseColor - { - get => baseColor; - set - { - baseColor = value; - - // use hls color for shading - HlsColor hls = new HlsColor(baseColor); - System.Drawing.Color c1 = hls.Darker(0.25f); - System.Drawing.Color c2 = hls.Lighter(0.25f); - - // Create fill and stroke when color is created. - // this is created here becuse of wpf depencency - _fill = new LinearGradientBrush( - Color.FromArgb(0x80, c1.R, c1.G, c1.B), - Color.FromArgb(0x80, baseColor.R, baseColor.G, baseColor.B), 45); - _stroke = new LinearGradientBrush( - Color.FromArgb(0x80, baseColor.R, baseColor.G, baseColor.B), - Color.FromArgb(0x80, c2.R, c2.G, c2.B), 45); - } - } - - public void Initialize(RectangleF bounds, TestShapeType shape, Random r) - { - _bounds = bounds; - _shape = shape; - if (_shape == TestShapeType.Curve) - { - _bounds.Width *= 2; - _bounds.Height *= 2; - BoundsChanged?.Invoke(this, null); - - _points = new Point[3]; - - bounds = new RectangleF(0, 0, _bounds.Width, _bounds.Height); - switch (r.Next(0, 8)) - { - case 0: - _points[0] = new Point(bounds.Left, bounds.Top); - _points[1] = new Point(bounds.Right, bounds.Top); - _points[2] = new Point(bounds.Right, bounds.Bottom); - break; - - case 1: - _points[0] = new Point(bounds.Right, bounds.Top); - _points[1] = new Point(bounds.Right, bounds.Bottom); - _points[2] = new Point(bounds.Left, bounds.Right); - break; - - case 2: - _points[0] = new Point(bounds.Right, bounds.Bottom); - _points[1] = new Point(bounds.Left, bounds.Bottom); - _points[2] = new Point(bounds.Left, bounds.Top); - break; - - case 3: - _points[0] = new Point(bounds.Left, bounds.Bottom); - _points[1] = new Point(bounds.Left, bounds.Top); - _points[2] = new Point(bounds.Right, bounds.Top); - break; - - case 4: - _points[0] = new Point(bounds.Left, bounds.Top); - _points[1] = new Point(bounds.Right, bounds.Height / 2); - _points[2] = new Point(bounds.Left, bounds.Bottom); - break; - - case 5: - _points[0] = new Point(bounds.Right, bounds.Top); - _points[1] = new Point(bounds.Left, bounds.Height / 2); - _points[2] = new Point(bounds.Right, bounds.Bottom); - break; - - case 6: - _points[0] = new Point(bounds.Left, bounds.Top); - _points[1] = new Point(bounds.Width / 2, bounds.Bottom); - _points[2] = new Point(bounds.Right, bounds.Top); - break; - - case 7: - _points[0] = new Point(bounds.Left, bounds.Bottom); - _points[1] = new Point(bounds.Width / 2, bounds.Top); - _points[2] = new Point(bounds.Right, bounds.Bottom); - break; - } - } - } - - public Object Visual { get; private set; } - - public Object CreateVisual(IMesVirtualCanvasControl parent) - { - if (Visual == null) - { - switch (_shape) - { - case TestShapeType.Curve: - { - PathGeometry g = new PathGeometry(); - PathFigure f = new PathFigure - { - StartPoint = _points[0] - }; - g.Figures.Add(f); - for (Int32 i = 0, n = _points.Length; i < n; i += 3) - { - BezierSegment s = new BezierSegment(_points[i], _points[i + 1], _points[i + 2], true); - f.Segments.Add(s); - } - Path p = new Path - { - Data = g, - - Stroke = _stroke, - StrokeThickness = 2 - }; - - //DropShadowBitmapEffect effect = new DropShadowBitmapEffect(); - //effect.Opacity = 0.8; - //effect.ShadowDepth = 3; - //effect.Direction = 270; - //c.BitmapEffect = effect; - Visual = p; - break; - } - case TestShapeType.Ellipse: - { - Canvas c = new Canvas(); - - Ellipse e = new Ellipse(); - c.Width = e.Width = _bounds.Width; - c.Height = e.Height = _bounds.Height; - c.Children.Add(e); - - Size s = MeasureText(parent, Label); - Double x = (_bounds.Width - s.Width) / 2; - Double y = (_bounds.Height - s.Height) / 2; - - TextBlock text = new TextBlock - { - Text = Label - }; - Canvas.SetLeft(text, x); - Canvas.SetTop(text, y); - c.Children.Add(text); - - e.StrokeThickness = 2; - e.Stroke = _stroke; - e.Fill = _fill; - - //DropShadowBitmapEffect effect = new DropShadowBitmapEffect(); - //effect.Opacity = 0.8; - //effect.ShadowDepth = 3; - //effect.Direction = 270; - //c.BitmapEffect = effect; - Visual = c; - break; - } - case TestShapeType.Rectangle: - { - Border b = new Border - { - CornerRadius = new CornerRadius(3), - Width = _bounds.Width, - Height = _bounds.Height - }; - TextBlock text = new TextBlock - { - Text = Label, - VerticalAlignment = VerticalAlignment.Center, - HorizontalAlignment = HorizontalAlignment.Center - }; - - // Testing for BoundsChanged event. - b.MouseRightButtonDown += (s, e) => - { - _bounds = new RectangleF( - Bounds.X + 10, - Bounds.Y + 10, - (Single)b.Width, - (Single)b.Height); - BoundsChanged?.Invoke(this, null); - }; - b.Child = text; - b.Background = _fill; - //DropShadowBitmapEffect effect = new DropShadowBitmapEffect(); - //effect.Opacity = 0.8; - //effect.ShadowDepth = 3; - //effect.Direction = 270; - //b.BitmapEffect = effect; - Visual = b; - break; - } - } - } - return Visual; - } - - public void DisposeVisual() => Visual = null; - - public RectangleF Bounds => _bounds; - - public Size MeasureText(IMesVirtualCanvasControl parent, String label) - { - if (_parent != parent && parent is MinoriEditorShell.VirtualCanvas.Platforms.Wpf.Controls.MesVirtualCanvas control) - { - FontFamily fontFamily = (FontFamily)control.GetValue(TextBlock.FontFamilyProperty); - FontStyle fontStyle = (FontStyle)control.GetValue(TextBlock.FontStyleProperty); - FontWeight fontWeight = (FontWeight)control.GetValue(TextBlock.FontWeightProperty); - FontStretch fontStretch = (FontStretch)control.GetValue(TextBlock.FontStretchProperty); - _fontSize = (Double)control.GetValue(TextBlock.FontSizeProperty); - _typeface = new Typeface(fontFamily, fontStyle, fontWeight, fontStretch); - _parent = parent; - } - FormattedText ft = new FormattedText(label, CultureInfo.CurrentUICulture, - FlowDirection.LeftToRight, _typeface, _fontSize, Brushes.Black); - return new Size(ft.Width, ft.Height); - } - } -} \ No newline at end of file diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/MainView.xaml.cs b/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/MainView.xaml.cs deleted file mode 100644 index 89fa03fd..00000000 --- a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/MainView.xaml.cs +++ /dev/null @@ -1,12 +0,0 @@ -using MvvmCross.Platforms.Wpf.Views; - -namespace MinoriDemo.RibbonWPF.Views -{ - /// - /// Interaction logic for MainView.xaml - /// - public partial class MainView : MvxWpfView - { - public MainView() => InitializeComponent(); - } -} \ No newline at end of file diff --git a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/ThemeEditorView.xaml b/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/ThemeEditorView.xaml deleted file mode 100644 index c73ea261..00000000 --- a/Demos/MinoriDemo/MinoriDemo.RibbonWpfCore/Views/ThemeEditorView.xaml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesSettingsView.xaml.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesSettingsView.xaml.cs deleted file mode 100644 index 77bdac96..00000000 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesSettingsView.xaml.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Windows; - -namespace MinoriEditorShell.Platforms.Avalonia.Views -{ - /// - /// Interaction logic for SettingsView.xaml - /// - public partial class MesSettingsView - { - public MesSettingsView() - { - // InitializeComponent(); - // Owner = Application.Current.MainWindow; - - // Closing += (s, e) => Owner.Focus(); - } - } -} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/Views/MesMainWindowView.xaml b/Modules/MinoriEditorShell.Platforms.Wpf/Views/MesMainWindowView.xaml deleted file mode 100644 index bcc29134..00000000 --- a/Modules/MinoriEditorShell.Platforms.Wpf/Views/MesMainWindowView.xaml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/Views/MesMainWindowView.xaml.cs b/Modules/MinoriEditorShell.Platforms.Wpf/Views/MesMainWindowView.xaml.cs deleted file mode 100644 index 87db1da0..00000000 --- a/Modules/MinoriEditorShell.Platforms.Wpf/Views/MesMainWindowView.xaml.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace MinoriEditorShell.Platforms.Wpf.Views -{ - public partial class MesMainWindowView - { - public MesMainWindowView() - { - InitializeComponent(); - } - } -} \ No newline at end of file From 302a67c2e8df68f958e2ba52f2edddcb747df4cc Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Mon, 23 Aug 2021 22:15:37 -0400 Subject: [PATCH 58/68] remove un-used classes --- .../ShaderEffects/MesGrayscaleEffect.cs | 21 ------------ .../ShaderEffects/MesGrayscaleEffect.ps | Bin 236 -> 0 bytes .../ShaderEffects/MesShaderEffectBase.cs | 18 ---------- .../ShaderEffects/MesShaderEffectUtility.cs | 13 ------- .../ShaderEffects/MesGrayscaleEffect.cs | 21 ------------ .../ShaderEffects/MesGrayscaleEffect.ps | Bin 236 -> 0 bytes .../ShaderEffects/MesShaderEffectBase.cs | 18 ---------- .../ShaderEffects/MesShaderEffectUtility.cs | 13 ------- .../ViewModels/MesStatusBarItemViewModel.cs | 32 ------------------ .../Threading/MesTaskUtility.cs | 9 ----- 10 files changed, 145 deletions(-) delete mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesGrayscaleEffect.cs delete mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesGrayscaleEffect.ps delete mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesShaderEffectBase.cs delete mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesShaderEffectUtility.cs delete mode 100644 Modules/MinoriEditorShell.Platforms.Wpf/ShaderEffects/MesGrayscaleEffect.cs delete mode 100644 Modules/MinoriEditorShell.Platforms.Wpf/ShaderEffects/MesGrayscaleEffect.ps delete mode 100644 Modules/MinoriEditorShell.Platforms.Wpf/ShaderEffects/MesShaderEffectBase.cs delete mode 100644 Modules/MinoriEditorShell.Platforms.Wpf/ShaderEffects/MesShaderEffectUtility.cs delete mode 100644 Modules/MinoriEditorShell.Platforms.Wpf/ViewModels/MesStatusBarItemViewModel.cs delete mode 100644 Modules/MinoriEditorShell/Threading/MesTaskUtility.cs diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesGrayscaleEffect.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesGrayscaleEffect.cs deleted file mode 100644 index 53195811..00000000 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesGrayscaleEffect.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Windows; -// using System.Windows.Media; - -namespace MinoriEditorShell.Platforms.Avalonia.ShaderEffects -{ - // public class MesGrayscaleEffect : MesShaderEffectBase - // { - // // public static readonly DependencyProperty InputProperty = RegisterPixelShaderSamplerProperty("Input", typeof(MesGrayscaleEffect), 0); - - // // public Brush Input - // // { - // // get => (Brush)GetValue(InputProperty); - // // set => SetValue(InputProperty, value); - // // } - - // // public MesGrayscaleEffect() - // // { - // // UpdateShaderValue(InputProperty); - // // } - // } -} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesGrayscaleEffect.ps b/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesGrayscaleEffect.ps deleted file mode 100644 index 52ccfa0670cee1cb7715bc88b2e42ad815e14958..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 236 zcmZQz`v3pme?f)ryz4AQR<*E&@^wKo@L)vL`Tb@Go!z lJBc4C{$v9K$CCvdU_LvDzW|6EfbL-essr&G{{LrS003NHFoysD diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesShaderEffectBase.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesShaderEffectBase.cs deleted file mode 100644 index 28de2b2d..00000000 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesShaderEffectBase.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -// using System.Windows.Media.Effects; - -namespace MinoriEditorShell.Platforms.Avalonia.ShaderEffects -{ - // public class MesShaderEffectBase : ShaderEffect, IDisposable - // where T : MesShaderEffectBase - // { - // [ThreadStatic] - // private static PixelShader _shader; - - // private static PixelShader Shader => _shader ?? (_shader = MesShaderEffectUtility.GetPixelShader(typeof(T).Name)); - - // protected MesShaderEffectBase() => PixelShader = Shader; - - // void IDisposable.Dispose() => PixelShader = null; - // } -} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesShaderEffectUtility.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesShaderEffectUtility.cs deleted file mode 100644 index 00dbf00f..00000000 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/ShaderEffects/MesShaderEffectUtility.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -// using System.Windows.Media.Effects; - -namespace MinoriEditorShell.Platforms.Avalonia.ShaderEffects -{ - internal static class MesShaderEffectUtility - { - // public static PixelShader GetPixelShader(string name) => new PixelShader - // { - // UriSource = new Uri($@"pack://application:,,,/MinoriEditorStudio;component/Framework/ShaderEffects/{name}.ps") - // }; - } -} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/ShaderEffects/MesGrayscaleEffect.cs b/Modules/MinoriEditorShell.Platforms.Wpf/ShaderEffects/MesGrayscaleEffect.cs deleted file mode 100644 index e156bde1..00000000 --- a/Modules/MinoriEditorShell.Platforms.Wpf/ShaderEffects/MesGrayscaleEffect.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Windows; -using System.Windows.Media; - -namespace MinoriEditorShell.Platforms.Wpf.ShaderEffects -{ - public class MesGrayscaleEffect : MesShaderEffectBase - { - public static readonly DependencyProperty InputProperty = RegisterPixelShaderSamplerProperty("Input", typeof(MesGrayscaleEffect), 0); - - public Brush Input - { - get => (Brush)GetValue(InputProperty); - set => SetValue(InputProperty, value); - } - - public MesGrayscaleEffect() - { - UpdateShaderValue(InputProperty); - } - } -} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/ShaderEffects/MesGrayscaleEffect.ps b/Modules/MinoriEditorShell.Platforms.Wpf/ShaderEffects/MesGrayscaleEffect.ps deleted file mode 100644 index 52ccfa0670cee1cb7715bc88b2e42ad815e14958..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 236 zcmZQz`v3pme?f)ryz4AQR<*E&@^wKo@L)vL`Tb@Go!z lJBc4C{$v9K$CCvdU_LvDzW|6EfbL-essr&G{{LrS003NHFoysD diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/ShaderEffects/MesShaderEffectBase.cs b/Modules/MinoriEditorShell.Platforms.Wpf/ShaderEffects/MesShaderEffectBase.cs deleted file mode 100644 index 6cc89a6b..00000000 --- a/Modules/MinoriEditorShell.Platforms.Wpf/ShaderEffects/MesShaderEffectBase.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Windows.Media.Effects; - -namespace MinoriEditorShell.Platforms.Wpf.ShaderEffects -{ - public class MesShaderEffectBase : ShaderEffect, IDisposable - where T : MesShaderEffectBase - { - [ThreadStatic] - private static PixelShader _shader; - - private static PixelShader Shader => _shader ?? (_shader = MesShaderEffectUtility.GetPixelShader(typeof(T).Name)); - - protected MesShaderEffectBase() => PixelShader = Shader; - - void IDisposable.Dispose() => PixelShader = null; - } -} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/ShaderEffects/MesShaderEffectUtility.cs b/Modules/MinoriEditorShell.Platforms.Wpf/ShaderEffects/MesShaderEffectUtility.cs deleted file mode 100644 index d0645520..00000000 --- a/Modules/MinoriEditorShell.Platforms.Wpf/ShaderEffects/MesShaderEffectUtility.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Windows.Media.Effects; - -namespace MinoriEditorShell.Platforms.Wpf.ShaderEffects -{ - internal static class MesShaderEffectUtility - { - public static PixelShader GetPixelShader(string name) => new PixelShader - { - UriSource = new Uri($@"pack://application:,,,/MinoriEditorStudio;component/Framework/ShaderEffects/{name}.ps") - }; - } -} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/ViewModels/MesStatusBarItemViewModel.cs b/Modules/MinoriEditorShell.Platforms.Wpf/ViewModels/MesStatusBarItemViewModel.cs deleted file mode 100644 index ba907681..00000000 --- a/Modules/MinoriEditorShell.Platforms.Wpf/ViewModels/MesStatusBarItemViewModel.cs +++ /dev/null @@ -1,32 +0,0 @@ -using MvvmCross.ViewModels; -using System; -using System.Windows; - -namespace MinoriEditorShell.Platforms.Wpf.ViewModels -{ - public class MesStatusBarItemViewModel : MvxNotifyPropertyChanged - { - private Int32 _index; - private String _message; - - public Int32 Index - { - get => _index; - internal set => SetProperty(ref _index, value); - } - - public String Message - { - get => _message; - set => SetProperty(ref _message, value); - } - - public GridLength Width { get; } - - public MesStatusBarItemViewModel(String message, GridLength width) - { - _message = message; - Width = width; - } - } -} \ No newline at end of file diff --git a/Modules/MinoriEditorShell/Threading/MesTaskUtility.cs b/Modules/MinoriEditorShell/Threading/MesTaskUtility.cs deleted file mode 100644 index 6b1d4aa7..00000000 --- a/Modules/MinoriEditorShell/Threading/MesTaskUtility.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Threading.Tasks; - -namespace MinoriEditorShell.Threading -{ - public class MesTaskUtility - { - public static readonly Task Completed = Task.FromResult(true); - } -} \ No newline at end of file From 4443b812beaaa102a864b2fd21dce52d8992b8d3 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Mon, 23 Aug 2021 22:16:12 -0400 Subject: [PATCH 59/68] update statusbar some --- .../SimpleDemo.Avalonia/Views/MainView.axaml | 2 +- .../Views/MesStatusBarView.axaml | 113 ++++++++---------- .../Views/MesStatusBarView.axaml.cs | 16 +-- .../Services/IMesStatusBar.cs | 54 +++++++++ 4 files changed, 116 insertions(+), 69 deletions(-) diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/Views/MainView.axaml b/Demos/SimpleDemo/SimpleDemo.Avalonia/Views/MainView.axaml index 651317b0..a97b38e3 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/Views/MainView.axaml +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/Views/MainView.axaml @@ -12,7 +12,7 @@ - + \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesStatusBarView.axaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesStatusBarView.axaml index ddd25482..2eb8c357 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesStatusBarView.axaml +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesStatusBarView.axaml @@ -4,7 +4,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:converter="using:MinoriEditorShell.Platforms.Avalonia.Converters" - mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" + mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="25" x:Class="MinoriEditorShell.Platforms.Avalonia.Views.MesStatusBarView"> @@ -15,90 +15,83 @@ - + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + - + + + + + - - - - - + + + + + + + + - - - - - + + + + + + + + - - - - - + + + + + + + + - - - - + + + + - + \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.axaml.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.axaml.cs index 340e0e02..9cd32b11 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.axaml.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.axaml.cs @@ -1,7 +1,10 @@ using Avalonia; using Avalonia.Controls; +using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Markup.Xaml; +using Dock.Model.Core; using MinoriEditorShell.Services; +using MvvmCross; using System; using System.Collections.Generic; using System.IO; @@ -14,37 +17,37 @@ public MesDocumentManagerView() { InitializeComponent(); - // try - // { - // IMesDocumentManager manager = Mvx.IoCProvider.Resolve(); - // manager.ManagerView = this; - // DataContext = manager; - // } - // catch { } + try + { + IMesDocumentManager manager = Mvx.IoCProvider.Resolve(); + manager.UpdateFloatingWindows += Manager_UpdateFloatingWindows; + DataContext = manager; + } + catch { } } public void LoadLayout(Stream stream, Action addToolCallback, Action addDocumentCallback, Dictionary itemsState) { - //MesLayoutUtility.LoadLayout(Manager, stream, addDocumentCallback, addToolCallback, itemsState); + IDockControl Manager = this.Get("Manager"); + MesLayoutUtility.LoadLayout(Manager, stream, addDocumentCallback, addToolCallback, itemsState); } // private void OnManagerLayoutUpdated(Object sender, EventArgs e) => UpdateFloatingWindows(); public void SaveLayout(Stream stream) => throw new NotImplementedException(); - public void UpdateFloatingWindows() + private void Manager_UpdateFloatingWindows(Object sender, EventArgs e) { - // Window mainWindow = Window.GetWindow(this); - // if (mainWindow != null) - // { - // ImageSource mainWindowIcon = mainWindow.Icon; - // Boolean showFloatingWindowsInTaskbar = ((MesDocumentManagerViewModel)DataContext).ShowFloatingWindowsInTaskbar; - // foreach (LayoutFloatingWindowControl window in Manager?.FloatingWindows) - // { - // window.Icon = mainWindowIcon; - // window.ShowInTaskbar = showFloatingWindowsInTaskbar; - // } - // } + //if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + //{ + // WindowIcon mainWindowIcon = desktop.MainWindow.Icon; + // Boolean showFloatingWindowsInTaskbar = ((MesDocumentManagerViewModel)DataContext).ShowFloatingWindowsInTaskbar; + // foreach (LayoutFloatingWindowControl window in Manager?.FloatingWindows) + // { + // window.Icon = mainWindowIcon; + // window.ShowInTaskbar = showFloatingWindowsInTaskbar; + // } + //} } private void InitializeComponent() diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/Views/MesDocumentManagerView.xaml.cs b/Modules/MinoriEditorShell.Platforms.Wpf/Views/MesDocumentManagerView.xaml.cs index ae953c68..06a5b90f 100644 --- a/Modules/MinoriEditorShell.Platforms.Wpf/Views/MesDocumentManagerView.xaml.cs +++ b/Modules/MinoriEditorShell.Platforms.Wpf/Views/MesDocumentManagerView.xaml.cs @@ -19,7 +19,7 @@ public MesDocumentManagerView() try { IMesDocumentManager manager = Mvx.IoCProvider.Resolve(); - manager.ManagerView = this; + manager.UpdateFloatingWindows += UpdateFloatingWindows; DataContext = manager; } catch { } @@ -34,9 +34,9 @@ public void LoadLayout( public void SaveLayout(Stream stream) => MesLayoutUtility.SaveLayout(Manager, stream); - private void OnManagerLayoutUpdated(Object sender, EventArgs e) => UpdateFloatingWindows(); + private void OnManagerLayoutUpdated(Object sender, EventArgs e) => UpdateFloatingWindows(sender, e); - public void UpdateFloatingWindows() + private void UpdateFloatingWindows(Object sender, EventArgs e) { Window mainWindow = Window.GetWindow(this); if (mainWindow != null) diff --git a/Modules/MinoriEditorShell/Services/IMesDocumentManager.cs b/Modules/MinoriEditorShell/Services/IMesDocumentManager.cs index 2cec332e..3284154e 100644 --- a/Modules/MinoriEditorShell/Services/IMesDocumentManager.cs +++ b/Modules/MinoriEditorShell/Services/IMesDocumentManager.cs @@ -9,9 +9,9 @@ public interface IMesDocumentManager event EventHandler ActiveDocumentChanged; - Boolean ShowFloatingWindowsInTaskbar { get; set; } + event EventHandler UpdateFloatingWindows; - IMesDocumentManagerView ManagerView { get; set; } + Boolean ShowFloatingWindowsInTaskbar { get; set; } IMesLayoutItem ActiveItem { get; set; } diff --git a/Modules/MinoriEditorShell/Services/IMesDocumentManagerView.cs b/Modules/MinoriEditorShell/Services/IMesDocumentManagerView.cs index 896883dd..e7ef5c2d 100644 --- a/Modules/MinoriEditorShell/Services/IMesDocumentManagerView.cs +++ b/Modules/MinoriEditorShell/Services/IMesDocumentManagerView.cs @@ -12,7 +12,5 @@ void LoadLayout( Dictionary itemsState); void SaveLayout(Stream stream); - - void UpdateFloatingWindows(); } } \ No newline at end of file diff --git a/Modules/MinoriEditorShell/ViewModels/MesDocumentManagerViewModel.cs b/Modules/MinoriEditorShell/ViewModels/MesDocumentManagerViewModel.cs index cd535d10..5055a1da 100644 --- a/Modules/MinoriEditorShell/ViewModels/MesDocumentManagerViewModel.cs +++ b/Modules/MinoriEditorShell/ViewModels/MesDocumentManagerViewModel.cs @@ -12,7 +12,8 @@ public class MesDocumentManagerViewModel : MvxViewModel, IMesDocumentManager public event EventHandler ActiveDocumentChanged; - public IMesDocumentManagerView ManagerView { get; set; } + public event EventHandler UpdateFloatingWindows; + private readonly Boolean _closing; private IMesLayoutItem _activeItem; @@ -42,10 +43,7 @@ public Boolean ShowFloatingWindowsInTaskbar { _showFloatingWindowsInTaskbar = value; RaisePropertyChanged(() => ShowFloatingWindowsInTaskbar); - if (ManagerView != null) - { - ManagerView.UpdateFloatingWindows(); - } + UpdateFloatingWindows?.Invoke(this, EventArgs.Empty); } } From 9976d333642636aadc0e3e90f4ccde66d615ce0a Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Mon, 6 Sep 2021 20:05:00 -0400 Subject: [PATCH 61/68] combine factory into vm --- .../Controls/MesDockDock.cs | 24 + .../Controls/MesDocumentDock.cs | 31 + .../Controls/MesProportionalDock.cs | 27 + .../Controls/MesRootDock.cs | 73 + .../Controls/MesSplitterDockable.cs | 9 + .../Controls/MesToolDock.cs | 58 + .../Core/MesAvnSetup.cs | 11 +- .../Core/MesDockBase.cs | 196 +++ .../Core/MesDockWindow.cs | 189 +++ .../Core/MesDockableBase.cs | 284 ++++ ...inoriEditorShell.Platforms.Avalonia.csproj | 1 + .../ViewModels/IDropTarget.cs | 11 + .../ViewModels/MesDocumentManagerViewModel.cs | 1237 +++++++++++++++++ .../ViewModels/MesDocumentView.cs | 12 + .../ViewModels/MesToolView.cs | 15 + .../Views/MesDocumentManagerView.axaml | 2 +- .../Views/MesDocumentManagerView.axaml.cs | 26 +- .../ViewModels/MesDocumentManagerViewModel.cs | 2 +- .../Views/MesDocumentManagerView.xaml.cs | 6 +- .../Services/IMesDocumentManager.cs | 13 +- 20 files changed, 2213 insertions(+), 14 deletions(-) create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesDockDock.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesDocumentDock.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesProportionalDock.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesRootDock.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesSplitterDockable.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesToolDock.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesDockBase.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesDockWindow.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesDockableBase.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/IDropTarget.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesDocumentManagerViewModel.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesDocumentView.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesToolView.cs rename Modules/{MinoriEditorShell => MinoriEditorShell.Platforms.Wpf}/ViewModels/MesDocumentManagerViewModel.cs (99%) diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesDockDock.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesDockDock.cs new file mode 100644 index 00000000..51fbad88 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesDockDock.cs @@ -0,0 +1,24 @@ +using Dock.Model.Controls; +using MinoriEditorShell.Platforms.Avalonia.Core; +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; + +namespace MinoriEditorShell.Platforms.Avalonia.Controls +{ + internal class MesDockDock : MesDockBase, IDockDock + { + private Boolean _lastChildFill = true; + + /// + /// if last child + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public Boolean LastChildFill + { + get => _lastChildFill; + set => SetProperty(ref _lastChildFill, value); + } + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesDocumentDock.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesDocumentDock.cs new file mode 100644 index 00000000..432ea4fd --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesDocumentDock.cs @@ -0,0 +1,31 @@ +using Dock.Model.Controls; +using MinoriEditorShell.Platforms.Avalonia.Core; +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using System.Windows.Input; + +namespace MinoriEditorShell.Platforms.Avalonia.Controls +{ + internal class MesDocumentDock : MesDockBase, IDocumentDock + { + private Boolean _canCreateDocument; + + /// + /// Determine if we can crate command + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public Boolean CanCreateDocument + { + get => _canCreateDocument; + set => SetProperty(ref _canCreateDocument, value); + } + + /// + /// Command to create document + /// + [IgnoreDataMember] + public ICommand CreateDocument { get; set; } + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesProportionalDock.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesProportionalDock.cs new file mode 100644 index 00000000..f8d999df --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesProportionalDock.cs @@ -0,0 +1,27 @@ +using Dock.Model.Controls; +using Dock.Model.Core; +using MinoriEditorShell.Platforms.Avalonia.Core; +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; + +namespace MinoriEditorShell.Platforms.Avalonia.Controls +{ + /// + /// Proportional dock. + /// + [DataContract(IsReference = true)] + internal class MesProportionalDock : MesDockBase, IProportionalDock + { + private Orientation _orientation; + + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public Orientation Orientation + { + get => _orientation; + set => SetProperty(ref _orientation, value); + } + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesRootDock.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesRootDock.cs new file mode 100644 index 00000000..276bf884 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesRootDock.cs @@ -0,0 +1,73 @@ +using Dock.Model.Controls; +using Dock.Model.Core; +using MinoriEditorShell.Platforms.Avalonia.Core; +using MvvmCross.Commands; +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using System.Windows.Input; + +namespace MinoriEditorShell.Platforms.Avalonia.Controls +{ + /// + /// Main root dock + /// + internal class MesRootDock : MesDockBase, IRootDock + { + private Boolean _isFocusableRoot = true; + private IDockWindow _window; + private IList _windows; + + /// + /// is root focusable + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public Boolean IsFocusableRoot + { + get => _isFocusableRoot; + set => SetProperty(ref _isFocusableRoot, value); + } + + /// + /// Dockable Window + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public IDockWindow Window + { + get => _window; + set => SetProperty(ref _window, value); + } + + /// + /// List of windows + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public IList Windows + { + get => _windows; + set => SetProperty(ref _windows, value); + } + + /// + /// Initializes new instance of the class. + /// + public MesRootDock() + { + ShowWindows = new MvxCommand(() => _navigateAdapter.ShowWindows()); + ExitWindows = new MvxCommand(() => _navigateAdapter.ExitWindows()); + } + + /// + /// Show window command + /// + [IgnoreDataMember] + public ICommand ShowWindows { get; } + + /// + /// Exit window command + /// + [IgnoreDataMember] + public ICommand ExitWindows { get; } + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesSplitterDockable.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesSplitterDockable.cs new file mode 100644 index 00000000..f2c0d921 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesSplitterDockable.cs @@ -0,0 +1,9 @@ +using Dock.Model.Controls; +using MinoriEditorShell.Platforms.Avalonia.Core; + +namespace MinoriEditorShell.Platforms.Avalonia.Controls +{ + internal class MesSplitterDockable : MesDockableBase, ISplitterDockable + { + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesToolDock.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesToolDock.cs new file mode 100644 index 00000000..f30a1f27 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesToolDock.cs @@ -0,0 +1,58 @@ +using Dock.Model.Controls; +using Dock.Model.Core; +using MinoriEditorShell.Platforms.Avalonia.Core; +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; + +namespace MinoriEditorShell.Platforms.Avalonia.Controls +{ + internal class MesToolDock : MesDockBase, IToolDock + { + private Alignment _alignment = Alignment.Unset; + private Boolean _isExpanded; + private Boolean _autoHide = true; + private GripMode _gripMode = GripMode.Visible; + + /// + /// Current Alignment + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public Alignment Alignment + { + get => _alignment; + set => SetProperty(ref _alignment, value); + } + + /// + /// Is expandable? + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public Boolean IsExpanded + { + get => _isExpanded; + set => SetProperty(ref _isExpanded, value); + } + + /// + /// Is Autohide is set? + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public Boolean AutoHide + { + get => _autoHide; + set => SetProperty(ref _autoHide, value); + } + + /// + /// Type of grip + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public GripMode GripMode + { + get => _gripMode; + set => SetProperty(ref _gripMode, value); + } + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs index 44b127bb..bd49138d 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesAvnSetup.cs @@ -28,6 +28,7 @@ using MvvmCross.Binding.Binders; using Microsoft.Extensions.Logging; using MinoriEditorShell.Platforms.Avalonia.Binding; +using MinoriEditorShell.Platforms.Avalonia.ViewModels; // Portions of this was barrowed from MvvmCross. namespace MinoriEditorShell.Platforms.Avalonia @@ -39,9 +40,11 @@ public abstract class MesAvnSetup : MvxSetup, IMvxAvnSetup { // To handle messages between classes private MvvmCross.Plugin.Messenger.IMvxMessenger _messenger; + private IMesAvnViewPresenter _presenter; private ContentControl _root; private Dispatcher _uiThreadDispatcher; + protected IMesAvnViewPresenter Presenter { get @@ -138,7 +141,7 @@ public void PlatformInitialize(Dispatcher uiThreadDispatcher, ContentControl roo /// Creates the app. /// /// An instance of MvxApplication - protected override IMvxApplication CreateApp(IMvxIoCProvider iocProvider) + protected override IMvxApplication CreateApp(IMvxIoCProvider iocProvider) { _messenger = iocProvider.Resolve(); Properties.Settings.Default.PropertyChanged += (s, e) => @@ -167,7 +170,7 @@ protected virtual MvxBindingBuilder CreateBindingBuilder() /// Used to ensure plugins are loaded. /// /// returns base manager - protected override IMvxPluginManager CreatePluginManager(IMvxIoCProvider iocProvider) + protected override IMvxPluginManager CreatePluginManager(IMvxIoCProvider iocProvider) { IMvxPluginManager manager = base.CreatePluginManager(iocProvider); manager.EnsurePluginLoaded(); @@ -197,6 +200,7 @@ protected override IMvxViewsContainer CreateViewsContainer(IMvxIoCProvider iocPr iocProvider.RegisterSingleton(toReturn); return toReturn; } + protected override IMvxNameMapping CreateViewToViewModelNaming() { return new MvxPostfixAwareViewToViewModelNameMapping("View", "Control"); @@ -248,6 +252,7 @@ protected override IDictionary InitializeLookupDictionary(IMvxIoCPro container.Add(typeof(MesGeneralSettingsViewModel), typeof(MesGeneralSettingsView)); return container; } + protected virtual void RegisterBindingBuilderCallbacks(IMvxIoCProvider iocProvider) { if (iocProvider is null) throw new ArgumentNullException(nameof(iocProvider)); @@ -274,7 +279,9 @@ protected virtual void RegisterPresenter(IMvxIoCProvider iocProvider) public abstract class MesAvnSetup : MesAvnSetup where TApplication : class, IMvxApplication, new() { public override IEnumerable GetViewModelAssemblies() => new[] { typeof(TApplication).GetTypeInfo().Assembly }; + protected override IMvxApplication CreateApp(IMvxIoCProvider iocProvider) => iocProvider.IoCConstruct(); + protected override IMvxViewsContainer CreateViewsContainer(IMvxIoCProvider iocProvider) => base.CreateViewsContainer(iocProvider); } } \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesDockBase.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesDockBase.cs new file mode 100644 index 00000000..d10a0a59 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesDockBase.cs @@ -0,0 +1,196 @@ +using Dock.Model.Adapters; +using Dock.Model.Core; +using MvvmCross.Commands; +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using System.Windows.Input; + +namespace MinoriEditorShell.Platforms.Avalonia.Core +{ + /// + /// Base of dockable interfaces + /// + public abstract class MesDockBase : MesDockableBase, IDock + { + internal readonly INavigateAdapter _navigateAdapter; + private IList _visibleDockables; + private IList _hiddenDockables; + private IList _pinnedDockables; + private IDockable _activeDockable; + private IDockable _defaultDockable; + private IDockable _focusedDockable; + private Double _proportion = Double.NaN; + private DockMode _dock = DockMode.Center; + private Boolean _isCollapsable = true; + private Boolean _isActive; + + /// + /// Initializes new instance of the class. + /// + protected MesDockBase() + { + _navigateAdapter = new NavigateAdapter(this); + GoBack = new MvxCommand(() => _navigateAdapter.GoBack()); + GoForward = new MvxCommand(() => _navigateAdapter.GoForward()); + Navigate = new MvxCommand(root => _navigateAdapter.Navigate(root, true)); + Close = new MvxCommand(() => _navigateAdapter.Close()); + } + + /// + /// List of visible docks + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public IList VisibleDockables + { + get => _visibleDockables; + set => SetProperty(ref _visibleDockables, value); + } + + /// + /// Dock items that are hidden + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public IList HiddenDockables + { + get => _hiddenDockables; + set => SetProperty(ref _hiddenDockables, value); + } + + /// + /// Docks that are pinned + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public IList PinnedDockables + { + get => _pinnedDockables; + set => SetProperty(ref _pinnedDockables, value); + } + + /// + /// Active dock + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public IDockable ActiveDockable + { + get => _activeDockable; + set + { + SetProperty(ref _activeDockable, value); + Factory?.OnActiveDockableChanged(value); + if (value is { }) + { + Factory?.UpdateDockable(value, this); + value.OnSelected(); + } + if (value is { }) + { + Factory?.SetFocusedDockable(this, value); + } + RaisePropertyChanged(nameof(CanGoBack)); + RaisePropertyChanged(nameof(CanGoForward)); + } + } + + /// + /// Default dock item + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public IDockable DefaultDockable + { + get => _defaultDockable; + set => SetProperty(ref _defaultDockable, value); + } + + /// + /// dock item that is focused + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public IDockable FocusedDockable + { + get => _focusedDockable; + set + { + SetProperty(ref _focusedDockable, value); + Factory?.OnFocusedDockableChanged(value); + } + } + + /// + /// Porportion of the dock size + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public Double Proportion + { + get => _proportion; + set => SetProperty(ref _proportion, value); + } + + /// + /// Dock mode + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public DockMode Dock + { + get => _dock; + set => SetProperty(ref _dock, value); + } + + /// + /// Determine if dock item is active + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public Boolean IsActive + { + get => _isActive; + set => SetProperty(ref _isActive, value); + } + + /// + /// Is dock item collapsed (on the side) + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public Boolean IsCollapsable + { + get => _isCollapsable; + set => SetProperty(ref _isCollapsable, value); + } + + /// + /// Has a back step + /// + [IgnoreDataMember] + public Boolean CanGoBack => _navigateAdapter.CanGoBack; + + /// + /// Has a forward step + /// + [IgnoreDataMember] + public Boolean CanGoForward => _navigateAdapter.CanGoForward; + + /// + /// Command to go back + /// + [IgnoreDataMember] + public ICommand GoBack { get; } + + /// + /// Command to go forward + /// + [IgnoreDataMember] + public ICommand GoForward { get; } + + /// + /// Navigate command? + /// + [IgnoreDataMember] + public ICommand Navigate { get; } + + /// + /// Close command + /// + [IgnoreDataMember] + public ICommand Close { get; } + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesDockWindow.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesDockWindow.cs new file mode 100644 index 00000000..a7d75579 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesDockWindow.cs @@ -0,0 +1,189 @@ +using Dock.Model.Adapters; +using Dock.Model.Controls; +using Dock.Model.Core; +using MvvmCross.ViewModels; +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; + +namespace MinoriEditorShell.Platforms.Avalonia.Core +{ + internal class MesDockWindow : MvxNotifyPropertyChanged, IDockWindow + { + private readonly IHostAdapter _hostAdapter; + private String _id; + private Double _x; + private Double _y; + private Double _width; + private Double _height; + private Boolean _topmost; + private String _title; + private IDockable _owner; + private IFactory _factory; + private IRootDock _layout; + private IHostWindow _host; + + /// + /// Unique ID? + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public String Id + { + get => _id; + set => SetProperty(ref _id, value); + } + + /// + /// Window X + /// + [DataMember(IsRequired = true, EmitDefaultValue = true)] + public Double X + { + get => _x; + set => SetProperty(ref _x, value); + } + + /// + /// Window Y + /// + [DataMember(IsRequired = true, EmitDefaultValue = true)] + public Double Y + { + get => _y; + set => SetProperty(ref _y, value); + } + + /// + /// Window Width + /// + [DataMember(IsRequired = true, EmitDefaultValue = true)] + public Double Width + { + get => _width; + set => SetProperty(ref _width, value); + } + + /// + /// Window Height + /// + [DataMember(IsRequired = true, EmitDefaultValue = true)] + public Double Height + { + get => _height; + set => SetProperty(ref _height, value); + } + + /// + /// Are we on top most view + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public Boolean Topmost + { + get => _topmost; + set => SetProperty(ref _topmost, value); + } + + /// + /// Declare title + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public String Title + { + get => _title; + set => SetProperty(ref _title, value); + } + + /// + /// Owner dock + /// + [IgnoreDataMember] + public IDockable Owner + { + get => _owner; + set => SetProperty(ref _owner, value); + } + + /// + /// Main factory dock + /// + [IgnoreDataMember] + public IFactory Factory + { + get => _factory; + set => SetProperty(ref _factory, value); + } + + /// + /// Layout dock + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public IRootDock Layout + { + get => _layout; + set => SetProperty(ref _layout, value); + } + + /// + /// Host window + /// + [IgnoreDataMember] + public IHostWindow Host + { + get => _host; + set => SetProperty(ref _host, value); + } + + /// + /// Initializes new instance of the class. + /// + public MesDockWindow() + { + _id = nameof(IDockWindow); + _title = nameof(IDockWindow); + _hostAdapter = new HostAdapter(this); + } + + /// + /// Window is closing + /// + /// + public virtual Boolean OnClose() => true; + + /// + /// Move or drag has begun + /// + /// + public virtual Boolean OnMoveDragBegin() => true; + + /// + /// Move or drag + /// + public virtual void OnMoveDrag() + { + } + + /// + /// Drag has ended + /// + public virtual void OnMoveDragEnd() + { + } + + /// + /// Save state + /// + public void Save() => _hostAdapter.Save(); + + /// + /// Present window + /// + /// Are we a dialog + public void Present(Boolean isDialog) => _hostAdapter.Present(isDialog); + + /// + /// Exit window? + /// + public void Exit() => _hostAdapter.Exit(); + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesDockableBase.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesDockableBase.cs new file mode 100644 index 00000000..6e8f530a --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Core/MesDockableBase.cs @@ -0,0 +1,284 @@ +using Dock.Model.Adapters; +using Dock.Model.Core; +using MvvmCross.ViewModels; +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; + +namespace MinoriEditorShell.Platforms.Avalonia.Core +{ + /// + /// This is used as a base for other dockable interfaces + /// + [DataContract(IsReference = true)] + public abstract class MesDockableBase : MvxNotifyPropertyChanged, IDockable + { + private readonly TrackingAdapter _trackingAdapter; + private String _id = String.Empty; + private String _title = String.Empty; + private Object _context; + private IDockable _owner; + private IFactory _factory; + private Boolean _canClose = true; + private Boolean _canPin = true; + private Boolean _canFloat = true; + + /// + /// Unique ID + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public String Id + { + get => _id; + set => SetProperty(ref _id, value); + } + + /// + /// The title / Name + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public String Title + { + get => _title; + set => SetProperty(ref _title, value); + } + + /// + /// Content? + /// + [IgnoreDataMember] + public Object Context + { + get => _context; + set => SetProperty(ref _context, value); + } + + /// + /// Define which dock we are in + /// + [IgnoreDataMember] + public IDockable Owner + { + get => _owner; + set => SetProperty(ref _owner, value); + } + + /// + /// The factory class, should be same for all classes + /// + [IgnoreDataMember] + public IFactory Factory + { + get => _factory; + set => SetProperty(ref _factory, value); + } + + /// + /// Can the window close + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public Boolean CanClose + { + get => _canClose; + set => SetProperty(ref _canClose, value); + } + + /// + /// Can pin the dockable window + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public Boolean CanPin + { + get => _canPin; + set => SetProperty(ref _canPin, value); + } + + /// + /// Set if document can close + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public Boolean CanFloat + { + get => _canFloat; + set => SetProperty(ref _canFloat, value); + } + + /// + /// Initializes new instance of the class. + /// + protected MesDockableBase() => + _trackingAdapter = new TrackingAdapter(); + + /// + /// Can Close + /// + /// + public virtual Boolean OnClose() => true; + + /// + /// Selection changed + /// + public virtual void OnSelected() + { + } + + /// + /// Get Visible bounds + /// + /// + /// + /// + /// + public void GetVisibleBounds(out Double x, out Double y, out Double width, out Double height) => + _trackingAdapter.GetVisibleBounds(out x, out y, out width, out height); + + /// + /// Set Visible bounds + /// + /// + /// + /// + /// + public void SetVisibleBounds(Double x, Double y, Double width, Double height) + { + _trackingAdapter.SetVisibleBounds(x, y, width, height); + OnVisibleBoundsChanged(x, y, width, height); + } + + /// + /// Visible bouncs changed + /// + /// + /// + /// + /// + public virtual void OnVisibleBoundsChanged(Double x, Double y, Double width, Double height) + { + } + + /// + /// Get Pinned Bounds + /// + /// + /// + /// + /// + public void GetPinnedBounds(out Double x, out Double y, out Double width, out Double height) => + _trackingAdapter.GetPinnedBounds(out x, out y, out width, out height); + + /// + /// Set Pinned Bounds + /// + /// + /// + /// + /// + public void SetPinnedBounds(Double x, Double y, Double width, Double height) + { + _trackingAdapter.SetPinnedBounds(x, y, width, height); + OnPinnedBoundsChanged(x, y, width, height); + } + + /// + /// Pinned Bounds Change method event + /// + /// + /// + /// + /// + public virtual void OnPinnedBoundsChanged(Double x, Double y, Double width, Double height) + { + } + + /// + /// Get Tab Bounds + /// + /// + /// + /// + /// + public void GetTabBounds(out Double x, out Double y, out Double width, out Double height) => + _trackingAdapter.GetTabBounds(out x, out y, out width, out height); + + /// + /// Set Tab Bounds + /// + /// + /// + /// + /// + public void SetTabBounds(Double x, Double y, Double width, Double height) + { + _trackingAdapter.SetTabBounds(x, y, width, height); + OnTabBoundsChanged(x, y, width, height); + } + + /// + /// Tab Bounds changed method event + /// + /// + /// + /// + /// + public virtual void OnTabBoundsChanged(Double x, Double y, Double width, Double height) + { + } + + /// + /// Get Pointer position + /// + /// + /// + public void GetPointerPosition(out Double x, out Double y) => + _trackingAdapter.GetPointerPosition(out x, out y); + + /// + /// Set pointer position + /// + /// + /// + public void SetPointerPosition(Double x, Double y) + { + _trackingAdapter.SetPointerPosition(x, y); + OnPointerPositionChanged(x, y); + } + + /// + /// Event for pointer position + /// + /// + /// + public virtual void OnPointerPositionChanged(Double x, Double y) + { + } + + /// + /// Get the screen position + /// + /// + /// + public void GetPointerScreenPosition(out Double x, out Double y) => + _trackingAdapter.GetPointerScreenPosition(out x, out y); + + /// + /// Set the pointer position + /// + /// + /// + public void SetPointerScreenPosition(Double x, Double y) + { + _trackingAdapter.SetPointerScreenPosition(x, y); + OnPointerScreenPositionChanged(x, y); + } + + /// + /// When pointer screen position changed + /// + /// + /// + public virtual void OnPointerScreenPositionChanged(Double x, Double y) + { + } + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj index b347fbda..231f614f 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj @@ -18,6 +18,7 @@ Library bin\MinoriEditorShell.Platforms.Avalonia.xml ..\..\.sonarlint\torisankitsune_minorieditorshellcsharp.ruleset + 9.0 diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/IDropTarget.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/IDropTarget.cs new file mode 100644 index 00000000..bc008329 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/IDropTarget.cs @@ -0,0 +1,11 @@ +using Avalonia.Input; + +namespace MinoriEditorShell.Platforms.Avalonia.ViewModels +{ + internal interface IDropTarget + { + void DragOver(System.Object sender, DragEventArgs e); + + void Drop(System.Object sender, DragEventArgs e); + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesDocumentManagerViewModel.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesDocumentManagerViewModel.cs new file mode 100644 index 00000000..a2917892 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesDocumentManagerViewModel.cs @@ -0,0 +1,1237 @@ +using Dock.Avalonia.Controls; +using Dock.Model.Controls; +using Dock.Model.Core; +using Dock.Model.Core.Events; +using MinoriEditorShell.Platforms.Avalonia.Controls; +using MinoriEditorShell.Platforms.Avalonia.Core; +using MinoriEditorShell.Services; +using MvvmCross.ViewModels; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Text; + +namespace MinoriEditorShell.Platforms.Avalonia.ViewModels +{ + public class MesDocumentManagerViewModel : MvxViewModel, IFactory, IMesDocumentManager + { + private IDocumentDock _documentDock; + private ITool _findTool; + private ITool _replaceTool; + private IRootDock _rootDock; + + /// + /// Create document dock + /// + /// + //public IDocumentDock CreateDocumentDock() => new FilesDocumentDock(); + + //public IRootDock CreateLayout() + //{ + // var untitledFileViewModel = new FileViewModel() + // { + // Path = string.Empty, + // Title = "Untitled", + // Text = "", + // Encoding = Encoding.Default.WebName + // }; + + // var findViewModel = new FindViewModel() + // { + // Id = "Find", + // Title = "Find" + // }; + + // var replaceViewModel = new ReplaceViewModel() + // { + // Id = "Replace", + // Title = "Replace" + // }; + + // var documentDock = new FilesDocumentDock() + // { + // Id = "Files", + // Title = "Files", + // IsCollapsable = false, + // Proportion = double.NaN, + // ActiveDockable = untitledFileViewModel, + // VisibleDockables = CreateList + // ( + // untitledFileViewModel + // ), + // CanCreateDocument = true + // }; + + // MesProportionalDock tools = new() + // { + // Proportion = 0.2, + // Orientation = Orientation.Vertical, + // VisibleDockables = CreateList + // ( + // new MesToolDock + // { + // ActiveDockable = findViewModel, + // VisibleDockables = CreateList + // ( + // findViewModel + // ), + // Alignment = Alignment.Right, + // GripMode = GripMode.Visible + // }, + // new MesSplitterDockable(), + // new MesToolDock + // { + // ActiveDockable = replaceViewModel, + // VisibleDockables = CreateList + // ( + // replaceViewModel + // ), + // Alignment = Alignment.Right, + // GripMode = GripMode.Visible + // } + // ) + // }; + + // IRootDock windowLayout = CreateRootDock(); + // windowLayout.Title = "Default"; + // MesProportionalDock windowLayoutContent = new() + // { + // Orientation = Orientation.Horizontal, + // IsCollapsable = false, + // VisibleDockables = CreateList + // ( + // documentDock, + // new MesSplitterDockable(), + // tools + // ) + // }; + // windowLayout.IsCollapsable = false; + // windowLayout.VisibleDockables = CreateList(windowLayoutContent); + // windowLayout.ActiveDockable = windowLayoutContent; + + // IRootDock rootDock = CreateRootDock(); + + // rootDock.IsCollapsable = false; + // rootDock.VisibleDockables = CreateList(windowLayout); + // rootDock.ActiveDockable = windowLayout; + // rootDock.DefaultDockable = windowLayout; + + // _documentDock = documentDock; + // _rootDock = rootDock; + // _findTool = findViewModel; + // _replaceTool = replaceViewModel; + + // return rootDock; + //} + + /// + /// Initializes the new instance of class. + /// + protected MesDocumentManagerViewModel() + { + VisibleDockableControls = new Dictionary(); + PinnedDockableControls = new Dictionary(); + TabDockableControls = new Dictionary(); + DockControls = new ObservableCollection(); + HostWindows = new ObservableCollection(); + } + + public event EventHandler ActiveDockableChanged; + + public event EventHandler ActiveDocumentChanged; + + public event EventHandler ActiveDocumentChanging; + + public event EventHandler DockableAdded; + + public event EventHandler DockableClosed; + + public event EventHandler DockableMoved; + + public event EventHandler DockablePinned; + + public event EventHandler DockableRemoved; + + public event EventHandler DockableSwapped; + + public event EventHandler DockableUnpinned; + + public event EventHandler FocusedDockableChanged; + + public event EventHandler UpdateFloatingWindows; + + public event EventHandler WindowAdded; + + public event EventHandler WindowClosed; + + public event EventHandler WindowClosing; + + public event EventHandler WindowMoveDrag; + + public event EventHandler WindowMoveDragBegin; + + public event EventHandler WindowMoveDragEnd; + + public event EventHandler WindowOpened; + + public event EventHandler WindowRemoved; + + public IMesLayoutItem ActiveItem { get; set; } + public IDictionary> ContextLocator { get; set; } + public IDictionary> DockableLocator { get; set; } + public IList DockControls { get; } + public MvxObservableCollection Documents { get; } + public IDictionary> HostWindowLocator { get; set; } + public IList HostWindows { get; } + public IDictionary PinnedDockableControls { get; } + public IMesDocument SelectedDocument { get; } + public Boolean ShowFloatingWindowsInTaskbar { get; set; } + public IDictionary TabDockableControls { get; } + public MvxObservableCollection Tools { get; } + public IDictionary VisibleDockableControls { get; } + + public virtual void AddDockable(IDock dock, IDockable dockable) + { + UpdateDockable(dockable, dock); + dock.VisibleDockables ??= CreateList(); + dock.VisibleDockables.Add(dockable); + OnDockableAdded(dockable); + } + + public virtual void AddWindow(IRootDock rootDock, IDockWindow window) + { + rootDock.Windows ??= CreateList(); + rootDock.Windows.Add(window); + OnWindowAdded(window); + UpdateDockWindow(window, rootDock); + } + + public void Close() => throw new NotImplementedException(); + + public virtual void CloseDockable(IDockable dockable) + { + if (dockable.OnClose()) + { + RemoveDockable(dockable, true); + OnDockableClosed(dockable); + } + } + + public void CloseDocument(IMesDocument document) => throw new NotImplementedException(); + + public void CollapseDock(IDock dock) + { + if (!dock.IsCollapsable || dock.VisibleDockables is null || dock.VisibleDockables.Count != 0) + { + return; + } + + if (dock.PinnedDockables is not null && dock.PinnedDockables.Count != 0) + { + return; + } + + if (dock.Owner is IDock ownerDock && ownerDock.VisibleDockables is { }) + { + var toRemove = new List(); + var dockIndex = ownerDock.VisibleDockables.IndexOf(dock); + + if (dockIndex >= 0) + { + var indexSplitterPrevious = dockIndex - 1; + if (dockIndex > 0 && indexSplitterPrevious >= 0) + { + var previousVisible = ownerDock.VisibleDockables[indexSplitterPrevious]; + if (previousVisible is ISplitterDockable splitterPrevious) + { + toRemove.Add(splitterPrevious); + } + } + + var indexSplitterNext = dockIndex + 1; + if (dockIndex < ownerDock.VisibleDockables.Count - 1 && indexSplitterNext >= 0) + { + var nextVisible = ownerDock.VisibleDockables[indexSplitterNext]; + if (nextVisible is ISplitterDockable splitterNext) + { + toRemove.Add(splitterNext); + } + } + + foreach (var removeVisible in toRemove) + { + RemoveDockable(removeVisible, true); + } + } + } + + if (dock is IRootDock rootDock && rootDock.Window is { }) + { + RemoveWindow(rootDock.Window); + } + else + { + RemoveDockable(dock, true); + } + } + + public IDockDock CreateDockDock() => new MesDockDock(); + + public IDockWindow CreateDockWindow() => new MesDockWindow(); + + public IDocumentDock CreateDocumentDock() => new MesDocumentDock(); + + public IRootDock CreateLayout() => CreateRootDock(); + + public IList CreateList(params T[] items) => new ObservableCollection(items); + + public IProportionalDock CreateProportionalDock() => new MesProportionalDock(); + + public IRootDock CreateRootDock() => new MesRootDock(); + + public virtual IDock CreateSplitLayout(IDock dock, IDockable dockable, DockOperation operation) + { + IDock split; + + if (dockable is IDock dockableDock) + { + split = dockableDock; + } + else + { + split = CreateProportionalDock(); + split.Id = nameof(IProportionalDock); + split.Title = nameof(IProportionalDock); + split.VisibleDockables = CreateList(); + if (split.VisibleDockables is not null) + { + split.VisibleDockables.Add(dockable); + OnDockableAdded(dockable); + split.ActiveDockable = dockable; + } + } + + var containerProportion = dock.Proportion; + dock.Proportion = double.NaN; + + var layout = CreateProportionalDock(); + layout.Id = nameof(IProportionalDock); + layout.Title = nameof(IProportionalDock); + layout.VisibleDockables = CreateList(); + layout.Proportion = containerProportion; + + var splitter = CreateSplitterDockable(); + splitter.Id = nameof(ISplitterDockable); + splitter.Title = nameof(ISplitterDockable); + + switch (operation) + { + case DockOperation.Left: + case DockOperation.Right: + layout.Orientation = Orientation.Horizontal; + break; + + case DockOperation.Top: + case DockOperation.Bottom: + layout.Orientation = Orientation.Vertical; + break; + } + + switch (operation) + { + case DockOperation.Left: + case DockOperation.Top: + if (layout.VisibleDockables is not null) + { + layout.VisibleDockables.Add(split); + OnDockableAdded(split); + layout.ActiveDockable = split; + } + break; + + case DockOperation.Right: + case DockOperation.Bottom: + if (layout.VisibleDockables is not null) + { + layout.VisibleDockables.Add(dock); + OnDockableAdded(dock); + layout.ActiveDockable = dock; + } + break; + } + + layout.VisibleDockables?.Add(splitter); + OnDockableAdded(splitter); + + switch (operation) + { + case DockOperation.Left: + case DockOperation.Top: + if (layout.VisibleDockables is not null) + { + layout.VisibleDockables.Add(dock); + OnDockableAdded(dock); + layout.ActiveDockable = dock; + } + break; + + case DockOperation.Right: + case DockOperation.Bottom: + if (layout.VisibleDockables is not null) + { + layout.VisibleDockables.Add(split); + OnDockableAdded(split); + layout.ActiveDockable = split; + } + break; + } + + return layout; + } + + public ISplitterDockable CreateSplitterDockable() => new MesSplitterDockable(); + + public IToolDock CreateToolDock() => new MesToolDock(); + + public IDockWindow CreateWindowFrom(IDockable dockable) + { + IDockable? target; + bool topmost; + + switch (dockable) + { + case ITool: + { + target = CreateToolDock(); + target.Id = nameof(IToolDock); + target.Title = nameof(IToolDock); + if (target is IDock dock) + { + dock.VisibleDockables = CreateList(); + if (dock.VisibleDockables is not null) + { + dock.VisibleDockables.Add(dockable); + OnDockableAdded(dockable); + dock.ActiveDockable = dockable; + } + } + topmost = true; + } + break; + + case IDocument: + { + target = CreateDocumentDock(); + target.Id = nameof(IDocumentDock); + target.Title = nameof(IDocumentDock); + if (target is IDock dock) + { + dock.VisibleDockables = CreateList(); + if (dockable.Owner is IDocumentDock sourceDocumentDock) + { + ((target as IDocumentDock)!).CanCreateDocument = sourceDocumentDock.CanCreateDocument; + } + if (dock.VisibleDockables is not null) + { + dock.VisibleDockables.Add(dockable); + OnDockableAdded(dockable); + dock.ActiveDockable = dockable; + } + } + topmost = false; + } + break; + + case IToolDock: + { + target = dockable; + topmost = true; + } + break; + + case IDocumentDock: + { + target = dockable; + topmost = false; + } + break; + + case IProportionalDock proportionalDock: + { + target = proportionalDock; + topmost = false; + } + break; + + case IDockDock dockDock: + { + target = dockDock; + topmost = false; + } + break; + + case IRootDock rootDock: + { + target = rootDock.ActiveDockable; + topmost = false; + } + break; + + default: + { + return null; + } + } + + var root = CreateRootDock(); + root.Id = nameof(IRootDock); + root.Title = nameof(IRootDock); + root.VisibleDockables = CreateList(); + if (root.VisibleDockables is not null && target is not null) + { + root.VisibleDockables.Add(target); + OnDockableAdded(target); + root.ActiveDockable = target; + root.DefaultDockable = target; + } + root.Owner = null; + + var window = CreateDockWindow(); + window.Id = nameof(IDockWindow); + window.Title = ""; + window.Width = double.NaN; + window.Height = double.NaN; + window.Topmost = topmost; + window.Layout = root; + + root.Window = window; + + return window; + } + + public IDockable FindDockable(IDock dock, Func predicate) + { + if (predicate(dock)) + { + return dock; + } + + if (dock.VisibleDockables is not null) + { + foreach (var dockable in dock.VisibleDockables) + { + if (predicate(dockable)) + { + return dockable; + } + + if (dockable is IDock childDock) + { + var result = FindDockable(childDock, predicate); + if (result is not null) + { + return result; + } + } + } + } + + if (dock is IRootDock rootDock && rootDock.Windows is not null) + { + foreach (IDockWindow window in rootDock.Windows) + { + if (window.Layout is null) + { + continue; + } + + if (predicate(window.Layout)) + { + return window.Layout; + } + + var result = FindDockable(window.Layout, predicate); + if (result is not null) + { + return result; + } + } + } + + return null; + } + + public virtual IRootDock FindRoot(IDockable dockable, Func predicate) + { + if (dockable.Owner is null) + { + return null; + } + if (dockable.Owner is IRootDock rootDock && predicate(rootDock)) + { + return rootDock; + } + return FindRoot(dockable.Owner, predicate); + } + + public void FloatDockable(IDockable dockable) + { + if (dockable.Owner is not IDock dock) + { + return; + } + + dock.GetPointerScreenPosition(out var dockPointerScreenX, out Double dockPointerScreenY); + dockable.GetPointerScreenPosition(out var dockablePointerScreenX, out Double dockablePointerScreenY); + + if (Double.IsNaN(dockablePointerScreenX)) + { + dockablePointerScreenX = dockPointerScreenX; + } + if (Double.IsNaN(dockablePointerScreenY)) + { + dockablePointerScreenY = dockPointerScreenY; + } + + dock.GetVisibleBounds(out var ownerX, out var ownerY, out var ownerWidth, out var ownerHeight); + dockable.GetVisibleBounds(out var dockableX, out var dockableY, out var dockableWidth, out var dockableHeight); + + if (Double.IsNaN(dockablePointerScreenX)) + { + dockablePointerScreenX = !Double.IsNaN(dockableX) ? dockableX : !Double.IsNaN(ownerX) ? ownerX : 0; + } + if (Double.IsNaN(dockablePointerScreenY)) + { + dockablePointerScreenY = !Double.IsNaN(dockableY) ? dockableY : !Double.IsNaN(ownerY) ? ownerY : 0; + } + if (Double.IsNaN(dockableWidth)) + { + dockableWidth = Double.IsNaN(ownerWidth) ? 300 : ownerWidth; + } + if (Double.IsNaN(dockableHeight)) + { + dockableHeight = Double.IsNaN(ownerHeight) ? 400 : ownerHeight; + } + + SplitToWindow(dock, dockable, dockablePointerScreenX, dockablePointerScreenY, dockableWidth, dockableHeight); + } + + public Object GetContext(String id) + { + if (!String.IsNullOrEmpty(id)) + { + Func locator = null; + if (ContextLocator.TryGetValue(id, out locator) == true) + { + return locator.Invoke(); + } + } + return null; + } + + public virtual T GetDockable(String id) where T : class, IDockable + { + if (!String.IsNullOrEmpty(id)) + { + if (DockableLocator.TryGetValue(id, out Func locator)) + { + return locator.Invoke() as T; + } + } + return default; + } + + public IHostWindow GetHostWindow(String id) + { + if (!String.IsNullOrEmpty(id)) + { + Func locator = null; + if (HostWindowLocator.TryGetValue(id, out locator) == true) + { + return locator.Invoke(); + } + } + return null; + } + + public void InitLayout(IDockable layout) + { + UpdateDockable(layout, null); + + if (layout is IDock dock) + { + if (dock.DefaultDockable is not null) + { + dock.ActiveDockable = dock.DefaultDockable; + } + } + + if (layout is IRootDock rootDock) + { + if (rootDock.ShowWindows.CanExecute(null)) + { + rootDock.ShowWindows.Execute(null); + } + } + + ContextLocator = new Dictionary> + { + ["Find"] = () => layout, + ["Replace"] = () => layout + }; + + DockableLocator = new Dictionary>() + { + ["Root"] = () => _rootDock, + ["Files"] = () => _documentDock, + ["Find"] = () => _findTool, + ["Replace"] = () => _replaceTool + }; + + HostWindowLocator = new Dictionary> + { + [nameof(IDockWindow)] = () => new HostWindow() + }; + } + + public virtual void InsertDockable(IDock dock, IDockable dockable, int index) + { + if (index >= 0) + { + UpdateDockable(dockable, dock); + dock.VisibleDockables ??= CreateList(); + dock.VisibleDockables.Insert(index, dockable); + OnDockableAdded(dockable); + } + } + + public virtual void MoveDockable(IDock dock, IDockable sourceDockable, IDockable targetDockable) + { + if (dock.VisibleDockables is null) + { + return; + } + + var sourceIndex = dock.VisibleDockables.IndexOf(sourceDockable); + Int32 targetIndex = dock.VisibleDockables.IndexOf(targetDockable); + + if (sourceIndex >= 0 && targetIndex >= 0 && sourceIndex != targetIndex) + { + dock.VisibleDockables.RemoveAt(sourceIndex); + OnDockableRemoved(sourceDockable); + dock.VisibleDockables.Insert(targetIndex, sourceDockable); + OnDockableAdded(sourceDockable); + OnDockableMoved(sourceDockable); + dock.ActiveDockable = sourceDockable; + } + } + + public void MoveDockable(IDock sourceDock, IDock targetDock, IDockable sourceDockable, IDockable targetDockable) + { + if (targetDock.VisibleDockables is null) + { + targetDock.VisibleDockables = CreateList(); + if (targetDock.VisibleDockables is null) + { + return; + } + } + + var isSameOwner = sourceDock == targetDock; + + var targetIndex = 0; + + if (sourceDock.VisibleDockables is not null && targetDock.VisibleDockables is not null && targetDock.VisibleDockables.Count > 0) + { + if (isSameOwner) + { + var sourceIndex = sourceDock.VisibleDockables.IndexOf(sourceDockable); + + if (targetDockable is not null) + { + targetIndex = targetDock.VisibleDockables.IndexOf(targetDockable); + } + else + { + targetIndex = targetDock.VisibleDockables.Count - 1; + } + + if (sourceIndex == targetIndex) + { + return; + } + } + else + { + if (targetDockable is not null) + { + targetIndex = targetDock.VisibleDockables.IndexOf(targetDockable); + if (targetIndex >= 0) + { + targetIndex += 1; + } + else + { + targetIndex = targetDock.VisibleDockables.Count - 1; + } + } + else + { + targetIndex = targetDock.VisibleDockables.Count - 1; + } + } + } + + if (sourceDock.VisibleDockables is not null && targetDock.VisibleDockables is not null) + { + if (isSameOwner) + { + var sourceIndex = sourceDock.VisibleDockables.IndexOf(sourceDockable); + if (sourceIndex < targetIndex) + { + targetDock.VisibleDockables.Insert(targetIndex + 1, sourceDockable); + OnDockableAdded(sourceDockable); + targetDock.VisibleDockables.RemoveAt(sourceIndex); + OnDockableRemoved(sourceDockable); + OnDockableMoved(sourceDockable); + } + else + { + var removeIndex = sourceIndex + 1; + if (targetDock.VisibleDockables.Count + 1 > removeIndex) + { + targetDock.VisibleDockables.Insert(targetIndex, sourceDockable); + OnDockableAdded(sourceDockable); + targetDock.VisibleDockables.RemoveAt(removeIndex); + OnDockableRemoved(sourceDockable); + OnDockableMoved(sourceDockable); + } + } + } + else + { + RemoveDockable(sourceDockable, true); + targetDock.VisibleDockables.Insert(targetIndex, sourceDockable); + OnDockableAdded(sourceDockable); + OnDockableMoved(sourceDockable); + UpdateDockable(sourceDockable, targetDock); + targetDock.ActiveDockable = sourceDockable; + } + } + } + + public virtual void OnActiveDockableChanged(IDockable dockable) => + ActiveDockableChanged?.Invoke(this, new ActiveDockableChangedEventArgs(dockable)); + + public virtual void OnDockableAdded(IDockable dockable) => + DockableAdded?.Invoke(this, new DockableAddedEventArgs(dockable)); + + public virtual void OnDockableClosed(IDockable dockable) => + DockableClosed?.Invoke(this, new DockableClosedEventArgs(dockable)); + + public virtual void OnDockableMoved(IDockable dockable) => + DockableMoved?.Invoke(this, new DockableMovedEventArgs(dockable)); + + public virtual void OnDockablePinned(IDockable dockable) => + DockablePinned?.Invoke(this, new DockablePinnedEventArgs(dockable)); + + public virtual void OnDockableRemoved(IDockable dockable) => + DockableRemoved?.Invoke(this, new DockableRemovedEventArgs(dockable)); + + public virtual void OnDockableSwapped(IDockable dockable) => + DockableSwapped?.Invoke(this, new DockableSwappedEventArgs(dockable)); + + public virtual void OnDockableUnpinned(IDockable dockable) => + DockableUnpinned?.Invoke(this, new DockableUnpinnedEventArgs(dockable)); + + public virtual void OnFocusedDockableChanged(IDockable dockable) => + FocusedDockableChanged?.Invoke(this, new FocusedDockableChangedEventArgs(dockable)); + + public virtual void OnWindowAdded(IDockWindow window) => + WindowAdded?.Invoke(this, new WindowAddedEventArgs(window)); + + public virtual void OnWindowClosed(IDockWindow window) => + WindowClosed?.Invoke(this, new WindowClosedEventArgs(window)); + + public Boolean OnWindowClosing(IDockWindow window) + { + Boolean canClose = window?.OnClose() ?? true; + + WindowClosingEventArgs eventArgs = new(window) + { + Cancel = !canClose + }; + + WindowClosing?.Invoke(this, eventArgs); + + return !eventArgs.Cancel; + } + + public virtual void OnWindowMoveDrag(IDockWindow window) + { + window?.OnMoveDrag(); + WindowMoveDrag?.Invoke(this, new WindowMoveDragEventArgs(window)); + } + + public Boolean OnWindowMoveDragBegin(IDockWindow window) + { + Boolean canMoveDrag = window?.OnMoveDragBegin() ?? true; + + WindowMoveDragBeginEventArgs eventArgs = new(window) + { + Cancel = !canMoveDrag + }; + + WindowMoveDragBegin?.Invoke(this, eventArgs); + + return !eventArgs.Cancel; + } + + public virtual void OnWindowMoveDragEnd(IDockWindow window) + { + window?.OnMoveDragEnd(); + WindowMoveDragEnd?.Invoke(this, new WindowMoveDragEndEventArgs(window)); + } + + public virtual void OnWindowOpened(IDockWindow window) => + WindowOpened?.Invoke(this, new WindowOpenedEventArgs(window)); + + public virtual void OnWindowRemoved(IDockWindow window) => + WindowRemoved?.Invoke(this, new WindowRemovedEventArgs(window)); + + public void OpenDocument(IMesDocument model) => throw new NotImplementedException(); + + public virtual void PinDockable(IDockable dockable) + { + switch (dockable.Owner) + { + case IToolDock toolDock: + { + var isVisible = false; + var isPinned = false; + + if (toolDock.VisibleDockables is not null) + { + isVisible = toolDock.VisibleDockables.Contains(dockable); + } + + if (toolDock.PinnedDockables is not null) + { + isPinned = toolDock.PinnedDockables.Contains(dockable); + } + + if (isVisible && !isPinned) + { + // Pin dockable. + + toolDock.PinnedDockables ??= CreateList(); + + if (toolDock.VisibleDockables is not null) + { + toolDock.VisibleDockables.Remove(dockable); + OnDockableRemoved(dockable); + toolDock.PinnedDockables.Add(dockable); + OnDockablePinned(dockable); + } + + // TODO: Handle ActiveDockable state. + // TODO: Handle IsExpanded property of IToolDock. + // TODO: Handle AutoHide property of IToolDock. + } + else if (!isVisible && isPinned) + { + // Unpin dockable. + + toolDock.VisibleDockables ??= CreateList(); + + if (toolDock.PinnedDockables is not null) + { + toolDock.PinnedDockables.Remove(dockable); + OnDockableUnpinned(dockable); + toolDock.VisibleDockables.Add(dockable); + OnDockableAdded(dockable); + } + + // TODO: Handle ActiveDockable state. + // TODO: Handle IsExpanded property of IToolDock. + // TODO: Handle AutoHide property of IToolDock. + } + else + { + // TODO: Handle invalid state. + } + + break; + } + } + } + + public void RemoveDockable(IDockable dockable, bool collapse) + { + if (dockable.Owner is not IDock dock || dock.VisibleDockables is null) + { + return; + } + + var index = dock.VisibleDockables.IndexOf(dockable); + if (index < 0) + { + return; + } + + dock.VisibleDockables.Remove(dockable); + OnDockableRemoved(dockable); + + var indexActiveDockable = index > 0 ? index - 1 : 0; + if (dock.VisibleDockables.Count > 0) + { + var nextActiveDockable = dock.VisibleDockables[indexActiveDockable]; + dock.ActiveDockable = nextActiveDockable is not ISplitterDockable ? nextActiveDockable : null; + } + else + { + dock.ActiveDockable = null; + } + + if (dock.VisibleDockables.Count == 1) + { + IDockable dockable0 = dock.VisibleDockables[0]; + if (dockable0 is ISplitterDockable splitter0) + { + RemoveDockable(splitter0, false); + } + } + + if (dock.VisibleDockables.Count == 2) + { + IDockable dockable0 = dock.VisibleDockables[0]; + IDockable dockable1 = dock.VisibleDockables[1]; + if (dockable0 is ISplitterDockable splitter0) + { + RemoveDockable(splitter0, false); + } + if (dockable1 is ISplitterDockable splitter1) + { + RemoveDockable(splitter1, false); + } + } + + if (collapse) + { + CollapseDock(dock); + } + } + + public virtual void RemoveWindow(IDockWindow window) + { + if (window.Owner is IRootDock rootDock) + { + window.Exit(); + rootDock.Windows?.Remove(window); + OnWindowRemoved(window); + } + } + + public virtual void SetActiveDockable(IDockable dockable) + { + if (dockable.Owner is IDock dock) + { + dock.ActiveDockable = dockable; + } + } + + public virtual void SetFocusedDockable(IDock dock, IDockable dockable) + { + if (dock.ActiveDockable is not null && FindRoot(dock.ActiveDockable, x => x.IsFocusableRoot) is { } root) + { + if (root.FocusedDockable?.Owner is not null) + { + SetIsActive(root.FocusedDockable.Owner, false); + } + + if (dockable is not null) + { + if (root.FocusedDockable != dockable) + { + root.FocusedDockable = dockable; + } + } + + if (root.FocusedDockable?.Owner is not null) + { + SetIsActive(root.FocusedDockable.Owner, true); + } + } + } + + public void ShowTool() where TTool : IMesTool => throw new NotImplementedException(); + + public void ShowTool(IMesTool model) => throw new NotImplementedException(); + + public void SplitToDock(IDock dock, IDockable dockable, DockOperation operation) + { + switch (operation) + { + case DockOperation.Left: + case DockOperation.Right: + case DockOperation.Top: + case DockOperation.Bottom: + { + if (dock.Owner is IDock ownerDock && ownerDock.VisibleDockables is { }) + { + var index = ownerDock.VisibleDockables.IndexOf(dock); + if (index >= 0) + { + var layout = CreateSplitLayout(dock, dockable, operation); + ownerDock.VisibleDockables.RemoveAt(index); + OnDockableRemoved(dockable); + ownerDock.VisibleDockables.Insert(index, layout); + OnDockableAdded(dockable); + UpdateDockable(layout, ownerDock); + ownerDock.ActiveDockable = layout; + } + } + } + break; + + default: + throw new NotSupportedException($"Not supported split operation: {operation}."); + } + } + + public virtual void SplitToWindow(IDock dock, IDockable dockable, Double x, Double y, Double width, Double height) + { + IRootDock rootDock = FindRoot(dock, _ => true); + if (rootDock is null) + { + return; + } + + RemoveDockable(dockable, true); + + var window = CreateWindowFrom(dockable); + if (window is not null) + { + AddWindow(rootDock, window); + window.X = x; + window.Y = y; + window.Width = width; + window.Height = height; + window.Present(false); + } + } + + public virtual void SwapDockable(IDock dock, IDockable sourceDockable, IDockable targetDockable) + { + if (dock.VisibleDockables is null) + { + return; + } + + Int32 sourceIndex = dock.VisibleDockables.IndexOf(sourceDockable); + Int32 targetIndex = dock.VisibleDockables.IndexOf(targetDockable); + + if (sourceIndex >= 0 && targetIndex >= 0 && sourceIndex != targetIndex) + { + IDockable originalSourceDockable = dock.VisibleDockables[sourceIndex]; + IDockable originalTargetDockable = dock.VisibleDockables[targetIndex]; + + dock.VisibleDockables[targetIndex] = originalSourceDockable; + OnDockableRemoved(originalTargetDockable); + OnDockableAdded(originalSourceDockable); + dock.VisibleDockables[sourceIndex] = originalTargetDockable; + OnDockableAdded(originalTargetDockable); + OnDockableSwapped(originalSourceDockable); + OnDockableSwapped(originalTargetDockable); + dock.ActiveDockable = originalTargetDockable; + } + } + + public void SwapDockable(IDock sourceDock, IDock targetDock, IDockable sourceDockable, IDockable targetDockable) + { + if (sourceDock.VisibleDockables is null || targetDock.VisibleDockables is null) + { + return; + } + + var sourceIndex = sourceDock.VisibleDockables.IndexOf(sourceDockable); + var targetIndex = targetDock.VisibleDockables.IndexOf(targetDockable); + + if (sourceIndex >= 0 && targetIndex >= 0) + { + var originalSourceDockable = sourceDock.VisibleDockables[sourceIndex]; + var originalTargetDockable = targetDock.VisibleDockables[targetIndex]; + sourceDock.VisibleDockables[sourceIndex] = originalTargetDockable; + targetDock.VisibleDockables[targetIndex] = originalSourceDockable; + + UpdateDockable(originalSourceDockable, targetDock); + UpdateDockable(originalTargetDockable, sourceDock); + + OnDockableSwapped(originalTargetDockable); + OnDockableSwapped(originalSourceDockable); + + sourceDock.ActiveDockable = originalTargetDockable; + targetDock.ActiveDockable = originalSourceDockable; + } + } + + public virtual void UpdateDockable(IDockable dockable, IDockable owner) + { + if (GetContext(dockable.Id) is { } context) + { + dockable.Context = context; + } + + dockable.Owner = owner; + + if (dockable is IDock dock) + { + dock.Factory = this; + + if (dock.VisibleDockables is not null) + { + foreach (var child in dock.VisibleDockables) + { + UpdateDockable(child, dockable); + } + } + } + + if (dockable is IRootDock rootDock) + { + if (rootDock.Windows is not null) + { + foreach (var child in rootDock.Windows) + { + UpdateDockWindow(child, dockable); + } + } + } + } + + public virtual void UpdateDockWindow(IDockWindow window, IDockable owner) + { + window.Host = GetHostWindow(window.Id); + if (window.Host is not null) + { + window.Host.Window = window; + } + + window.Owner = owner; + window.Factory = this; + + if (window.Layout is not null) + { + UpdateDockable(window.Layout, window.Layout.Owner); + } + } + + private void SetIsActive(IDockable dockable, bool active) + { + if (dockable is IDock dock) + { + dock.IsActive = active; + } + } + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesDocumentView.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesDocumentView.cs new file mode 100644 index 00000000..7265d039 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesDocumentView.cs @@ -0,0 +1,12 @@ +using Dock.Model.Controls; +using MinoriEditorShell.Platforms.Avalonia.Core; +using System; +using System.Collections.Generic; +using System.Text; + +namespace MinoriEditorShell.Platforms.Avalonia.ViewModels +{ + internal class MesDocumentView : MesDockableBase, IDocument + { + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesToolView.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesToolView.cs new file mode 100644 index 00000000..572ebeb5 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesToolView.cs @@ -0,0 +1,15 @@ +using Dock.Model.Controls; +using MinoriEditorShell.Platforms.Avalonia.Core; +using System; +using System.Collections.Generic; +using System.Text; + +namespace MinoriEditorShell.Platforms.Avalonia.ViewModels +{ + /// + /// Tool view + /// + public class MesToolView : MesDockableBase, ITool, IDocument + { + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.axaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.axaml index d1a55d49..f0997946 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.axaml +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.axaml @@ -9,5 +9,5 @@ x:Class="MinoriEditorShell.Platforms.Avalonia.Views.MesDocumentManagerView"> - + \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.axaml.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.axaml.cs index 9cd32b11..bb5fa2fd 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.axaml.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.axaml.cs @@ -1,8 +1,10 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Input; using Avalonia.Markup.Xaml; using Dock.Model.Core; +using MinoriEditorShell.Platforms.Avalonia.ViewModels; using MinoriEditorShell.Services; using MvvmCross; using System; @@ -16,14 +18,28 @@ public partial class MesDocumentManagerView : UserControl, IMesDocumentManagerVi public MesDocumentManagerView() { InitializeComponent(); + AddHandler(DragDrop.DropEvent, Drop); + AddHandler(DragDrop.DragOverEvent, DragOver); - try + IMesDocumentManager manager = Mvx.IoCProvider.Resolve(); + //manager.UpdateFloatingWindows += Manager_UpdateFloatingWindows; + DataContext = (MesDocumentManagerViewModel)manager; + } + + private void DragOver(Object sender, DragEventArgs e) + { + if (DataContext is IDropTarget dropTarget) + { + dropTarget.DragOver(sender, e); + } + } + + private void Drop(Object sender, DragEventArgs e) + { + if (DataContext is IDropTarget dropTarget) { - IMesDocumentManager manager = Mvx.IoCProvider.Resolve(); - manager.UpdateFloatingWindows += Manager_UpdateFloatingWindows; - DataContext = manager; + dropTarget.Drop(sender, e); } - catch { } } public void LoadLayout(Stream stream, Action addToolCallback, Action addDocumentCallback, Dictionary itemsState) diff --git a/Modules/MinoriEditorShell/ViewModels/MesDocumentManagerViewModel.cs b/Modules/MinoriEditorShell.Platforms.Wpf/ViewModels/MesDocumentManagerViewModel.cs similarity index 99% rename from Modules/MinoriEditorShell/ViewModels/MesDocumentManagerViewModel.cs rename to Modules/MinoriEditorShell.Platforms.Wpf/ViewModels/MesDocumentManagerViewModel.cs index 5055a1da..8d2e0122 100644 --- a/Modules/MinoriEditorShell/ViewModels/MesDocumentManagerViewModel.cs +++ b/Modules/MinoriEditorShell.Platforms.Wpf/ViewModels/MesDocumentManagerViewModel.cs @@ -4,7 +4,7 @@ using System; using System.IO; -namespace MinoriEditorShell.ViewModels +namespace MinoriEditorShell.Platforms.Wpf.ViewModels { public class MesDocumentManagerViewModel : MvxViewModel, IMesDocumentManager { diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/Views/MesDocumentManagerView.xaml.cs b/Modules/MinoriEditorShell.Platforms.Wpf/Views/MesDocumentManagerView.xaml.cs index 06a5b90f..ad73dfc4 100644 --- a/Modules/MinoriEditorShell.Platforms.Wpf/Views/MesDocumentManagerView.xaml.cs +++ b/Modules/MinoriEditorShell.Platforms.Wpf/Views/MesDocumentManagerView.xaml.cs @@ -1,4 +1,5 @@ using AvalonDock.Controls; +using MinoriEditorShell.Platforms.Wpf.ViewModels; using MinoriEditorShell.Services; using MinoriEditorShell.ViewModels; using MvvmCross; @@ -19,7 +20,10 @@ public MesDocumentManagerView() try { IMesDocumentManager manager = Mvx.IoCProvider.Resolve(); - manager.UpdateFloatingWindows += UpdateFloatingWindows; + if (manager is MesDocumentManagerViewModel model) + { + model.UpdateFloatingWindows += UpdateFloatingWindows; + } DataContext = manager; } catch { } diff --git a/Modules/MinoriEditorShell/Services/IMesDocumentManager.cs b/Modules/MinoriEditorShell/Services/IMesDocumentManager.cs index 3284154e..ca8ede40 100644 --- a/Modules/MinoriEditorShell/Services/IMesDocumentManager.cs +++ b/Modules/MinoriEditorShell/Services/IMesDocumentManager.cs @@ -3,16 +3,21 @@ namespace MinoriEditorShell.Services { + /// + /// Main interface for interfacing with document manager + /// public interface IMesDocumentManager { + /// + /// Document is about to change + /// event EventHandler ActiveDocumentChanging; + /// + /// Docuemnt has chagned + /// event EventHandler ActiveDocumentChanged; - event EventHandler UpdateFloatingWindows; - - Boolean ShowFloatingWindowsInTaskbar { get; set; } - IMesLayoutItem ActiveItem { get; set; } IMesDocument SelectedDocument { get; } From 38771350da19dff0323fa41874928587b21dc0cf Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Mon, 6 Sep 2021 21:31:36 -0400 Subject: [PATCH 62/68] remove messages --- Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml.cs b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml.cs index b75115e6..8e398531 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml.cs +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/App.axaml.cs @@ -11,11 +11,11 @@ namespace SimpleDemo.Avalonia public class App : MesApplication { public override void Initialize() => AvaloniaXamlLoader.Load(this); + protected override void RegisterSetup() => this.RegisterSetupType(); public override void OnFrameworkInitializationCompleted() { - Debug.WriteLine("InitTest"); if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { desktop.MainWindow = new MainWindow(); @@ -24,4 +24,4 @@ public override void OnFrameworkInitializationCompleted() base.OnFrameworkInitializationCompleted(); } } -} +} \ No newline at end of file From 5d0ea02126aa7dbaba9b98e4565d407ed5a83fbb Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Mon, 6 Sep 2021 22:37:42 -0400 Subject: [PATCH 63/68] Try to add wrapper --- .../Extensions/ConsoleModifiersExtension.cs | 26 ----------------- .../Presenters/MesAvnViewPresenter.cs | 29 +++++++++++-------- .../ViewModels/MesDocumentManagerViewModel.cs | 6 ++-- .../ViewModels/MesDocumentWrapper.cs | 18 ++++++++++++ .../ViewModels/MesToolWrapper.cs | 12 ++++++++ 5 files changed, 50 insertions(+), 41 deletions(-) delete mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Extensions/ConsoleModifiersExtension.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesDocumentWrapper.cs create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesToolWrapper.cs diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Extensions/ConsoleModifiersExtension.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Extensions/ConsoleModifiersExtension.cs deleted file mode 100644 index 3bd8c52d..00000000 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Extensions/ConsoleModifiersExtension.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Windows.Input; - -namespace MinoriEditorShell.Platforms.Avalonia.Extensions -{ - public static class ConsoleModifiersExtension - { - // public static ModifierKeys ToModifierKeys(this ConsoleModifiers console) - // { - // switch (console) - // { - // case ConsoleModifiers.Alt: - // return ModifierKeys.Alt; - - // case ConsoleModifiers.Shift: - // return ModifierKeys.Shift; - - // case ConsoleModifiers.Control: - // return ModifierKeys.Control; - - // default: - // return ModifierKeys.None; - // } - // } - } -} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs index d2784d43..a2eee4c5 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs @@ -1,6 +1,8 @@ using Avalonia.Controls; +using Dock.Model.Controls; using Microsoft.Extensions.Logging; using MinoriEditorShell.Platforms.Avalonia.Presenters.Attributes; +using MinoriEditorShell.Platforms.Avalonia.ViewModels; using MinoriEditorShell.Platforms.Avalonia.Views; using MinoriEditorShell.Services; using MvvmCross; @@ -56,23 +58,23 @@ protected MesAvnViewPresenter() { } - protected Dictionary> FrameworkElementsDictionary + protected IMesAvnViewLoader AvnViewLoader { get { - if (_frameworkElementsDictionary == null) - _frameworkElementsDictionary = new Dictionary>(); - return _frameworkElementsDictionary; + if (_wpfViewLoader == null) + _wpfViewLoader = Mvx.IoCProvider.Resolve(); + return _wpfViewLoader; } } - protected IMesAvnViewLoader AvnViewLoader + protected Dictionary> FrameworkElementsDictionary { get { - if (_wpfViewLoader == null) - _wpfViewLoader = Mvx.IoCProvider.Resolve(); - return _wpfViewLoader; + if (_frameworkElementsDictionary == null) + _frameworkElementsDictionary = new Dictionary>(); + return _frameworkElementsDictionary; } } @@ -208,7 +210,7 @@ protected async Task ShowContentView( { // Everything that passes here should be a view IMvxView view = element as IMvxView; - IMesDocumentManager manager = Mvx.IoCProvider.Resolve(); + MesDocumentManagerViewModel manager = (MesDocumentManagerViewModel)Mvx.IoCProvider.Resolve(); // from which we can now get the view model. switch (view.ViewModel) @@ -219,8 +221,11 @@ protected async Task ShowContentView( IMesDocument docViewModel = (IMesDocument)view.ViewModel; docViewModel.View = view; // Needed for Binding with AvalonDock + MesDocumentWrapper documentWrapper = new(docViewModel); + // Add to manager model - manager.Documents.Add(docViewModel); + //manager.Documents.Add(docViewModel); + manager.AddDockable(manager.GetDockable("Files"), documentWrapper); _log.LogTrace($"Add {document} to IMesDocumentManager.Documents"); return true; @@ -236,7 +241,7 @@ protected async Task ShowContentView( default: _log.LogTrace($"Passing to parent {view.ViewModel}"); - ContentControl contentControl = FrameworkElementsDictionary.Keys.FirstOrDefault(w => (w as MesWindow)?.Identifier == attribute.WindowIdentifier) + ContentControl contentControl = FrameworkElementsDictionary.Keys.FirstOrDefault(w => (w as MesWindow)?.Identifier == attribute.WindowIdentifier) ?? FrameworkElementsDictionary.Keys.Last(); if (!attribute.StackNavigation && FrameworkElementsDictionary[contentControl].Any()) @@ -287,7 +292,7 @@ protected virtual Task ShowWindow(IMesAvnView element, MesWindowPresentati if (attribute.Modal) throw new NotImplementedException(); - //window.ShowDialog(); + //window.ShowDialog(); else window.Show(); return Task.FromResult(true); diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesDocumentManagerViewModel.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesDocumentManagerViewModel.cs index a2917892..7ae24748 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesDocumentManagerViewModel.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesDocumentManagerViewModel.cs @@ -127,7 +127,7 @@ public class MesDocumentManagerViewModel : MvxViewModel, IFactory, IMesDocumentM /// /// Initializes the new instance of class. /// - protected MesDocumentManagerViewModel() + public MesDocumentManagerViewModel() { VisibleDockableControls = new Dictionary(); PinnedDockableControls = new Dictionary(); @@ -190,7 +190,7 @@ protected MesDocumentManagerViewModel() public MvxObservableCollection Tools { get; } public IDictionary VisibleDockableControls { get; } - public virtual void AddDockable(IDock dock, IDockable dockable) + public void AddDockable(IDock dock, IDockable dockable) { UpdateDockable(dockable, dock); dock.VisibleDockables ??= CreateList(); @@ -198,7 +198,7 @@ public virtual void AddDockable(IDock dock, IDockable dockable) OnDockableAdded(dockable); } - public virtual void AddWindow(IRootDock rootDock, IDockWindow window) + public void AddWindow(IRootDock rootDock, IDockWindow window) { rootDock.Windows ??= CreateList(); rootDock.Windows.Add(window); diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesDocumentWrapper.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesDocumentWrapper.cs new file mode 100644 index 00000000..329d6024 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesDocumentWrapper.cs @@ -0,0 +1,18 @@ +using Dock.Model.Controls; +using MinoriEditorShell.Platforms.Avalonia.Core; +using MinoriEditorShell.Services; +using System; +using System.Collections.Generic; +using System.Text; + +namespace MinoriEditorShell.Platforms.Avalonia.ViewModels +{ + internal class MesDocumentWrapper : MesDockableBase, IDocument + { + private IMesDocument docViewModel; + + public MesDocumentWrapper(IMesDocument docViewModel) => this.docViewModel = docViewModel; + + public IMesDocument ViewModel { get; set; } + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesToolWrapper.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesToolWrapper.cs new file mode 100644 index 00000000..dbb1a796 --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesToolWrapper.cs @@ -0,0 +1,12 @@ +using Dock.Model.Controls; +using MinoriEditorShell.Platforms.Avalonia.Core; +using System; +using System.Collections.Generic; +using System.Text; + +namespace MinoriEditorShell.Platforms.Avalonia.ViewModels +{ + internal class MesToolWrapper : MesDockableBase, ITool + { + } +} \ No newline at end of file From 20f1499360bbee9e0011c5db2e4ecdf895b73077 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Wed, 27 Oct 2021 23:50:55 -0400 Subject: [PATCH 64/68] nuget update --- .../SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj | 6 +++--- .../MinoriEditorShell.Platforms.Avalonia.csproj | 7 ++++--- .../MinoriEditorShell.Platforms.Wpf.csproj | 6 +++--- .../MinoriEditorShell.Platforms.WpfTests.csproj | 6 +++--- .../MinoriEditorShell.RibbonTests.csproj | 6 +++--- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj b/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj index b6e236e7..42370574 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj @@ -8,9 +8,9 @@ - - - + + + diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj index 231f614f..67a0ff96 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj @@ -34,9 +34,10 @@ - - - + + + + diff --git a/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj b/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj index a7b797f0..4a762c0e 100644 --- a/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj +++ b/Modules/MinoriEditorShell.Platforms.Wpf/MinoriEditorShell.Platforms.Wpf.csproj @@ -42,9 +42,9 @@ - - - + + + \ No newline at end of file diff --git a/Tests/MinoriEditorShell.Platforms.WpfTests/MinoriEditorShell.Platforms.WpfTests.csproj b/Tests/MinoriEditorShell.Platforms.WpfTests/MinoriEditorShell.Platforms.WpfTests.csproj index 56204b81..13f699e3 100644 --- a/Tests/MinoriEditorShell.Platforms.WpfTests/MinoriEditorShell.Platforms.WpfTests.csproj +++ b/Tests/MinoriEditorShell.Platforms.WpfTests/MinoriEditorShell.Platforms.WpfTests.csproj @@ -7,10 +7,10 @@ - + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Tests/MinoriEditorShell.RibbonTests/MinoriEditorShell.RibbonTests.csproj b/Tests/MinoriEditorShell.RibbonTests/MinoriEditorShell.RibbonTests.csproj index f817780b..d8c6496e 100644 --- a/Tests/MinoriEditorShell.RibbonTests/MinoriEditorShell.RibbonTests.csproj +++ b/Tests/MinoriEditorShell.RibbonTests/MinoriEditorShell.RibbonTests.csproj @@ -7,10 +7,10 @@ - + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive From 62e7f357c5c5324aca04813f9c52cfe025a779e4 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Wed, 27 Oct 2021 23:53:50 -0400 Subject: [PATCH 65/68] dock update --- .../{MesSplitterDockable.cs => MesProportionalDockSplitter.cs} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename Modules/MinoriEditorShell.Platforms.Avalonia/Controls/{MesSplitterDockable.cs => MesProportionalDockSplitter.cs} (62%) diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesSplitterDockable.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesProportionalDockSplitter.cs similarity index 62% rename from Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesSplitterDockable.cs rename to Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesProportionalDockSplitter.cs index f2c0d921..2184476b 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesSplitterDockable.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesProportionalDockSplitter.cs @@ -3,7 +3,7 @@ namespace MinoriEditorShell.Platforms.Avalonia.Controls { - internal class MesSplitterDockable : MesDockableBase, ISplitterDockable + public class MesProportionalDockSplitter : MesDockableBase, IProportionalDockSplitter { } } \ No newline at end of file From 5433d0114f7fa1256df9476fe05b2b6cf5ea31e5 Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sun, 31 Oct 2021 14:52:26 -0400 Subject: [PATCH 66/68] sonarlint update --- .sonarlint/MinoriEditorShell.slconfig | 2 +- .sonarlint/torisankitsune_minorieditorshellcsharp.ruleset | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.sonarlint/MinoriEditorShell.slconfig b/.sonarlint/MinoriEditorShell.slconfig index edbf02e2..ae55e19b 100644 --- a/.sonarlint/MinoriEditorShell.slconfig +++ b/.sonarlint/MinoriEditorShell.slconfig @@ -9,7 +9,7 @@ "Profiles": { "CSharp": { "ProfileKey": "AXHDDFLUVHc24qBALL5K", - "ProfileTimestamp": "2021-05-05T07:40:20Z" + "ProfileTimestamp": "2021-10-27T09:08:11Z" } } } \ No newline at end of file diff --git a/.sonarlint/torisankitsune_minorieditorshellcsharp.ruleset b/.sonarlint/torisankitsune_minorieditorshellcsharp.ruleset index f9145a58..6bc76dac 100644 --- a/.sonarlint/torisankitsune_minorieditorshellcsharp.ruleset +++ b/.sonarlint/torisankitsune_minorieditorshellcsharp.ruleset @@ -169,6 +169,7 @@ + @@ -194,11 +195,13 @@ + + From 5508c5ba81297cbf175f3d8d22023775243324ca Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sat, 2 Jul 2022 22:23:45 -0400 Subject: [PATCH 67/68] change perms --- .../Controls/MesDocumentDock.cs | 2 +- .../Controls/MesProportionalDock.cs | 2 +- .../Controls/MesRootDock.cs | 2 +- .../Controls/MesToolDock.cs | 2 +- ...inoriEditorShell.Platforms.Avalonia.csproj | 5 +- .../Presenters/MesAvnViewPresenter.cs | 73 +++- .../ViewModels/MesDocumentManagerViewModel.cs | 406 ++++++++++-------- .../ViewModels/MesDocumentWrapper.cs | 10 +- .../Views/MesApplication.cs | 21 +- .../Views/MesDocumentManagerView.axaml | 7 +- .../Views/MesDocumentManagerView.axaml.cs | 8 +- .../Views/ViewTemplate.cs | 22 + .../MinoriEditorShell.csproj | 9 +- 13 files changed, 336 insertions(+), 233 deletions(-) create mode 100644 Modules/MinoriEditorShell.Platforms.Avalonia/Views/ViewTemplate.cs diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesDocumentDock.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesDocumentDock.cs index 432ea4fd..f01d561c 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesDocumentDock.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesDocumentDock.cs @@ -8,7 +8,7 @@ namespace MinoriEditorShell.Platforms.Avalonia.Controls { - internal class MesDocumentDock : MesDockBase, IDocumentDock + public class MesDocumentDock : MesDockBase, IDocumentDock { private Boolean _canCreateDocument; diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesProportionalDock.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesProportionalDock.cs index f8d999df..f0d3fd3e 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesProportionalDock.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesProportionalDock.cs @@ -12,7 +12,7 @@ namespace MinoriEditorShell.Platforms.Avalonia.Controls /// Proportional dock. /// [DataContract(IsReference = true)] - internal class MesProportionalDock : MesDockBase, IProportionalDock + public class MesProportionalDock : MesDockBase, IProportionalDock { private Orientation _orientation; diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesRootDock.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesRootDock.cs index 276bf884..ee97f9e8 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesRootDock.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesRootDock.cs @@ -13,7 +13,7 @@ namespace MinoriEditorShell.Platforms.Avalonia.Controls /// /// Main root dock /// - internal class MesRootDock : MesDockBase, IRootDock + public class MesRootDock : MesDockBase, IRootDock { private Boolean _isFocusableRoot = true; private IDockWindow _window; diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesToolDock.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesToolDock.cs index f30a1f27..022432aa 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesToolDock.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Controls/MesToolDock.cs @@ -8,7 +8,7 @@ namespace MinoriEditorShell.Platforms.Avalonia.Controls { - internal class MesToolDock : MesDockBase, IToolDock + public class MesToolDock : MesDockBase, IToolDock { private Alignment _alignment = Alignment.Unset; private Boolean _isExpanded; diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj index 67a0ff96..a2f52d5e 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj @@ -32,15 +32,14 @@ + + - - - diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs index a2eee4c5..2cebf0bb 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Presenters/MesAvnViewPresenter.cs @@ -1,5 +1,6 @@ using Avalonia.Controls; using Dock.Model.Controls; +using Dock.Model.Core; using Microsoft.Extensions.Logging; using MinoriEditorShell.Platforms.Avalonia.Presenters.Attributes; using MinoriEditorShell.Platforms.Avalonia.ViewModels; @@ -199,35 +200,59 @@ protected virtual Task CloseWindow(IMvxViewModel toClose) /// Depending on what the type is, will define where the class goes. /// Either to MesDocumentManager or main view if not a IMesDocument or IMesTool /// - /// + /// /// /// /// - protected async Task ShowContentView( - IMvxView element, MesContentPresentationAttribute attribute, MvxViewModelRequest request) + protected async Task ShowContentView(IMvxView view, MesContentPresentationAttribute attribute, MvxViewModelRequest request) { try { // Everything that passes here should be a view - IMvxView view = element as IMvxView; MesDocumentManagerViewModel manager = (MesDocumentManagerViewModel)Mvx.IoCProvider.Resolve(); // from which we can now get the view model. switch (view.ViewModel) { case IMesDocument document: + { + // Try to set view, this is needed for DocumentManager + IMesDocument docViewModel = (IMesDocument)view.ViewModel; + docViewModel.View = view; // Needed for Binding with AvalonDock - // Try to set view, this is needed for DocumentManager - IMesDocument docViewModel = (IMesDocument)view.ViewModel; - docViewModel.View = view; // Needed for Binding with AvalonDock + MesDocumentWrapper documentWrapper = new(docViewModel); - MesDocumentWrapper documentWrapper = new(docViewModel); + // Add to manager model + IDocumentDock docdock = manager.DocumentDock; + IRootDock layout = manager.Layout; - // Add to manager model - //manager.Documents.Add(docViewModel); - manager.AddDockable(manager.GetDockable("Files"), documentWrapper); - _log.LogTrace($"Add {document} to IMesDocumentManager.Documents"); - return true; + if (layout is { } && docdock is { }) + { + manager.DocumentDock.VisibleDockables.Add(documentWrapper); + manager.AddDockable(docdock, documentWrapper); + manager.SetActiveDockable(documentWrapper); + manager.SetFocusedDockable(layout, documentWrapper); + + _log.LogTrace($"Add {document} to IMesDocumentManager.Documents"); + } + else + { + _log.LogTrace("There was an error attaching to layout"); + } + + // ---------- remove after test + ContentControl contentControl = FrameworkElementsDictionary.Keys.FirstOrDefault(w => (w as MesWindow)?.Identifier == attribute.WindowIdentifier) + ?? FrameworkElementsDictionary.Keys.Last(); + + if (!attribute.StackNavigation && FrameworkElementsDictionary[contentControl].Any()) + FrameworkElementsDictionary[contentControl].Pop(); // Close previous view + + FrameworkElementsDictionary[contentControl].Push((Control)view); + contentControl.Content = documentWrapper; + _log.LogTrace($"Passing to parent {view.ViewModel}"); + + return true; + } case IMesTool tool: // Try to set view, this is needed for DocumentManager @@ -240,16 +265,18 @@ protected async Task ShowContentView( return true; default: - _log.LogTrace($"Passing to parent {view.ViewModel}"); - ContentControl contentControl = FrameworkElementsDictionary.Keys.FirstOrDefault(w => (w as MesWindow)?.Identifier == attribute.WindowIdentifier) - ?? FrameworkElementsDictionary.Keys.Last(); - - if (!attribute.StackNavigation && FrameworkElementsDictionary[contentControl].Any()) - FrameworkElementsDictionary[contentControl].Pop(); // Close previous view - - FrameworkElementsDictionary[contentControl].Push((Control)element); - contentControl.Content = element; - return true; + { + _log.LogTrace($"Passing to parent {view.ViewModel}"); + ContentControl contentControl = FrameworkElementsDictionary.Keys.FirstOrDefault(w => (w as MesWindow)?.Identifier == attribute.WindowIdentifier) + ?? FrameworkElementsDictionary.Keys.Last(); + + if (!attribute.StackNavigation && FrameworkElementsDictionary[contentControl].Any()) + FrameworkElementsDictionary[contentControl].Pop(); // Close previous view + + FrameworkElementsDictionary[contentControl].Push((Control)view); + contentControl.Content = view; + return true; + } } } catch (Exception exception) diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesDocumentManagerViewModel.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesDocumentManagerViewModel.cs index 7ae24748..2734d6a5 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesDocumentManagerViewModel.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesDocumentManagerViewModel.cs @@ -1,4 +1,5 @@ -using Dock.Avalonia.Controls; +using Avalonia.Controls.Templates; +using Dock.Avalonia.Controls; using Dock.Model.Controls; using Dock.Model.Core; using Dock.Model.Core.Events; @@ -9,6 +10,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Linq; using System.Text; namespace MinoriEditorShell.Platforms.Avalonia.ViewModels @@ -16,8 +18,11 @@ namespace MinoriEditorShell.Platforms.Avalonia.ViewModels public class MesDocumentManagerViewModel : MvxViewModel, IFactory, IMesDocumentManager { private IDocumentDock _documentDock; - private ITool _findTool; - private ITool _replaceTool; + + //private ITool _findTool; + private IRootDock _layout; + + //private ITool _replaceTool; private IRootDock _rootDock; /// @@ -26,104 +31,6 @@ public class MesDocumentManagerViewModel : MvxViewModel, IFactory, IMesDocumentM /// //public IDocumentDock CreateDocumentDock() => new FilesDocumentDock(); - //public IRootDock CreateLayout() - //{ - // var untitledFileViewModel = new FileViewModel() - // { - // Path = string.Empty, - // Title = "Untitled", - // Text = "", - // Encoding = Encoding.Default.WebName - // }; - - // var findViewModel = new FindViewModel() - // { - // Id = "Find", - // Title = "Find" - // }; - - // var replaceViewModel = new ReplaceViewModel() - // { - // Id = "Replace", - // Title = "Replace" - // }; - - // var documentDock = new FilesDocumentDock() - // { - // Id = "Files", - // Title = "Files", - // IsCollapsable = false, - // Proportion = double.NaN, - // ActiveDockable = untitledFileViewModel, - // VisibleDockables = CreateList - // ( - // untitledFileViewModel - // ), - // CanCreateDocument = true - // }; - - // MesProportionalDock tools = new() - // { - // Proportion = 0.2, - // Orientation = Orientation.Vertical, - // VisibleDockables = CreateList - // ( - // new MesToolDock - // { - // ActiveDockable = findViewModel, - // VisibleDockables = CreateList - // ( - // findViewModel - // ), - // Alignment = Alignment.Right, - // GripMode = GripMode.Visible - // }, - // new MesSplitterDockable(), - // new MesToolDock - // { - // ActiveDockable = replaceViewModel, - // VisibleDockables = CreateList - // ( - // replaceViewModel - // ), - // Alignment = Alignment.Right, - // GripMode = GripMode.Visible - // } - // ) - // }; - - // IRootDock windowLayout = CreateRootDock(); - // windowLayout.Title = "Default"; - // MesProportionalDock windowLayoutContent = new() - // { - // Orientation = Orientation.Horizontal, - // IsCollapsable = false, - // VisibleDockables = CreateList - // ( - // documentDock, - // new MesSplitterDockable(), - // tools - // ) - // }; - // windowLayout.IsCollapsable = false; - // windowLayout.VisibleDockables = CreateList(windowLayoutContent); - // windowLayout.ActiveDockable = windowLayoutContent; - - // IRootDock rootDock = CreateRootDock(); - - // rootDock.IsCollapsable = false; - // rootDock.VisibleDockables = CreateList(windowLayout); - // rootDock.ActiveDockable = windowLayout; - // rootDock.DefaultDockable = windowLayout; - - // _documentDock = documentDock; - // _rootDock = rootDock; - // _findTool = findViewModel; - // _replaceTool = replaceViewModel; - - // return rootDock; - //} - /// /// Initializes the new instance of class. /// @@ -132,8 +39,8 @@ public MesDocumentManagerViewModel() VisibleDockableControls = new Dictionary(); PinnedDockableControls = new Dictionary(); TabDockableControls = new Dictionary(); - DockControls = new ObservableCollection(); - HostWindows = new ObservableCollection(); + DockControls = new MvxObservableCollection(); + HostWindows = new MvxObservableCollection(); } public event EventHandler ActiveDockableChanged; @@ -177,17 +84,54 @@ public MesDocumentManagerViewModel() public event EventHandler WindowRemoved; public IMesLayoutItem ActiveItem { get; set; } + public IDictionary> ContextLocator { get; set; } + public Func DefaultContextLocator { get; set; } + public IDictionary> DockableLocator { get; set; } + public IList DockControls { get; } + + public IDocumentDock DocumentDock { get; internal set; } + public MvxObservableCollection Documents { get; } + public IDictionary> HostWindowLocator { get; set; } + public Func DefaultHostWindowLocator { get; set; } + public IList HostWindows { get; } + + public Boolean IsDataTemplatesInitialized { get; } + + /// + /// Get initial layout + /// + public IRootDock Layout + { + get + { + if (_layout == null) + { + _layout = CreateLayout(); + if (_layout is { }) + { + InitLayout(_layout); + } + } + return _layout; + } + } + public IDictionary PinnedDockableControls { get; } + public IMesDocument SelectedDocument { get; } + public Boolean ShowFloatingWindowsInTaskbar { get; set; } + public IDictionary TabDockableControls { get; } + public MvxObservableCollection Tools { get; } + public IDictionary VisibleDockableControls { get; } public void AddDockable(IDock dock, IDockable dockable) @@ -217,6 +161,14 @@ public virtual void CloseDockable(IDockable dockable) } } + public virtual void CloseAllDockables(IDockable dockable) => throw new NotImplementedException(); + + public virtual void CloseLeftDockables(IDockable dockable) => throw new NotImplementedException(); + + public virtual void CloseRightDockables(IDockable dockable) => throw new NotImplementedException(); + + public virtual void CloseOtherDockables(IDockable dockable) => throw new NotImplementedException(); + public void CloseDocument(IMesDocument document) => throw new NotImplementedException(); public void CollapseDock(IDock dock) @@ -233,32 +185,32 @@ public void CollapseDock(IDock dock) if (dock.Owner is IDock ownerDock && ownerDock.VisibleDockables is { }) { - var toRemove = new List(); - var dockIndex = ownerDock.VisibleDockables.IndexOf(dock); + List toRemove = new(); + Int32 dockIndex = ownerDock.VisibleDockables.IndexOf(dock); if (dockIndex >= 0) { - var indexSplitterPrevious = dockIndex - 1; + Int32 indexSplitterPrevious = dockIndex - 1; if (dockIndex > 0 && indexSplitterPrevious >= 0) { - var previousVisible = ownerDock.VisibleDockables[indexSplitterPrevious]; - if (previousVisible is ISplitterDockable splitterPrevious) + IDockable previousVisible = ownerDock.VisibleDockables[indexSplitterPrevious]; + if (previousVisible is IProportionalDockSplitter splitterPrevious) { toRemove.Add(splitterPrevious); } } - var indexSplitterNext = dockIndex + 1; + Int32 indexSplitterNext = dockIndex + 1; if (dockIndex < ownerDock.VisibleDockables.Count - 1 && indexSplitterNext >= 0) { - var nextVisible = ownerDock.VisibleDockables[indexSplitterNext]; - if (nextVisible is ISplitterDockable splitterNext) + IDockable nextVisible = ownerDock.VisibleDockables[indexSplitterNext]; + if (nextVisible is IProportionalDockSplitter splitterNext) { toRemove.Add(splitterNext); } } - foreach (var removeVisible in toRemove) + foreach (IDockable removeVisible in toRemove) { RemoveDockable(removeVisible, true); } @@ -281,7 +233,107 @@ public void CollapseDock(IDock dock) public IDocumentDock CreateDocumentDock() => new MesDocumentDock(); - public IRootDock CreateLayout() => CreateRootDock(); + public virtual IRootDock CreateLayout() + { + //var untitledFileViewModel = new FileViewModel() + //{ + // Path = string.Empty, + // Title = "Untitled", + // Text = "", + // Encoding = Encoding.Default.WebName + //}; + + //var findViewModel = new FindViewModel() + //{ + // Id = "Find", + // Title = "Find" + //}; + + //var replaceViewModel = new ReplaceViewModel() + //{ + // Id = "Replace", + // Title = "Replace" + //}; + + MesDocumentDock documentDock = new() + { + Id = "Files", + Title = "Files", + IsCollapsable = false, + Proportion = Double.NaN, + //ActiveDockable = untitledFileViewModel, + VisibleDockables = CreateList + ( + //untitledFileViewModel + ), + CanCreateDocument = true + }; + + MesProportionalDock tools = new() + { + Proportion = 0.2, + Orientation = Orientation.Vertical, + VisibleDockables = CreateList + ( + new MesToolDock + { + //ActiveDockable = findViewModel, + VisibleDockables = CreateList + ( + //findViewModel + ), + Alignment = Alignment.Right, + GripMode = GripMode.Visible + }, + new MesProportionalDockSplitter(), + new MesToolDock + { + //ActiveDockable = replaceViewModel, + VisibleDockables = CreateList + ( + //replaceViewModel + ), + Alignment = Alignment.Right, + GripMode = GripMode.Visible + } + ) + }; + + IRootDock windowLayout = CreateRootDock(); + windowLayout.Title = "Default"; + MesProportionalDock windowLayoutContent = new() + { + Orientation = Orientation.Horizontal, + IsCollapsable = false, + VisibleDockables = CreateList + ( + documentDock, + new MesProportionalDockSplitter(), + tools + ) + }; + windowLayout.IsCollapsable = false; + windowLayout.VisibleDockables = CreateList(windowLayoutContent); + windowLayout.ActiveDockable = windowLayoutContent; + + IRootDock rootDock = CreateRootDock(); + + rootDock.IsCollapsable = false; + rootDock.VisibleDockables = CreateList(windowLayout); + rootDock.ActiveDockable = windowLayout; + rootDock.DefaultDockable = windowLayout; + + _documentDock = documentDock; + DocumentDock = documentDock; + _rootDock = rootDock; + //_findTool = findViewModel; + //_replaceTool = replaceViewModel; + + return rootDock; + } + +#warning disable CreateLayout + //public IRootDock CreateLayout() => CreateRootDock(); public IList CreateList(params T[] items) => new ObservableCollection(items); @@ -311,18 +363,18 @@ public virtual IDock CreateSplitLayout(IDock dock, IDockable dockable, DockOpera } } - var containerProportion = dock.Proportion; - dock.Proportion = double.NaN; + Double containerProportion = dock.Proportion; + dock.Proportion = Double.NaN; - var layout = CreateProportionalDock(); + IProportionalDock layout = CreateProportionalDock(); layout.Id = nameof(IProportionalDock); layout.Title = nameof(IProportionalDock); layout.VisibleDockables = CreateList(); layout.Proportion = containerProportion; - var splitter = CreateSplitterDockable(); - splitter.Id = nameof(ISplitterDockable); - splitter.Title = nameof(ISplitterDockable); + IProportionalDockSplitter splitter = CreateProportionalDockSplitter(); + splitter.Id = nameof(IProportionalDockSplitter); + splitter.Title = nameof(IProportionalDockSplitter); switch (operation) { @@ -389,14 +441,14 @@ public virtual IDock CreateSplitLayout(IDock dock, IDockable dockable, DockOpera return layout; } - public ISplitterDockable CreateSplitterDockable() => new MesSplitterDockable(); + public IProportionalDockSplitter CreateProportionalDockSplitter() => new MesProportionalDockSplitter(); public IToolDock CreateToolDock() => new MesToolDock(); public IDockWindow CreateWindowFrom(IDockable dockable) { IDockable? target; - bool topmost; + Boolean topmost; switch (dockable) { @@ -483,7 +535,7 @@ public IDockWindow CreateWindowFrom(IDockable dockable) } } - var root = CreateRootDock(); + IRootDock root = CreateRootDock(); root.Id = nameof(IRootDock); root.Title = nameof(IRootDock); root.VisibleDockables = CreateList(); @@ -496,11 +548,11 @@ public IDockWindow CreateWindowFrom(IDockable dockable) } root.Owner = null; - var window = CreateDockWindow(); + IDockWindow window = CreateDockWindow(); window.Id = nameof(IDockWindow); window.Title = ""; - window.Width = double.NaN; - window.Height = double.NaN; + window.Width = Double.NaN; + window.Height = Double.NaN; window.Topmost = topmost; window.Layout = root; @@ -518,7 +570,7 @@ public IDockable FindDockable(IDock dock, Func predicate) if (dock.VisibleDockables is not null) { - foreach (var dockable in dock.VisibleDockables) + foreach (IDockable dockable in dock.VisibleDockables) { if (predicate(dockable)) { @@ -527,7 +579,7 @@ public IDockable FindDockable(IDock dock, Func predicate) if (dockable is IDock childDock) { - var result = FindDockable(childDock, predicate); + IDockable result = FindDockable(childDock, predicate); if (result is not null) { return result; @@ -550,7 +602,7 @@ public IDockable FindDockable(IDock dock, Func predicate) return window.Layout; } - var result = FindDockable(window.Layout, predicate); + IDockable result = FindDockable(window.Layout, predicate); if (result is not null) { return result; @@ -567,11 +619,9 @@ public virtual IRootDock FindRoot(IDockable dockable, Func p { return null; } - if (dockable.Owner is IRootDock rootDock && predicate(rootDock)) - { - return rootDock; - } - return FindRoot(dockable.Owner, predicate); + return dockable.Owner is IRootDock rootDock && predicate(rootDock) + ? rootDock + : FindRoot(dockable.Owner, predicate); } public void FloatDockable(IDockable dockable) @@ -581,8 +631,8 @@ public void FloatDockable(IDockable dockable) return; } - dock.GetPointerScreenPosition(out var dockPointerScreenX, out Double dockPointerScreenY); - dockable.GetPointerScreenPosition(out var dockablePointerScreenX, out Double dockablePointerScreenY); + dock.GetPointerScreenPosition(out Double dockPointerScreenX, out Double dockPointerScreenY); + dockable.GetPointerScreenPosition(out Double dockablePointerScreenX, out Double dockablePointerScreenY); if (Double.IsNaN(dockablePointerScreenX)) { @@ -593,8 +643,8 @@ public void FloatDockable(IDockable dockable) dockablePointerScreenY = dockPointerScreenY; } - dock.GetVisibleBounds(out var ownerX, out var ownerY, out var ownerWidth, out var ownerHeight); - dockable.GetVisibleBounds(out var dockableX, out var dockableY, out var dockableWidth, out var dockableHeight); + dock.GetVisibleBounds(out Double ownerX, out Double ownerY, out Double ownerWidth, out Double ownerHeight); + dockable.GetVisibleBounds(out Double dockableX, out Double dockableY, out Double dockableWidth, out Double dockableHeight); if (Double.IsNaN(dockablePointerScreenX)) { @@ -618,10 +668,9 @@ public void FloatDockable(IDockable dockable) public Object GetContext(String id) { - if (!String.IsNullOrEmpty(id)) + if (!String.IsNullOrEmpty(id) && ContextLocator != null) { - Func locator = null; - if (ContextLocator.TryGetValue(id, out locator) == true) + if (ContextLocator.TryGetValue(id, out Func locator)) { return locator.Invoke(); } @@ -631,7 +680,7 @@ public Object GetContext(String id) public virtual T GetDockable(String id) where T : class, IDockable { - if (!String.IsNullOrEmpty(id)) + if (!String.IsNullOrEmpty(id) && DockableLocator != null) { if (DockableLocator.TryGetValue(id, out Func locator)) { @@ -645,8 +694,7 @@ public IHostWindow GetHostWindow(String id) { if (!String.IsNullOrEmpty(id)) { - Func locator = null; - if (HostWindowLocator.TryGetValue(id, out locator) == true) + if (HostWindowLocator.TryGetValue(id, out Func locator)) { return locator.Invoke(); } @@ -654,7 +702,7 @@ public IHostWindow GetHostWindow(String id) return null; } - public void InitLayout(IDockable layout) + public virtual void InitLayout(IDockable layout) { UpdateDockable(layout, null); @@ -674,27 +722,27 @@ public void InitLayout(IDockable layout) } } - ContextLocator = new Dictionary> + ContextLocator = new Dictionary> { - ["Find"] = () => layout, - ["Replace"] = () => layout + //["Find"] = () => layout, + //["Replace"] = () => layout }; - DockableLocator = new Dictionary>() + DockableLocator = new Dictionary>() { ["Root"] = () => _rootDock, ["Files"] = () => _documentDock, - ["Find"] = () => _findTool, - ["Replace"] = () => _replaceTool + //["Find"] = () => _findTool, + //["Replace"] = () => _replaceTool }; - HostWindowLocator = new Dictionary> + HostWindowLocator = new Dictionary> { [nameof(IDockWindow)] = () => new HostWindow() }; } - public virtual void InsertDockable(IDock dock, IDockable dockable, int index) + public virtual void InsertDockable(IDock dock, IDockable dockable, Int32 index) { if (index >= 0) { @@ -712,7 +760,7 @@ public virtual void MoveDockable(IDock dock, IDockable sourceDockable, IDockable return; } - var sourceIndex = dock.VisibleDockables.IndexOf(sourceDockable); + Int32 sourceIndex = dock.VisibleDockables.IndexOf(sourceDockable); Int32 targetIndex = dock.VisibleDockables.IndexOf(targetDockable); if (sourceIndex >= 0 && targetIndex >= 0 && sourceIndex != targetIndex) @@ -737,15 +785,15 @@ public void MoveDockable(IDock sourceDock, IDock targetDock, IDockable sourceDoc } } - var isSameOwner = sourceDock == targetDock; + Boolean isSameOwner = sourceDock == targetDock; - var targetIndex = 0; + Int32 targetIndex = 0; if (sourceDock.VisibleDockables is not null && targetDock.VisibleDockables is not null && targetDock.VisibleDockables.Count > 0) { if (isSameOwner) { - var sourceIndex = sourceDock.VisibleDockables.IndexOf(sourceDockable); + Int32 sourceIndex = sourceDock.VisibleDockables.IndexOf(sourceDockable); if (targetDockable is not null) { @@ -786,7 +834,7 @@ public void MoveDockable(IDock sourceDock, IDock targetDock, IDockable sourceDoc { if (isSameOwner) { - var sourceIndex = sourceDock.VisibleDockables.IndexOf(sourceDockable); + Int32 sourceIndex = sourceDock.VisibleDockables.IndexOf(sourceDockable); if (sourceIndex < targetIndex) { targetDock.VisibleDockables.Insert(targetIndex + 1, sourceDockable); @@ -797,7 +845,7 @@ public void MoveDockable(IDock sourceDock, IDock targetDock, IDockable sourceDoc } else { - var removeIndex = sourceIndex + 1; + Int32 removeIndex = sourceIndex + 1; if (targetDock.VisibleDockables.Count + 1 > removeIndex) { targetDock.VisibleDockables.Insert(targetIndex, sourceDockable); @@ -907,8 +955,8 @@ public virtual void PinDockable(IDockable dockable) { case IToolDock toolDock: { - var isVisible = false; - var isPinned = false; + Boolean isVisible = false; + Boolean isPinned = false; if (toolDock.VisibleDockables is not null) { @@ -966,14 +1014,14 @@ public virtual void PinDockable(IDockable dockable) } } - public void RemoveDockable(IDockable dockable, bool collapse) + public void RemoveDockable(IDockable dockable, Boolean collapse) { if (dockable.Owner is not IDock dock || dock.VisibleDockables is null) { return; } - var index = dock.VisibleDockables.IndexOf(dockable); + Int32 index = dock.VisibleDockables.IndexOf(dockable); if (index < 0) { return; @@ -982,11 +1030,11 @@ public void RemoveDockable(IDockable dockable, bool collapse) dock.VisibleDockables.Remove(dockable); OnDockableRemoved(dockable); - var indexActiveDockable = index > 0 ? index - 1 : 0; + Int32 indexActiveDockable = index > 0 ? index - 1 : 0; if (dock.VisibleDockables.Count > 0) { - var nextActiveDockable = dock.VisibleDockables[indexActiveDockable]; - dock.ActiveDockable = nextActiveDockable is not ISplitterDockable ? nextActiveDockable : null; + IDockable nextActiveDockable = dock.VisibleDockables[indexActiveDockable]; + dock.ActiveDockable = nextActiveDockable is not IProportionalDockSplitter ? nextActiveDockable : null; } else { @@ -996,7 +1044,7 @@ public void RemoveDockable(IDockable dockable, bool collapse) if (dock.VisibleDockables.Count == 1) { IDockable dockable0 = dock.VisibleDockables[0]; - if (dockable0 is ISplitterDockable splitter0) + if (dockable0 is IProportionalDockSplitter splitter0) { RemoveDockable(splitter0, false); } @@ -1006,11 +1054,11 @@ public void RemoveDockable(IDockable dockable, bool collapse) { IDockable dockable0 = dock.VisibleDockables[0]; IDockable dockable1 = dock.VisibleDockables[1]; - if (dockable0 is ISplitterDockable splitter0) + if (dockable0 is IProportionalDockSplitter splitter0) { RemoveDockable(splitter0, false); } - if (dockable1 is ISplitterDockable splitter1) + if (dockable1 is IProportionalDockSplitter splitter1) { RemoveDockable(splitter1, false); } @@ -1079,10 +1127,10 @@ public void SplitToDock(IDock dock, IDockable dockable, DockOperation operation) { if (dock.Owner is IDock ownerDock && ownerDock.VisibleDockables is { }) { - var index = ownerDock.VisibleDockables.IndexOf(dock); + Int32 index = ownerDock.VisibleDockables.IndexOf(dock); if (index >= 0) { - var layout = CreateSplitLayout(dock, dockable, operation); + IDock layout = CreateSplitLayout(dock, dockable, operation); ownerDock.VisibleDockables.RemoveAt(index); OnDockableRemoved(dockable); ownerDock.VisibleDockables.Insert(index, layout); @@ -1109,7 +1157,7 @@ public virtual void SplitToWindow(IDock dock, IDockable dockable, Double x, Doub RemoveDockable(dockable, true); - var window = CreateWindowFrom(dockable); + IDockWindow window = CreateWindowFrom(dockable); if (window is not null) { AddWindow(rootDock, window); @@ -1154,13 +1202,13 @@ public void SwapDockable(IDock sourceDock, IDock targetDock, IDockable sourceDoc return; } - var sourceIndex = sourceDock.VisibleDockables.IndexOf(sourceDockable); - var targetIndex = targetDock.VisibleDockables.IndexOf(targetDockable); + Int32 sourceIndex = sourceDock.VisibleDockables.IndexOf(sourceDockable); + Int32 targetIndex = targetDock.VisibleDockables.IndexOf(targetDockable); if (sourceIndex >= 0 && targetIndex >= 0) { - var originalSourceDockable = sourceDock.VisibleDockables[sourceIndex]; - var originalTargetDockable = targetDock.VisibleDockables[targetIndex]; + IDockable originalSourceDockable = sourceDock.VisibleDockables[sourceIndex]; + IDockable originalTargetDockable = targetDock.VisibleDockables[targetIndex]; sourceDock.VisibleDockables[sourceIndex] = originalTargetDockable; targetDock.VisibleDockables[targetIndex] = originalSourceDockable; @@ -1190,7 +1238,7 @@ public virtual void UpdateDockable(IDockable dockable, IDockable owner) if (dock.VisibleDockables is not null) { - foreach (var child in dock.VisibleDockables) + foreach (IDockable child in dock.VisibleDockables) { UpdateDockable(child, dockable); } @@ -1199,9 +1247,10 @@ public virtual void UpdateDockable(IDockable dockable, IDockable owner) if (dockable is IRootDock rootDock) { + rootDock.Factory = this; if (rootDock.Windows is not null) { - foreach (var child in rootDock.Windows) + foreach (IDockWindow child in rootDock.Windows) { UpdateDockWindow(child, dockable); } @@ -1226,10 +1275,11 @@ public virtual void UpdateDockWindow(IDockWindow window, IDockable owner) } } - private void SetIsActive(IDockable dockable, bool active) + private void SetIsActive(IDockable dockable, Boolean active) { if (dockable is IDock dock) { + dock.Factory = this; dock.IsActive = active; } } diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesDocumentWrapper.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesDocumentWrapper.cs index 329d6024..00113401 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesDocumentWrapper.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/ViewModels/MesDocumentWrapper.cs @@ -9,10 +9,12 @@ namespace MinoriEditorShell.Platforms.Avalonia.ViewModels { internal class MesDocumentWrapper : MesDockableBase, IDocument { - private IMesDocument docViewModel; + private IMesDocument _docViewModel; - public MesDocumentWrapper(IMesDocument docViewModel) => this.docViewModel = docViewModel; - - public IMesDocument ViewModel { get; set; } + public MesDocumentWrapper(IMesDocument docViewModel) + { + _docViewModel = docViewModel; + Context = _docViewModel.View; + } } } \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesApplication.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesApplication.cs index 7a7b074c..dcb220ca 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesApplication.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesApplication.cs @@ -1,5 +1,6 @@ using Avalonia; using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Controls.Templates; using Avalonia.Threading; using MvvmCross; using MvvmCross.Core; @@ -18,14 +19,15 @@ public abstract class MesApplication : Application /// /// Main application class interface /// - protected MesApplication() : base() => RegisterSetup(); - - public virtual void ApplicationInitialized() + protected MesApplication() : base() { - RunAppStart(); + DataTemplates.Add(new ViewTemplate()); + RegisterSetup(); } - protected virtual void RunAppStart(object hint = null) + public virtual void ApplicationInitialized() => RunAppStart(); + + protected virtual void RunAppStart(Object hint = null) { if (Mvx.IoCProvider.TryResolve(out IMvxAppStart startup) && !startup.IsStarted) { @@ -33,16 +35,13 @@ protected virtual void RunAppStart(object hint = null) } } - protected virtual object GetAppStartHint(object hint = null) - { - return hint; - } + protected virtual Object GetAppStartHint(Object hint = null) => hint; protected abstract void RegisterSetup(); } /// - /// This is an Generics helper for MesApplication for + /// This is an Generics helper for MesApplication for /// /// /// @@ -55,4 +54,4 @@ public class MesApplication : MesApplication /// protected override void RegisterSetup() => this.RegisterSetupType(); } -} +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.axaml b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.axaml index f0997946..d95922f4 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.axaml +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.axaml @@ -4,10 +4,13 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:idc="clr-namespace:Dock.Avalonia.Controls;assembly=Dock.Avalonia" + xmlns:views="using:MinoriEditorShell.Platforms.Avalonia.Views" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" Background="LightBlue" x:Class="MinoriEditorShell.Platforms.Avalonia.Views.MesDocumentManagerView"> - - + + + + \ No newline at end of file diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.axaml.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.axaml.cs index bb5fa2fd..36da5426 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.axaml.cs +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/MesDocumentManagerView.axaml.cs @@ -17,13 +17,13 @@ public partial class MesDocumentManagerView : UserControl, IMesDocumentManagerVi { public MesDocumentManagerView() { - InitializeComponent(); - AddHandler(DragDrop.DropEvent, Drop); - AddHandler(DragDrop.DragOverEvent, DragOver); - IMesDocumentManager manager = Mvx.IoCProvider.Resolve(); //manager.UpdateFloatingWindows += Manager_UpdateFloatingWindows; DataContext = (MesDocumentManagerViewModel)manager; + + InitializeComponent(); + AddHandler(DragDrop.DropEvent, Drop); + AddHandler(DragDrop.DragOverEvent, DragOver); } private void DragOver(Object sender, DragEventArgs e) diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/Views/ViewTemplate.cs b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/ViewTemplate.cs new file mode 100644 index 00000000..2882f60c --- /dev/null +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/Views/ViewTemplate.cs @@ -0,0 +1,22 @@ +using Avalonia.Controls; +using Avalonia.Controls.Templates; +using MinoriEditorShell.Platforms.Avalonia.ViewModels; +using System; + +namespace MinoriEditorShell.Platforms.Avalonia.Views +{ + public class ViewTemplate : IDataTemplate + { + public IControl Build(Object param) + { + if (param is MesDocumentWrapper mdw) + { + return (IControl)mdw.Context; + } + return null; + } + + public Boolean Match(Object data) => + data is MesDocumentWrapper; + } +} \ No newline at end of file diff --git a/Modules/MinoriEditorShell/MinoriEditorShell.csproj b/Modules/MinoriEditorShell/MinoriEditorShell.csproj index 2fcf1a4c..5248aa00 100644 --- a/Modules/MinoriEditorShell/MinoriEditorShell.csproj +++ b/Modules/MinoriEditorShell/MinoriEditorShell.csproj @@ -24,15 +24,16 @@ - - - - + + + + + PublicSettingsSingleFileGenerator From 21f0ad70d977b2dfbe814f84b9fe0a534c74a49e Mon Sep 17 00:00:00 2001 From: Mark Kromis <143529142+mkromis@users.noreply.github.com> Date: Sun, 3 Jul 2022 20:59:05 -0400 Subject: [PATCH 68/68] nuget updates --- .../SimpleDemo.Avalonia.csproj | 12 ++++---- MinoriEditorShell-Avalonia.sln | 30 +++++++++---------- ...inoriEditorShell.Platforms.Avalonia.csproj | 23 +++++++------- .../MinoriEditorShell.csproj | 10 ++----- 4 files changed, 36 insertions(+), 39 deletions(-) diff --git a/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj b/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj index 42370574..4688dd4e 100644 --- a/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj +++ b/Demos/SimpleDemo/SimpleDemo.Avalonia/SimpleDemo.Avalonia.csproj @@ -8,12 +8,12 @@ - - - - - - + + + + + + diff --git a/MinoriEditorShell-Avalonia.sln b/MinoriEditorShell-Avalonia.sln index 2720fa9f..1cba21c4 100644 --- a/MinoriEditorShell-Avalonia.sln +++ b/MinoriEditorShell-Avalonia.sln @@ -13,10 +13,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SimpleDemo", "SimpleDemo", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleDemo.Core", "Demos\SimpleDemo\SimpleDemo.Core\SimpleDemo.Core.csproj", "{5D755878-EA31-4D57-B5D9-D36EA9275DA9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MinoriEditorShell.Platforms.Avolonia", "Modules\MinoriEditorShell.Platforms.Avalonia\MinoriEditorShell.Platforms.Avolonia.csproj", "{761A0C29-1CBC-4AB0-AB90-5899136CAEB6}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleDemo.Avalonia", "Demos\SimpleDemo\SimpleDemo.Avalonia\SimpleDemo.Avalonia.csproj", "{4AEE5668-722A-4799-9399-DBF9023D14F5}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MinoriEditorShell.Platforms.Avalonia", "Modules\MinoriEditorShell.Platforms.Avalonia\MinoriEditorShell.Platforms.Avalonia.csproj", "{CCFF52CE-0ECB-4135-946D-D249DE58AA6D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -54,18 +54,6 @@ Global {5D755878-EA31-4D57-B5D9-D36EA9275DA9}.Release|x64.Build.0 = Release|Any CPU {5D755878-EA31-4D57-B5D9-D36EA9275DA9}.Release|x86.ActiveCfg = Release|Any CPU {5D755878-EA31-4D57-B5D9-D36EA9275DA9}.Release|x86.Build.0 = Release|Any CPU - {761A0C29-1CBC-4AB0-AB90-5899136CAEB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {761A0C29-1CBC-4AB0-AB90-5899136CAEB6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {761A0C29-1CBC-4AB0-AB90-5899136CAEB6}.Debug|x64.ActiveCfg = Debug|Any CPU - {761A0C29-1CBC-4AB0-AB90-5899136CAEB6}.Debug|x64.Build.0 = Debug|Any CPU - {761A0C29-1CBC-4AB0-AB90-5899136CAEB6}.Debug|x86.ActiveCfg = Debug|Any CPU - {761A0C29-1CBC-4AB0-AB90-5899136CAEB6}.Debug|x86.Build.0 = Debug|Any CPU - {761A0C29-1CBC-4AB0-AB90-5899136CAEB6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {761A0C29-1CBC-4AB0-AB90-5899136CAEB6}.Release|Any CPU.Build.0 = Release|Any CPU - {761A0C29-1CBC-4AB0-AB90-5899136CAEB6}.Release|x64.ActiveCfg = Release|Any CPU - {761A0C29-1CBC-4AB0-AB90-5899136CAEB6}.Release|x64.Build.0 = Release|Any CPU - {761A0C29-1CBC-4AB0-AB90-5899136CAEB6}.Release|x86.ActiveCfg = Release|Any CPU - {761A0C29-1CBC-4AB0-AB90-5899136CAEB6}.Release|x86.Build.0 = Release|Any CPU {4AEE5668-722A-4799-9399-DBF9023D14F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4AEE5668-722A-4799-9399-DBF9023D14F5}.Debug|Any CPU.Build.0 = Debug|Any CPU {4AEE5668-722A-4799-9399-DBF9023D14F5}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -78,12 +66,24 @@ Global {4AEE5668-722A-4799-9399-DBF9023D14F5}.Release|x64.Build.0 = Release|Any CPU {4AEE5668-722A-4799-9399-DBF9023D14F5}.Release|x86.ActiveCfg = Release|Any CPU {4AEE5668-722A-4799-9399-DBF9023D14F5}.Release|x86.Build.0 = Release|Any CPU + {CCFF52CE-0ECB-4135-946D-D249DE58AA6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CCFF52CE-0ECB-4135-946D-D249DE58AA6D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CCFF52CE-0ECB-4135-946D-D249DE58AA6D}.Debug|x64.ActiveCfg = Debug|Any CPU + {CCFF52CE-0ECB-4135-946D-D249DE58AA6D}.Debug|x64.Build.0 = Debug|Any CPU + {CCFF52CE-0ECB-4135-946D-D249DE58AA6D}.Debug|x86.ActiveCfg = Debug|Any CPU + {CCFF52CE-0ECB-4135-946D-D249DE58AA6D}.Debug|x86.Build.0 = Debug|Any CPU + {CCFF52CE-0ECB-4135-946D-D249DE58AA6D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CCFF52CE-0ECB-4135-946D-D249DE58AA6D}.Release|Any CPU.Build.0 = Release|Any CPU + {CCFF52CE-0ECB-4135-946D-D249DE58AA6D}.Release|x64.ActiveCfg = Release|Any CPU + {CCFF52CE-0ECB-4135-946D-D249DE58AA6D}.Release|x64.Build.0 = Release|Any CPU + {CCFF52CE-0ECB-4135-946D-D249DE58AA6D}.Release|x86.ActiveCfg = Release|Any CPU + {CCFF52CE-0ECB-4135-946D-D249DE58AA6D}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {C7863C93-477E-445B-98A1-F09454583537} = {D9E73129-B533-484C-AEFC-7DA139610289} {40760750-D249-419D-B947-BB18B5A7FC4B} = {3787F54F-76A2-47AE-AA26-79065C6CE52F} {5D755878-EA31-4D57-B5D9-D36EA9275DA9} = {40760750-D249-419D-B947-BB18B5A7FC4B} - {761A0C29-1CBC-4AB0-AB90-5899136CAEB6} = {D9E73129-B533-484C-AEFC-7DA139610289} {4AEE5668-722A-4799-9399-DBF9023D14F5} = {40760750-D249-419D-B947-BB18B5A7FC4B} + {CCFF52CE-0ECB-4135-946D-D249DE58AA6D} = {D9E73129-B533-484C-AEFC-7DA139610289} EndGlobalSection EndGlobal diff --git a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj index a2f52d5e..aa5204f1 100644 --- a/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj +++ b/Modules/MinoriEditorShell.Platforms.Avalonia/MinoriEditorShell.Platforms.Avalonia.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + netstandard2.0 MinoriEditorStudio is an application shell similar in concept to the Visual Studio Shell. This uses AvalonDock and has an MVVM architecture based on MvvmCross. @@ -9,7 +9,6 @@ Copyright 2019 https://github.com/TorisanKitsune/MinoriEditorShell https://github.com/TorisanKitsune/MinoriEditorShell - git .net40 netcoreapp AvaloniaUI MvvmCross AvalonDock Visual Studio IDE Shell true @@ -30,18 +29,20 @@ - + - - - - - - - - + + + + + + + + + + \ No newline at end of file diff --git a/Modules/MinoriEditorShell/MinoriEditorShell.csproj b/Modules/MinoriEditorShell/MinoriEditorShell.csproj index 5248aa00..d11d446a 100644 --- a/Modules/MinoriEditorShell/MinoriEditorShell.csproj +++ b/Modules/MinoriEditorShell/MinoriEditorShell.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + netstandard2.0 MinoriEditorStudio is an application shell similar in concept to the Visual Studio Shell. This uses AvalonDock and has an MVVM architecture based on MvvmCross. @@ -9,7 +9,6 @@ Copyright 2019 https://github.com/TorisanKitsune/MinoriEditorShell https://github.com/TorisanKitsune/MinoriEditorShell - git .net40 WPF MvvmCross AvalonDock Visual Studio IDE Shell true @@ -24,16 +23,13 @@ + + - - - - - PublicSettingsSingleFileGenerator