Updated for RGB.NET's changes regarding rotation

This commit is contained in:
SpoinkyNL committed 2019-11-21 08:45:38 +01:00
1 parent 97907c97eb
commit 086f2fc1f9
19 files changed
+175 -88

No files matched your search

+6 -3
View File
@@ -24,7 +24,7 @@ namespace Artemis.Core.Models.Surface
ZIndex = 1;
ApplyToEntity();
CalculateRenderRectangle();
CalculateRenderProperties();
}
internal Device(IRGBDevice rgbDevice, Plugin plugin, Surface surface, DeviceEntity deviceEntity)
@@ -78,10 +78,12 @@ namespace Artemis.Core.Models.Surface
internal void ApplyToRgbDevice()
{
RgbDevice.Location = new Point(DeviceEntity.X, DeviceEntity.Y);
CalculateRenderRectangle();
RgbDevice.Rotation = DeviceEntity.Rotation;
CalculateRenderProperties();
}
internal void CalculateRenderRectangle()
internal void CalculateRenderProperties()
{
RenderRectangle = new Rectangle(
(int) Math.Round(RgbDevice.Location.X * Surface.Scale, MidpointRounding.AwayFromZero),
@@ -98,6 +100,7 @@ namespace Artemis.Core.Models.Surface
var path = new GraphicsPath();
path.AddRectangles(Leds.Select(l => l.AbsoluteRenderRectangle).ToArray());
path.FillMode = FillMode.Winding;
RenderPath = path;
}
@@ -0,0 +1,38 @@
using System;
using RGB.NET.Core;
using Rectangle = System.Drawing.Rectangle;
namespace Artemis.Core.Models.Surface
{
public class DeviceLed
{
public DeviceLed(Led led, Device device)
{
RgbLed = led;
Device = device;
CalculateRenderRectangle();
}
public Led RgbLed { get; }
public Device Device { get; }
public Rectangle RenderRectangle { get; private set; }
public Rectangle AbsoluteRenderRectangle { get; private set; }
public void CalculateRenderRectangle()
{
RenderRectangle = new Rectangle(
(int) Math.Round(RgbLed.LedRectangle.Location.X * Device.Surface.Scale, MidpointRounding.AwayFromZero),
(int) Math.Round(RgbLed.LedRectangle.Location.Y * Device.Surface.Scale, MidpointRounding.AwayFromZero),
(int) Math.Round(RgbLed.LedRectangle.Size.Width * Device.Surface.Scale, MidpointRounding.AwayFromZero),
(int) Math.Round(RgbLed.LedRectangle.Size.Height * Device.Surface.Scale, MidpointRounding.AwayFromZero)
);
AbsoluteRenderRectangle = new Rectangle(
(int) Math.Round(RgbLed.AbsoluteLedRectangle.Location.X * Device.Surface.Scale, MidpointRounding.AwayFromZero),
(int) Math.Round(RgbLed.AbsoluteLedRectangle.Location.Y * Device.Surface.Scale, MidpointRounding.AwayFromZero),
(int) Math.Round(RgbLed.AbsoluteLedRectangle.Size.Width * Device.Surface.Scale, MidpointRounding.AwayFromZero),
(int) Math.Round(RgbLed.AbsoluteLedRectangle.Size.Height * Device.Surface.Scale, MidpointRounding.AwayFromZero)
);
}
}
}
-38
View File
@@ -1,38 +0,0 @@
using System;
using RGB.NET.Core;
using Rectangle = System.Drawing.Rectangle;
namespace Artemis.Core.Models.Surface
{
public class DeviceLed
{
public DeviceLed(Led led, Device device)
{
RgbLed = led;
Device = device;
CalculateRenderRectangle();
}
public Led RgbLed { get; }
public Device Device { get; }
public Rectangle RenderRectangle { get; private set; }
public Rectangle AbsoluteRenderRectangle { get; private set; }
public void CalculateRenderRectangle()
{
RenderRectangle = new Rectangle(
(int) Math.Round(RgbLed.LedRectangle.X * Device.Surface.Scale, MidpointRounding.AwayFromZero),
(int) Math.Round(RgbLed.LedRectangle.Y * Device.Surface.Scale, MidpointRounding.AwayFromZero),
(int) Math.Round(RgbLed.LedRectangle.Width * Device.Surface.Scale, MidpointRounding.AwayFromZero),
(int) Math.Round(RgbLed.LedRectangle.Height * Device.Surface.Scale, MidpointRounding.AwayFromZero)
);
AbsoluteRenderRectangle = new Rectangle(
(int) Math.Round(RgbLed.AbsoluteLedRectangle.X * Device.Surface.Scale, MidpointRounding.AwayFromZero),
(int) Math.Round(RgbLed.AbsoluteLedRectangle.Y * Device.Surface.Scale, MidpointRounding.AwayFromZero),
(int) Math.Round(RgbLed.AbsoluteLedRectangle.Width * Device.Surface.Scale, MidpointRounding.AwayFromZero),
(int) Math.Round(RgbLed.AbsoluteLedRectangle.Height * Device.Surface.Scale, MidpointRounding.AwayFromZero)
);
}
}
}
+1 -1
View File
@@ -65,7 +65,7 @@ namespace Artemis.Core.Models.Surface
{
Scale = value;
foreach (var device in Devices)
device.CalculateRenderRectangle();
device.CalculateRenderProperties();
OnScaleChanged();
}