1
0
mirror of https://github.com/DarthAffe/RGB.NET.git synced 2025-12-13 10:08:31 +00:00

Renamed SurfaceRectangle and fixed spelling mistake

This commit is contained in:
Darth Affe 2021-02-09 23:17:11 +01:00
parent d44223ee6a
commit 07a6d8952c
6 changed files with 36 additions and 36 deletions

View File

@ -55,11 +55,11 @@ namespace RGB.NET.Core
Led? IRGBDevice.this[LedId ledId] => LedMapping.TryGetValue(ledId, out Led? led) ? led : null; Led? IRGBDevice.this[LedId ledId] => LedMapping.TryGetValue(ledId, out Led? led) ? led : null;
/// <inheritdoc /> /// <inheritdoc />
Led? IRGBDevice.this[Point location] => LedMapping.Values.FirstOrDefault(x => x.Boundry.Contains(location)); Led? IRGBDevice.this[Point location] => LedMapping.Values.FirstOrDefault(x => x.Boundary.Contains(location));
/// <inheritdoc /> /// <inheritdoc />
IEnumerable<Led> IRGBDevice.this[Rectangle referenceRect, double minOverlayPercentage] IEnumerable<Led> IRGBDevice.this[Rectangle referenceRect, double minOverlayPercentage]
=> LedMapping.Values.Where(x => referenceRect.CalculateIntersectPercentage(x.Boundry) >= minOverlayPercentage); => LedMapping.Values.Where(x => referenceRect.CalculateIntersectPercentage(x.Boundary) >= minOverlayPercentage);
#endregion #endregion
@ -136,7 +136,7 @@ namespace RGB.NET.Core
if (Location == Point.Invalid) Location = new Point(0, 0); if (Location == Point.Invalid) Location = new Point(0, 0);
if (Size == Size.Invalid) if (Size == Size.Invalid)
{ {
Rectangle ledRectangle = new(this.Select(x => x.Boundry)); Rectangle ledRectangle = new(this.Select(x => x.Boundary));
Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y); Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
} }
} }

View File

@ -43,14 +43,14 @@ namespace RGB.NET.Core
set => SetProperty(ref _shapeData, value); set => SetProperty(ref _shapeData, value);
} }
private Rectangle _absoluteBoundry; private Rectangle _absoluteBoundary;
/// <summary> /// <summary>
/// Gets a rectangle representing the logical location of the <see cref="Led"/> on the <see cref="RGBSurface"/>. /// Gets a rectangle representing the logical location of the <see cref="Led"/> on the <see cref="RGBSurface"/>.
/// </summary> /// </summary>
public Rectangle AbsoluteBoundry public Rectangle AbsoluteBoundary
{ {
get => _absoluteBoundry; get => _absoluteBoundary;
private set => SetProperty(ref _absoluteBoundry, value); private set => SetProperty(ref _absoluteBoundary, value);
} }
/// <summary> /// <summary>
@ -128,7 +128,7 @@ namespace RGB.NET.Core
{ {
base.UpdateActualPlaceableData(); base.UpdateActualPlaceableData();
AbsoluteBoundry = Boundry.Translate(Device.Location); AbsoluteBoundary = Boundary.Translate(Device.Location);
} }
/// <summary> /// <summary>
@ -177,7 +177,7 @@ namespace RGB.NET.Core
/// Converts a <see cref="Led" /> to a <see cref="Rectangle" />. /// Converts a <see cref="Led" /> to a <see cref="Rectangle" />.
/// </summary> /// </summary>
/// <param name="led">The <see cref="Led"/> to convert.</param> /// <param name="led">The <see cref="Led"/> to convert.</param>
public static implicit operator Rectangle(Led led) => led.Boundry; public static implicit operator Rectangle(Led led) => led.Boundary;
#endregion #endregion
} }

View File

