using System.Collections.Generic; using System.Linq; using RGB.NET.Core; using RGB.NET.Devices.Msi.Native; 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; } #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() { 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) { List leds = ledsToUpdate.Where(x => x.Color.A > 0).ToList(); if (leds.Count > 0) { string deviceType = DeviceInfo.MsiDeviceType; foreach (Led led in leds) _MsiSDK.SetLedColor(deviceType, (int)led.CustomData, led.Color.R, led.Color.G, led.Color.B); } } #endregion } }