using System.Collections.Generic;
using System.Linq;
using RGB.NET.Core;
namespace RGB.NET.Devices.SteelSeries
{
///
///
///
/// Represents a SteelSeries-device. (keyboard, mouse, headset, mousepad).
///
public class SteelSeriesRGBDevice : AbstractRGBDevice, ISteelSeriesRGBDevice, IUnknownDevice//TODO DarthAffe 18.04.2020: It's know which kind of device this is, but they would need to be separated
{
#region Properties & Fields
private Dictionary _ledMapping = new();
///
///
/// Gets information about the .
///
public override SteelSeriesRGBDeviceInfo DeviceInfo { get; }
///
/// Gets or sets the update queue performing updates for this device.
///
// ReSharper disable once MemberCanBePrivate.Global
protected UpdateQueue? UpdateQueue { get; set; }
#endregion
#region Constructors
///
/// Initializes a new instance of the class.
///
/// The generic information provided by SteelSeries for the device.
internal SteelSeriesRGBDevice(SteelSeriesRGBDeviceInfo info)
{
this.DeviceInfo = info;
}
#endregion
#region Methods
///
/// Initializes the device.
///
void ISteelSeriesRGBDevice.Initialize(UpdateQueue updateQueue, Dictionary ledMapping)
{
_ledMapping = ledMapping;
int counter = 0;
foreach (KeyValuePair mapping in ledMapping)
AddLed(mapping.Key, new Point((counter++) * 10, 0), new Size(10, 10));
UpdateQueue = updateQueue;
}
///
protected override object GetLedCustomData(LedId ledId) => _ledMapping[ledId];
///
protected override void UpdateLeds(IEnumerable ledsToUpdate) => UpdateQueue?.SetData(GetUpdateData(ledsToUpdate));
///
public override void Dispose()
{
try { UpdateQueue?.Dispose(); }
catch { /* at least we tried */ }
base.Dispose();
}
#endregion
}
}