mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2026-01-01 18:23:38 +00:00
Compare commits
No commits in common. "5fc2e34f289edd18ea9d34cb7dd8865dea5e0644" and "e645e4dcf20d6b25180351aa237065c8678b4876" have entirely different histories.
5fc2e34f28
...
e645e4dcf2
@ -14,18 +14,13 @@ namespace RGB.NET.Core
|
|||||||
private readonly List<T> _decorators = new();
|
private readonly List<T> _decorators = new();
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IReadOnlyList<T> Decorators { get; }
|
public IReadOnlyCollection<T> Decorators
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Constructors
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="AbstractDecoratable{T}"/> class.
|
|
||||||
/// </summary>
|
|
||||||
protected AbstractDecoratable()
|
|
||||||
{
|
{
|
||||||
Decorators = new ReadOnlyCollection<T>(_decorators);
|
get
|
||||||
|
{
|
||||||
|
lock (_decorators)
|
||||||
|
return new ReadOnlyCollection<T>(_decorators);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -20,7 +20,7 @@ namespace RGB.NET.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a readonly-list of all <see cref="IDecorator"/> attached to this <see cref="IDecoratable{T}"/>.
|
/// Gets a readonly-list of all <see cref="IDecorator"/> attached to this <see cref="IDecoratable{T}"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
IReadOnlyList<T> Decorators { get; }
|
IReadOnlyCollection<T> Decorators { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds an <see cref="IDecorator"/> to the <see cref="IDecoratable"/>.
|
/// Adds an <see cref="IDecorator"/> to the <see cref="IDecoratable"/>.
|
||||||
|
|||||||
@ -30,7 +30,7 @@ namespace RGB.NET.Core
|
|||||||
protected Dictionary<int, IDeviceUpdateTrigger> UpdateTriggerMapping { get; } = new();
|
protected Dictionary<int, IDeviceUpdateTrigger> UpdateTriggerMapping { get; } = new();
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IReadOnlyList<(int id, IDeviceUpdateTrigger trigger)> UpdateTriggers => new ReadOnlyCollection<(int id, IDeviceUpdateTrigger trigger)>(UpdateTriggerMapping.Select(x => (x.Key, x.Value)).ToList());
|
public ReadOnlyCollection<(int id, IDeviceUpdateTrigger trigger)> UpdateTriggers => new(UpdateTriggerMapping.Select(x => (x.Key, x.Value)).ToList());
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
|
||||||
namespace RGB.NET.Core
|
namespace RGB.NET.Core
|
||||||
{
|
{
|
||||||
@ -30,7 +31,7 @@ namespace RGB.NET.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a collection <see cref="IDeviceUpdateTrigger"/> registered to this device provider.
|
/// Gets a collection <see cref="IDeviceUpdateTrigger"/> registered to this device provider.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
IReadOnlyList<(int id, IDeviceUpdateTrigger trigger)> UpdateTriggers { get; }
|
ReadOnlyCollection<(int id, IDeviceUpdateTrigger trigger)> UpdateTriggers { get; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@ -26,15 +26,20 @@ namespace RGB.NET.Core
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a readonly list containing all loaded <see cref="IRGBDevice"/>.
|
/// Gets a readonly list containing all loaded <see cref="IRGBDevice"/>.
|
||||||
/// This collection should be locked when enumerated in a multi-threaded application.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IReadOnlyList<IRGBDevice> Devices { get; }
|
public IEnumerable<IRGBDevice> Devices
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
lock (_devices)
|
||||||
|
return new ReadOnlyCollection<IRGBDevice>(_devices);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a readonly list containing all registered <see cref="IUpdateTrigger"/>.
|
/// Gets a readonly list containing all registered <see cref="IUpdateTrigger"/>.
|
||||||
/// This collection should be locked when enumerated in a multi-threaded application.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IReadOnlyList<IUpdateTrigger> UpdateTriggers { get; }
|
public IEnumerable<IUpdateTrigger> UpdateTriggers => new ReadOnlyCollection<IUpdateTrigger>(_updateTriggers);
|
||||||
|
|
||||||
/// <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"/>.
|
||||||
@ -48,7 +53,7 @@ namespace RGB.NET.Core
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
lock (Devices)
|
lock (_devices)
|
||||||
return _devices.SelectMany(x => x);
|
return _devices.SelectMany(x => x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,9 +124,6 @@ namespace RGB.NET.Core
|
|||||||
public RGBSurface()
|
public RGBSurface()
|
||||||
{
|
{
|
||||||
_deltaTimeCounter = Stopwatch.StartNew();
|
_deltaTimeCounter = Stopwatch.StartNew();
|
||||||
|
|
||||||
Devices = new ReadOnlyCollection<IRGBDevice>(_devices);
|
|
||||||
UpdateTriggers = new ReadOnlyCollection<IUpdateTrigger>(_updateTriggers);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -144,8 +146,8 @@ namespace RGB.NET.Core
|
|||||||
bool render = customData["render"] as bool? ?? true;
|
bool render = customData["render"] as bool? ?? true;
|
||||||
bool updateDevices = customData["updateDevices"] as bool? ?? true;
|
bool updateDevices = customData["updateDevices"] as bool? ?? true;
|
||||||
|
|
||||||
lock (UpdateTriggers)
|
lock (_updateTriggers)
|
||||||
lock (Devices)
|
lock (_devices)
|
||||||
{
|
{
|
||||||
OnUpdating(updateTrigger, customData);
|
OnUpdating(updateTrigger, customData);
|
||||||
|
|
||||||
@ -176,7 +178,7 @@ namespace RGB.NET.Core
|
|||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
List<IRGBDevice> devices;
|
List<IRGBDevice> devices;
|
||||||
lock (Devices)
|
lock (_devices)
|
||||||
devices = new List<IRGBDevice>(_devices);
|
devices = new List<IRGBDevice>(_devices);
|
||||||
|
|
||||||
foreach (IRGBDevice device in devices)
|
foreach (IRGBDevice device in devices)
|
||||||
@ -265,7 +267,7 @@ namespace RGB.NET.Core
|
|||||||
/// <param name="device">The <see cref="IRGBDevice"/> to attach.</param>
|
/// <param name="device">The <see cref="IRGBDevice"/> to attach.</param>
|
||||||
public void Attach(IRGBDevice device)
|
public void Attach(IRGBDevice device)
|
||||||
{
|
{
|
||||||
lock (Devices)
|
lock (_devices)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(device.DeviceInfo.DeviceName)) throw new RGBDeviceException($"The device '{device.DeviceInfo.Manufacturer} {device.DeviceInfo.Model}' has no valid name.");
|
if (string.IsNullOrWhiteSpace(device.DeviceInfo.DeviceName)) throw new RGBDeviceException($"The device '{device.DeviceInfo.Manufacturer} {device.DeviceInfo.Model}' has no valid name.");
|
||||||
if (device.Surface != null) throw new RGBSurfaceException($"The device '{device.DeviceInfo.DeviceName}' is already attached to a surface.");
|
if (device.Surface != null) throw new RGBSurfaceException($"The device '{device.DeviceInfo.DeviceName}' is already attached to a surface.");
|
||||||
@ -285,7 +287,7 @@ namespace RGB.NET.Core
|
|||||||
/// <returns><c>true</c> if the <see cref="IRGBDevice"/> could be detached; <c>false</c> otherwise.</returns>
|
/// <returns><c>true</c> if the <see cref="IRGBDevice"/> could be detached; <c>false</c> otherwise.</returns>
|
||||||
public void Detach(IRGBDevice device)
|
public void Detach(IRGBDevice device)
|
||||||
{
|
{
|
||||||
lock (Devices)
|
lock (_devices)
|
||||||
{
|
{
|
||||||
if (!_devices.Contains(device)) throw new RGBSurfaceException($"The device '{device.DeviceInfo.DeviceName}' is not attached to this surface.");
|
if (!_devices.Contains(device)) throw new RGBSurfaceException($"The device '{device.DeviceInfo.DeviceName}' is not attached to this surface.");
|
||||||
|
|
||||||
@ -312,7 +314,7 @@ namespace RGB.NET.Core
|
|||||||
|
|
||||||
private void UpdateSurfaceRectangle()
|
private void UpdateSurfaceRectangle()
|
||||||
{
|
{
|
||||||
lock (Devices)
|
lock (_devices)
|
||||||
{
|
{
|
||||||
Rectangle devicesRectangle = new(_devices.Select(d => d.Boundary));
|
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));
|
Boundary = Boundary.SetSize(new Size(devicesRectangle.Location.X + devicesRectangle.Size.Width, devicesRectangle.Location.Y + devicesRectangle.Size.Height));
|
||||||
|
|||||||
@ -68,7 +68,7 @@ namespace RGB.NET.Devices.DMX.E131
|
|||||||
this.Hostname = deviceDefinition.Hostname;
|
this.Hostname = deviceDefinition.Hostname;
|
||||||
this.Port = deviceDefinition.Port;
|
this.Port = deviceDefinition.Port;
|
||||||
this.Universe = deviceDefinition.Universe;
|
this.Universe = deviceDefinition.Universe;
|
||||||
|
|
||||||
byte[]? cid = deviceDefinition.CID;
|
byte[]? cid = deviceDefinition.CID;
|
||||||
if ((cid == null) || (cid.Length != CID_LENGTH))
|
if ((cid == null) || (cid.Length != CID_LENGTH))
|
||||||
{
|
{
|
||||||
@ -76,7 +76,7 @@ namespace RGB.NET.Devices.DMX.E131
|
|||||||
new Random().NextBytes(cid);
|
new Random().NextBytes(cid);
|
||||||
}
|
}
|
||||||
|
|
||||||
CID = cid;
|
CID = cid!;
|
||||||
|
|
||||||
DeviceName = DeviceHelper.CreateDeviceName(Manufacturer, Model);
|
DeviceName = DeviceHelper.CreateDeviceName(Manufacturer, Model);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user