diff --git a/RGB.NET.Core/Devices/AbstractRGBDevice.cs b/RGB.NET.Core/Devices/AbstractRGBDevice.cs
index 83acda9..305e1a2 100644
--- a/RGB.NET.Core/Devices/AbstractRGBDevice.cs
+++ b/RGB.NET.Core/Devices/AbstractRGBDevice.cs
@@ -24,30 +24,20 @@ namespace RGB.NET.Core
///
IRGBDeviceInfo IRGBDevice.DeviceInfo => DeviceInfo;
+ private Size _size = Size.Invalid;
///
- public Size Size => new Size(InternalSize?.Width ?? 0, InternalSize?.Height ?? 0);
-
- private Size _internalSize;
- ///
- /// Gets the of the whole .
- ///
- protected Size InternalSize
+ public Size Size
{
- get => _internalSize;
- set
- {
- // ReSharper disable once ExplicitCallerInfoArgument
- if (SetProperty(ref _internalSize, value))
- OnPropertyChanged(nameof(Size));
- }
+ get => _size;
+ set => SetProperty(ref _size, value);
}
- private Point _location = new Point();
+ private Point _location = new Point(0, 0);
///
public Point Location
{
get => _location;
- set => SetProperty(ref _location, value ?? new Point());
+ set => SetProperty(ref _location, value);
}
///
diff --git a/RGB.NET.Core/Leds/Color.cs b/RGB.NET.Core/Leds/Color.cs
index 65786b0..f67a4d8 100644
--- a/RGB.NET.Core/Leds/Color.cs
+++ b/RGB.NET.Core/Leds/Color.cs
@@ -454,7 +454,7 @@ namespace RGB.NET.Core
/// The value value to add.
/// The new color after the modification.
public Color AddHSV(int a, double hue, double saturation, double value)
- => Color.FromHSV(A + a, Hue + hue, Saturation + saturation, Value + value);
+ => FromHSV(A + a, Hue + hue, Saturation + saturation, Value + value);
///
/// Adds the given alpha value to this color.
diff --git a/RGB.NET.Core/Positioning/Point.cs b/RGB.NET.Core/Positioning/Point.cs
index 8d05d55..de28c22 100644
--- a/RGB.NET.Core/Positioning/Point.cs
+++ b/RGB.NET.Core/Positioning/Point.cs
@@ -5,45 +5,37 @@ using System.Diagnostics;
namespace RGB.NET.Core
{
- ///
///
/// Represents a point consisting of a X- and a Y-position.
///
[DebuggerDisplay("[X: {X}, Y: {Y}]")]
- public class Point : AbstractBindable
+ public struct Point
{
+ #region Constants
+
+ ///
+ /// Gets a [NaN,NaN]-Point.
+ ///
+ public static Point Invalid => new Point(double.NaN, double.NaN);
+
+ #endregion
+
#region Properties & Fields
- private double _x;
///
- /// Gets or sets the X-position of this .
+ /// Gets the X-position of this .
///
- public double X
- {
- get => _x;
- set => SetProperty(ref _x, value);
- }
+ public double X { get; }
- private double _y;
///
- /// Gets or sets the Y-position of this .
+ /// Gets the Y-position of this .
///
- public double Y
- {
- get => _y;
- set => SetProperty(ref _y, value);
- }
+ public double Y { get; }
#endregion
#region Constructors
- ///
- /// Initializes a new instance of the class.
- ///
- public Point()
- { }
-
///
/// Initializes a new instance of the class using the provided values.
///
@@ -63,10 +55,7 @@ namespace RGB.NET.Core
/// Converts the - and -position of this to a human-readable string.
///
/// A string that contains the and of this . For example "[X: 100, Y: 20]".
- public override string ToString()
- {
- return $"[X: {X}, Y: {Y}]";
- }
+ public override string ToString() => $"[X: {X}, Y: {Y}]";
///
/// Tests whether the specified object is a and is equivalent to this .
@@ -75,16 +64,9 @@ namespace RGB.NET.Core
/// true if is a equivalent to this ; otherwise, false.
public override bool Equals(object obj)
{
- Point comparePoint = obj as Point;
- if (ReferenceEquals(comparePoint, null))
- return false;
-
- if (ReferenceEquals(this, comparePoint))
- return true;
-
- if (GetType() != comparePoint.GetType())
- return false;
+ if (!(obj is Point)) return false;
+ Point comparePoint = (Point)obj;
return X.EqualsInTolerance(comparePoint.X) && Y.EqualsInTolerance(comparePoint.Y);
}
@@ -112,10 +94,7 @@ namespace RGB.NET.Core
/// The first to compare.
/// The second to compare.
/// true if and are equal; otherwise, false.
- public static bool operator ==(Point point1, Point point2)
- {
- return ReferenceEquals(point1, null) ? ReferenceEquals(point2, null) : point1.Equals(point2);
- }
+ public static bool operator ==(Point point1, Point point2) => point1.Equals(point2);
///
/// Returns a value that indicates whether two specified are equal.
@@ -123,10 +102,7 @@ namespace RGB.NET.Core
/// The first to compare.
/// The second to compare.
/// true if and are not equal; otherwise, false.
- public static bool operator !=(Point point1, Point point2)
- {
- return !(point1 == point2);
- }
+ public static bool operator !=(Point point1, Point point2) => !(point1 == point2);
///
/// Returns a new representing the addition of the two provided .
@@ -134,10 +110,15 @@ namespace RGB.NET.Core
/// The first .
/// The second .
/// A new representing the addition of the two provided .
- public static Point operator +(Point point1, Point point2)
- {
- return new Point(point1.X + point2.X, point1.Y + point2.Y);
- }
+ public static Point operator +(Point point1, Point point2) => new Point(point1.X + point2.X, point1.Y + point2.Y);
+
+ ///
+ /// Returns a new created from the provided and .
+ ///
+ /// The of the rectangle.
+ /// The of the rectangle.
+ /// The rectangle created from the provided and .
+ public static Rectangle operator +(Point point, Size size) => new Rectangle(point, size);
///
/// Returns a new representing the subtraction of the two provided .
@@ -145,10 +126,7 @@ namespace RGB.NET.Core
/// The first .
/// The second .
/// A new representing the subtraction of the two provided .
- public static Point operator -(Point point1, Point point2)
- {
- return new Point(point1.X - point2.X, point1.Y - point2.Y);
- }
+ public static Point operator -(Point point1, Point point2) => new Point(point1.X - point2.X, point1.Y - point2.Y);
///
/// Returns a new representing the multiplication of the two provided .
@@ -156,10 +134,7 @@ namespace RGB.NET.Core
/// The first .
/// The second .
/// A new representing the multiplication of the two provided .
- public static Point operator *(Point point1, Point point2)
- {
- return new Point(point1.X * point2.X, point1.Y * point2.Y);
- }
+ public static Point operator *(Point point1, Point point2) => new Point(point1.X * point2.X, point1.Y * point2.Y);
///
/// Returns a new representing the division of the two provided .
@@ -169,7 +144,7 @@ namespace RGB.NET.Core
/// A new representing the division of the two provided .
public static Point operator /(Point point1, Point point2)
{
- if (point2.X.EqualsInTolerance(0) || point2.Y.EqualsInTolerance(0)) return new Point();
+ if (point2.X.EqualsInTolerance(0) || point2.Y.EqualsInTolerance(0)) return Invalid;
return new Point(point1.X / point2.X, point1.Y / point2.Y);
}
diff --git a/RGB.NET.Core/Positioning/Rectangle.cs b/RGB.NET.Core/Positioning/Rectangle.cs
index d7bc89b..2f55af2 100644
--- a/RGB.NET.Core/Positioning/Rectangle.cs
+++ b/RGB.NET.Core/Positioning/Rectangle.cs
@@ -3,7 +3,6 @@
using System;
using System.Collections.Generic;
-using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
@@ -18,48 +17,111 @@ namespace RGB.NET.Core
{
#region Properties & Fields
- private Point _location;
+ private double _x;
+ ///
+ /// Gets or sets the X-position of this .
+ ///
+ public double X
+ {
+ get => _x;
+ set
+ {
+ if (SetProperty(ref _x, value))
+ {
+ OnPropertyChanged(nameof(Location));
+ OnPropertyChanged(nameof(Center));
+ }
+ }
+ }
+
+ private double _y;
+ ///
+ /// Gets or sets the Y-position of this .
+ ///
+ public double Y
+ {
+ get => _y;
+ set
+ {
+ if (SetProperty(ref _y, value))
+ {
+ OnPropertyChanged(nameof(Location));
+ OnPropertyChanged(nameof(Center));
+ }
+ }
+ }
+
+ private double _width;
+ ///
+ /// Gets or sets the width of this .
+ ///
+ public double Width
+ {
+ get => _width;
+ set
+ {
+ if (SetProperty(ref _width, Math.Max(0, value)))
+ {
+ OnPropertyChanged(nameof(Size));
+ OnPropertyChanged(nameof(Center));
+ OnPropertyChanged(nameof(IsEmpty));
+ }
+ }
+ }
+
+ private double _height;
+ ///
+ /// Gets or sets the height of this .
+ ///
+ public double Height
+ {
+ get => _height;
+ set
+ {
+ if (SetProperty(ref _height, Math.Max(0, value)))
+ {
+ OnPropertyChanged(nameof(Size));
+ OnPropertyChanged(nameof(Center));
+ OnPropertyChanged(nameof(IsEmpty));
+ }
+ }
+ }
+
///
/// Gets or sets the representing the top-left corner of the .
///
public Point Location
{
- get => _location;
+ get => new Point(X, Y);
set
{
- Point oldValue = _location;
- if (SetProperty(ref _location, value))
+ if (Location != value)
{
- if (oldValue != null)
- oldValue.PropertyChanged -= LocationPropertyChanged;
+ _x = value.X;
+ _y = value.Y;
- if (_location != null)
- _location.PropertyChanged += LocationPropertyChanged;
-
- OnLocationChanged();
+ OnPropertyChanged(nameof(Location));
+ OnPropertyChanged(nameof(Center));
}
}
}
- private Size _size;
///
/// Gets or sets the of the .
///
public Size Size
{
- get => _size;
+ get => new Size(Width, Height);
set
{
- Size oldValue = _size;
- if (SetProperty(ref _size, value))
+ if (Size != value)
{
- if (oldValue != null)
- oldValue.PropertyChanged -= SizePropertyChanged;
+ _width = value.Width;
+ _height = value.Height;
- if (_size != null)
- _size.PropertyChanged += SizePropertyChanged;
-
- OnSizeChanged();
+ OnPropertyChanged(nameof(Size));
+ OnPropertyChanged(nameof(Center));
+ OnPropertyChanged(nameof(IsEmpty));
}
}
}
@@ -67,37 +129,16 @@ namespace RGB.NET.Core
///
/// Gets a new representing the center-point of the .
///
- public Point Center => new Point(Location.X + (Size.Width / 2.0), Location.Y + (Size.Height / 2.0));
+ public Point Center => new Point(X + (Width / 2.0), Y + (Height / 2.0));
///
/// Gets a bool indicating if both, the width and the height of the rectangle is greater than zero.
/// True if the rectangle has a width or a height of zero; otherwise, false.
///
- public bool IsEmpty => (Size.Width <= DoubleExtensions.TOLERANCE) || (Size.Height <= DoubleExtensions.TOLERANCE);
+ public bool IsEmpty => (Width <= DoubleExtensions.TOLERANCE) || (Height <= DoubleExtensions.TOLERANCE);
#endregion
- #region Events
- // ReSharper disable EventNeverSubscribedTo.Global
-
- ///
- /// Occurs when a the of the changes.
- ///
- public event EventHandler LocationChanged;
-
- ///
- /// Occurs when a the of the changes.
- ///
- public event EventHandler SizeChanged;
-
- ///
- /// Occurs when the or the of the changes.
- ///
- public event EventHandler Changed;
-
- // ReSharper restore EventNeverSubscribedTo.Global
- #endregion
-
#region Constructors
///
@@ -321,24 +362,6 @@ namespace RGB.NET.Core
}
}
- private void LocationPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs) => OnLocationChanged();
- private void OnLocationChanged()
- {
- // ReSharper disable once ExplicitCallerInfoArgument
- OnPropertyChanged(nameof(Center));
- LocationChanged?.Invoke(this, new EventArgs());
- Changed?.Invoke(this, new EventArgs());
- }
-
- private void SizePropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs) => OnSizeChanged();
- private void OnSizeChanged()
- {
- // ReSharper disable once ExplicitCallerInfoArgument
- OnPropertyChanged(nameof(Center));
- SizeChanged?.Invoke(this, new EventArgs());
- Changed?.Invoke(this, new EventArgs());
- }
-
#endregion
#region Operators
diff --git a/RGB.NET.Core/Positioning/Size.cs b/RGB.NET.Core/Positioning/Size.cs
index 8cc8cd0..2d967f8 100644
--- a/RGB.NET.Core/Positioning/Size.cs
+++ b/RGB.NET.Core/Positioning/Size.cs
@@ -5,45 +5,37 @@ using System.Diagnostics;
namespace RGB.NET.Core
{
- ///
///
/// Represents a size consisting of a width and a height.
///
[DebuggerDisplay("[Width: {Width}, Height: {Height}]")]
- public class Size : AbstractBindable
+ public struct Size
{
+ #region Constants
+
+ ///
+ /// Gets a [NaN,NaN]-Size.
+ ///
+ public static Size Invalid => new Size(double.NaN, double.NaN);
+
+ #endregion
+
#region Properties & Fields
- private double _width;
///
/// Gets or sets the width component value of this .
///
- public double Width
- {
- get => _width;
- set => SetProperty(ref _width, value);
- }
+ public double Width { get; }
- private double _height;
///
/// Gets or sets the height component value of this .
///
- public double Height
- {
- get => _height;
- set => SetProperty(ref _height, value);
- }
+ public double Height { get; }
#endregion
#region Constructors
- ///
- /// Initializes a new instance of the class.
- ///
- public Size()
- { }
-
///
///
/// Initializes a new instance of the using the provided size to define a square.
@@ -72,10 +64,7 @@ namespace RGB.NET.Core
/// Converts the and of this to a human-readable string.
///
/// A string that contains the and of this . For example "[Width: 100, Height: 20]".
- public override string ToString()
- {
- return $"[Width: {Width}, Height: {Height}]";
- }
+ public override string ToString() => $"[Width: {Width}, Height: {Height}]";
///
/// Tests whether the specified object is a and is equivalent to this .
@@ -84,16 +73,9 @@ namespace RGB.NET.Core
/// true if is a equivalent to this ; otherwise, false.
public override bool Equals(object obj)
{
- Size compareSize = obj as Size;
- if (ReferenceEquals(compareSize, null))
- return false;
-
- if (ReferenceEquals(this, compareSize))
- return true;
-
- if (GetType() != compareSize.GetType())
- return false;
+ if (!(obj is Size)) return false;
+ Size compareSize = (Size)obj;
return Width.EqualsInTolerance(compareSize.Width) && Height.EqualsInTolerance(compareSize.Height);
}
@@ -121,10 +103,7 @@ namespace RGB.NET.Core
/// The first to compare.
/// The second to compare.
/// true if and are equal; otherwise, false.
- public static bool operator ==(Size size1, Size size2)
- {
- return ReferenceEquals(size1, null) ? ReferenceEquals(size2, null) : size1.Equals(size2);
- }
+ public static bool operator ==(Size size1, Size size2) => size1.Equals(size2);
///
/// Returns a value that indicates whether two specified are equal.
@@ -132,10 +111,7 @@ namespace RGB.NET.Core
/// The first to compare.
/// The second to compare.
/// true if and are not equal; otherwise, false.
- public static bool operator !=(Size size1, Size size2)
- {
- return !(size1 == size2);
- }
+ public static bool operator !=(Size size1, Size size2) => !(size1 == size2);
///
/// Returns a new representing the addition of the two provided .
@@ -143,10 +119,15 @@ namespace RGB.NET.Core
/// The first .
/// The second .
/// A new representing the addition of the two provided .
- public static Size operator +(Size size1, Size size2)
- {
- return new Size(size1.Width + size2.Width, size1.Height + size2.Height);
- }
+ public static Size operator +(Size size1, Size size2) => new Size(size1.Width + size2.Width, size1.Height + size2.Height);
+
+ ///
+ /// Returns a new created from the provided and .
+ ///
+ /// The of the rectangle.
+ /// The of the rectangle.
+ /// The rectangle created from the provided and .
+ public static Rectangle operator +(Size size, Point point) => new Rectangle(point, size);
///
/// Returns a new representing the subtraction of the two provided .
@@ -154,10 +135,7 @@ namespace RGB.NET.Core
/// The first .
/// The second .
/// A new representing the subtraction of the two provided .
- public static Size operator -(Size size1, Size size2)
- {
- return new Size(size1.Width - size2.Width, size1.Height - size2.Height);
- }
+ public static Size operator -(Size size1, Size size2) => new Size(size1.Width - size2.Width, size1.Height - size2.Height);
///
/// Returns a new representing the multiplication of the two provided .
@@ -165,10 +143,15 @@ namespace RGB.NET.Core
/// The first .
/// The second .
/// A new representing the multiplication of the two provided .
- public static Size operator *(Size size1, Size size2)
- {
- return new Size(size1.Width * size2.Width, size1.Height * size2.Height);
- }
+ public static Size operator *(Size size1, Size size2) => new Size(size1.Width * size2.Width, size1.Height * size2.Height);
+
+ ///
+ /// Returns a new representing the multiplication of the and the provided factor.
+ ///
+ /// The .
+ /// The factor by which the should be multiplied.
+ /// A new representing the multiplication of the and the provided factor.
+ public static Size operator *(Size size, double factor) => new Size(size.Width * factor, size.Height * factor);
///
/// Returns a new representing the division of the two provided .
@@ -177,10 +160,16 @@ namespace RGB.NET.Core
/// The second .
/// A new representing the division of the two provided .
public static Size operator /(Size size1, Size size2)
- {
- if (size2.Width.EqualsInTolerance(0) || size2.Height.EqualsInTolerance(0)) return new Size();
- return new Size(size1.Width / size2.Width, size1.Height / size2.Height);
- }
+ => size2.Width.EqualsInTolerance(0) || size2.Height.EqualsInTolerance(0)
+ ? Invalid : new Size(size1.Width / size2.Width, size1.Height / size2.Height);
+
+ ///
+ /// Returns a new representing the division of the and the provided factor.
+ ///
+ /// The .
+ /// The factor by which the should be divided.
+ /// A new representing the division of the and the provided factor.
+ public static Size operator /(Size size, double factor) => factor.EqualsInTolerance(0) ? Invalid : new Size(size.Width / factor, size.Height / factor);
#endregion
}
diff --git a/RGB.NET.Core/RGBSurface.cs b/RGB.NET.Core/RGBSurface.cs
index 14b1e26..435f2dd 100644
--- a/RGB.NET.Core/RGBSurface.cs
+++ b/RGB.NET.Core/RGBSurface.cs
@@ -125,10 +125,9 @@ namespace RGB.NET.Core
switch (brush.BrushCalculationMode)
{
case BrushCalculationMode.Relative:
- Rectangle brushRectangle = new Rectangle(leds.Select(x => GetDeviceLedLocation(x)));
+ Rectangle brushRectangle = new Rectangle(leds.Select(GetDeviceLedLocation));
Point offset = new Point(-brushRectangle.Location.X, -brushRectangle.Location.Y);
- brushRectangle.Location.X = 0;
- brushRectangle.Location.Y = 0;
+ brushRectangle.Location = new Point(0, 0);
brush.PerformRender(brushRectangle,
leds.Select(x => new BrushRenderTarget(x, GetDeviceLedLocation(x, offset))));
break;
@@ -146,12 +145,9 @@ namespace RGB.NET.Core
renders.Key.Led.Color = renders.Value;
}
- private Rectangle GetDeviceLedLocation(Led led, Point extraOffset = null)
- {
- return extraOffset != null
- ? new Rectangle(led.LedRectangle.Location + led.Device.Location + extraOffset, new Size(led.LedRectangle.Size.Width, led.LedRectangle.Size.Height))
- : new Rectangle(led.LedRectangle.Location + led.Device.Location, new Size(led.LedRectangle.Size.Width, led.LedRectangle.Size.Height));
- }
+ private Rectangle GetDeviceLedLocation(Led led) => (led.LedRectangle.Location + led.Device.Location) + new Size(led.LedRectangle.Size.Width, led.LedRectangle.Size.Height);
+
+ private Rectangle GetDeviceLedLocation(Led led, Point extraOffset) => (led.LedRectangle.Location + led.Device.Location + extraOffset) + new Size(led.LedRectangle.Size.Width, led.LedRectangle.Size.Height);
///
/// Attaches the given .
@@ -198,8 +194,8 @@ namespace RGB.NET.Core
{
Rectangle devicesRectangle = new Rectangle(_devices.Select(d => new Rectangle(d.Location, d.Size)));
- _surfaceRectangle.Size.Width = devicesRectangle.Location.X + devicesRectangle.Size.Width;
- _surfaceRectangle.Size.Height = devicesRectangle.Location.Y + devicesRectangle.Size.Height;
+ _surfaceRectangle.Width = devicesRectangle.Location.X + devicesRectangle.Size.Width;
+ _surfaceRectangle.Height = devicesRectangle.Location.Y + devicesRectangle.Size.Height;
}
#endregion
diff --git a/RGB.NET.Core/RGBSurfaceDeviceLoader.cs b/RGB.NET.Core/RGBSurfaceDeviceLoader.cs
index ebe0ef6..a072ec9 100644
--- a/RGB.NET.Core/RGBSurfaceDeviceLoader.cs
+++ b/RGB.NET.Core/RGBSurfaceDeviceLoader.cs
@@ -30,7 +30,6 @@ namespace RGB.NET.Core
addedDevices.Add(device);
device.PropertyChanged += DeviceOnPropertyChanged;
- device.Location.PropertyChanged += DeviceLocationOnPropertyChanged;
_devices.Add(device);
}
}
@@ -50,23 +49,12 @@ namespace RGB.NET.Core
double posX = 0;
foreach (IRGBDevice device in Devices)
{
- device.Location.X = posX;
+ device.Location += new Point(posX, 0);
posX += device.Size.Width + 1;
}
}
private void DeviceOnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs)
- {
- if (string.Equals(propertyChangedEventArgs.PropertyName, nameof(IRGBDevice.Location)))
- {
- UpdateSurfaceRectangle();
- SurfaceLayoutChanged?.Invoke(new SurfaceLayoutChangedEventArgs(new[] { sender as IRGBDevice }, false, true));
-
- ((IRGBDevice)sender).Location.PropertyChanged += DeviceLocationOnPropertyChanged;
- }
- }
-
- private void DeviceLocationOnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs)
{
UpdateSurfaceRectangle();
SurfaceLayoutChanged?.Invoke(new SurfaceLayoutChangedEventArgs(new[] { sender as IRGBDevice }, false, true));
diff --git a/RGB.NET.Devices.Asus/Generic/AsusRGBDevice.cs b/RGB.NET.Devices.Asus/Generic/AsusRGBDevice.cs
index 46303a9..471626d 100644
--- a/RGB.NET.Devices.Asus/Generic/AsusRGBDevice.cs
+++ b/RGB.NET.Devices.Asus/Generic/AsusRGBDevice.cs
@@ -53,10 +53,10 @@ namespace RGB.NET.Devices.Asus
{
InitializeLayout();
- if (InternalSize == null)
+ if (Size == Size.Invalid)
{
Rectangle ledRectangle = new Rectangle(this.Select(x => x.LedRectangle));
- InternalSize = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
+ Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
}
ColorData = new byte[LedMapping.Count * 3];
@@ -80,7 +80,7 @@ namespace RGB.NET.Devices.Asus
{
LedImageLayout ledImageLayout = layout.LedImageLayouts.FirstOrDefault(x => string.Equals(x.Layout, imageLayout, StringComparison.OrdinalIgnoreCase));
- InternalSize = new Size(layout.Width, layout.Height);
+ Size = new Size(layout.Width, layout.Height);
if (layout.Leds != null)
foreach (LedLayout layoutLed in layout.Leds)
@@ -89,10 +89,8 @@ namespace RGB.NET.Devices.Asus
{
if (LedMapping.TryGetValue(new AsusLedId(this, ledId), out Led led))
{
- led.LedRectangle.Location.X = layoutLed.X;
- led.LedRectangle.Location.Y = layoutLed.Y;
- led.LedRectangle.Size.Width = layoutLed.Width;
- led.LedRectangle.Size.Height = layoutLed.Height;
+ led.LedRectangle.Location = new Point(layoutLed.X, layoutLed.Y);
+ led.LedRectangle.Size = new Size(layoutLed.Width, layoutLed.Height);
led.Shape = layoutLed.Shape;
led.ShapeData = layoutLed.ShapeData;
diff --git a/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDevice.cs b/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDevice.cs
index 1928340..b920640 100644
--- a/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDevice.cs
+++ b/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDevice.cs
@@ -48,10 +48,10 @@ namespace RGB.NET.Devices.CoolerMaster
{
InitializeLayout();
- if (InternalSize == null)
+ if (Size == Size.Invalid)
{
Rectangle ledRectangle = new Rectangle(this.Select(x => x.LedRectangle));
- InternalSize = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
+ Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
}
}
@@ -73,7 +73,7 @@ namespace RGB.NET.Devices.CoolerMaster
{
LedImageLayout ledImageLayout = layout.LedImageLayouts.FirstOrDefault(x => string.Equals(x.Layout, imageLayout, StringComparison.OrdinalIgnoreCase));
- InternalSize = new Size(layout.Width, layout.Height);
+ Size = new Size(layout.Width, layout.Height);
if (layout.Leds != null)
foreach (LedLayout layoutLed in layout.Leds)
@@ -82,10 +82,8 @@ namespace RGB.NET.Devices.CoolerMaster
{
if (LedMapping.TryGetValue(new CoolerMasterLedId(this, ledId), out Led led))
{
- led.LedRectangle.Location.X = layoutLed.X;
- led.LedRectangle.Location.Y = layoutLed.Y;
- led.LedRectangle.Size.Width = layoutLed.Width;
- led.LedRectangle.Size.Height = layoutLed.Height;
+ led.LedRectangle.Location = new Point(layoutLed.X, layoutLed.Y);
+ led.LedRectangle.Size = new Size(layoutLed.Width, layoutLed.Height);
led.Shape = layoutLed.Shape;
led.ShapeData = layoutLed.ShapeData;
diff --git a/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs b/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs
index c7a904b..2cbf7c3 100644
--- a/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs
+++ b/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs
@@ -49,10 +49,10 @@ namespace RGB.NET.Devices.Corsair
{
InitializeLayout();
- if (InternalSize == null)
+ if (Size == Size.Invalid)
{
Rectangle ledRectangle = new Rectangle(this.Select(x => x.LedRectangle));
- InternalSize = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
+ Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
}
}
@@ -74,7 +74,7 @@ namespace RGB.NET.Devices.Corsair
{
LedImageLayout ledImageLayout = layout.LedImageLayouts.FirstOrDefault(x => string.Equals(x.Layout, imageLayout, StringComparison.OrdinalIgnoreCase));
- InternalSize = new Size(layout.Width, layout.Height);
+ Size = new Size(layout.Width, layout.Height);
if (layout.Leds != null)
foreach (LedLayout layoutLed in layout.Leds)
@@ -83,10 +83,8 @@ namespace RGB.NET.Devices.Corsair
{
if (LedMapping.TryGetValue(new CorsairLedId(this, ledId), out Led led))
{
- led.LedRectangle.Location.X = layoutLed.X;
- led.LedRectangle.Location.Y = layoutLed.Y;
- led.LedRectangle.Size.Width = layoutLed.Width;
- led.LedRectangle.Size.Height = layoutLed.Height;
+ led.LedRectangle.Location = new Point(layoutLed.X, layoutLed.Y);
+ led.LedRectangle.Size = new Size(layoutLed.Width, layoutLed.Height);
led.Shape = layoutLed.Shape;
led.ShapeData = layoutLed.ShapeData;
diff --git a/RGB.NET.Devices.Logitech/Generic/LogitechRGBDevice.cs b/RGB.NET.Devices.Logitech/Generic/LogitechRGBDevice.cs
index 9922c3f..56a0948 100644
--- a/RGB.NET.Devices.Logitech/Generic/LogitechRGBDevice.cs
+++ b/RGB.NET.Devices.Logitech/Generic/LogitechRGBDevice.cs
@@ -46,10 +46,10 @@ namespace RGB.NET.Devices.Logitech
{
InitializeLayout();
- if (InternalSize == null)
+ if (Size == Size.Invalid)
{
Rectangle ledRectangle = new Rectangle(this.Select(x => x.LedRectangle));
- InternalSize = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
+ Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
}
}
@@ -78,7 +78,7 @@ namespace RGB.NET.Devices.Logitech
{
LedImageLayout ledImageLayout = layout.LedImageLayouts.FirstOrDefault(x => string.Equals(x.Layout, imageLayout, StringComparison.OrdinalIgnoreCase));
- InternalSize = new Size(layout.Width, layout.Height);
+ Size = new Size(layout.Width, layout.Height);
if (layout.Leds != null)
foreach (LedLayout layoutLed in layout.Leds)
@@ -89,10 +89,8 @@ namespace RGB.NET.Devices.Logitech
if (!LedMapping.TryGetValue(id, out Led led))
led = InitializeLed(id, new Rectangle());
- led.LedRectangle.Location.X = layoutLed.X;
- led.LedRectangle.Location.Y = layoutLed.Y;
- led.LedRectangle.Size.Width = layoutLed.Width;
- led.LedRectangle.Size.Height = layoutLed.Height;
+ led.LedRectangle.Location = new Point(layoutLed.X, layoutLed.Y);
+ led.LedRectangle.Size = new Size(layoutLed.Width, layoutLed.Height);
led.Shape = layoutLed.Shape;
led.ShapeData = layoutLed.ShapeData;
diff --git a/RGB.NET.Devices.Msi/Generic/MsiRGBDevice.cs b/RGB.NET.Devices.Msi/Generic/MsiRGBDevice.cs
index 0e1cdeb..9e3e8ff 100644
--- a/RGB.NET.Devices.Msi/Generic/MsiRGBDevice.cs
+++ b/RGB.NET.Devices.Msi/Generic/MsiRGBDevice.cs
@@ -48,10 +48,10 @@ namespace RGB.NET.Devices.Msi
{
InitializeLayout();
- if (InternalSize == null)
+ if (Size == Size.Invalid)
{
Rectangle ledRectangle = new Rectangle(this.Select(x => x.LedRectangle));
- InternalSize = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
+ Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
}
}
@@ -73,7 +73,7 @@ namespace RGB.NET.Devices.Msi
{
LedImageLayout ledImageLayout = layout.LedImageLayouts.FirstOrDefault(x => string.Equals(x.Layout, imageLayout, StringComparison.OrdinalIgnoreCase));
- InternalSize = new Size(layout.Width, layout.Height);
+ Size = new Size(layout.Width, layout.Height);
if (layout.Leds != null)
foreach (LedLayout layoutLed in layout.Leds)
@@ -82,10 +82,8 @@ namespace RGB.NET.Devices.Msi
{
if (LedMapping.TryGetValue(new MsiLedId(this, ledId), out Led led))
{
- led.LedRectangle.Location.X = layoutLed.X;
- led.LedRectangle.Location.Y = layoutLed.Y;
- led.LedRectangle.Size.Width = layoutLed.Width;
- led.LedRectangle.Size.Height = layoutLed.Height;
+ led.LedRectangle.Location = new Point(layoutLed.X, layoutLed.Y);
+ led.LedRectangle.Size = new Size(layoutLed.Width, layoutLed.Height);
led.Shape = layoutLed.Shape;
led.ShapeData = layoutLed.ShapeData;
diff --git a/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs b/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs
index 5a2aeea..ba24016 100644
--- a/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs
+++ b/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs
@@ -54,10 +54,10 @@ namespace RGB.NET.Devices.Novation
{
InitializeLayout();
- if (InternalSize == null)
+ if (Size == Size.Invalid)
{
Rectangle ledRectangle = new Rectangle(this.Select(x => x.LedRectangle));
- InternalSize = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
+ Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
}
}
@@ -79,7 +79,7 @@ namespace RGB.NET.Devices.Novation
{
LedImageLayout ledImageLayout = layout.LedImageLayouts.FirstOrDefault(x => string.Equals(x.Layout, imageLayout, StringComparison.OrdinalIgnoreCase));
- InternalSize = new Size(layout.Width, layout.Height);
+ Size = new Size(layout.Width, layout.Height);
if (layout.Leds != null)
foreach (LedLayout layoutLed in layout.Leds)
@@ -88,10 +88,8 @@ namespace RGB.NET.Devices.Novation
{
if (LedMapping.TryGetValue(new NovationLedId(this, ledId), out Led led))
{
- led.LedRectangle.Location.X = layoutLed.X;
- led.LedRectangle.Location.Y = layoutLed.Y;
- led.LedRectangle.Size.Width = layoutLed.Width;
- led.LedRectangle.Size.Height = layoutLed.Height;
+ led.LedRectangle.Location = new Point(layoutLed.X, layoutLed.Y);
+ led.LedRectangle.Size = new Size(layoutLed.Width, layoutLed.Height);
led.Shape = layoutLed.Shape;
led.ShapeData = layoutLed.ShapeData;
diff --git a/RGB.NET.Groups/Groups/RectangleLedGroup.cs b/RGB.NET.Groups/Groups/RectangleLedGroup.cs
index fd6d663..3573d56 100644
--- a/RGB.NET.Groups/Groups/RectangleLedGroup.cs
+++ b/RGB.NET.Groups/Groups/RectangleLedGroup.cs
@@ -32,10 +32,10 @@ namespace RGB.NET.Groups
if (SetProperty(ref _rectangle, value))
{
if (oldValue != null)
- oldValue.Changed -= RectangleChanged;
+ oldValue.PropertyChanged -= RectangleChanged;
if (_rectangle != null)
- _rectangle.Changed += RectangleChanged;
+ _rectangle.PropertyChanged += RectangleChanged;
InvalidateCache();
}