mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2026-11-11 04:57:15 +00:00
Streamlined device loading/handling in device providers
This commit is contained in:
1 parent
f6f3e9185c
commit
2a9a43683c
81 files changed
+867
-1864
No files matched your search
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.SteelSeries
|
||||
{
|
||||
@@ -7,7 +6,5 @@ namespace RGB.NET.Devices.SteelSeries
|
||||
/// Represents a steelseries RGB-device.
|
||||
/// </summary>
|
||||
internal interface ISteelSeriesRGBDevice : IRGBDevice
|
||||
{
|
||||
void Initialize(UpdateQueue updateQueue, Dictionary<LedId, SteelSeriesLedId> ledMapping);
|
||||
}
|
||||
{ }
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.SteelSeries
|
||||
@@ -13,19 +12,7 @@ namespace RGB.NET.Devices.SteelSeries
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
private Dictionary<LedId, SteelSeriesLedId> _ledMapping = new();
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Gets information about the <see cref="SteelSeriesRGBDevice" />.
|
||||
/// </summary>
|
||||
public override SteelSeriesRGBDeviceInfo 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; }
|
||||
private readonly Dictionary<LedId, SteelSeriesLedId> _ledMapping;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -35,34 +22,30 @@ namespace RGB.NET.Devices.SteelSeries
|
||||
/// Initializes a new instance of the <see cref="SteelSeriesRGBDevice"/> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The generic information provided by SteelSeries for the device.</param>
|
||||
internal SteelSeriesRGBDevice(SteelSeriesRGBDeviceInfo info)
|
||||
internal SteelSeriesRGBDevice(SteelSeriesRGBDeviceInfo info, string apiName, Dictionary<LedId, SteelSeriesLedId> ledMapping, IDeviceUpdateTrigger updateTrigger)
|
||||
: base(info, new SteelSeriesDeviceUpdateQueue(updateTrigger, apiName))
|
||||
{
|
||||
this.DeviceInfo = info;
|
||||
this._ledMapping = ledMapping;
|
||||
|
||||
InitializeLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the device.
|
||||
/// </summary>
|
||||
void ISteelSeriesRGBDevice.Initialize(UpdateQueue updateQueue, Dictionary<LedId, SteelSeriesLedId> ledMapping)
|
||||
private void InitializeLayout()
|
||||
{
|
||||
_ledMapping = ledMapping;
|
||||
|
||||
int counter = 0;
|
||||
foreach (KeyValuePair<LedId, SteelSeriesLedId> mapping in ledMapping)
|
||||
foreach (KeyValuePair<LedId, SteelSeriesLedId> mapping in _ledMapping)
|
||||
AddLed(mapping.Key, new Point((counter++) * 10, 0), new Size(10, 10));
|
||||
|
||||
UpdateQueue = updateQueue;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override object GetLedCustomData(LedId ledId) => _ledMapping[ledId];
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue?.SetData(GetUpdateData(ledsToUpdate));
|
||||
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue.SetData(GetUpdateData(ledsToUpdate));
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Dispose()
|
||||
|
||||
Reference in new issue
Block a user