using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using CUE.NET.Brushes; using CUE.NET.Devices.Generic; using CUE.NET.Devices.Keyboard.Extensions; using CUE.NET.Effects; namespace CUE.NET.Devices.Keyboard.Keys { /// /// Represents a basic keygroup. /// public abstract class AbstractKeyGroup : AbstractEffectTarget, IKeyGroup { #region Properties & Fields /// /// Gets the keyboard this keygroup belongs to. /// internal CorsairKeyboard Keyboard { get; } /// /// Gets a read-only collection containing the keys from this group. /// public IEnumerable Keys => new ReadOnlyCollection(GetGroupKeys()); /// /// Gets or sets the brush which should be drawn over this group. /// public IBrush Brush { get; set; } /// /// Gets or sets the z-index of this keygroup to allow ordering them before drawing. (lowest first) (default: 0) /// public int ZIndex { get; set; } = 0; #endregion #region Constructors /// /// Initializes a new instance of the class. /// /// The keyboard this keygroup belongs to. /// Specifies whether this group should be automatically attached or not. protected AbstractKeyGroup(CorsairKeyboard keyboard, bool autoAttach = true) { this.Keyboard = keyboard; if (autoAttach) this.Attach(); } #endregion #region Methods public IEnumerable GetLeds() { return GetGroupKeys().Select(x => x.Led); } /// /// Gets a list containing the keys from this group. /// /// The list containing the keys. protected abstract IList GetGroupKeys(); #endregion } }