// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedMember.Global
using System.Collections.Generic;
using RGB.NET.Core;
namespace RGB.NET.Groups
{
///
/// Represents a ledgroup containing arbitrary .
///
public class ListLedGroup : AbstractLedGroup
{
#region Properties & Fields
///
protected override ILedGroup EffectTarget => this;
///
/// Gets the list containing the of this .
///
protected IList GroupLeds { get; } = new List();
#endregion
#region Constructors
///
/// Initializes a new instance of the class.
///
/// Specifies whether this should be automatically attached or not.
public ListLedGroup(bool autoAttach = true)
: base(autoAttach)
{ }
///
/// Initializes a new instance of the class.
///
/// The initial of this .
public ListLedGroup(params Led[] leds)
: this(true, leds)
{ }
///
/// Initializes a new instance of the class.
///
/// The initial of this .
public ListLedGroup(IEnumerable leds)
: this(true, leds)
{ }
///
/// Initializes a new instance of the class.
///
/// Specifies whether this should be automatically attached or not.
/// The initial of this .
public ListLedGroup(bool autoAttach, IEnumerable leds)
: base(autoAttach)
{
AddLeds(leds);
}
///
/// Initializes a new instance of the class.
///
/// Specifies whether this should be automatically attached or not.
/// The initial of this .
public ListLedGroup(bool autoAttach, params Led[] leds)
: base(autoAttach)
{
AddLeds(leds);
}
///
/// Initializes a new instance of the class.
///
/// The IDs of the initial of this .
public ListLedGroup(params ILedId[] leds)
: this(true, leds)
{ }
///
/// Initializes a new instance of the class.
///
/// The IDs of the initial of this .
public ListLedGroup(IEnumerable leds)
: this(true, leds)
{ }
///
/// Initializes a new instance of the class.
///
/// Specifies whether this should be automatically attached or not.
/// The IDs of the initial of this .
public ListLedGroup(bool autoAttach, params ILedId[] leds)
: base(autoAttach)
{
AddLeds(leds);
}
///
/// Initializes a new instance of the class.
///
/// Specifies whether this should be automatically attached or not.
/// The IDs of the initial of this .
public ListLedGroup(bool autoAttach, IEnumerable leds)
: base(autoAttach)
{
AddLeds(leds);
}
#endregion
#region Methods
///
/// Adds the given LED(s) to this .
///
/// The LED(s) to add.
public void AddLed(params Led[] leds)
{
AddLeds(leds);
}
///
/// Adds the given LED(s) to this .
///
/// The ID(s) of the LED(s) to add.
public void AddLed(params ILedId[] ledIds)
{
AddLeds(ledIds);
}
///
/// Adds the given to this .
///
/// The to add.
public void AddLeds(IEnumerable leds)
{
if (leds == null) return;
foreach (Led led in leds)
if ((led != null) && !ContainsLed(led))
GroupLeds.Add(led);
}
///
/// Adds the given to this .
///
/// The IDs of the to add.
public void AddLeds(IEnumerable ledIds)
{
if (ledIds == null) return;
foreach (ILedId ledId in ledIds)
AddLed(ledId.Device[ledId]);
}
///
/// Removes the given LED(s) from this .
///
/// The LED(s) to remove.
public void RemoveLed(params Led[] leds)
{
RemoveLeds(leds);
}
///
/// Removes the given LED(s) from this .
///
/// The ID(s) of the LED(s) to remove.
public void RemoveLed(params ILedId[] ledIds)
{
RemoveLeds(ledIds);
}
///
/// Removes the given from this .
///
/// The to remove.
public void RemoveLeds(IEnumerable leds)
{
if (leds == null) return;
foreach (Led led in leds)
if (led != null)
GroupLeds.Remove(led);
}
///
/// Removes the given from this .
///
/// The IDs of the to remove.
public void RemoveLeds(IEnumerable ledIds)
{
if (ledIds == null) return;
foreach (ILedId ledId in ledIds)
RemoveLed(ledId.Device[ledId]);
}
///
/// Checks if a given LED is contained by this ledgroup.
///
/// The LED which should be checked.
/// true if the LED is contained by this ledgroup; otherwise, false.
public bool ContainsLed(Led led)
{
return (led != null) && GroupLeds.Contains(led);
}
///
/// Checks if a given LED is contained by this ledgroup.
///
/// The ID of the LED which should be checked.
/// true if the LED is contained by this ledgroup; otherwise, false.
public bool ContainsLed(ILedId ledId)
{
return ContainsLed(ledId.Device[ledId]);
}
///
/// Merges the from the given ledgroup in this ledgroup.
///
/// The ledgroup to merge.
public void MergeLeds(ILedGroup groupToMerge)
{
foreach (Led led in groupToMerge.GetLeds())
if (!GroupLeds.Contains(led))
GroupLeds.Add(led);
}
///
/// Gets a list containing the from this group.
///
/// The list containing the .
public override IEnumerable GetLeds()
{
return GroupLeds;
}
#endregion
}
}