using System; using System.Collections.Generic; using RGB.NET.Core; using RGB.NET.Devices.Razer.Native; namespace RGB.NET.Devices.Razer { public abstract class RazerUpdateQueue : UpdateQueue { #region Properties & Fields private readonly Guid _deviceId; private Guid? _lastEffect; #endregion #region Constructors protected RazerUpdateQueue(IUpdateTrigger updateTrigger, Guid deviceId) : base(updateTrigger) { this._deviceId = deviceId; } #endregion #region Methods /// protected override void Update(Dictionary dataSet) { IntPtr effectParams = CreateEffectParams(dataSet); Guid effectId = Guid.NewGuid(); _RazerSDK.CreateEffect(_deviceId, _Defines.EFFECT_ID, effectParams, ref effectId); _RazerSDK.SetEffect(effectId); if (_lastEffect.HasValue) _RazerSDK.DeleteEffect(_lastEffect.Value); _lastEffect = effectId; } /// public override void Reset() { if (_lastEffect.HasValue) { _RazerSDK.DeleteEffect(_lastEffect.Value); _lastEffect = null; } } /// /// Creates the device-specific effect parameters for the led-update. /// /// The data to be updated. /// An pointing to the effect parameter struct. protected abstract IntPtr CreateEffectParams(Dictionary dataSet); #endregion } }