1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2026-01-01 18:23:32 +00:00

Fixed most of the editor performance

This commit is contained in:
SpoinkyNL 2019-11-12 22:34:44 +01:00
parent ee5c5c1d74
commit 5f10627345
3 changed files with 26 additions and 22 deletions

View File

@ -31,6 +31,8 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
_timer = new Timer(1000.0 / 15) {AutoReset = true}; _timer = new Timer(1000.0 / 15) {AutoReset = true};
_timer.Elapsed += UpdateLeds; _timer.Elapsed += UpdateLeds;
// Remove
_timer.Start();
} }
public ObservableCollection<ProfileDeviceViewModel> Devices { get; set; } public ObservableCollection<ProfileDeviceViewModel> Devices { get; set; }

View File

@ -4,6 +4,7 @@ using System.Windows.Media;
using Artemis.UI.Extensions; using Artemis.UI.Extensions;
using RGB.NET.Core; using RGB.NET.Core;
using Stylet; using Stylet;
using Color = System.Windows.Media.Color;
namespace Artemis.UI.ViewModels.Controls.ProfileEditor namespace Artemis.UI.ViewModels.Controls.ProfileEditor
{ {
@ -13,12 +14,7 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
{ {
Led = led; Led = led;
Execute.OnUIThread(() => Execute.OnUIThread(() => { CreateLedGeometry(); });
{
CreateLedGeometry();
FillBrush = new SolidColorBrush { Opacity = 0.25 };
BorderBrush = new SolidColorBrush();
});
} }
public Led Led { get; } public Led Led { get; }
@ -29,9 +25,8 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
public double Height { get; private set; } public double Height { get; private set; }
public Geometry DisplayGeometry { get; private set; } public Geometry DisplayGeometry { get; private set; }
public SolidColorBrush FillBrush { get; set; } public Geometry StrokeGeometry { get; private set; }
public SolidColorBrush BorderBrush { get; set; } public Color DisplayColor { get; private set; }
public string Tooltip => $"{Led.Id} - {Led.LedRectangle}"; public string Tooltip => $"{Led.Id} - {Led.LedRectangle}";
@ -69,6 +64,12 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
GeometryCombineMode.Union, GeometryCombineMode.Union,
new ScaleTransform(Led.LedRectangle.Width, Led.LedRectangle.Height) 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() public void Update()
@ -76,11 +77,8 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
var newColor = Led.Color.ToMediaColor(); var newColor = Led.Color.ToMediaColor();
Execute.OnUIThread(() => Execute.OnUIThread(() =>
{ {
if (!FillBrush.Color.Equals(newColor)) if (!DisplayColor.Equals(newColor))
{ DisplayColor = newColor;
FillBrush.Color = newColor;
BorderBrush.Color = newColor;
}
}); });
if (Math.Abs(Led.LedRectangle.X - X) > 0.1) if (Math.Abs(Led.LedRectangle.X - X) > 0.1)

View File

@ -10,19 +10,23 @@
d:DesignHeight="25" d:DesignWidth="25" d:DesignHeight="25" d:DesignWidth="25"
ToolTip="{Binding Tooltip}"> ToolTip="{Binding Tooltip}">
<UserControl.Resources> <UserControl.Resources>
<Converters:NullToImageConverter x:Key="NullToImageConverter"/> <Converters:NullToImageConverter x:Key="NullToImageConverter" />
</UserControl.Resources> </UserControl.Resources>
<Grid Width="{Binding Width}" Height="{Binding Height}"> <Grid Width="{Binding Width}" Height="{Binding Height}" ClipToBounds="False">
<Grid.Background> <Grid.Background>
<ImageBrush AlignmentX="Center" AlignmentY="Center" Stretch="Fill" ImageSource="{Binding Led.Image, Converter={StaticResource NullToImageConverter}}" /> <ImageBrush AlignmentX="Center" AlignmentY="Center" Stretch="Fill" ImageSource="{Binding Led.Image, Converter={StaticResource NullToImageConverter}}" />
</Grid.Background> </Grid.Background>
<Path Data="{Binding DisplayGeometry}" <Path Data="{Binding DisplayGeometry}" ClipToBounds="False">
Clip="{Binding Data, RelativeSource={RelativeSource Self}}" <Path.Fill>
ClipToBounds="False" <SolidColorBrush Color="{Binding DisplayColor}" Opacity="0.25" />
Fill="{Binding FillBrush}" </Path.Fill>
Stroke="{Binding BorderBrush}"
StrokeThickness="2">
</Path> </Path>
<Path Data="{Binding StrokeGeometry}" ClipToBounds="False">
<Path.Fill>
<SolidColorBrush Color="{Binding DisplayColor}" />
</Path.Fill>
</Path>
</Grid> </Grid>
</UserControl> </UserControl>