Core - Refactored layout loading, fixing LED images

Core - Make a better effort at removing orphaned devices from device providers that failed to load
This commit is contained in:
Robert committed 2023-10-16 19:44:13 +02:00
1 parent 38f18613c1
commit 43e396bf6d
10 files changed
+111 -124

No files matched your search

@@ -123,27 +123,35 @@ public class DeviceVisualizer : Control
if (Device == null)
return false;
bool difference = false;
int newLedCount = Device.RgbDevice.Count();
if (_previousState.Length != newLedCount)
// Device might be modified mid-check, in that case just pretend it was not dirty
try
{
_previousState = new Color[newLedCount];
difference = true;
}
bool difference = false;
// Check all LEDs for differences and copy the colors to a new state
int index = 0;
foreach (Led led in Device.RgbDevice)
{
if (_previousState[index] != led.Color)
int newLedCount = Device.RgbDevice.Count();
if (_previousState.Length != newLedCount)
{
_previousState = new Color[newLedCount];
difference = true;
}
_previousState[index] = led.Color;
index++;
// Check all LEDs for differences and copy the colors to a new state
int index = 0;
foreach (Led led in Device.RgbDevice)
{
if (_previousState[index] != led.Color)
difference = true;
_previousState[index] = led.Color;
index++;
}
return difference;
}
catch (Exception)
{
return false;
}
return difference;
}
private void Update()
@@ -335,7 +343,7 @@ public class DeviceVisualizer : Control
deviceVisualizerLed.DrawBitmap(context, 2 * device.Scale);
}
BitmapCache[path] = renderTargetBitmap;
// BitmapCache[path] = renderTargetBitmap;
return renderTargetBitmap;
}