Core - Ensure devices owned by ArtemisDevice always have valid dimensions

This commit is contained in:
Robert committed 2023-10-14 19:36:46 +02:00
1 parent 76d424012a
commit 38f18613c1
3 files changed
+38 -9

No files matched your search

@@ -22,13 +22,13 @@ public class ArtemisDevice : CorePropertyChanged
internal ArtemisDevice(IRGBDevice rgbDevice, DeviceProvider deviceProvider)
{
Rectangle ledRectangle = new(rgbDevice.Select(x => x.Boundary));
rgbDevice.EnsureValidDimensions();
_originalLeds = new List<OriginalLed>(rgbDevice.Select(l => new OriginalLed(l)));
_originalSize = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
_originalSize = rgbDevice.Size;
RgbDevice = rgbDevice;
Identifier = rgbDevice.GetDeviceIdentifier();
DeviceEntity = new DeviceEntity();
RgbDevice = rgbDevice;
DeviceProvider = deviceProvider;
Rotation = 0;
@@ -58,13 +58,13 @@ public class ArtemisDevice : CorePropertyChanged
internal ArtemisDevice(IRGBDevice rgbDevice, DeviceProvider deviceProvider, DeviceEntity deviceEntity)
{
Rectangle ledRectangle = new(rgbDevice.Select(x => x.Boundary));
rgbDevice.EnsureValidDimensions();
_originalLeds = new List<OriginalLed>(rgbDevice.Select(l => new OriginalLed(l)));
_originalSize = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
_originalSize = rgbDevice.Size;
RgbDevice = rgbDevice;
Identifier = rgbDevice.GetDeviceIdentifier();
DeviceEntity = deviceEntity;
RgbDevice = rgbDevice;
DeviceProvider = deviceProvider;
LedIds = new ReadOnlyDictionary<LedId, ArtemisLed>(new Dictionary<LedId, ArtemisLed>());
@@ -609,9 +609,9 @@ public class ArtemisDevice : CorePropertyChanged
private void RgbDeviceOnPropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName != nameof(IRGBDevice.Surface))
if (e.PropertyName != nameof(IRGBDevice.Surface) || RgbDevice.Surface == null)
return;
RgbDevice.Rotation = DeviceEntity.Rotation;
RgbDevice.Scale = DeviceEntity.Scale;
ApplyLocation(DeviceEntity.X, DeviceEntity.Y);