using System.Collections; using System.Collections.Generic; using System.Linq; namespace RGB.NET.Core { /// /// Represents a generic RGB-device /// public abstract class AbstractRGBDevice : IRGBDevice { #region Properties & Fields /// /// Gets generic information about the . /// public IRGBDeviceInfo DeviceInfo { get; } /// /// Gets the representing the whole . /// public Rectangle DeviceRectangle { get; } /// /// Gets a dictionary containing all of the . /// protected Dictionary LedMapping { get; } = new Dictionary(); #region Indexer Led IRGBDevice.this[ILedId ledId] { get { Led led; return LedMapping.TryGetValue(ledId, out led) ? led : null; } } Led IRGBDevice.this[Point location] => LedMapping.Values.FirstOrDefault(x => x.LedRectangle.Contains(location)); IEnumerable IRGBDevice.this[Rectangle referenceRect, float minOverlayPercentage] => LedMapping.Values.Where(x => referenceRect.CalculateIntersectPercentage(x.LedRectangle) >= minOverlayPercentage) ; #endregion #endregion #region Constructors #endregion #region Methods public void Initialize() { throw new System.NotImplementedException(); } public void Update(bool flushLeds = false) { throw new System.NotImplementedException(); } #region Enumerator /// /// Returns an enumerator that iterates over all of the . /// /// An enumerator for all of the . public IEnumerator GetEnumerator() { return LedMapping.Values.GetEnumerator(); } /// /// Returns an enumerator that iterates over all of the . /// /// An enumerator for all of the . IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } #endregion #endregion } }