@ -42,7 +42,7 @@ namespace RGB.NET.Core
/// Gets a rectangle containing the whole <see cref="IPlaceable"/>. /// Gets a rectangle containing the whole <see cref="IPlaceable"/>.
/// This includes <see cref="Location"/>, <see cref="Size"/>, <see cref="Scale"/> and <see cref="Rotation"/>. /// This includes <see cref="Location"/>, <see cref="Size"/>, <see cref="Scale"/> and <see cref="Rotation"/>.
/// </summary> /// </summary>
Rectangle Boundry { get; } Rectangle Boundary { get; }
#endregion #endregion
@ -54,7 +54,7 @@ namespace RGB.NET.Core
event EventHandler<EventArgs> RotationChanged; event EventHandler<EventArgs> RotationChanged;
event EventHandler<EventArgs> ActualLocationChanged; event EventHandler<EventArgs> ActualLocationChanged;
event EventHandler<EventArgs> ActualSizeChanged; event EventHandler<EventArgs> ActualSizeChanged;
event EventHandler<EventArgs> BoundryChanged; event EventHandler<EventArgs> BoundaryChanged;
#endregion #endregion
} }

View File

@ -80,15 +80,15 @@ namespace RGB.NET.Core
} }
} }
private Rectangle _boundry = new(Point.Invalid, Point.Invalid); private Rectangle _boundary = new(Point.Invalid, Point.Invalid);
/// <inheritdoc /> /// <inheritdoc />
public Rectangle Boundry public Rectangle Boundary
{ {
get => _boundry; get => _boundary;
private set private set
{ {
if (SetProperty(ref _boundry, value)) if (SetProperty(ref _boundary, value))
OnBoundryChanged(); OnBoundaryChanged();
} }
} }
@ -102,7 +102,7 @@ namespace RGB.NET.Core
public event EventHandler<EventArgs>? RotationChanged; public event EventHandler<EventArgs>? RotationChanged;
public event EventHandler<EventArgs>? ActualLocationChanged; public event EventHandler<EventArgs>? ActualLocationChanged;
public event EventHandler<EventArgs>? ActualSizeChanged; public event EventHandler<EventArgs>? ActualSizeChanged;
public event EventHandler<EventArgs>? BoundryChanged; public event EventHandler<EventArgs>? BoundaryChanged;
#endregion #endregion
@ -114,7 +114,7 @@ namespace RGB.NET.Core
{ {
this.Parent = parent; this.Parent = parent;
Parent.BoundryChanged += (_, _) => UpdateActualPlaceableData(); Parent.BoundaryChanged += (_, _) => UpdateActualPlaceableData();
} }
public Placeable(Point location, Size size) public Placeable(Point location, Size size)
@ -129,7 +129,7 @@ namespace RGB.NET.Core
this.Location = location; this.Location = location;
this.Size = size; this.Size = size;
Parent.BoundryChanged += (_, _) => UpdateActualPlaceableData(); Parent.BoundaryChanged += (_, _) => UpdateActualPlaceableData();
} }
#endregion #endregion
@ -142,27 +142,27 @@ namespace RGB.NET.Core
{ {
Size actualSize = Size * Parent.Scale; Size actualSize = Size * Parent.Scale;
Point actualLocation = (Location * Parent.Scale); Point actualLocation = (Location * Parent.Scale);
Rectangle boundry = new(actualLocation, actualSize); Rectangle boundary = new(actualLocation, actualSize);
if (Parent.Rotation.IsRotated) if (Parent.Rotation.IsRotated)
{ {
Point parentCenter = new Rectangle(Parent.ActualSize).Center; Point parentCenter = new Rectangle(Parent.ActualSize).Center;
Point actualParentCenter = new Rectangle(Parent.Boundry.Size).Center; Point actualParentCenter = new Rectangle(Parent.Boundary.Size).Center;
Point centerOffset = new(actualParentCenter.X - parentCenter.X, actualParentCenter.Y - parentCenter.Y); Point centerOffset = new(actualParentCenter.X - parentCenter.X, actualParentCenter.Y - parentCenter.Y);
actualLocation = actualLocation.Rotate(Parent.Rotation, new Rectangle(Parent.ActualSize).Center) + centerOffset; 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); boundary = new Rectangle(boundary.Rotate(Parent.Rotation, new Rectangle(Parent.ActualSize).Center)).Translate(centerOffset);
} }
ActualLocation = actualLocation; ActualLocation = actualLocation;
ActualSize = actualSize; ActualSize = actualSize;
Boundry = boundry; Boundary = boundary;
} }
else else
{ {
ActualLocation = Location; ActualLocation = Location;
ActualSize = Size * Scale; ActualSize = Size * Scale;
Boundry = new Rectangle(Location, new Rectangle(new Rectangle(Location, ActualSize).Rotate(Rotation)).Size); Boundary = new Rectangle(Location, new Rectangle(new Rectangle(Location, ActualSize).Rotate(Rotation)).Size);
} }
} }
@ -192,7 +192,7 @@ namespace RGB.NET.Core
protected virtual void OnActualLocationChanged() => ActualLocationChanged?.Invoke(this, new EventArgs()); protected virtual void OnActualLocationChanged() => ActualLocationChanged?.Invoke(this, new EventArgs());
protected virtual void OnActualSizeChanged() => ActualSizeChanged?.Invoke(this, new EventArgs()); protected virtual void OnActualSizeChanged() => ActualSizeChanged?.Invoke(this, new EventArgs());
protected virtual void OnBoundryChanged() => BoundryChanged?.Invoke(this, new EventArgs()); protected virtual void OnBoundaryChanged() => BoundaryChanged?.Invoke(this, new EventArgs());
#endregion #endregion
} }

