using System.Linq; using RGB.NET.Core; namespace RGB.NET.Devices.Wooting.Generic { /// /// /// /// Represents a Wooting-device /// public abstract class WootingRGBDevice : AbstractRGBDevice, IWootingRGBDevice where TDeviceInfo : WootingRGBDeviceInfo { #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 UpdateQueue UpdateQueue { get; set; } #endregion #region Constructors /// /// Initializes a new instance of the class. /// /// The generic information provided by Wooting for the device. protected WootingRGBDevice(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 WootingUpdateQueue(updateTrigger); } /// /// Initializes the and of the device. /// protected abstract void InitializeLayout(); /// public override void Dispose() { try { UpdateQueue?.Dispose(); } catch { /* at least we tried */ } base.Dispose(); } #endregion } }