mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Fixed most of the editor performance
This commit is contained in:
parent
ee5c5c1d74
commit
5f10627345
@ -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<ProfileDeviceViewModel> Devices { get; set; }
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -10,19 +10,23 @@
|
||||
d:DesignHeight="25" d:DesignWidth="25"
|
||||
ToolTip="{Binding Tooltip}">
|
||||
<UserControl.Resources>
|
||||
<Converters:NullToImageConverter x:Key="NullToImageConverter"/>
|
||||
<Converters:NullToImageConverter x:Key="NullToImageConverter" />
|
||||
</UserControl.Resources>
|
||||
<Grid Width="{Binding Width}" Height="{Binding Height}">
|
||||
<Grid Width="{Binding Width}" Height="{Binding Height}" ClipToBounds="False">
|
||||
<Grid.Background>
|
||||
<ImageBrush AlignmentX="Center" AlignmentY="Center" Stretch="Fill" ImageSource="{Binding Led.Image, Converter={StaticResource NullToImageConverter}}" />
|
||||
</Grid.Background>
|
||||
|
||||
<Path Data="{Binding DisplayGeometry}"
|
||||
Clip="{Binding Data, RelativeSource={RelativeSource Self}}"
|
||||
ClipToBounds="False"
|
||||
Fill="{Binding FillBrush}"
|
||||
Stroke="{Binding BorderBrush}"
|
||||
StrokeThickness="2">
|
||||
<Path Data="{Binding DisplayGeometry}" ClipToBounds="False">
|
||||
<Path.Fill>
|
||||
<SolidColorBrush Color="{Binding DisplayColor}" Opacity="0.25" />
|
||||
</Path.Fill>
|
||||
</Path>
|
||||
<Path Data="{Binding StrokeGeometry}" ClipToBounds="False">
|
||||
<Path.Fill>
|
||||
<SolidColorBrush Color="{Binding DisplayColor}" />
|
||||
</Path.Fill>
|
||||
</Path>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
Loading…
x
Reference in New Issue
Block a user