1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-12 21:38:38 +00:00

Device visualizer - Fix crash when LED geometry is null

This commit is contained in:
Robert 2023-04-20 14:00:51 +02:00
parent afa76a262a
commit de23b5449b
2 changed files with 10 additions and 4 deletions

View File

@ -1,5 +1,5 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" <wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=controls/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=exceptions/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=exceptions/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=plugins/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=plugins/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=services_005Cwindow/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=services_005Cwindow/@EntryIndexedValue">True</s:Boolean>

View File

@ -61,6 +61,9 @@ internal class DeviceVisualizerLed
public void RenderGeometry(DrawingContext drawingContext, bool dimmed) public void RenderGeometry(DrawingContext drawingContext, bool dimmed)
{ {
if (DisplayGeometry == null)
return;
byte r = Led.RgbLed.Color.GetR(); byte r = Led.RgbLed.Color.GetR();
byte g = Led.RgbLed.Color.GetG(); byte g = Led.RgbLed.Color.GetG();
byte b = Led.RgbLed.Color.GetB(); byte b = Led.RgbLed.Color.GetB();
@ -94,13 +97,13 @@ internal class DeviceVisualizerLed
switch (Led.RgbLed.Shape) switch (Led.RgbLed.Shape)
{ {
case Shape.Custom: 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); CreateCustomGeometry(2.0);
else else
CreateCustomGeometry(1.0); CreateCustomGeometry(1.0);
break; break;
case Shape.Rectangle: 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(); CreateKeyCapGeometry();
else else
CreateRectangleGeometry(); CreateRectangleGeometry();
@ -132,6 +135,9 @@ internal class DeviceVisualizerLed
{ {
try try
{ {
if (Led.RgbLed.ShapeData == null)
return;
double width = Led.RgbLed.Size.Width - deflateAmount; double width = Led.RgbLed.Size.Width - deflateAmount;
double height = Led.RgbLed.Size.Height - deflateAmount; double height = Led.RgbLed.Size.Height - deflateAmount;