using System.Collections.Generic; using System.Linq; using RGB.NET.Core; using RGB.NET.Devices.SteelSeries.API; using RGB.NET.Devices.SteelSeries.Helper; namespace RGB.NET.Devices.SteelSeries { /// /// /// Represents the update-queue performing updates for steelseries devices. /// internal class SteelSeriesDeviceUpdateQueue : UpdateQueue { #region Properties & Fields private string _deviceType; #endregion #region Constructors /// /// Initializes a new instance of the class. /// /// The update trigger used by this queue. /// The device type used to identify the device. public SteelSeriesDeviceUpdateQueue(IDeviceUpdateTrigger updateTrigger, string deviceType) : base(updateTrigger) { this._deviceType = deviceType; } #endregion #region Methods protected override void OnUpdate(object sender, CustomUpdateData customData) { if ((customData != null) && (customData["refresh"] as bool? ?? false)) SteelSeriesSDK.SendHeartbeat(); else base.OnUpdate(sender, customData); } /// protected override void Update(Dictionary dataSet) => SteelSeriesSDK.UpdateLeds(_deviceType, dataSet.ToDictionary(x => ((SteelSeriesLedId)x.Key).GetAPIName(), x => x.Value.ToIntArray())); #endregion } }