mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Fixed LED UI rendering perf
This commit is contained in:
parent
71a6181df7
commit
8e7d543a80
@ -28,6 +28,7 @@ namespace Artemis.UI.ViewModels.Controls.RgbDevice
|
||||
public double Height { get; private set; }
|
||||
|
||||
public Geometry DisplayGeometry { get; private set; }
|
||||
public Geometry StrokeGeometry { get; private set; }
|
||||
public Color DisplayColor { get; private set; }
|
||||
|
||||
public string Tooltip => $"{Led.Id} - {Led.LedRectangle}";
|
||||
@ -66,6 +67,28 @@ namespace Artemis.UI.ViewModels.Controls.RgbDevice
|
||||
GeometryCombineMode.Union,
|
||||
new ScaleTransform(Led.LedRectangle.Width, Led.LedRectangle.Height)
|
||||
);
|
||||
|
||||
// Create a smaller version of the display geometry
|
||||
var innerGeometry = Geometry.Combine(
|
||||
Geometry.Empty,
|
||||
geometry,
|
||||
GeometryCombineMode.Union,
|
||||
new TransformGroup
|
||||
{
|
||||
Children = new TransformCollection
|
||||
{
|
||||
new ScaleTransform(Led.LedRectangle.Width - 2, Led.LedRectangle.Height - 2),
|
||||
new TranslateTransform(1, 1)
|
||||
}
|
||||
}
|
||||
);
|
||||
// Stroke geometry is the display geometry excluding the inner geometry
|
||||
StrokeGeometry = Geometry.Combine(
|
||||
DisplayGeometry,
|
||||
innerGeometry,
|
||||
GeometryCombineMode.Exclude,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
|
||||
@ -8,20 +8,22 @@
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance rgbDevice:RgbLedViewModel}"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Border Width="{Binding Width}" Height="{Binding Height}">
|
||||
<Border.Background>
|
||||
<Grid Width="{Binding Width}" Height="{Binding Height}">
|
||||
<Grid.Background>
|
||||
<ImageBrush AlignmentX="Center" AlignmentY="Center"
|
||||
Stretch="Fill"
|
||||
ImageSource="{Binding Led.Image}" />
|
||||
</Border.Background>
|
||||
</Grid.Background>
|
||||
|
||||
<Path Data="{Binding DisplayGeometry}" ClipToBounds="False" StrokeThickness="2">
|
||||
<Path.Fill>
|
||||
<SolidColorBrush Color="{Binding DisplayColor}" Opacity="0.25" />
|
||||
</Path.Fill>
|
||||
<!-- TODO: Causes big perf degradation because it makes the entire path recalculate its size -->
|
||||
<Path.Stroke>
|
||||
<SolidColorBrush Color="{Binding DisplayColor}" />
|
||||
</Path.Stroke>
|
||||
</Path>
|
||||
</Border>
|
||||
<Path Data="{Binding StrokeGeometry}" ClipToBounds="False" StrokeThickness="2">
|
||||
<Path.Fill>
|
||||
<SolidColorBrush Color="{Binding DisplayColor}" />
|
||||
</Path.Fill>
|
||||
</Path>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
Loading…
x
Reference in New Issue
Block a user