View File

@ -49,7 +49,7 @@ namespace RGB.NET.Core
/// <summary> /// <summary>
/// Gets a copy of the <see cref="Rectangle"/> representing this <see cref="RGBSurface"/>. /// Gets a copy of the <see cref="Rectangle"/> representing this <see cref="RGBSurface"/>.
/// </summary> /// </summary>
public Rectangle SurfaceRectangle { get; private set; } public Rectangle Boundary { get; private set; } = new(new Point(0, 0), new Size(0, 0));
/// <summary> /// <summary>
/// Gets a list of all <see cref="Led"/> on this <see cref="RGBSurface"/>. /// Gets a list of all <see cref="Led"/> on this <see cref="RGBSurface"/>.
@ -211,13 +211,13 @@ namespace RGB.NET.Core
switch (brush.BrushCalculationMode) switch (brush.BrushCalculationMode)
{ {
case BrushCalculationMode.Relative: case BrushCalculationMode.Relative:
Rectangle brushRectangle = new(leds.Select(led => led.AbsoluteBoundry)); Rectangle brushRectangle = new(leds.Select(led => led.AbsoluteBoundary));
Point offset = new(-brushRectangle.Location.X, -brushRectangle.Location.Y); Point offset = new(-brushRectangle.Location.X, -brushRectangle.Location.Y);
brushRectangle = brushRectangle.SetLocation(new Point(0, 0)); brushRectangle = brushRectangle.SetLocation(new Point(0, 0));
brush.PerformRender(brushRectangle, leds.Select(led => new BrushRenderTarget(led, led.AbsoluteBoundry.Translate(offset)))); brush.PerformRender(brushRectangle, leds.Select(led => new BrushRenderTarget(led, led.AbsoluteBoundary.Translate(offset))));
break; break;
case BrushCalculationMode.Absolute: case BrushCalculationMode.Absolute:
brush.PerformRender(SurfaceRectangle, leds.Select(led => new BrushRenderTarget(led, led.AbsoluteBoundry))); brush.PerformRender(Boundary, leds.Select(led => new BrushRenderTarget(led, led.AbsoluteBoundary)));
break; break;
default: default:
throw new ArgumentException(); throw new ArgumentException();
@ -283,7 +283,7 @@ namespace RGB.NET.Core
if (device.Surface != null) throw new RGBSurfaceException($"The device '{device.DeviceInfo.Manufacturer} {device.DeviceInfo.Model}' is already attached to a surface."); 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.Surface = this;
device.BoundryChanged += DeviceOnBoundryChanged; device.BoundaryChanged += DeviceOnBoundaryChanged;
_devices.Add(device); _devices.Add(device);
OnSurfaceLayoutChanged(SurfaceLayoutChangedEventArgs.FromAddedDevice(device)); OnSurfaceLayoutChanged(SurfaceLayoutChangedEventArgs.FromAddedDevice(device));
@ -305,7 +305,7 @@ namespace RGB.NET.Core
{ {
if (!_devices.Contains(device)) throw new RGBSurfaceException($"The device '{device.DeviceInfo.Manufacturer} {device.DeviceInfo.Model}' isn't not attached to this surface."); 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.BoundaryChanged -= DeviceOnBoundaryChanged;
device.Surface = null; device.Surface = null;
_devices.Remove(device); _devices.Remove(device);
@ -329,7 +329,7 @@ namespace RGB.NET.Core
// ReSharper restore UnusedMember.Global // ReSharper restore UnusedMember.Global
private void DeviceOnBoundryChanged(object? sender, EventArgs args) private void DeviceOnBoundaryChanged(object? sender, EventArgs args)
=> OnSurfaceLayoutChanged((sender is IRGBDevice device) ? SurfaceLayoutChangedEventArgs.FromChangedDevice(device) : SurfaceLayoutChangedEventArgs.Misc()); => OnSurfaceLayoutChanged((sender is IRGBDevice device) ? SurfaceLayoutChangedEventArgs.FromChangedDevice(device) : SurfaceLayoutChangedEventArgs.Misc());
private void OnSurfaceLayoutChanged(SurfaceLayoutChangedEventArgs args) private void OnSurfaceLayoutChanged(SurfaceLayoutChangedEventArgs args)
@ -343,8 +343,8 @@ namespace RGB.NET.Core
{ {
lock (_devices) lock (_devices)
{ {
Rectangle devicesRectangle = new(_devices.Select(d => d.Boundry)); Rectangle devicesRectangle = new(_devices.Select(d => d.Boundary));
SurfaceRectangle = SurfaceRectangle.SetSize(new Size(devicesRectangle.Location.X + devicesRectangle.Size.Width, devicesRectangle.Location.Y + devicesRectangle.Size.Height)); Boundary = Boundary.SetSize(new Size(devicesRectangle.Location.X + devicesRectangle.Size.Width, devicesRectangle.Location.Y + devicesRectangle.Size.Height));
} }
} }

View File

@ -59,7 +59,7 @@ namespace RGB.NET.Groups
/// <param name="minOverlayPercentage">(optional) The minimal percentage overlay a <see cref="T:RGB.NET.Core.Led" /> must have with the <see cref="P:RGB.NET.Groups.RectangleLedGroup.Rectangle" /> to be taken into the <see cref="T:RGB.NET.Groups.RectangleLedGroup" />. (default: 0.5)</param> /// <param name="minOverlayPercentage">(optional) The minimal percentage overlay a <see cref="T:RGB.NET.Core.Led" /> must have with the <see cref="P:RGB.NET.Groups.RectangleLedGroup.Rectangle" /> to be taken into the <see cref="T:RGB.NET.Groups.RectangleLedGroup" />. (default: 0.5)</param>
/// <param name="autoAttach">(optional) Specifies whether this <see cref="T:RGB.NET.Groups.RectangleLedGroup" /> should be automatically attached or not. (default: true)</param> /// <param name="autoAttach">(optional) Specifies whether this <see cref="T:RGB.NET.Groups.RectangleLedGroup" /> should be automatically attached or not. (default: true)</param>
public RectangleLedGroup(RGBSurface? surface, Led fromLed, Led toLed, double minOverlayPercentage = 0.5) public RectangleLedGroup(RGBSurface? surface, Led fromLed, Led toLed, double minOverlayPercentage = 0.5)
: this(surface, new Rectangle(fromLed.Boundry, toLed.Boundry), minOverlayPercentage) : this(surface, new Rectangle(fromLed.Boundary, toLed.Boundary), minOverlayPercentage)
{ } { }
/// <inheritdoc /> /// <inheritdoc />
@ -117,7 +117,7 @@ namespace RGB.NET.Groups
/// Gets a list containing all <see cref="T:RGB.NET.Core.Led" /> of this <see cref="T:RGB.NET.Groups.RectangleLedGroup" />. /// Gets a list containing all <see cref="T:RGB.NET.Core.Led" /> of this <see cref="T:RGB.NET.Groups.RectangleLedGroup" />.
/// </summary> /// </summary>
/// <returns>The list containing all <see cref="T:RGB.NET.Core.Led" /> of this <see cref="T:RGB.NET.Groups.RectangleLedGroup" />.</returns> /// <returns>The list containing all <see cref="T:RGB.NET.Core.Led" /> of this <see cref="T:RGB.NET.Groups.RectangleLedGroup" />.</returns>
public override IList<Led> GetLeds() => _ledCache ??= (Surface?.Leds.Where(led => led.AbsoluteBoundry.CalculateIntersectPercentage(Rectangle) >= MinOverlayPercentage).ToList() ?? new List<Led>()); public override IList<Led> GetLeds() => _ledCache ??= (Surface?.Leds.Where(led => led.AbsoluteBoundary.CalculateIntersectPercentage(Rectangle) >= MinOverlayPercentage).ToList() ?? new List<Led>());
private void InvalidateCache() => _ledCache = null; private void InvalidateCache() => _ledCache = null;