using System; using System.Collections.Generic; using AuraServiceLib; using RGB.NET.Core; namespace RGB.NET.Devices.Asus { /// /// /// Represents the update-queue performing updates for asus devices. /// public class AsusUpdateQueue : UpdateQueue { #region Properties & Fields /// /// The device to be updated. /// protected IAuraSyncDevice Device { get; private set; } #endregion #region Constructors /// /// Initializes a new instance of the class. /// /// The update trigger used by this queue. public AsusUpdateQueue(IDeviceUpdateTrigger updateTrigger) : base(updateTrigger) { } #endregion #region Methods /// /// Initializes the queue. /// /// The device to be updated. public void Initialize(IAuraSyncDevice device) { Device = device; } /// protected override void Update(Dictionary dataSet) { try { foreach (KeyValuePair data in dataSet) { int index = (int)data.Key; IAuraRgbLight light = Device.Lights[index]; (_, byte r, byte g, byte b) = data.Value.GetRGBBytes(); light.Red = r; light.Green = g; light.Blue = b; } Device.Apply(); } catch (Exception ex) { /* "The server threw an exception." seems to be a thing here ... */ } } #endregion } }