From 5f1062734538925f72ca7938255a3d084c5d2b34 Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Tue, 12 Nov 2019 22:34:44 +0100 Subject: [PATCH] Fixed most of the editor performance --- .../ProfileEditor/ProfileEditorViewModel.cs | 2 ++ .../ProfileEditor/ProfileLedViewModel.cs | 26 +++++++++---------- .../ProfileEditor/ProfileLedView.xaml | 20 ++++++++------ 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/Artemis.UI/ViewModels/Controls/ProfileEditor/ProfileEditorViewModel.cs b/src/Artemis.UI/ViewModels/Controls/ProfileEditor/ProfileEditorViewModel.cs index aebf093da..f67f3e84e 100644 --- a/src/Artemis.UI/ViewModels/Controls/ProfileEditor/ProfileEditorViewModel.cs +++ b/src/Artemis.UI/ViewModels/Controls/ProfileEditor/ProfileEditorViewModel.cs @@ -31,6 +31,8 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor _timer = new Timer(1000.0 / 15) {AutoReset = true}; _timer.Elapsed += UpdateLeds; + // Remove + _timer.Start(); } public ObservableCollection Devices { get; set; } diff --git a/src/Artemis.UI/ViewModels/Controls/ProfileEditor/ProfileLedViewModel.cs b/src/Artemis.UI/ViewModels/Controls/ProfileEditor/ProfileLedViewModel.cs index 9e7cdc86a..55e7c1a54 100644 --- a/src/Artemis.UI/ViewModels/Controls/ProfileEditor/ProfileLedViewModel.cs +++ b/src/Artemis.UI/ViewModels/Controls/ProfileEditor/ProfileLedViewModel.cs @@ -4,6 +4,7 @@ using System.Windows.Media; using Artemis.UI.Extensions; using RGB.NET.Core; using Stylet; +using Color = System.Windows.Media.Color; namespace Artemis.UI.ViewModels.Controls.ProfileEditor { @@ -13,12 +14,7 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor { Led = led; - Execute.OnUIThread(() => - { - CreateLedGeometry(); - FillBrush = new SolidColorBrush { Opacity = 0.25 }; - BorderBrush = new SolidColorBrush(); - }); + Execute.OnUIThread(() => { CreateLedGeometry(); }); } public Led Led { get; } @@ -29,9 +25,8 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor public double Height { get; private set; } public Geometry DisplayGeometry { get; private set; } - public SolidColorBrush FillBrush { get; set; } - public SolidColorBrush BorderBrush { get; set; } - + public Geometry StrokeGeometry { get; private set; } + public Color DisplayColor { get; private set; } public string Tooltip => $"{Led.Id} - {Led.LedRectangle}"; @@ -69,6 +64,12 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor GeometryCombineMode.Union, new ScaleTransform(Led.LedRectangle.Width, Led.LedRectangle.Height) ); + + // Stroke geometry is the display geometry excluding the inner geometry + StrokeGeometry = DisplayGeometry.GetWidenedPathGeometry(new Pen(null, Led.Shape == Shape.Rectangle ? 2.0 : 1.0), 0.1, ToleranceType.Absolute); + + DisplayGeometry.Freeze(); + StrokeGeometry.Freeze(); } public void Update() @@ -76,11 +77,8 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor var newColor = Led.Color.ToMediaColor(); Execute.OnUIThread(() => { - if (!FillBrush.Color.Equals(newColor)) - { - FillBrush.Color = newColor; - BorderBrush.Color = newColor; - } + if (!DisplayColor.Equals(newColor)) + DisplayColor = newColor; }); if (Math.Abs(Led.LedRectangle.X - X) > 0.1) diff --git a/src/Artemis.UI/Views/Controls/ProfileEditor/ProfileLedView.xaml b/src/Artemis.UI/Views/Controls/ProfileEditor/ProfileLedView.xaml index 7ea215399..67e112818 100644 --- a/src/Artemis.UI/Views/Controls/ProfileEditor/ProfileLedView.xaml +++ b/src/Artemis.UI/Views/Controls/ProfileEditor/ProfileLedView.xaml @@ -10,19 +10,23 @@ d:DesignHeight="25" d:DesignWidth="25" ToolTip="{Binding Tooltip}"> - + - + - + + + + + + + + + + \ No newline at end of file