diff --git a/RGB.NET.Core/Devices/AbstractRGBDevice.cs b/RGB.NET.Core/Devices/AbstractRGBDevice.cs
index e7c6d08..a83fa16 100644
--- a/RGB.NET.Core/Devices/AbstractRGBDevice.cs
+++ b/RGB.NET.Core/Devices/AbstractRGBDevice.cs
@@ -13,12 +13,25 @@ namespace RGB.NET.Core
///
/// Represents a generic RGB-device.
///
- public abstract class AbstractRGBDevice : AbstractBindable, IRGBDevice
+ public abstract class AbstractRGBDevice : Placeable, IRGBDevice
where TDeviceInfo : class, IRGBDeviceInfo
{
+ private RGBSurface? _surface;
+
#region Properties & Fields
- RGBSurface? IRGBDevice.Surface { get; set; }
+ RGBSurface? IRGBDevice.Surface
+ {
+ get => _surface;
+ set
+ {
+ if (SetProperty(ref _surface, value))
+ {
+ if (value == null) OnDetached();
+ else OnAttached();
+ }
+ }
+ }
///
public abstract TDeviceInfo DeviceInfo { get; }
@@ -26,70 +39,6 @@ namespace RGB.NET.Core
///
IRGBDeviceInfo IRGBDevice.DeviceInfo => DeviceInfo;
- private Point _location = new(0, 0);
- ///
- public Point Location
- {
- get => _location;
- set
- {
- if (SetProperty(ref _location, value))
- UpdateActualData();
- }
- }
-
- private Size _size = Size.Invalid;
- ///
- public Size Size
- {
- get => _size;
- set
- {
- if (SetProperty(ref _size, value))
- UpdateActualData();
- }
- }
-
- private Size _actualSize;
- ///
- public Size ActualSize
- {
- get => _actualSize;
- private set => SetProperty(ref _actualSize, value);
- }
-
- private Rectangle _deviceRectangle;
- ///
- public Rectangle DeviceRectangle
- {
- get => _deviceRectangle;
- private set => SetProperty(ref _deviceRectangle, value);
- }
-
- private Scale _scale = new(1);
- ///
- public Scale Scale
- {
- get => _scale;
- set
- {
- if (SetProperty(ref _scale, value))
- UpdateActualData();
- }
- }
-
- private Rotation _rotation = new(0);
- ///
- public Rotation Rotation
- {
- get => _rotation;
- set
- {
- if (SetProperty(ref _rotation, value))
- UpdateActualData();
- }
- }
-
///
/// Gets or sets if the device needs to be flushed on every update.
///
@@ -106,11 +55,11 @@ namespace RGB.NET.Core
Led? IRGBDevice.this[LedId ledId] => LedMapping.TryGetValue(ledId, out Led? led) ? led : null;
///
- Led? IRGBDevice.this[Point location] => LedMapping.Values.FirstOrDefault(x => x.LedRectangle.Contains(location));
+ Led? IRGBDevice.this[Point location] => LedMapping.Values.FirstOrDefault(x => x.Boundry.Contains(location));
///
IEnumerable IRGBDevice.this[Rectangle referenceRect, double minOverlayPercentage]
- => LedMapping.Values.Where(x => referenceRect.CalculateIntersectPercentage(x.LedRectangle) >= minOverlayPercentage);
+ => LedMapping.Values.Where(x => referenceRect.CalculateIntersectPercentage(x.Boundry) >= minOverlayPercentage);
#endregion
@@ -118,12 +67,6 @@ namespace RGB.NET.Core
#region Methods
- private void UpdateActualData()
- {
- ActualSize = Size * Scale;
- DeviceRectangle = new Rectangle(Location, new Rectangle(new Rectangle(Location, ActualSize).Rotate(Rotation)).Size);
- }
-
///
public virtual void Update(bool flushLeds = false)
{
@@ -188,6 +131,18 @@ namespace RGB.NET.Core
protected virtual object? GetLedCustomData(LedId ledId) => null;
+ protected virtual void OnAttached()
+ {
+ if (Location == Point.Invalid) Location = new Point(0, 0);
+ if (Size == Size.Invalid)
+ {
+ Rectangle ledRectangle = new(this.Select(x => x.Boundry));
+ Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
+ }
+ }
+
+ protected virtual void OnDetached() { }
+
#region Enumerator
///
diff --git a/RGB.NET.Core/Devices/IRGBDevice.cs b/RGB.NET.Core/Devices/IRGBDevice.cs
index 7103773..15d607e 100644
--- a/RGB.NET.Core/Devices/IRGBDevice.cs
+++ b/RGB.NET.Core/Devices/IRGBDevice.cs
@@ -9,7 +9,7 @@ namespace RGB.NET.Core
///
/// Represents a generic RGB-device.
///
- public interface IRGBDevice : IEnumerable, IBindable, IDisposable
+ public interface IRGBDevice : IEnumerable, IPlaceable, IBindable, IDisposable
{
#region Properties
@@ -19,38 +19,7 @@ namespace RGB.NET.Core
/// Gets generic information about the .
///
IRGBDeviceInfo DeviceInfo { get; }
-
- ///
- /// Gets or sets the location of the .
- ///
- Point Location { get; set; }
-
- ///
- /// Gets the of the .
- ///
- Size Size { get; set; }
-
- ///
- /// Gets the actual of the .
- /// This includes the .
- ///
- Size ActualSize { get; }
-
- ///
- /// Gets a representing the logical location of the relative to the .
- ///
- Rectangle DeviceRectangle { get; }
-
- ///
- /// Gets or sets the scale of the .
- ///
- Scale Scale { get; set; }
-
- ///
- /// Gets or sets the rotation of the .
- ///
- Rotation Rotation { get; set; }
-
+
#endregion
#region Indexer
diff --git a/RGB.NET.Core/Events/SurfaceLayoutChangedEventArgs.cs b/RGB.NET.Core/Events/SurfaceLayoutChangedEventArgs.cs
index 5e4840a..64a91df 100644
--- a/RGB.NET.Core/Events/SurfaceLayoutChangedEventArgs.cs
+++ b/RGB.NET.Core/Events/SurfaceLayoutChangedEventArgs.cs
@@ -17,7 +17,7 @@ namespace RGB.NET.Core
///
/// Gets the that caused the change. Returns null if the change isn't caused by a .
///
- public IEnumerable Devices { get; }
+ public IRGBDevice? Devices { get; }
///
/// Gets a value indicating if the event is caused by the addition of a new to the .
@@ -25,9 +25,14 @@ namespace RGB.NET.Core
public bool DeviceAdded { get; }
///
- /// Gets a value indicating if the event is caused by a changed location of one of the devices on the .
+ /// Gets a value indicating if the event is caused by the removal of a to the .
///
- public bool DeviceLocationChanged { get; }
+ public bool DeviceRemoved { get; }
+
+ ///
+ /// Gets a value indicating if the event is caused by a changed location or size of one of the on the .
+ ///
+ public bool DeviceChanged { get; }
#endregion
@@ -40,13 +45,23 @@ namespace RGB.NET.Core
/// The that caused the change.
/// A value indicating if the event is caused by the addition of a new to the .
/// A value indicating if the event is caused by a changed location of one of the devices on the .
- public SurfaceLayoutChangedEventArgs(IEnumerable devices, bool deviceAdded, bool deviceLocationChanged)
+ private SurfaceLayoutChangedEventArgs(IRGBDevice? devices, bool deviceAdded, bool deviceRemoved, bool deviceChanged)
{
this.Devices = devices;
this.DeviceAdded = deviceAdded;
- this.DeviceLocationChanged = deviceLocationChanged;
+ this.DeviceRemoved = deviceRemoved;
+ this.DeviceChanged = deviceChanged;
}
#endregion
+
+ #region Factory
+
+ internal static SurfaceLayoutChangedEventArgs FromAddedDevice(IRGBDevice device) => new(device, true, false, false);
+ internal static SurfaceLayoutChangedEventArgs FromRemovedDevice(IRGBDevice device) => new(device, false, true, false);
+ internal static SurfaceLayoutChangedEventArgs FromChangedDevice(IRGBDevice device) => new(device, false, false, true);
+ internal static SurfaceLayoutChangedEventArgs Misc() => new(null, false, false, false);
+
+ #endregion
}
}
diff --git a/RGB.NET.Core/Leds/Led.cs b/RGB.NET.Core/Leds/Led.cs
index 9766043..217580f 100644
--- a/RGB.NET.Core/Leds/Led.cs
+++ b/RGB.NET.Core/Leds/Led.cs
@@ -1,7 +1,5 @@
// ReSharper disable MemberCanBePrivate.Global
-using System;
-using System.ComponentModel;
using System.Diagnostics;
namespace RGB.NET.Core
@@ -11,7 +9,7 @@ namespace RGB.NET.Core
/// Represents a single LED of a RGB-device.
///
[DebuggerDisplay("{Id} {Color}")]
- public class Led : AbstractBindable
+ public class Led : Placeable
{
#region Properties & Fields
@@ -45,80 +43,14 @@ namespace RGB.NET.Core
set => SetProperty(ref _shapeData, value);
}
- private Point _location;
- ///
- /// Gets or sets the relative location of the .
- ///
- public Point Location
- {
- get => _location;
- set
- {
- if (SetProperty(ref _location, value))
- {
- UpdateActualData();
- UpdateAbsoluteData();
- }
- }
- }
-
- private Size _size;
- ///
- /// Gets or sets the size of the .
- ///
- public Size Size
- {
- get => _size;
- set
- {
- if (SetProperty(ref _size, value))
- {
- UpdateActualData();
- UpdateAbsoluteData();
- }
- }
- }
-
- private Point _actualLocation;
- ///
- /// Gets the actual location of the .
- /// This includes device-scaling and rotation.
- ///
- public Point ActualLocation
- {
- get => _actualLocation;
- private set => SetProperty(ref _actualLocation, value);
- }
-
- private Size _actualSize;
- ///
- /// Gets the actual size of the .
- /// This includes device-scaling.
- ///
- public Size ActualSize
- {
- get => _actualSize;
- private set => SetProperty(ref _actualSize, value);
- }
-
- private Rectangle _ledRectangle;
- ///
- /// Gets a rectangle representing the logical location of the relative to the .
- ///
- public Rectangle LedRectangle
- {
- get => _ledRectangle;
- private set => SetProperty(ref _ledRectangle, value);
- }
-
- private Rectangle _absoluteLedRectangle;
+ private Rectangle _absoluteBoundry;
///
/// Gets a rectangle representing the logical location of the on the .
///
- public Rectangle AbsoluteLedRectangle
+ public Rectangle AbsoluteBoundry
{
- get => _absoluteLedRectangle;
- private set => SetProperty(ref _absoluteLedRectangle, value);
+ get => _absoluteBoundry;
+ private set => SetProperty(ref _absoluteBoundry, value);
}
///
@@ -159,11 +91,6 @@ namespace RGB.NET.Core
}
}
- ///
- /// Gets the URI of an image of the or null if there is no image.
- ///
- public Uri? Image { get; set; }
-
///
/// Gets the provider-specific data associated with this led.
///
@@ -184,59 +111,24 @@ namespace RGB.NET.Core
/// The size of the .
/// The provider-specific data associated with this led.
internal Led(IRGBDevice device, LedId id, Point location, Size size, object? customData = null)
+ : base(device)
{
this.Device = device;
this.Id = id;
this.Location = location;
this.Size = size;
this.CustomData = customData;
-
- device.PropertyChanged += DevicePropertyChanged;
}
#endregion
#region Methods
- private void DevicePropertyChanged(object? sender, PropertyChangedEventArgs e)
+ protected override void UpdateActualPlaceableData()
{
- switch (e.PropertyName)
- {
- case nameof(IRGBDevice.Location):
- UpdateAbsoluteData();
- break;
+ base.UpdateActualPlaceableData();
- case nameof(IRGBDevice.DeviceRectangle):
- UpdateActualData();
- UpdateAbsoluteData();
- break;
- }
- }
-
- private void UpdateActualData()
- {
- ActualSize = Size * Device.Scale;
-
- Point actualLocation = (Location * Device.Scale);
- Rectangle ledRectangle = new(Location * Device.Scale, Size * Device.Scale);
-
- if (Device.Rotation.IsRotated)
- {
- Point deviceCenter = new Rectangle(Device.ActualSize).Center;
- Point actualDeviceCenter = new Rectangle(Device.DeviceRectangle.Size).Center;
- Point centerOffset = new(actualDeviceCenter.X - deviceCenter.X, actualDeviceCenter.Y - deviceCenter.Y);
-
- actualLocation = actualLocation.Rotate(Device.Rotation, new Rectangle(Device.ActualSize).Center) + centerOffset;
- ledRectangle = new Rectangle(ledRectangle.Rotate(Device.Rotation, new Rectangle(Device.ActualSize).Center)).Translate(centerOffset);
- }
-
- ActualLocation = actualLocation;
- LedRectangle = ledRectangle;
- }
-
- private void UpdateAbsoluteData()
- {
- AbsoluteLedRectangle = LedRectangle.Translate(Device.Location);
+ AbsoluteBoundry = Boundry.Translate(Device.Location);
}
///
@@ -285,7 +177,7 @@ namespace RGB.NET.Core
/// Converts a to a .
///
/// The to convert.
- public static implicit operator Rectangle(Led led) => led.LedRectangle;
+ public static implicit operator Rectangle(Led led) => led.Boundry;
#endregion
}
diff --git a/RGB.NET.Core/Positioning/IPlaceable.cs b/RGB.NET.Core/Positioning/IPlaceable.cs
new file mode 100644
index 0000000..d8921c5
--- /dev/null
+++ b/RGB.NET.Core/Positioning/IPlaceable.cs
@@ -0,0 +1,61 @@
+using System;
+
+namespace RGB.NET.Core
+{
+ public interface IPlaceable
+ {
+ #region Properties & Fields
+
+ ///
+ /// Gets or sets the location of the .
+ ///
+ Point Location { get; set; }
+
+ ///
+ /// Gets the size of the .
+ ///
+ Size Size { get; set; }
+
+ ///
+ /// Gets or sets the scale of the .
+ ///
+ Scale Scale { get; set; }
+
+ ///
+ /// Gets or sets the rotation of the .
+ ///
+ Rotation Rotation { get; set; }
+
+ ///
+ /// Gets the actual location of the .
+ /// This includes the .
+ ///
+ Point ActualLocation { get; }
+
+ ///
+ /// Gets the actual of the .
+ /// This includes the .
+ ///
+ Size ActualSize { get; }
+
+ ///
+ /// Gets a rectangle containing the whole .
+ /// This includes , , and .
+ ///
+ Rectangle Boundry { get; }
+
+ #endregion
+
+ #region Events
+
+ event EventHandler LocationChanged;
+ event EventHandler SizeChanged;
+ event EventHandler ScaleChanged;
+ event EventHandler RotationChanged;
+ event EventHandler ActualLocationChanged;
+ event EventHandler ActualSizeChanged;
+ event EventHandler BoundryChanged;
+
+ #endregion
+ }
+}
diff --git a/RGB.NET.Core/Positioning/Placeable.cs b/RGB.NET.Core/Positioning/Placeable.cs
new file mode 100644
index 0000000..9db851d
--- /dev/null
+++ b/RGB.NET.Core/Positioning/Placeable.cs
@@ -0,0 +1,199 @@
+using System;
+
+namespace RGB.NET.Core
+{
+ public class Placeable : AbstractBindable, IPlaceable
+ {
+ #region Properties & Fields
+
+ protected IPlaceable? Parent { get; }
+
+ private Point _location = Point.Invalid;
+ ///
+ public Point Location
+ {
+ get => _location;
+ set
+ {
+ if (SetProperty(ref _location, value))
+ OnLocationChanged();
+ }
+ }
+
+ private Size _size = Size.Invalid;
+ ///
+ public Size Size
+ {
+ get => _size;
+ set
+ {
+ if (SetProperty(ref _size, value))
+ OnSizeChanged();
+ }
+ }
+
+ private Scale _scale = new(1);
+ ///
+ public Scale Scale
+ {
+ get => _scale;
+ set
+ {
+ if (SetProperty(ref _scale, value))
+ OnScaleChanged();
+ }
+ }
+
+ private Rotation _rotation = new(0);
+ ///
+ public Rotation Rotation
+ {
+ get => _rotation;
+ set
+ {
+ if (SetProperty(ref _rotation, value))
+ OnRotationChanged();
+ }
+ }
+
+ private Point _actualLocation = Point.Invalid;
+ ///
+ public Point ActualLocation
+ {
+ get => _actualLocation;
+ private set
+ {
+ if (SetProperty(ref _actualLocation, value))
+ OnActualLocationChanged();
+ }
+ }
+
+ private Size _actualSize = Size.Invalid;
+ ///
+ public Size ActualSize
+ {
+ get => _actualSize;
+ private set
+ {
+ if (SetProperty(ref _actualSize, value))
+ OnActualSizeChanged();
+ }
+ }
+
+ private Rectangle _boundry = new(Point.Invalid, Point.Invalid);
+ ///
+ public Rectangle Boundry
+ {
+ get => _boundry;
+ private set
+ {
+ if (SetProperty(ref _boundry, value))
+ OnBoundryChanged();
+ }
+ }
+
+ #endregion
+
+ #region Events
+
+ public event EventHandler? LocationChanged;
+ public event EventHandler? SizeChanged;
+ public event EventHandler? ScaleChanged;
+ public event EventHandler? RotationChanged;
+ public event EventHandler? ActualLocationChanged;
+ public event EventHandler? ActualSizeChanged;
+ public event EventHandler? BoundryChanged;
+
+ #endregion
+
+ #region Constructors
+
+ public Placeable() { }
+
+ public Placeable(IPlaceable parent)
+ {
+ this.Parent = parent;
+
+ Parent.BoundryChanged += (_, _) => UpdateActualPlaceableData();
+ }
+
+ public Placeable(Point location, Size size)
+ {
+ this.Location = location;
+ this.Size = size;
+ }
+
+ public Placeable(IPlaceable parent, Point location, Size size)
+ {
+ this.Parent = parent;
+ this.Location = location;
+ this.Size = size;
+
+ Parent.BoundryChanged += (_, _) => UpdateActualPlaceableData();
+ }
+
+ #endregion
+
+ #region Methods
+
+ protected virtual void UpdateActualPlaceableData()
+ {
+ if (Parent != null)
+ {
+ Size actualSize = Size * Parent.Scale;
+ Point actualLocation = (Location * Parent.Scale);
+ Rectangle boundry = new(actualLocation, actualSize);
+
+ if (Parent.Rotation.IsRotated)
+ {
+ Point parentCenter = new Rectangle(Parent.ActualSize).Center;
+ Point actualParentCenter = new Rectangle(Parent.Boundry.Size).Center;
+ Point centerOffset = new(actualParentCenter.X - parentCenter.X, actualParentCenter.Y - parentCenter.Y);
+
+ actualLocation = actualLocation.Rotate(Parent.Rotation, new Rectangle(Parent.ActualSize).Center) + centerOffset;
+ boundry = new Rectangle(boundry.Rotate(Parent.Rotation, new Rectangle(Parent.ActualSize).Center)).Translate(centerOffset);
+ }
+
+ ActualLocation = actualLocation;
+ ActualSize = actualSize;
+ Boundry = boundry;
+ }
+ else
+ {
+ ActualLocation = Location;
+ ActualSize = Size * Scale;
+ Boundry = new Rectangle(Location, new Rectangle(new Rectangle(Location, ActualSize).Rotate(Rotation)).Size);
+ }
+ }
+
+ protected virtual void OnLocationChanged()
+ {
+ LocationChanged?.Invoke(this, new EventArgs());
+ UpdateActualPlaceableData();
+ }
+
+ protected virtual void OnSizeChanged()
+ {
+ SizeChanged?.Invoke(this, new EventArgs());
+ UpdateActualPlaceableData();
+ }
+
+ protected virtual void OnScaleChanged()
+ {
+ ScaleChanged?.Invoke(this, new EventArgs());
+ UpdateActualPlaceableData();
+ }
+
+ protected virtual void OnRotationChanged()
+ {
+ RotationChanged?.Invoke(this, new EventArgs());
+ UpdateActualPlaceableData();
+ }
+
+ protected virtual void OnActualLocationChanged() => ActualLocationChanged?.Invoke(this, new EventArgs());
+ protected virtual void OnActualSizeChanged() => ActualSizeChanged?.Invoke(this, new EventArgs());
+ protected virtual void OnBoundryChanged() => BoundryChanged?.Invoke(this, new EventArgs());
+
+ #endregion
+ }
+}
diff --git a/RGB.NET.Core/RGB.NET.Core.csproj.DotSettings b/RGB.NET.Core/RGB.NET.Core.csproj.DotSettings
index 9555e90..8f59663 100644
--- a/RGB.NET.Core/RGB.NET.Core.csproj.DotSettings
+++ b/RGB.NET.Core/RGB.NET.Core.csproj.DotSettings
@@ -9,6 +9,7 @@
True
True
True
+ True
True
True
True
diff --git a/RGB.NET.Core/RGBSurface.cs b/RGB.NET.Core/RGBSurface.cs
index 4c6ec12..e1dd16e 100644
--- a/RGB.NET.Core/RGBSurface.cs
+++ b/RGB.NET.Core/RGBSurface.cs
@@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
-using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
@@ -212,13 +211,13 @@ namespace RGB.NET.Core
switch (brush.BrushCalculationMode)
{
case BrushCalculationMode.Relative:
- Rectangle brushRectangle = new(leds.Select(led => led.AbsoluteLedRectangle));
+ Rectangle brushRectangle = new(leds.Select(led => led.AbsoluteBoundry));
Point offset = new(-brushRectangle.Location.X, -brushRectangle.Location.Y);
brushRectangle = brushRectangle.SetLocation(new Point(0, 0));
- brush.PerformRender(brushRectangle, leds.Select(led => new BrushRenderTarget(led, led.AbsoluteLedRectangle.Translate(offset))));
+ brush.PerformRender(brushRectangle, leds.Select(led => new BrushRenderTarget(led, led.AbsoluteBoundry.Translate(offset))));
break;
case BrushCalculationMode.Absolute:
- brush.PerformRender(SurfaceRectangle, leds.Select(led => new BrushRenderTarget(led, led.AbsoluteLedRectangle)));
+ brush.PerformRender(SurfaceRectangle, leds.Select(led => new BrushRenderTarget(led, led.AbsoluteBoundry)));
break;
default:
throw new ArgumentException();
@@ -281,11 +280,13 @@ namespace RGB.NET.Core
{
lock (_devices)
{
- if (_devices.Contains(device)) throw new RGBSurfaceException($"The device '{device.DeviceInfo.Manufacturer} {device.DeviceInfo.Model}' is already attached.");
+ if (device.Surface != null) throw new RGBSurfaceException($"The device '{device.DeviceInfo.Manufacturer} {device.DeviceInfo.Model}' is already attached to a surface.");
device.Surface = this;
+ device.BoundryChanged += DeviceOnBoundryChanged;
_devices.Add(device);
+ OnSurfaceLayoutChanged(SurfaceLayoutChangedEventArgs.FromAddedDevice(device));
}
}
@@ -302,11 +303,14 @@ namespace RGB.NET.Core
{
lock (_devices)
{
- if (!_devices.Contains(device)) throw new RGBSurfaceException($"The device '{device.DeviceInfo.Manufacturer} {device.DeviceInfo.Model}' isn't attached.");
+ if (!_devices.Contains(device)) throw new RGBSurfaceException($"The device '{device.DeviceInfo.Manufacturer} {device.DeviceInfo.Model}' isn't not attached to this surface.");
+ device.BoundryChanged -= DeviceOnBoundryChanged;
device.Surface = null;
_devices.Remove(device);
+
+ OnSurfaceLayoutChanged(SurfaceLayoutChangedEventArgs.FromRemovedDevice(device));
}
}
@@ -325,17 +329,21 @@ namespace RGB.NET.Core
// ReSharper restore UnusedMember.Global
- private void DeviceOnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs)
+ private void DeviceOnBoundryChanged(object? sender, EventArgs args)
+ => OnSurfaceLayoutChanged((sender is IRGBDevice device) ? SurfaceLayoutChangedEventArgs.FromChangedDevice(device) : SurfaceLayoutChangedEventArgs.Misc());
+
+ private void OnSurfaceLayoutChanged(SurfaceLayoutChangedEventArgs args)
{
UpdateSurfaceRectangle();
- SurfaceLayoutChanged?.Invoke(new SurfaceLayoutChangedEventArgs((sender is IRGBDevice device) ? new[] { device } : Array.Empty(), false, true));
+
+ SurfaceLayoutChanged?.Invoke(args);
}
private void UpdateSurfaceRectangle()
{
lock (_devices)
{
- Rectangle devicesRectangle = new(_devices.Select(d => d.DeviceRectangle));
+ Rectangle devicesRectangle = new(_devices.Select(d => d.Boundry));
SurfaceRectangle = SurfaceRectangle.SetSize(new Size(devicesRectangle.Location.X + devicesRectangle.Size.Width, devicesRectangle.Location.Y + devicesRectangle.Size.Height));
}
}
diff --git a/RGB.NET.Devices.Asus/Generic/AsusRGBDevice.cs b/RGB.NET.Devices.Asus/Generic/AsusRGBDevice.cs
index 8b57013..f0fc1bc 100644
--- a/RGB.NET.Devices.Asus/Generic/AsusRGBDevice.cs
+++ b/RGB.NET.Devices.Asus/Generic/AsusRGBDevice.cs
@@ -49,13 +49,7 @@ namespace RGB.NET.Devices.Asus
public void Initialize(IDeviceUpdateTrigger updateTrigger)
{
InitializeLayout();
-
- if (Size == Size.Invalid)
- {
- Rectangle ledRectangle = new(this.Select(x => x.LedRectangle));
- Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
- }
-
+
UpdateQueue = new AsusUpdateQueue(updateTrigger);
UpdateQueue.Initialize(DeviceInfo.Device);
}
diff --git a/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDevice.cs b/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDevice.cs
index 054981d..b176bc7 100644
--- a/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDevice.cs
+++ b/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDevice.cs
@@ -52,13 +52,7 @@ namespace RGB.NET.Devices.CoolerMaster
public void Initialize(IDeviceUpdateTrigger updateTrigger)
{
InitializeLayout();
-
- if (Size == Size.Invalid)
- {
- Rectangle ledRectangle = new(this.Select(x => x.LedRectangle));
- Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
- }
-
+
UpdateQueue = new CoolerMasterUpdateQueue(updateTrigger, DeviceInfo.DeviceIndex);
}
diff --git a/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs b/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs
index 9dd74ea..d573ba2 100644
--- a/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs
+++ b/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs
@@ -75,12 +75,6 @@ namespace RGB.NET.Devices.Corsair
if (led.CustomData is CorsairLedId ledId && (ledId != CorsairLedId.Invalid))
InternalLedMapping.Add(ledId, led);
}
-
- if (Size == Size.Invalid)
- {
- Rectangle ledRectangle = new(this.Select(x => x.LedRectangle));
- Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
- }
}
///
diff --git a/RGB.NET.Devices.DMX/E131/E131Device.cs b/RGB.NET.Devices.DMX/E131/E131Device.cs
index edb078e..3a8c4fe 100644
--- a/RGB.NET.Devices.DMX/E131/E131Device.cs
+++ b/RGB.NET.Devices.DMX/E131/E131Device.cs
@@ -39,13 +39,7 @@ namespace RGB.NET.Devices.DMX.E131
int count = 0;
foreach (LedId id in _ledMappings.Keys)
AddLed(id, new Point((count++) * 10, 0), new Size(10, 10));
-
- if (Size == Size.Invalid)
- {
- Rectangle ledRectangle = new(this.Select(x => x.LedRectangle));
- Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
- }
-
+
_updateQueue = new E131UpdateQueue(updateTrigger, DeviceInfo.Hostname, DeviceInfo.Port);
_updateQueue.DataPacket.SetCID(DeviceInfo.CID);
_updateQueue.DataPacket.SetUniverse(DeviceInfo.Universe);
diff --git a/RGB.NET.Devices.Msi/Generic/MsiRGBDevice.cs b/RGB.NET.Devices.Msi/Generic/MsiRGBDevice.cs
index a6933cc..3da1d27 100644
--- a/RGB.NET.Devices.Msi/Generic/MsiRGBDevice.cs
+++ b/RGB.NET.Devices.Msi/Generic/MsiRGBDevice.cs
@@ -51,12 +51,6 @@ namespace RGB.NET.Devices.Msi
DeviceUpdateQueue = updateQueue;
InitializeLayout(ledCount);
-
- if (Size == Size.Invalid)
- {
- Rectangle ledRectangle = new(this.Select(x => x.LedRectangle));
- Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
- }
}
///
diff --git a/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs b/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs
index c41c77e..2976355 100644
--- a/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs
+++ b/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs
@@ -50,13 +50,7 @@ namespace RGB.NET.Devices.Novation
public void Initialize(IDeviceUpdateTrigger updateTrigger)
{
InitializeLayout();
-
- if (Size == Size.Invalid)
- {
- Rectangle ledRectangle = new(this.Select(x => x.LedRectangle));
- Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
- }
-
+
UpdateQueue = DeviceInfo.ColorCapabilities switch
{
NovationColorCapabilities.LimitedRG => new LimitedColorUpdateQueue(updateTrigger, DeviceInfo.DeviceId),
diff --git a/RGB.NET.Devices.Razer/Generic/RazerRGBDevice.cs b/RGB.NET.Devices.Razer/Generic/RazerRGBDevice.cs
index 25dc2f9..afab079 100644
--- a/RGB.NET.Devices.Razer/Generic/RazerRGBDevice.cs
+++ b/RGB.NET.Devices.Razer/Generic/RazerRGBDevice.cs
@@ -51,13 +51,7 @@ namespace RGB.NET.Devices.Razer
public void Initialize(IDeviceUpdateTrigger updateTrigger)
{
InitializeLayout();
-
- if (Size == Size.Invalid)
- {
- Rectangle ledRectangle = new(this.Select(x => x.LedRectangle));
- Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
- }
-
+
UpdateQueue = CreateUpdateQueue(updateTrigger);
}
diff --git a/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesRGBDevice.cs b/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesRGBDevice.cs
index 255dd90..1f31857 100644
--- a/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesRGBDevice.cs
+++ b/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesRGBDevice.cs
@@ -54,13 +54,7 @@ namespace RGB.NET.Devices.SteelSeries
int counter = 0;
foreach (KeyValuePair mapping in ledMapping)
AddLed(mapping.Key, new Point((counter++) * 10, 0), new Size(10, 10));
-
- if (Size == Size.Invalid)
- {
- Rectangle ledRectangle = new(this.Select(x => x.LedRectangle));
- Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
- }
-
+
UpdateQueue = updateQueue;
}
diff --git a/RGB.NET.Devices.WS281X/Arduino/ArduinoWS2812USBDevice.cs b/RGB.NET.Devices.WS281X/Arduino/ArduinoWS2812USBDevice.cs
index 53327cb..1a9f186 100644
--- a/RGB.NET.Devices.WS281X/Arduino/ArduinoWS2812USBDevice.cs
+++ b/RGB.NET.Devices.WS281X/Arduino/ArduinoWS2812USBDevice.cs
@@ -54,12 +54,6 @@ namespace RGB.NET.Devices.WS281X.Arduino
{
for (int i = 0; i < ledCount; i++)
AddLed(LedId.LedStripe1 + i, new Point(i * 10, 0), new Size(10, 10));
-
- if (Size == Size.Invalid)
- {
- Rectangle ledRectangle = new(this.Select(x => x.LedRectangle));
- Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
- }
}
///
diff --git a/RGB.NET.Devices.WS281X/Bitwizard/BitwizardWS2812USBDevice.cs b/RGB.NET.Devices.WS281X/Bitwizard/BitwizardWS2812USBDevice.cs
index f76ab40..6e2d813 100644
--- a/RGB.NET.Devices.WS281X/Bitwizard/BitwizardWS2812USBDevice.cs
+++ b/RGB.NET.Devices.WS281X/Bitwizard/BitwizardWS2812USBDevice.cs
@@ -51,12 +51,6 @@ namespace RGB.NET.Devices.WS281X.Bitwizard
{
for (int i = 0; i < ledCount; i++)
AddLed(LedId.LedStripe1 + i, new Point(i * 10, 0), new Size(10, 10));
-
- if (Size == Size.Invalid)
- {
- Rectangle ledRectangle = new(this.Select(x => x.LedRectangle));
- Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
- }
}
///
diff --git a/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBDevice.cs b/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBDevice.cs
index 6b24a74..b471e17 100644
--- a/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBDevice.cs
+++ b/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBDevice.cs
@@ -54,12 +54,6 @@ namespace RGB.NET.Devices.WS281X.NodeMCU
{
for (int i = 0; i < ledCount; i++)
AddLed(LedId.LedStripe1 + i, new Point(i * 10, 0), new Size(10, 10));
-
- if (Size == Size.Invalid)
- {
- Rectangle ledRectangle = new(this.Select(x => x.LedRectangle));
- Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
- }
}
///
diff --git a/RGB.NET.Devices.Wooting/Generic/WootingRGBDevice.cs b/RGB.NET.Devices.Wooting/Generic/WootingRGBDevice.cs
index b466ac8..4f843a8 100644
--- a/RGB.NET.Devices.Wooting/Generic/WootingRGBDevice.cs
+++ b/RGB.NET.Devices.Wooting/Generic/WootingRGBDevice.cs
@@ -1,5 +1,4 @@
-using System.Linq;
-using RGB.NET.Core;
+using RGB.NET.Core;
namespace RGB.NET.Devices.Wooting.Generic
{
@@ -48,13 +47,7 @@ namespace RGB.NET.Devices.Wooting.Generic
public void Initialize(IDeviceUpdateTrigger updateTrigger)
{
InitializeLayout();
-
- if (Size == Size.Invalid)
- {
- Rectangle ledRectangle = new(this.Select(x => x.LedRectangle));
- Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
- }
-
+
UpdateQueue = new WootingUpdateQueue(updateTrigger);
}
diff --git a/RGB.NET.Groups/Groups/RectangleLedGroup.cs b/RGB.NET.Groups/Groups/RectangleLedGroup.cs
index fadce4d..ef81c45 100644
--- a/RGB.NET.Groups/Groups/RectangleLedGroup.cs
+++ b/RGB.NET.Groups/Groups/RectangleLedGroup.cs
@@ -59,7 +59,7 @@ namespace RGB.NET.Groups
/// (optional) The minimal percentage overlay a must have with the to be taken into the . (default: 0.5)
/// (optional) Specifies whether this should be automatically attached or not. (default: true)
public RectangleLedGroup(RGBSurface? surface, Led fromLed, Led toLed, double minOverlayPercentage = 0.5)
- : this(surface, new Rectangle(fromLed.LedRectangle, toLed.LedRectangle), minOverlayPercentage)
+ : this(surface, new Rectangle(fromLed.Boundry, toLed.Boundry), minOverlayPercentage)
{ }
///
@@ -117,7 +117,7 @@ namespace RGB.NET.Groups
/// Gets a list containing all of this .
///
/// The list containing all of this .
- public override IList GetLeds() => _ledCache ??= (Surface?.Leds.Where(led => led.AbsoluteLedRectangle.CalculateIntersectPercentage(Rectangle) >= MinOverlayPercentage).ToList() ?? new List());
+ public override IList GetLeds() => _ledCache ??= (Surface?.Leds.Where(led => led.AbsoluteBoundry.CalculateIntersectPercentage(Rectangle) >= MinOverlayPercentage).ToList() ?? new List());
private void InvalidateCache() => _ledCache = null;