From 5921f8ab54433312274681710cf4e7f84d2d64e0 Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Sun, 17 Nov 2019 23:17:23 +0100 Subject: [PATCH] Added the views and VM's I'm planning to use --- .../Artemis.Plugins.Devices.Corsair.csproj | 4 +- .../CorsairDevice.cs | 4 +- .../x64/{CUESDK.dll => CUESDK.x64_2017.dll} | Bin .../x86/{CUESDK.dll => CUESDK_2017.dll} | Bin src/Artemis.UI/Artemis.UI.csproj | 35 ++++++++++++ src/Artemis.UI/SDK bug | 50 +++++++++++++++++ .../Screens/Module/ModuleRootView.xaml | 6 ++- .../Screens/Module/ModuleRootViewModel.cs | 30 ++++++++--- .../DisplayConditionView.xaml | 12 +++++ .../DisplayConditionViewModel.cs | 12 +++++ .../DisplayConditionsView.xaml | 12 +++++ .../DisplayConditionsViewModel.cs | 12 +++++ .../ElementPropertiesView.xaml | 12 +++++ .../ElementPropertiesViewModel.cs | 12 +++++ .../ElementPropertyView.xaml | 12 +++++ .../ElementPropertyViewModel.cs | 12 +++++ .../LayerElements/LayerElementView.xaml | 12 +++++ .../LayerElements/LayerElementViewModel.cs | 12 +++++ .../LayerElements/LayerElementsView.xaml | 12 +++++ .../LayerElements/LayerElementsViewModel.cs | 12 +++++ .../ProfileEditor/Layers/LayersView.xaml | 12 +++++ .../ProfileEditor/Layers/LayersViewModel.cs | 12 +++++ .../ProfileEditor/ProfileEditorView.xaml | 29 +++++++++- .../ProfileEditor/ProfileEditorViewModel.cs | 12 +++-- src/Artemis.UI/Screens/RootView.xaml | 51 ++++++++++++------ src/Artemis.UI/Screens/RootViewModel.cs | 26 +++++---- 26 files changed, 372 insertions(+), 43 deletions(-) rename src/Artemis.Plugins.Devices.Corsair/x64/{CUESDK.dll => CUESDK.x64_2017.dll} (100%) rename src/Artemis.Plugins.Devices.Corsair/x86/{CUESDK.dll => CUESDK_2017.dll} (100%) create mode 100644 src/Artemis.UI/SDK bug create mode 100644 src/Artemis.UI/Screens/Module/ProfileEditor/DisplayConditions/DisplayConditionView.xaml create mode 100644 src/Artemis.UI/Screens/Module/ProfileEditor/DisplayConditions/DisplayConditionViewModel.cs create mode 100644 src/Artemis.UI/Screens/Module/ProfileEditor/DisplayConditions/DisplayConditionsView.xaml create mode 100644 src/Artemis.UI/Screens/Module/ProfileEditor/DisplayConditions/DisplayConditionsViewModel.cs create mode 100644 src/Artemis.UI/Screens/Module/ProfileEditor/ElementProperties/ElementPropertiesView.xaml create mode 100644 src/Artemis.UI/Screens/Module/ProfileEditor/ElementProperties/ElementPropertiesViewModel.cs create mode 100644 src/Artemis.UI/Screens/Module/ProfileEditor/ElementProperties/ElementPropertyView.xaml create mode 100644 src/Artemis.UI/Screens/Module/ProfileEditor/ElementProperties/ElementPropertyViewModel.cs create mode 100644 src/Artemis.UI/Screens/Module/ProfileEditor/LayerElements/LayerElementView.xaml create mode 100644 src/Artemis.UI/Screens/Module/ProfileEditor/LayerElements/LayerElementViewModel.cs create mode 100644 src/Artemis.UI/Screens/Module/ProfileEditor/LayerElements/LayerElementsView.xaml create mode 100644 src/Artemis.UI/Screens/Module/ProfileEditor/LayerElements/LayerElementsViewModel.cs create mode 100644 src/Artemis.UI/Screens/Module/ProfileEditor/Layers/LayersView.xaml create mode 100644 src/Artemis.UI/Screens/Module/ProfileEditor/Layers/LayersViewModel.cs diff --git a/src/Artemis.Plugins.Devices.Corsair/Artemis.Plugins.Devices.Corsair.csproj b/src/Artemis.Plugins.Devices.Corsair/Artemis.Plugins.Devices.Corsair.csproj index b50d61617..a35f6590c 100644 --- a/src/Artemis.Plugins.Devices.Corsair/Artemis.Plugins.Devices.Corsair.csproj +++ b/src/Artemis.Plugins.Devices.Corsair/Artemis.Plugins.Devices.Corsair.csproj @@ -72,10 +72,10 @@ - + PreserveNewest - + PreserveNewest diff --git a/src/Artemis.Plugins.Devices.Corsair/CorsairDevice.cs b/src/Artemis.Plugins.Devices.Corsair/CorsairDevice.cs index 6635f8a88..e20f81def 100644 --- a/src/Artemis.Plugins.Devices.Corsair/CorsairDevice.cs +++ b/src/Artemis.Plugins.Devices.Corsair/CorsairDevice.cs @@ -20,8 +20,8 @@ namespace Artemis.Plugins.Devices.Corsair public override void EnablePlugin() { PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(CorsairRGBDevice<>), sender, args); - CorsairDeviceProvider.PossibleX64NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x64", "CUESDK.dll")); - CorsairDeviceProvider.PossibleX86NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x86", "CUESDK.dll")); + CorsairDeviceProvider.PossibleX64NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x64", "CUESDK.x64_2017.dll")); + CorsairDeviceProvider.PossibleX86NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x86", "CUESDK_2017.dll")); _rgbService.AddDeviceProvider(DeviceProvider); } diff --git a/src/Artemis.Plugins.Devices.Corsair/x64/CUESDK.dll b/src/Artemis.Plugins.Devices.Corsair/x64/CUESDK.x64_2017.dll similarity index 100% rename from src/Artemis.Plugins.Devices.Corsair/x64/CUESDK.dll rename to src/Artemis.Plugins.Devices.Corsair/x64/CUESDK.x64_2017.dll diff --git a/src/Artemis.Plugins.Devices.Corsair/x86/CUESDK.dll b/src/Artemis.Plugins.Devices.Corsair/x86/CUESDK_2017.dll similarity index 100% rename from src/Artemis.Plugins.Devices.Corsair/x86/CUESDK.dll rename to src/Artemis.Plugins.Devices.Corsair/x86/CUESDK_2017.dll diff --git a/src/Artemis.UI/Artemis.UI.csproj b/src/Artemis.UI/Artemis.UI.csproj index c7650c883..b1c65bcf8 100644 --- a/src/Artemis.UI/Artemis.UI.csproj +++ b/src/Artemis.UI/Artemis.UI.csproj @@ -174,6 +174,13 @@ True Resources.resx + + + + + + + @@ -206,6 +213,34 @@ Code + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/src/Artemis.UI/SDK bug b/src/Artemis.UI/SDK bug new file mode 100644 index 000000000..cbf620a34 --- /dev/null +++ b/src/Artemis.UI/SDK bug @@ -0,0 +1,50 @@ +Ok so with the following code: + +```cpp +bool errorCheck(const std::string &msg) { + auto error = CorsairGetLastError(); + if (error != CorsairError::CE_Success) { + std::cerr << msg << " (Error: " << toString(error) << ')' << std::endl; + return true; + } + + return false; +} + +int main(int argc, char *argv[]) +{ + CorsairPerformProtocolHandshake(); + if (errorCheck("Handshake error")) { + getchar(); + return -1; + } + + const auto devicesCount = CorsairGetDeviceCount(); + for (int i = 0; i < devicesCount; ++i) { + const auto info = CorsairGetDeviceInfo(i); + if (!info) { + errorCheck("Get device info error"); + continue; + } + + std::cout << "Model: " << info->model << "Logical layout: " << info->logicalLayout << std::endl; + } + + getchar(); + return 0; +} +``` + +I'm getting this output, which is as expected: +``` +Model: K95 RGB PLATINUMLogical layout: 13 +``` + +Then when I put the PC to full stand-by and wake it up again the code returns the following: +``` +Model: K95 RGB PLATINUMLogical layout: 0 +``` + +Windows 10 Home 1903 +iCUE v. 3.22.74 +SDK: 3.0.301 \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Module/ModuleRootView.xaml b/src/Artemis.UI/Screens/Module/ModuleRootView.xaml index 9bd2d971e..0a0582796 100644 --- a/src/Artemis.UI/Screens/Module/ModuleRootView.xaml +++ b/src/Artemis.UI/Screens/Module/ModuleRootView.xaml @@ -6,9 +6,11 @@ xmlns:dragablz="http://dragablz.net/winfx/xaml/dragablz" xmlns:s="https://github.com/canton7/Stylet" xmlns:module="clr-namespace:Artemis.UI.Screens.Module" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance module:ModuleRootViewModel}"> + @@ -17,7 +19,9 @@ - + + + diff --git a/src/Artemis.UI/Screens/Module/ModuleRootViewModel.cs b/src/Artemis.UI/Screens/Module/ModuleRootViewModel.cs index 3cf0b7fe1..a299832c5 100644 --- a/src/Artemis.UI/Screens/Module/ModuleRootViewModel.cs +++ b/src/Artemis.UI/Screens/Module/ModuleRootViewModel.cs @@ -1,4 +1,5 @@ -using Artemis.Core.Plugins.Abstract; +using System.Threading.Tasks; +using Artemis.Core.Plugins.Abstract; using Artemis.UI.Ninject.Factories; using Stylet; @@ -6,21 +7,34 @@ namespace Artemis.UI.Screens.Module { public class ModuleRootViewModel : Conductor.Collection.OneActive { + private readonly IProfileEditorViewModelFactory _profileEditorViewModelFactory; + public ModuleRootViewModel(Core.Plugins.Abstract.Module module, IProfileEditorViewModelFactory profileEditorViewModelFactory) { Module = module; + _profileEditorViewModelFactory = profileEditorViewModelFactory; - // Add the profile editor and module VMs - var profileEditor = profileEditorViewModelFactory.CreateModuleViewModel(Module); - Items.Add(profileEditor); - Items.AddRange(Module.GetViewModels()); - - // Activate the profile editor - ActiveItem = profileEditor; + Task.Run(AddTabsAsync); } public string Title => Module?.DisplayName; public Core.Plugins.Abstract.Module Module { get; } public int FixedHeaderCount => Items.Count; + + private async Task AddTabsAsync() + { + // Give the screen a moment to active without freezing the UI thread + await Task.Delay(400); + + // Create the profile editor and module VMs + var profileEditor = _profileEditorViewModelFactory.CreateModuleViewModel(Module); + var moduleViewModels = Module.GetViewModels(); + + Items.Add(profileEditor); + Items.AddRange(moduleViewModels); + + // Activate the profile editor + ActiveItem = profileEditor; + } } } \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/DisplayConditions/DisplayConditionView.xaml b/src/Artemis.UI/Screens/Module/ProfileEditor/DisplayConditions/DisplayConditionView.xaml new file mode 100644 index 000000000..0f7850149 --- /dev/null +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/DisplayConditions/DisplayConditionView.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/DisplayConditions/DisplayConditionViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/DisplayConditions/DisplayConditionViewModel.cs new file mode 100644 index 000000000..b7e1e7e9d --- /dev/null +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/DisplayConditions/DisplayConditionViewModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions +{ + public class DisplayConditionViewModel + { + } +} diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/DisplayConditions/DisplayConditionsView.xaml b/src/Artemis.UI/Screens/Module/ProfileEditor/DisplayConditions/DisplayConditionsView.xaml new file mode 100644 index 000000000..b72bf2077 --- /dev/null +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/DisplayConditions/DisplayConditionsView.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/DisplayConditions/DisplayConditionsViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/DisplayConditions/DisplayConditionsViewModel.cs new file mode 100644 index 000000000..7bf9b1a8e --- /dev/null +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/DisplayConditions/DisplayConditionsViewModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions +{ + class DisplayConditionsViewModel + { + } +} diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/ElementProperties/ElementPropertiesView.xaml b/src/Artemis.UI/Screens/Module/ProfileEditor/ElementProperties/ElementPropertiesView.xaml new file mode 100644 index 000000000..cc288498f --- /dev/null +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/ElementProperties/ElementPropertiesView.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/ElementProperties/ElementPropertiesViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/ElementProperties/ElementPropertiesViewModel.cs new file mode 100644 index 000000000..5f2db30a7 --- /dev/null +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/ElementProperties/ElementPropertiesViewModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Artemis.UI.Screens.Module.ProfileEditor.ElementProperties +{ + class ElementPropertiesViewModel + { + } +} diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/ElementProperties/ElementPropertyView.xaml b/src/Artemis.UI/Screens/Module/ProfileEditor/ElementProperties/ElementPropertyView.xaml new file mode 100644 index 000000000..717b0d49b --- /dev/null +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/ElementProperties/ElementPropertyView.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/ElementProperties/ElementPropertyViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/ElementProperties/ElementPropertyViewModel.cs new file mode 100644 index 000000000..47b1f5273 --- /dev/null +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/ElementProperties/ElementPropertyViewModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Artemis.UI.Screens.Module.ProfileEditor.ElementProperties +{ + public class ElementPropertyViewModel + { + } +} diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerElements/LayerElementView.xaml b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerElements/LayerElementView.xaml new file mode 100644 index 000000000..74cb1b04b --- /dev/null +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerElements/LayerElementView.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerElements/LayerElementViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerElements/LayerElementViewModel.cs new file mode 100644 index 000000000..fe46522df --- /dev/null +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerElements/LayerElementViewModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Artemis.UI.Screens.Module.ProfileEditor.LayerElements +{ + public class LayerElementViewModel + { + } +} diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerElements/LayerElementsView.xaml b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerElements/LayerElementsView.xaml new file mode 100644 index 000000000..f0d304dc4 --- /dev/null +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerElements/LayerElementsView.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerElements/LayerElementsViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerElements/LayerElementsViewModel.cs new file mode 100644 index 000000000..594150b1b --- /dev/null +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerElements/LayerElementsViewModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Artemis.UI.Screens.Module.ProfileEditor.LayerElements +{ + public class LayerElementsViewModel + { + } +} diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/Layers/LayersView.xaml b/src/Artemis.UI/Screens/Module/ProfileEditor/Layers/LayersView.xaml new file mode 100644 index 000000000..af0e8100a --- /dev/null +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/Layers/LayersView.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/Layers/LayersViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/Layers/LayersViewModel.cs new file mode 100644 index 000000000..6efa9ec85 --- /dev/null +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/Layers/LayersViewModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Artemis.UI.Screens.Module.ProfileEditor.Layers +{ + public class LayersViewModel + { + } +} diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorView.xaml b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorView.xaml index 5c0285449..21c6f6617 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorView.xaml +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorView.xaml @@ -17,8 +17,34 @@ + + + @@ -145,7 +171,8 @@ - + + Initializing LED visualization... diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorViewModel.cs index 99aa9d7c2..31000990c 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorViewModel.cs +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorViewModel.cs @@ -76,7 +76,10 @@ namespace Artemis.UI.Screens.Module.ProfileEditor { // Gotta call IsInitializing on the UI thread or its never gets picked up IsInitializing = true; - Devices.Add(profileDeviceViewModel); + lock (Devices) + { + Devices.Add(profileDeviceViewModel); + } }); } // Update existing devices @@ -87,8 +90,11 @@ namespace Artemis.UI.Screens.Module.ProfileEditor // Sort the devices by ZIndex Execute.OnUIThread(() => { - foreach (var device in Devices.OrderBy(d => d.ZIndex).ToList()) - Devices.Move(Devices.IndexOf(device), device.ZIndex - 1); + lock (Devices) + { + foreach (var device in Devices.OrderBy(d => d.ZIndex).ToList()) + Devices.Move(Devices.IndexOf(device), device.ZIndex - 1); + } }); } diff --git a/src/Artemis.UI/Screens/RootView.xaml b/src/Artemis.UI/Screens/RootView.xaml index 12842873b..54360be7e 100644 --- a/src/Artemis.UI/Screens/RootView.xaml +++ b/src/Artemis.UI/Screens/RootView.xaml @@ -7,6 +7,7 @@ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:s="https://github.com/canton7/Stylet" xmlns:abstract="clr-namespace:Artemis.Core.Plugins.Abstract;assembly=Artemis.Core" + xmlns:screens="clr-namespace:Artemis.UI.Screens" mc:Ignorable="d" GlowBrush="{DynamicResource AccentColorBrush}" FontFamily="{StaticResource DefaultFont}" @@ -16,6 +17,32 @@ d:DataContext="{d:DesignInstance screens:RootViewModel}" SaveWindowPosition="True" Icon="/Artemis.UI;component/Resources/logo-512.png"> + + + @@ -112,34 +139,24 @@ - + - - + +