using System.Collections.Generic; using System.Linq; using RGB.NET.Core; namespace RGB.NET.Devices.Msi { /// /// /// /// Represents a generic MSI-device. (keyboard, mouse, headset, mousepad). /// public abstract class MsiRGBDevice : AbstractRGBDevice, IMsiRGBDevice where TDeviceInfo : MsiRGBDeviceInfo { #region Properties & Fields /// /// /// Gets information about the . /// public override TDeviceInfo DeviceInfo { get; } /// /// Gets or sets the update queue performing updates for this device. /// // ReSharper disable once MemberCanBePrivate.Global protected MsiDeviceUpdateQueue DeviceUpdateQueue { get; set; } #endregion #region Constructors /// /// Initializes a new instance of the class. /// /// The generic information provided by MSI for the device. protected MsiRGBDevice(TDeviceInfo info) { this.DeviceInfo = info; } #endregion #region Methods /// /// Initializes the device. /// public void Initialize(MsiDeviceUpdateQueue updateQueue) { DeviceUpdateQueue = updateQueue; InitializeLayout(); if (Size == Size.Invalid) { Rectangle ledRectangle = new Rectangle(this.Select(x => x.LedRectangle)); Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y); } } /// /// Initializes the and of the device. /// protected abstract void InitializeLayout(); /// protected override void UpdateLeds(IEnumerable ledsToUpdate) => DeviceUpdateQueue.SetData(ledsToUpdate.Where(x => (x.Color.A > 0) && (x.CustomData is int))); #endregion } }