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

Merge pull request #173 from DarthAffe/Core/DeviceHandling

Renamed SurfaceRectangle and fixed spelling mistake
This commit is contained in:
DarthAffe 2021-02-09 23:18:06 +01:00 committed by GitHub
commit 4edc665403
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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;
/// <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 />
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
@ -136,7 +136,7 @@ namespace RGB.NET.Core
if (Location == Point.Invalid) Location = new Point(0, 0);
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);
}
}

View File

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

View File

@ -42,7 +42,7 @@ namespace RGB.NET.Core
/// Gets a rectangle containing the whole <see cref="IPlaceable"/>.
/// This includes <see cref="Location"/>, <see cref="Size"/>, <see cref="Scale"/> and <see cref="Rotation"/>.
/// </summary>
Rectangle Boundry { get; }
Rectangle Boundary { get; }
#endregion
@ -54,7 +54,7 @@ namespace RGB.NET.Core
event EventHandler<EventArgs> RotationChanged;
event EventHandler<EventArgs> ActualLocationChanged;
event EventHandler<EventArgs> ActualSizeChanged;
event EventHandler<EventArgs> BoundryChanged;
event EventHandler<EventArgs> BoundaryChanged;
#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 />
public Rectangle Boundry
public Rectangle Boundary
{
get => _boundry;
get => _boundary;
private set
{
if (SetProperty(ref _boundry, value))
OnBoundryChanged();
if (SetProperty(ref _boundary, value))
OnBoundaryChanged();
}
}
@ -102,7 +102,7 @@ namespace RGB.NET.Core
public event EventHandler<EventArgs>? RotationChanged;
public event EventHandler<EventArgs>? ActualLocationChanged;
public event EventHandler<EventArgs>? ActualSizeChanged;
public event EventHandler<EventArgs>? BoundryChanged;
public event EventHandler<EventArgs>? BoundaryChanged;
#endregion
@ -114,7 +114,7 @@ namespace RGB.NET.Core
{
this.Parent = parent;
Parent.BoundryChanged += (_, _) => UpdateActualPlaceableData();
Parent.BoundaryChanged += (_, _) => UpdateActualPlaceableData();
}
public Placeable(Point location, Size size)
@ -129,7 +129,7 @@ namespace RGB.NET.Core
this.Location = location;
this.Size = size;
Parent.BoundryChanged += (_, _) => UpdateActualPlaceableData();
Parent.BoundaryChanged += (_, _) => UpdateActualPlaceableData();
}
#endregion
@ -142,27 +142,27 @@ namespace RGB.NET.Core
{
Size actualSize = Size * Parent.Scale;
Point actualLocation = (Location * Parent.Scale);
Rectangle boundry = new(actualLocation, actualSize);
Rectangle boundary = new(actualLocation, actualSize);
if (Parent.Rotation.IsRotated)
{
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);
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;
ActualSize = actualSize;
Boundry = boundry;
Boundary = boundary;
}
else
{
ActualLocation = Location;
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 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
}

View File

@ -49,7 +49,7 @@ namespace RGB.NET.Core
/// <summary>
/// Gets a copy of the <see cref="Rectangle"/> representing this <see cref="RGBSurface"/>.
/// </summary>
public Rectangle SurfaceRectangle { get; private set; }
public Rectangle Boundary { get; private set; } = new(new Point(0, 0), new Size(0, 0));
/// <summary>
/// Gets a list of all <see cref="Led"/> on this <see cref="RGBSurface"/>.
@ -211,13 +211,13 @@ namespace RGB.NET.Core
switch (brush.BrushCalculationMode)
{
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);
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;
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;
default:
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.");
device.Surface = this;
device.BoundryChanged += DeviceOnBoundryChanged;
device.BoundaryChanged += DeviceOnBoundaryChanged;
_devices.Add(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.");
device.BoundryChanged -= DeviceOnBoundryChanged;
device.BoundaryChanged -= DeviceOnBoundaryChanged;
device.Surface = null;
_devices.Remove(device);
@ -329,7 +329,7 @@ namespace RGB.NET.Core
// 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());
private void OnSurfaceLayoutChanged(SurfaceLayoutChangedEventArgs args)
@ -343,8 +343,8 @@ namespace RGB.NET.Core
{
lock (_devices)
{
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));
Rectangle devicesRectangle = new(_devices.Select(d => d.Boundary));
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="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)
: this(surface, new Rectangle(fromLed.Boundry, toLed.Boundry), minOverlayPercentage)
: this(surface, new Rectangle(fromLed.Boundary, toLed.Boundary), minOverlayPercentage)
{ }
/// <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" />.
/// </summary>
/// <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;