From 06e6075c4d269942f5a878657abc6412c55d3d47 Mon Sep 17 00:00:00 2001 From: Diogo Trindade Date: Tue, 6 Jun 2023 12:00:05 +0100 Subject: [PATCH 01/13] DeviceVisualizer - reduce allocations --- .../Controls/DeviceVisualizer.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs b/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs index eca232ba4..c4d298f9f 100644 --- a/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs +++ b/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs @@ -120,23 +120,26 @@ public class DeviceVisualizer : Control if (Device == null) return false; - Color[] state = new Color[Device.RgbDevice.Count()]; - bool difference = _previousState.Length != state.Length; + bool difference = false; + + int newLedCount = Device.RgbDevice.Count(); + if (_previousState.Length != newLedCount) + { + _previousState = new Color[newLedCount]; + difference = true; + } // Check all LEDs for differences and copy the colors to a new state int index = 0; foreach (Led led in Device.RgbDevice) { - if (!difference && !led.Color.Equals(_previousState[index])) + if (_previousState[index] != led.Color) difference = true; - state[index] = led.Color; + _previousState[index] = led.Color; index++; } - // Store the new state for next time - _previousState = state; - return difference; } From 567ca193a487ef191c820bb53253d51c4703ce1d Mon Sep 17 00:00:00 2001 From: Diogo Trindade Date: Tue, 6 Jun 2023 12:00:48 +0100 Subject: [PATCH 02/13] DeviceVisualizer - don't check dirty unless necessary --- src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs b/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs index c4d298f9f..2521be969 100644 --- a/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs +++ b/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs @@ -162,7 +162,7 @@ public class DeviceVisualizer : Control private void TimerOnTick(object? sender, EventArgs e) { - if (IsDirty() && ShowColors && IsVisible && Opacity > 0) + if (ShowColors && IsVisible && Opacity > 0 && IsDirty()) Update(); } From 88322baafd22ac1317c815e5e073fd7bb89a04e8 Mon Sep 17 00:00:00 2001 From: Diogo Trindade Date: Tue, 6 Jun 2023 12:17:31 +0100 Subject: [PATCH 03/13] DeviceVisualizer - Tied update to core update instead of hardcoded 25fps --- .../Controls/DeviceVisualizer.cs | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs b/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs index 2521be969..80c72b0a5 100644 --- a/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs +++ b/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs @@ -1,9 +1,10 @@ -using System; +using System; using System.Collections.Generic; using System.ComponentModel; using System.IO; using System.Linq; using Artemis.Core; +using Artemis.Core.Services; using Artemis.UI.Shared.Events; using Avalonia; using Avalonia.Controls; @@ -13,6 +14,7 @@ using Avalonia.Media; using Avalonia.Media.Imaging; using Avalonia.Threading; using RGB.NET.Core; +using DryIoc; using Color = RGB.NET.Core.Color; using Point = Avalonia.Point; using Size = Avalonia.Size; @@ -24,20 +26,19 @@ namespace Artemis.UI.Shared; /// public class DeviceVisualizer : Control { - private const double UPDATE_FRAME_RATE = 25.0; + private readonly ICoreService _coreService; private readonly List _deviceVisualizerLeds; - private readonly DispatcherTimer _timer; private Rect _deviceBounds; private RenderTargetBitmap? _deviceImage; private ArtemisDevice? _oldDevice; private bool _loading; private Color[] _previousState = Array.Empty(); - + /// public DeviceVisualizer() { - _timer = new DispatcherTimer(DispatcherPriority.Background) {Interval = TimeSpan.FromMilliseconds(1000.0 / UPDATE_FRAME_RATE)}; + _coreService = UI.Locator.Resolve(); _deviceVisualizerLeds = new List(); PointerReleased += OnPointerReleased; @@ -159,11 +160,14 @@ public class DeviceVisualizer : Control return geometry.Bounds; } - - private void TimerOnTick(object? sender, EventArgs e) + + private void OnFrameRendered(object? sender, FrameRenderedEventArgs e) { - if (ShowColors && IsVisible && Opacity > 0 && IsDirty()) - Update(); + Dispatcher.UIThread.Post(() => + { + if (ShowColors && IsVisible && Opacity > 0 && IsDirty()) + Update(); + }, DispatcherPriority.Background); } private void OnPointerReleased(object? sender, PointerReleasedEventArgs e) @@ -253,16 +257,16 @@ public class DeviceVisualizer : Control /// protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { - _timer.Start(); - _timer.Tick += TimerOnTick; + _coreService.FrameRendered += OnFrameRendered; + base.OnAttachedToLogicalTree(e); } /// protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) { - _timer.Stop(); - _timer.Tick -= TimerOnTick; + _coreService.FrameRendered -= OnFrameRendered; + base.OnDetachedFromLogicalTree(e); } From ff55bf0d2659cb1520929b063f77a5234eaba991 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 Jun 2023 17:10:22 +0000 Subject: [PATCH 04/13] Bump Microsoft.Windows.Compatibility in /src/Artemis.UI.Windows Bumps [Microsoft.Windows.Compatibility](https://github.com/dotnet/runtime) from 7.0.0 to 7.0.3. - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/compare/v7.0.0...v7.0.3) --- updated-dependencies: - dependency-name: Microsoft.Windows.Compatibility dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- src/Artemis.UI.Windows/Artemis.UI.Windows.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Artemis.UI.Windows/Artemis.UI.Windows.csproj b/src/Artemis.UI.Windows/Artemis.UI.Windows.csproj index 3910a5e65..0110ec37e 100644 --- a/src/Artemis.UI.Windows/Artemis.UI.Windows.csproj +++ b/src/Artemis.UI.Windows/Artemis.UI.Windows.csproj @@ -1,4 +1,4 @@ - + WinExe net7.0-windows10.0.17763.0 @@ -29,7 +29,7 @@ - + From 0122ab00d9aac0482f977de0d019924ba36c4b85 Mon Sep 17 00:00:00 2001 From: Diogo Trindade Date: Mon, 5 Jun 2023 14:26:46 +0100 Subject: [PATCH 05/13] Added more Border styles --- src/Artemis.UI.Shared/Styles/Border.axaml | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/Artemis.UI.Shared/Styles/Border.axaml b/src/Artemis.UI.Shared/Styles/Border.axaml index afcd9dee8..d753809a0 100644 --- a/src/Artemis.UI.Shared/Styles/Border.axaml +++ b/src/Artemis.UI.Shared/Styles/Border.axaml @@ -10,6 +10,15 @@ I'm in a panel yo! I'm in a panel yo! + + I'm in a panel yo! + + + + + I'm in a panel yo! + + I'm in a panel yo! @@ -50,4 +59,23 @@ + + + + + + \ No newline at end of file From cdfa14441ed2ccbe12a52de75fcb850efcaf5697 Mon Sep 17 00:00:00 2001 From: Diogo Trindade Date: Mon, 5 Jun 2023 14:26:53 +0100 Subject: [PATCH 06/13] Clean up csproj --- src/Artemis.UI/Artemis.UI.csproj | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/src/Artemis.UI/Artemis.UI.csproj b/src/Artemis.UI/Artemis.UI.csproj index d57184629..fa8d34923 100644 --- a/src/Artemis.UI/Artemis.UI.csproj +++ b/src/Artemis.UI/Artemis.UI.csproj @@ -41,27 +41,4 @@ - - - - UpdatingTabView.axaml - Code - - - UpdatingTabView.axaml - Code - - - PluginFeatureView.axaml - Code - - - PluginPrerequisiteActionView.axaml - Code - - - PluginPrerequisiteView.axaml - Code - - \ No newline at end of file From db069ea8bf9580f13ced32dc2bd7767903f4e728 Mon Sep 17 00:00:00 2001 From: Diogo Trindade Date: Mon, 5 Jun 2023 18:48:07 +0100 Subject: [PATCH 07/13] Reworked device properties screen --- src/Artemis.UI/DryIoc/Factories/IVMFactory.cs | 15 +- .../Screens/Device/DevicePropertiesView.axaml | 6 +- .../Device/DevicePropertiesViewModel.cs | 6 +- .../Device/Tabs/DeviceGeneralTabView.axaml | 371 ++++++++++++++++++ .../Device/Tabs/DeviceGeneralTabView.axaml.cs | 11 + .../Device/Tabs/DeviceGeneralTabViewModel.cs | 256 ++++++++++++ .../Device/Tabs/DeviceLayoutTabView.axaml | 82 ++++ .../Device/Tabs/DeviceLayoutTabView.axaml.cs | 26 ++ .../Device/Tabs/DeviceLayoutTabViewModel.cs | 143 +++++++ 9 files changed, 910 insertions(+), 6 deletions(-) create mode 100644 src/Artemis.UI/Screens/Device/Tabs/DeviceGeneralTabView.axaml create mode 100644 src/Artemis.UI/Screens/Device/Tabs/DeviceGeneralTabView.axaml.cs create mode 100644 src/Artemis.UI/Screens/Device/Tabs/DeviceGeneralTabViewModel.cs create mode 100644 src/Artemis.UI/Screens/Device/Tabs/DeviceLayoutTabView.axaml create mode 100644 src/Artemis.UI/Screens/Device/Tabs/DeviceLayoutTabView.axaml.cs create mode 100644 src/Artemis.UI/Screens/Device/Tabs/DeviceLayoutTabViewModel.cs diff --git a/src/Artemis.UI/DryIoc/Factories/IVMFactory.cs b/src/Artemis.UI/DryIoc/Factories/IVMFactory.cs index d410e3cfc..8d94699dd 100644 --- a/src/Artemis.UI/DryIoc/Factories/IVMFactory.cs +++ b/src/Artemis.UI/DryIoc/Factories/IVMFactory.cs @@ -25,6 +25,7 @@ using Artemis.UI.Screens.Sidebar; using Artemis.UI.Screens.SurfaceEditor; using Artemis.UI.Screens.VisualScripting; using Artemis.UI.Screens.VisualScripting.Pins; +using Artemis.UI.Shared; using DryIoc; using ReactiveUI; @@ -40,9 +41,11 @@ public interface IDeviceVmFactory : IVmFactory DeviceSettingsViewModel DeviceSettingsViewModel(ArtemisDevice device, DevicesTabViewModel devicesTabViewModel); DeviceDetectInputViewModel DeviceDetectInputViewModel(ArtemisDevice device); DevicePropertiesTabViewModel DevicePropertiesTabViewModel(ArtemisDevice device); + DeviceLayoutTabViewModel DeviceLayoutTabViewModel(ArtemisDevice device); DeviceInfoTabViewModel DeviceInfoTabViewModel(ArtemisDevice device); DeviceLedsTabViewModel DeviceLedsTabViewModel(ArtemisDevice device, ObservableCollection selectedLeds); InputMappingsTabViewModel InputMappingsTabViewModel(ArtemisDevice device, ObservableCollection selectedLeds); + DeviceGeneralTabViewModel DeviceGeneralTabViewModel(ArtemisDevice device); } public class DeviceFactory : IDeviceVmFactory { @@ -72,7 +75,12 @@ public class DeviceFactory : IDeviceVmFactory { return _container.Resolve(new object[] { device }); } - + + public DeviceLayoutTabViewModel DeviceLayoutTabViewModel(ArtemisDevice device) + { + return _container.Resolve(new object[] { device }); + } + public DeviceInfoTabViewModel DeviceInfoTabViewModel(ArtemisDevice device) { return _container.Resolve(new object[] { device }); @@ -87,6 +95,11 @@ public class DeviceFactory : IDeviceVmFactory { return _container.Resolve(new object[] { device, selectedLeds }); } + + public DeviceGeneralTabViewModel DeviceGeneralTabViewModel(ArtemisDevice device) + { + return _container.Resolve(new object[] { device }); + } } public interface ISettingsVmFactory : IVmFactory diff --git a/src/Artemis.UI/Screens/Device/DevicePropertiesView.axaml b/src/Artemis.UI/Screens/Device/DevicePropertiesView.axaml index 22b63510e..9b78bb060 100644 --- a/src/Artemis.UI/Screens/Device/DevicePropertiesView.axaml +++ b/src/Artemis.UI/Screens/Device/DevicePropertiesView.axaml @@ -11,8 +11,8 @@ Icon="/Assets/Images/Logo/application.ico" Title="Artemis | Device Properties" WindowStartupLocation="CenterOwner" - Width="1250" - Height="900"> + Width="1400" + Height="800"> @@ -52,7 +52,7 @@ - + diff --git a/src/Artemis.UI/Screens/Device/DevicePropertiesViewModel.cs b/src/Artemis.UI/Screens/Device/DevicePropertiesViewModel.cs index 87ee3ae20..395a718f8 100644 --- a/src/Artemis.UI/Screens/Device/DevicePropertiesViewModel.cs +++ b/src/Artemis.UI/Screens/Device/DevicePropertiesViewModel.cs @@ -64,8 +64,10 @@ public class DevicePropertiesViewModel : DialogViewModelBase private void AddTabs() { - Tabs.Add(_deviceVmFactory.DevicePropertiesTabViewModel(Device)); - Tabs.Add(_deviceVmFactory.DeviceInfoTabViewModel(Device)); + Tabs.Add(_deviceVmFactory.DeviceGeneralTabViewModel(Device)); + Tabs.Add(_deviceVmFactory.DeviceLayoutTabViewModel(Device)); + //Tabs.Add(_deviceVmFactory.DevicePropertiesTabViewModel(Device)); + //Tabs.Add(_deviceVmFactory.DeviceInfoTabViewModel(Device)); if (Device.DeviceType == RGBDeviceType.Keyboard) Tabs.Add(_deviceVmFactory.InputMappingsTabViewModel(Device, SelectedLeds)); Tabs.Add(_deviceVmFactory.DeviceLedsTabViewModel(Device, SelectedLeds)); diff --git a/src/Artemis.UI/Screens/Device/Tabs/DeviceGeneralTabView.axaml b/src/Artemis.UI/Screens/Device/Tabs/DeviceGeneralTabView.axaml new file mode 100644 index 000000000..a62df0f73 --- /dev/null +++ b/src/Artemis.UI/Screens/Device/Tabs/DeviceGeneralTabView.axaml @@ -0,0 +1,371 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + X-coordinate + + mm + + Y-coordinate + + mm + + Scale + + times + + Rotation + + deg + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +