mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-01-01 10:13:30 +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 double Height { get; private set; }
|
||||||
|
|
||||||
public Geometry DisplayGeometry { get; private set; }
|
public Geometry DisplayGeometry { get; private set; }
|
||||||
|
public Geometry StrokeGeometry { get; private set; }
|
||||||
public Color DisplayColor { get; private set; }
|
public Color DisplayColor { get; private set; }
|
||||||
|
|
||||||
public string Tooltip => $"{Led.Id} - {Led.LedRectangle}";
|
public string Tooltip => $"{Led.Id} - {Led.LedRectangle}";
|
||||||
@ -66,6 +67,28 @@ namespace Artemis.UI.ViewModels.Controls.RgbDevice
|
|||||||
GeometryCombineMode.Union,
|
GeometryCombineMode.Union,
|
||||||
new ScaleTransform(Led.LedRectangle.Width, Led.LedRectangle.Height)
|
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()
|
public void Update()
|
||||||
|
|||||||
@ -8,20 +8,22 @@
|
|||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DataContext="{d:DesignInstance rgbDevice:RgbLedViewModel}"
|
d:DataContext="{d:DesignInstance rgbDevice:RgbLedViewModel}"
|
||||||
d:DesignHeight="450" d:DesignWidth="800">
|
d:DesignHeight="450" d:DesignWidth="800">
|
||||||
<Border Width="{Binding Width}" Height="{Binding Height}">
|
<Grid Width="{Binding Width}" Height="{Binding Height}">
|
||||||
<Border.Background>
|
<Grid.Background>
|
||||||
<ImageBrush AlignmentX="Center" AlignmentY="Center"
|
<ImageBrush AlignmentX="Center" AlignmentY="Center"
|
||||||
Stretch="Fill"
|
Stretch="Fill"
|
||||||
ImageSource="{Binding Led.Image}" />
|
ImageSource="{Binding Led.Image}" />
|
||||||
</Border.Background>
|
</Grid.Background>
|
||||||
|
|
||||||
<Path Data="{Binding DisplayGeometry}" ClipToBounds="False" StrokeThickness="2">
|
<Path Data="{Binding DisplayGeometry}" ClipToBounds="False" StrokeThickness="2">
|
||||||
<Path.Fill>
|
<Path.Fill>
|
||||||
<SolidColorBrush Color="{Binding DisplayColor}" Opacity="0.25" />
|
<SolidColorBrush Color="{Binding DisplayColor}" Opacity="0.25" />
|
||||||
</Path.Fill>
|
</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>
|
</Path>
|
||||||
</Border>
|
<Path Data="{Binding StrokeGeometry}" ClipToBounds="False" StrokeThickness="2">
|
||||||
|
<Path.Fill>
|
||||||
|
<SolidColorBrush Color="{Binding DisplayColor}" />
|
||||||
|
</Path.Fill>
|
||||||
|
</Path>
|
||||||
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
Loading…
x
Reference in New Issue
Block a user