using System; using System.Collections.Generic; using RGB.NET.Core; namespace RGB.NET.Devices.Novation { /// /// /// Represents a generic Novation-device. (launchpad). /// public abstract class NovationRGBDevice : AbstractRGBDevice, INovationRGBDevice where TDeviceInfo : NovationRGBDeviceInfo { #region Constructors /// /// Initializes a new instance of the class. /// /// The generic information provided by Novation for the device. protected NovationRGBDevice(TDeviceInfo info, IDeviceUpdateTrigger updateTrigger) : base(info, GetUpdateQueue(updateTrigger, info)) { } #endregion #region Methods private static UpdateQueue GetUpdateQueue(IDeviceUpdateTrigger updateTrigger, TDeviceInfo info) => info.ColorCapabilities switch { NovationColorCapabilities.LimitedRG => new LimitedColorUpdateQueue(updateTrigger, info.DeviceId), NovationColorCapabilities.RGB => new RGBColorUpdateQueue(updateTrigger, info.DeviceId), _ => throw new ArgumentOutOfRangeException() }; /// protected override void UpdateLeds(IEnumerable ledsToUpdate) => UpdateQueue.SetData(GetUpdateData(ledsToUpdate)); /// /// Resets the back to default. /// public virtual void Reset() => UpdateQueue.Reset(); /// /// public override void Dispose() { Reset(); base.Dispose(); } #endregion } }