using System.Collections.Generic; using System.Linq; using RGB.NET.Core; namespace RGB.NET.Devices.Asus { /// /// /// /// Represents a generic Asus-device. (keyboard, mouse, headset, mousepad). /// public abstract class AsusRGBDevice : AbstractRGBDevice, IAsusRGBDevice where TDeviceInfo : AsusRGBDeviceInfo { #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 AsusUpdateQueue UpdateQueue { get; set; } #endregion #region Constructors /// /// Initializes a new instance of the class. /// /// The generic information provided by Asus for the device. protected AsusRGBDevice(TDeviceInfo info) { this.DeviceInfo = info; } #endregion #region Methods /// /// Initializes the device. /// public void Initialize(IDeviceUpdateTrigger updateTrigger) { 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); } UpdateQueue = new AsusUpdateQueue(updateTrigger); UpdateQueue.Initialize(DeviceInfo.Device); } /// /// Initializes the and of the device. /// protected abstract void InitializeLayout(); /// protected override void UpdateLeds(IEnumerable ledsToUpdate) => UpdateQueue.SetData(ledsToUpdate.Where(x => x.Color.A > 0)); /// public override void SyncBack() { // DarthAffe 16.06.2019: This doesn't work since the SDK only returns the colors we set. //foreach (Led led in LedMapping.Values) //{ // int index = (int)led.CustomData; // IAuraRgbLight light = DeviceInfo.Device.Lights[index]; // SetLedColorWithoutRequest(led, new Color(light.Red, light.Green, light.Blue)); //} } #endregion } }