1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Device visualizer - Fixed custom LED shapes not being positioned correct

This commit is contained in:
SpoinkyNL 2020-07-31 23:51:28 +02:00
parent 385a30bec7
commit 3000d4607a
2 changed files with 13 additions and 11 deletions

View File

@ -111,6 +111,7 @@ namespace Artemis.UI.Shared.Controls
var rotationRect = new Rect(0, 0, Device.RgbDevice.ActualSize.Width, Device.RgbDevice.ActualSize.Height);
rotationRect.Transform(new RotateTransform(Device.Rotation).Value);
// TODO: If availableSize exceeds what we need, scale up
return rotationRect.Size;
}

View File

@ -13,8 +13,6 @@ namespace Artemis.UI.Shared.Controls
{
public DeviceVisualizerLed(ArtemisLed led)
{
if (led.Device.Scale != 1)
Console.WriteLine();
Led = led;
LedRect = new Rect(
Led.RgbLed.Location.X,
@ -68,7 +66,14 @@ namespace Artemis.UI.Shared.Controls
var penBrush = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));
penBrush.Freeze();
drawingContext.DrawGeometry(fillBrush, new Pen(penBrush, 1), DisplayGeometry);
// Create transparent pixels covering the entire LedRect so the image size matched the LedRect size
drawingContext.DrawRectangle(new SolidColorBrush(Colors.Transparent), null, LedRect);
// Translate to the top-left of the LedRect
drawingContext.PushTransform(new TranslateTransform(LedRect.X, LedRect.Y));
// Render the LED geometry
drawingContext.DrawGeometry(fillBrush, new Pen(penBrush, 1) {LineJoin = PenLineJoin.Round}, DisplayGeometry.GetOutlinedPathGeometry());
// Restore the drawing context
drawingContext.Pop();
}
private void CreateLedGeometry()
@ -83,7 +88,7 @@ namespace Artemis.UI.Shared.Controls
if (Led.RgbLed.Device.DeviceInfo.DeviceType == RGBDeviceType.Keyboard || Led.RgbLed.Device.DeviceInfo.DeviceType == RGBDeviceType.Keypad)
CreateCustomGeometry(2.0);
else
CreateCustomGeometry(1.0);
CreateCustomGeometry(0);
break;
case Shape.Rectangle:
if (Led.RgbLed.Device.DeviceInfo.DeviceType == RGBDeviceType.Keyboard || Led.RgbLed.Device.DeviceInfo.DeviceType == RGBDeviceType.Keypad)
@ -97,11 +102,6 @@ namespace Artemis.UI.Shared.Controls
default:
throw new ArgumentOutOfRangeException();
}
// Stroke geometry is the display geometry excluding the inner geometry
DisplayGeometry.Transform = new TranslateTransform(Led.RgbLed.Location.X, Led.RgbLed.Location.Y);
// Try to gain some performance
DisplayGeometry.Freeze();
}
private void CreateRectangleGeometry()
@ -123,6 +123,7 @@ namespace Artemis.UI.Shared.Controls
{
try
{
// DisplayGeometry = Geometry.Parse(Led.RgbLed.ShapeData);
DisplayGeometry = Geometry.Combine(
Geometry.Empty,
Geometry.Parse(Led.RgbLed.ShapeData),