From d5db17c0e3c1a59187f7bbec95380e9221528a4e Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Tue, 9 Apr 2019 19:38:07 +0200 Subject: [PATCH] Added some views, I really just need this code on adifferent machine --- src/Artemis.Core/Artemis.Core.csproj | 72 ++++++++++--------- src/Artemis.Core/Services/CoreService.cs | 2 +- src/Artemis.Core/Services/RgbService.cs | 20 +++++- src/Artemis.Core/app.config | 14 +++- src/Artemis.Core/packages.config | 45 ++++++------ .../Artemis.Plugins.BuiltIn.csproj | 17 +++-- .../Modules/General/GeneralModule.cs | 1 - src/Artemis.Plugins.BuiltIn/app.config | 14 +++- src/Artemis.Plugins.BuiltIn/packages.config | 7 +- src/Artemis.Storage/Artemis.Storage.csproj | 7 +- src/Artemis.UI/App.config | 14 +++- src/Artemis.UI/Artemis.UI.csproj | 50 ++++++++----- .../ColorToSolidColorBrushConverter.cs | 2 +- src/Artemis.UI/ViewModels/RootViewModel.cs | 1 + .../Settings/DeviceSettingsViewModel.cs | 25 +++++++ .../ViewModels/Settings/SettingsViewModel.cs | 29 ++++++++ .../ViewModels/SettingsViewModel.cs | 10 --- .../Views/Settings/DeviceSettingsView.xaml | 23 ++++++ .../Views/{ => Settings}/SettingsView.xaml | 13 +++- src/Artemis.UI/packages.config | 18 +++-- 20 files changed, 267 insertions(+), 117 deletions(-) create mode 100644 src/Artemis.UI/ViewModels/Settings/DeviceSettingsViewModel.cs create mode 100644 src/Artemis.UI/ViewModels/Settings/SettingsViewModel.cs delete mode 100644 src/Artemis.UI/ViewModels/SettingsViewModel.cs create mode 100644 src/Artemis.UI/Views/Settings/DeviceSettingsView.xaml rename src/Artemis.UI/Views/{ => Settings}/SettingsView.xaml (67%) diff --git a/src/Artemis.Core/Artemis.Core.csproj b/src/Artemis.Core/Artemis.Core.csproj index 659fbee6d..00277096e 100644 --- a/src/Artemis.Core/Artemis.Core.csproj +++ b/src/Artemis.Core/Artemis.Core.csproj @@ -1,5 +1,6 @@  + Debug @@ -52,31 +53,31 @@ - ..\packages\Castle.Core.4.3.1\lib\net45\Castle.Core.dll + ..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll ..\packages\CS-Script.bin.3.28.7\lib\net46\CSScriptLibrary.dll - - ..\packages\HidSharp.2.0.5\lib\net35\HidSharp.dll + + ..\packages\HidSharp.2.0.8\lib\net35\HidSharp.dll - - ..\packages\Microsoft.CodeAnalysis.Common.2.10.0\lib\netstandard1.3\Microsoft.CodeAnalysis.dll + + ..\packages\Microsoft.CodeAnalysis.Common.3.0.0\lib\netstandard2.0\Microsoft.CodeAnalysis.dll - - ..\packages\Microsoft.CodeAnalysis.CSharp.2.10.0\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.dll + + ..\packages\Microsoft.CodeAnalysis.CSharp.3.0.0\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.dll - - ..\packages\Microsoft.CodeAnalysis.CSharp.Scripting.2.10.0\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.Scripting.dll + + ..\packages\Microsoft.CodeAnalysis.CSharp.Scripting.3.0.0\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.Scripting.dll - - ..\packages\Microsoft.CodeAnalysis.Scripting.Common.2.10.0\lib\netstandard1.3\Microsoft.CodeAnalysis.Scripting.dll + + ..\packages\Microsoft.CodeAnalysis.Scripting.Common.3.0.0\lib\netstandard2.0\Microsoft.CodeAnalysis.Scripting.dll - - ..\packages\Microsoft.EntityFrameworkCore.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.dll + + ..\packages\Microsoft.EntityFrameworkCore.2.2.3\lib\netstandard2.0\Microsoft.EntityFrameworkCore.dll - - ..\packages\Microsoft.EntityFrameworkCore.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.Abstractions.dll + + ..\packages\Microsoft.EntityFrameworkCore.Abstractions.2.2.3\lib\netstandard2.0\Microsoft.EntityFrameworkCore.Abstractions.dll ..\packages\Microsoft.Extensions.Caching.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Abstractions.dll @@ -129,20 +130,20 @@ ..\packages\Remotion.Linq.2.2.0\lib\net45\Remotion.Linq.dll - - ..\packages\RGB.NET.Brushes.0.1.14\lib\net45\RGB.NET.Brushes.dll + + ..\packages\RGB.NET.Brushes.0.1.22\lib\net45\RGB.NET.Brushes.dll - - ..\packages\RGB.NET.Core.0.1.14\lib\net45\RGB.NET.Core.dll + + ..\packages\RGB.NET.Core.0.1.22\lib\net45\RGB.NET.Core.dll - - ..\packages\RGB.NET.Decorators.0.1.14\lib\net45\RGB.NET.Decorators.dll + + ..\packages\RGB.NET.Decorators.0.1.22\lib\net45\RGB.NET.Decorators.dll - - ..\packages\RGB.NET.Devices.Corsair.0.1.14\lib\net45\RGB.NET.Devices.Corsair.dll + + ..\packages\RGB.NET.Devices.Corsair.0.1.22\lib\net45\RGB.NET.Devices.Corsair.dll - - ..\packages\RGB.NET.Groups.0.1.14\lib\net45\RGB.NET.Groups.dll + + ..\packages\RGB.NET.Groups.0.1.22\lib\net45\RGB.NET.Groups.dll ..\packages\Sanford.Multimedia.Midi.Standard.6.6.0\lib\net35\Sanford.Multimedia.Midi.dll @@ -155,8 +156,8 @@ ..\packages\System.AppContext.4.3.0\lib\net46\System.AppContext.dll True - - ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll + + ..\packages\System.Buffers.4.5.0\lib\netstandard2.0\System.Buffers.dll ..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll @@ -201,11 +202,11 @@ True - ..\packages\System.Memory.4.5.1\lib\netstandard2.0\System.Memory.dll + ..\packages\System.Memory.4.5.2\lib\netstandard2.0\System.Memory.dll - - ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll + + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll ..\packages\System.Reflection.Metadata.1.6.0\lib\netstandard2.0\System.Reflection.Metadata.dll @@ -230,10 +231,10 @@ True - ..\packages\System.Text.Encoding.CodePages.4.5.0\lib\net461\System.Text.Encoding.CodePages.dll + ..\packages\System.Text.Encoding.CodePages.4.5.1\lib\net461\System.Text.Encoding.CodePages.dll - - ..\packages\System.Threading.Tasks.Extensions.4.3.0\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll + + ..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll ..\packages\System.Threading.Thread.4.3.0\lib\net46\System.Threading.Thread.dll @@ -315,13 +316,14 @@ - - + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + \ No newline at end of file diff --git a/src/Artemis.Core/Services/CoreService.cs b/src/Artemis.Core/Services/CoreService.cs index 44b921b0a..ef8cf81bf 100644 --- a/src/Artemis.Core/Services/CoreService.cs +++ b/src/Artemis.Core/Services/CoreService.cs @@ -58,7 +58,7 @@ namespace Artemis.Core.Services // Render all active modules using (var g = _rgbService.GraphicsDecorator.GetGraphics()) { - g.Clear(Color.Red); + g.Clear(Color.Black); foreach (var module in _pluginService.Plugins.Select(p => p.Plugin).OfType()) module.Render(args.DeltaTime, _rgbService.Surface, g); diff --git a/src/Artemis.Core/Services/RgbService.cs b/src/Artemis.Core/Services/RgbService.cs index ed4173d1f..abca2a892 100644 --- a/src/Artemis.Core/Services/RgbService.cs +++ b/src/Artemis.Core/Services/RgbService.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Threading.Tasks; using Artemis.Core.Events; using Artemis.Core.RGB.NET; @@ -13,6 +14,7 @@ namespace Artemis.Core.Services public class RgbService : IRgbService, IDisposable { private readonly TimerUpdateTrigger _updateTrigger; + private List _loadedDevices; public RgbService() { @@ -22,6 +24,7 @@ namespace Artemis.Core.Services // Let's throw these for now Surface.Exception += SurfaceOnException; + _loadedDevices = new List(); _updateTrigger = new TimerUpdateTrigger {UpdateFrequency = 1.0 / 30}; Surface.RegisterUpdateTrigger(_updateTrigger); } @@ -31,6 +34,7 @@ namespace Artemis.Core.Services /// public RGBSurface Surface { get; set; } + public GraphicsDecorator GraphicsDecorator { get; private set; } /// @@ -53,10 +57,24 @@ namespace Artemis.Core.Services // TODO SpoinkyNL 8-1-18: Load alignment Surface.AlignDevices(); + + lock (_loadedDevices) + { + foreach (var surfaceDevice in Surface.Devices) + { + if (!_loadedDevices.Contains(surfaceDevice)) + { + _loadedDevices.Add(surfaceDevice); + OnDeviceLoaded(new DeviceEventArgs(surfaceDevice)); + } + else + OnDeviceReloaded(new DeviceEventArgs(surfaceDevice)); + } + } }); // Apply the application wide brush and decorator - var background = new ListLedGroup(Surface.Leds) { Brush = new SolidColorBrush(new Color(255, 255, 255, 255)) }; + var background = new ListLedGroup(Surface.Leds) {Brush = new SolidColorBrush(new Color(255, 255, 255, 255))}; GraphicsDecorator = new GraphicsDecorator(background); background.Brush.AddDecorator(GraphicsDecorator); diff --git a/src/Artemis.Core/app.config b/src/Artemis.Core/app.config index 6de5fff3e..735ba3d2d 100644 --- a/src/Artemis.Core/app.config +++ b/src/Artemis.Core/app.config @@ -44,15 +44,15 @@ - + - + - + @@ -94,6 +94,14 @@ + + + + + + + + diff --git a/src/Artemis.Core/packages.config b/src/Artemis.Core/packages.config index 23d490f31..e9b85ee3a 100644 --- a/src/Artemis.Core/packages.config +++ b/src/Artemis.Core/packages.config @@ -1,16 +1,17 @@  - + - - - - - - - - - + + + + + + + + + + @@ -27,16 +28,16 @@ - - - - - + + + + + - + @@ -57,16 +58,16 @@ - - + + - + - + @@ -74,11 +75,11 @@ - + - + diff --git a/src/Artemis.Plugins.BuiltIn/Artemis.Plugins.BuiltIn.csproj b/src/Artemis.Plugins.BuiltIn/Artemis.Plugins.BuiltIn.csproj index 758cd9f3e..c84aa0a41 100644 --- a/src/Artemis.Plugins.BuiltIn/Artemis.Plugins.BuiltIn.csproj +++ b/src/Artemis.Plugins.BuiltIn/Artemis.Plugins.BuiltIn.csproj @@ -52,13 +52,22 @@ MinimumRecommendedRules.ruleset - - ..\packages\HidSharp.2.0.5\lib\net35\HidSharp.dll + + ..\packages\HidSharp.2.0.8\lib\net35\HidSharp.dll - - ..\packages\RGB.NET.Core.0.1.14\lib\net45\RGB.NET.Core.dll + + ..\packages\RGB.NET.Brushes.0.1.22\lib\net45\RGB.NET.Brushes.dll + + + ..\packages\RGB.NET.Core.0.1.22\lib\net45\RGB.NET.Core.dll + + + ..\packages\RGB.NET.Decorators.0.1.22\lib\net45\RGB.NET.Decorators.dll + + + ..\packages\RGB.NET.Groups.0.1.22\lib\net45\RGB.NET.Groups.dll ..\packages\Sanford.Multimedia.Midi.Standard.6.6.0\lib\net35\Sanford.Multimedia.Midi.dll diff --git a/src/Artemis.Plugins.BuiltIn/Modules/General/GeneralModule.cs b/src/Artemis.Plugins.BuiltIn/Modules/General/GeneralModule.cs index 01a43966e..ed7d93919 100644 --- a/src/Artemis.Plugins.BuiltIn/Modules/General/GeneralModule.cs +++ b/src/Artemis.Plugins.BuiltIn/Modules/General/GeneralModule.cs @@ -23,7 +23,6 @@ namespace Artemis.Plugins.BuiltIn.Modules.General public GeneralModule(IRgbService rgbService) { - Debugger.Break(); _rgbService = rgbService; _surface = _rgbService.Surface; _colors = new Dictionary(); diff --git a/src/Artemis.Plugins.BuiltIn/app.config b/src/Artemis.Plugins.BuiltIn/app.config index 7a8edf1b4..367494c7e 100644 --- a/src/Artemis.Plugins.BuiltIn/app.config +++ b/src/Artemis.Plugins.BuiltIn/app.config @@ -49,7 +49,7 @@ - + @@ -57,11 +57,11 @@ - + - + @@ -95,6 +95,14 @@ + + + + + + + + \ No newline at end of file diff --git a/src/Artemis.Plugins.BuiltIn/packages.config b/src/Artemis.Plugins.BuiltIn/packages.config index 3f072deb3..46aba147c 100644 --- a/src/Artemis.Plugins.BuiltIn/packages.config +++ b/src/Artemis.Plugins.BuiltIn/packages.config @@ -1,7 +1,10 @@  - - + + + + + diff --git a/src/Artemis.Storage/Artemis.Storage.csproj b/src/Artemis.Storage/Artemis.Storage.csproj index bb7b5f6cf..1f2cd2c2a 100644 --- a/src/Artemis.Storage/Artemis.Storage.csproj +++ b/src/Artemis.Storage/Artemis.Storage.csproj @@ -6,10 +6,9 @@ - - - - + + + diff --git a/src/Artemis.UI/App.config b/src/Artemis.UI/App.config index a3fcf96ed..39dcaca51 100644 --- a/src/Artemis.UI/App.config +++ b/src/Artemis.UI/App.config @@ -48,15 +48,15 @@ - + - + - + @@ -98,6 +98,14 @@ + + + + + + + + \ No newline at end of file diff --git a/src/Artemis.UI/Artemis.UI.csproj b/src/Artemis.UI/Artemis.UI.csproj index 011cd1cc6..741b3925c 100644 --- a/src/Artemis.UI/Artemis.UI.csproj +++ b/src/Artemis.UI/Artemis.UI.csproj @@ -1,6 +1,6 @@  - + Debug @@ -59,13 +59,16 @@ - ..\packages\Castle.Core.4.3.1\lib\net45\Castle.Core.dll + ..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll ..\packages\ControlzEx.3.0.2.4\lib\net45\ControlzEx.dll - - ..\packages\HidSharp.2.0.5\lib\net35\HidSharp.dll + + ..\packages\HidSharp.2.0.8\lib\net35\HidSharp.dll + + + ..\packages\Humanizer.Core.2.6.2\lib\netstandard2.0\Humanizer.dll ..\packages\MahApps.Metro.1.6.5\lib\net46\MahApps.Metro.dll @@ -76,8 +79,8 @@ ..\packages\MaterialDesignThemes.MahApps.0.0.12\lib\net45\MaterialDesignThemes.MahApps.dll - - ..\packages\MaterialDesignThemes.2.5.0.1205\lib\net45\MaterialDesignThemes.Wpf.dll + + ..\packages\MaterialDesignThemes.2.5.1\lib\net45\MaterialDesignThemes.Wpf.dll ..\packages\Ninject.3.3.4\lib\net45\Ninject.dll @@ -88,14 +91,20 @@ ..\packages\Ninject.Extensions.Factory.3.3.2\lib\net45\Ninject.Extensions.Factory.dll - - ..\packages\PropertyChanged.Fody.2.6.0\lib\net452\PropertyChanged.dll + + ..\packages\PropertyChanged.Fody.2.6.1\lib\net452\PropertyChanged.dll - - ..\packages\RGB.NET.Core.0.1.14\lib\net45\RGB.NET.Core.dll + + ..\packages\RGB.NET.Brushes.0.1.22\lib\net45\RGB.NET.Brushes.dll - - ..\packages\RGB.NET.Groups.0.1.14\lib\net45\RGB.NET.Groups.dll + + ..\packages\RGB.NET.Core.0.1.22\lib\net45\RGB.NET.Core.dll + + + ..\packages\RGB.NET.Decorators.0.1.22\lib\net45\RGB.NET.Decorators.dll + + + ..\packages\RGB.NET.Groups.0.1.22\lib\net45\RGB.NET.Groups.dll ..\packages\Sanford.Multimedia.Midi.Standard.6.6.0\lib\net35\Sanford.Multimedia.Midi.dll @@ -141,6 +150,7 @@ + @@ -150,7 +160,7 @@ App.xaml Code - + Designer MSBuild:Compile @@ -171,7 +181,11 @@ Designer MSBuild:Compile - + + Designer + MSBuild:Compile + + Designer MSBuild:Compile @@ -238,12 +252,14 @@ mkdir %25ProgramData%25\Artemis\plugins xcopy /s /y /q $(SolutionDir)Artemis.Plugins.BuiltIn\Modules %25ProgramData%25\Artemis\plugins - + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + + + \ No newline at end of file diff --git a/src/Artemis.UI/Converters/ColorToSolidColorBrushConverter.cs b/src/Artemis.UI/Converters/ColorToSolidColorBrushConverter.cs index bbca9ca79..33ef6194f 100644 --- a/src/Artemis.UI/Converters/ColorToSolidColorBrushConverter.cs +++ b/src/Artemis.UI/Converters/ColorToSolidColorBrushConverter.cs @@ -18,7 +18,7 @@ namespace Artemis.UI.Converters { return new SolidColorBrush(!(value is Color color) ? System.Windows.Media.Color.FromArgb(0, 0, 0, 0) - : System.Windows.Media.Color.FromArgb(color.A, color.R, color.G, color.B)); + : System.Windows.Media.Color.FromArgb((byte) color.A, (byte) color.R, (byte) color.G, (byte) color.B)); } /// diff --git a/src/Artemis.UI/ViewModels/RootViewModel.cs b/src/Artemis.UI/ViewModels/RootViewModel.cs index 65937ba15..f1c92210b 100644 --- a/src/Artemis.UI/ViewModels/RootViewModel.cs +++ b/src/Artemis.UI/ViewModels/RootViewModel.cs @@ -8,6 +8,7 @@ using Artemis.Core.Plugins.Interfaces; using Artemis.Core.Plugins.Models; using Artemis.Core.Services.Interfaces; using Artemis.UI.ViewModels.Interfaces; +using Artemis.UI.ViewModels.Settings; using Stylet; namespace Artemis.UI.ViewModels diff --git a/src/Artemis.UI/ViewModels/Settings/DeviceSettingsViewModel.cs b/src/Artemis.UI/ViewModels/Settings/DeviceSettingsViewModel.cs new file mode 100644 index 000000000..e04b528a2 --- /dev/null +++ b/src/Artemis.UI/ViewModels/Settings/DeviceSettingsViewModel.cs @@ -0,0 +1,25 @@ +using Humanizer; +using RGB.NET.Core; + +namespace Artemis.UI.ViewModels.Settings +{ + public class DeviceSettingsViewModel + { + private readonly IRGBDevice _device; + + public DeviceSettingsViewModel(IRGBDevice device) + { + _device = device; + + Type = _device.DeviceInfo.DeviceType.ToString().Humanize(); + Name = _device.DeviceInfo.Model; + Manufacturer = _device.DeviceInfo.Manufacturer; + Enabled = true; + } + + public string Type { get; set; } + public string Name { get; set; } + public string Manufacturer { get; set; } + public bool Enabled { get; set; } + } +} \ No newline at end of file diff --git a/src/Artemis.UI/ViewModels/Settings/SettingsViewModel.cs b/src/Artemis.UI/ViewModels/Settings/SettingsViewModel.cs new file mode 100644 index 000000000..504814b7a --- /dev/null +++ b/src/Artemis.UI/ViewModels/Settings/SettingsViewModel.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using Artemis.Core.Events; +using Artemis.Core.Services.Interfaces; +using Artemis.UI.ViewModels.Interfaces; +using Stylet; + +namespace Artemis.UI.ViewModels.Settings +{ + public class SettingsViewModel : Screen, ISettingsViewModel + { + public string Title => "Settings"; + + public SettingsViewModel(IRgbService rgbService) + { + DeviceSettingsViewModels = new List(); + foreach (var device in rgbService.Surface.Devices) + DeviceSettingsViewModels.Add(new DeviceSettingsViewModel(device)); + + rgbService.DeviceLoaded += UpdateDevices; + } + + public List DeviceSettingsViewModels { get; set; } + + private void UpdateDevices(object sender, DeviceEventArgs deviceEventArgs) + { + DeviceSettingsViewModels.Add(new DeviceSettingsViewModel(deviceEventArgs.Device)); + } + } +} \ No newline at end of file diff --git a/src/Artemis.UI/ViewModels/SettingsViewModel.cs b/src/Artemis.UI/ViewModels/SettingsViewModel.cs deleted file mode 100644 index 97f6dd8ec..000000000 --- a/src/Artemis.UI/ViewModels/SettingsViewModel.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Artemis.UI.ViewModels.Interfaces; -using Stylet; - -namespace Artemis.UI.ViewModels -{ - public class SettingsViewModel : Screen, ISettingsViewModel - { - public string Title => "Settings"; - } -} \ No newline at end of file diff --git a/src/Artemis.UI/Views/Settings/DeviceSettingsView.xaml b/src/Artemis.UI/Views/Settings/DeviceSettingsView.xaml new file mode 100644 index 000000000..5a0d5e17e --- /dev/null +++ b/src/Artemis.UI/Views/Settings/DeviceSettingsView.xaml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Artemis.UI/Views/SettingsView.xaml b/src/Artemis.UI/Views/Settings/SettingsView.xaml similarity index 67% rename from src/Artemis.UI/Views/SettingsView.xaml rename to src/Artemis.UI/Views/Settings/SettingsView.xaml index 37bc6493a..e37a90bd7 100644 --- a/src/Artemis.UI/Views/SettingsView.xaml +++ b/src/Artemis.UI/Views/Settings/SettingsView.xaml @@ -1,9 +1,11 @@ - @@ -14,12 +16,17 @@ - General + General General settings like start up with Windows etc. - Plugins + Devices + + A list of plugins and options to disable them + + + Plugins A list of plugins and options to disable them diff --git a/src/Artemis.UI/packages.config b/src/Artemis.UI/packages.config index b13573344..afdf4bfcf 100644 --- a/src/Artemis.UI/packages.config +++ b/src/Artemis.UI/packages.config @@ -1,19 +1,23 @@  - + - - + + + - + - - - + + + + + +