using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace RGB.NET.Core;
///
///
///
/// Represents a generic .
///
public abstract class AbstractLedGroup : AbstractDecoratable, ILedGroup
{
#region Properties & Fields
RGBSurface? ILedGroup.Surface { get; set; }
///
public RGBSurface? Surface => ((ILedGroup)this).Surface;
///
public IBrush? Brush { get; set; }
///
public int ZIndex { get; set; } = 0;
#endregion
#region Constructors
///
/// Initializes a new instance of the class.
///
protected AbstractLedGroup(RGBSurface? attachTo)
{
attachTo?.Attach(this);
}
#endregion
#region Methods
///
/// Gets a enumerable containing all leds in this group.
///
/// A enumerable containing all leds of this group.
protected abstract IEnumerable GetLeds();
///
public virtual void OnAttach() { }
///
public virtual void OnDetach() { }
///
public virtual IList ToList() => GetLeds().ToList();
///
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
///
public IEnumerator GetEnumerator() => GetLeds().GetEnumerator();
///
IDisposable? ILedGroup.ToListUnsafe(out IList leds) => ToListUnsafe(out leds);
protected virtual IDisposable? ToListUnsafe(out IList leds)
{
leds = ToList();
return null;
}
#endregion
}