// ReSharper disable UnusedMember.Global // ReSharper disable MemberCanBePrivate.Global using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using RGB.NET.Core; namespace RGB.NET.Devices.Corsair { /// /// /// Represents a lightbar attached to a /// public class LightbarSpecialPart : IRGBDeviceSpecialPart { #region Properties & Fields private List _leds; /// /// Gets a readonly collection of all of this . /// public IEnumerable Leds => new ReadOnlyCollection(_leds); private List _left; /// /// Gets a readonly collection of all in the left half of this . /// public IEnumerable Left => new ReadOnlyCollection(_left); private List _right; /// /// Gets a readonly collection of all in the right half of this . /// public IEnumerable Right => new ReadOnlyCollection(_right); /// /// Gets the Center of this . /// public Led Center { get; } #endregion #region Constructors /// /// Initializes a new instance of the class. /// /// The device associated with this . public LightbarSpecialPart(IRGBDevice device) { _leds = device.Where(led => ((CorsairLedId)led.CustomData >= CorsairLedId.Lightbar1) && ((CorsairLedId)led.CustomData <= CorsairLedId.Lightbar19)).ToList(); _left = _leds.Where(led => (CorsairLedId)led.CustomData < CorsairLedId.Lightbar10).ToList(); _right = _leds.Where(led => (CorsairLedId)led.CustomData > CorsairLedId.Lightbar10).ToList(); Center = _leds.FirstOrDefault(led => (CorsairLedId)led.CustomData == CorsairLedId.Lightbar10); } #endregion #region Methods /// /// /// Returns an enumerator that iterates over all of the . /// /// An enumerator for all of the . public IEnumerator GetEnumerator() => _leds.GetEnumerator(); /// /// /// Returns an enumerator that iterates over all of the . /// /// An enumerator for all of the . IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); #endregion } }