mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-13 01:58:30 +00:00
78 lines
2.3 KiB
C#
78 lines
2.3 KiB
C#
using System.Linq;
|
|
using RGB.NET.Core;
|
|
|
|
namespace RGB.NET.Devices.Wooting.Generic
|
|
{
|
|
/// <inheritdoc cref="AbstractRGBDevice{TDeviceInfo}" />
|
|
/// <inheritdoc cref="IWootingRGBDevice" />
|
|
/// <summary>
|
|
/// Represents a Wooting-device
|
|
/// </summary>
|
|
public abstract class WootingRGBDevice<TDeviceInfo> : AbstractRGBDevice<TDeviceInfo>, IWootingRGBDevice
|
|
where TDeviceInfo : WootingRGBDeviceInfo
|
|
{
|
|
#region Properties & Fields
|
|
|
|
/// <inheritdoc />
|
|
/// <summary>
|
|
/// Gets information about the <see cref="T:RGB.NET.Devices.Wooting.WootingRGBDevice" />.
|
|
/// </summary>
|
|
public override TDeviceInfo DeviceInfo { get; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the update queue performing updates for this device.
|
|
/// </summary>
|
|
// ReSharper disable once MemberCanBePrivate.Global
|
|
protected UpdateQueue? UpdateQueue { get; set; }
|
|
|
|
#endregion
|
|
|
|
#region Constructors
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="WootingRGBDevice{TDeviceInfo}"/> class.
|
|
/// </summary>
|
|
/// <param name="info">The generic information provided by Wooting for the device.</param>
|
|
protected WootingRGBDevice(TDeviceInfo info)
|
|
{
|
|
this.DeviceInfo = info;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
/// <summary>
|
|
/// Initializes the device.
|
|
/// </summary>
|
|
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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initializes the <see cref="Led"/> and <see cref="Size"/> of the device.
|
|
/// </summary>
|
|
protected abstract void InitializeLayout();
|
|
|
|
/// <inheritdoc />
|
|
public override void Dispose()
|
|
{
|
|
try { UpdateQueue?.Dispose(); }
|
|
catch { /* at least we tried */ }
|
|
|
|
base.Dispose();
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|