From de23b5449b1b2e89fe3b956d3e2065f19c7a230e Mon Sep 17 00:00:00 2001 From: Robert Date: Thu, 20 Apr 2023 14:00:51 +0200 Subject: [PATCH] Device visualizer - Fix crash when LED geometry is null --- .../Artemis.UI.Shared.csproj.DotSettings | 4 ++-- src/Artemis.UI.Shared/Controls/DeviceVisualizerLed.cs | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj.DotSettings b/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj.DotSettings index 4dc50ad43..849012cda 100644 --- a/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj.DotSettings +++ b/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj.DotSettings @@ -1,5 +1,5 @@ - + + True True True True diff --git a/src/Artemis.UI.Shared/Controls/DeviceVisualizerLed.cs b/src/Artemis.UI.Shared/Controls/DeviceVisualizerLed.cs index 30bb72b76..5164d5844 100644 --- a/src/Artemis.UI.Shared/Controls/DeviceVisualizerLed.cs +++ b/src/Artemis.UI.Shared/Controls/DeviceVisualizerLed.cs @@ -61,6 +61,9 @@ internal class DeviceVisualizerLed public void RenderGeometry(DrawingContext drawingContext, bool dimmed) { + if (DisplayGeometry == null) + return; + byte r = Led.RgbLed.Color.GetR(); byte g = Led.RgbLed.Color.GetG(); byte b = Led.RgbLed.Color.GetB(); @@ -94,13 +97,13 @@ internal class DeviceVisualizerLed switch (Led.RgbLed.Shape) { case Shape.Custom: - if (Led.RgbLed.Device.DeviceInfo.DeviceType == RGBDeviceType.Keyboard || Led.RgbLed.Device.DeviceInfo.DeviceType == RGBDeviceType.Keypad) + if (Led.RgbLed.Device.DeviceInfo.DeviceType is RGBDeviceType.Keyboard or RGBDeviceType.Keypad) CreateCustomGeometry(2.0); else CreateCustomGeometry(1.0); break; case Shape.Rectangle: - if (Led.RgbLed.Device.DeviceInfo.DeviceType == RGBDeviceType.Keyboard || Led.RgbLed.Device.DeviceInfo.DeviceType == RGBDeviceType.Keypad) + if (Led.RgbLed.Device.DeviceInfo.DeviceType is RGBDeviceType.Keyboard or RGBDeviceType.Keypad) CreateKeyCapGeometry(); else CreateRectangleGeometry(); @@ -132,6 +135,9 @@ internal class DeviceVisualizerLed { try { + if (Led.RgbLed.ShapeData == null) + return; + double width = Led.RgbLed.Size.Width - deflateAmount; double height = Led.RgbLed.Size.Height - deflateAmount;