// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedMember.Global
using System.Collections.Generic;
using CUE.NET.Devices;
using CUE.NET.Devices.Generic;
using CUE.NET.Devices.Generic.Enums;
namespace CUE.NET.Groups
{
///
/// Represents a ledgroup containing arbitrary LEDs.
///
public class ListLedGroup : AbstractLedGroup
{
#region Properties & Fields
///
/// Gets the strongly-typed target used for the effect.
///
protected override ILedGroup EffectTarget => this;
///
/// Gets the list containing the LEDs of this ledgroup.
///
protected IList GroupLeds { get; } = new List();
#endregion
#region Constructors
///
/// Initializes a new instance of the class.
///
/// The device this ledgroup belongs to.
/// Specifies whether this ledgroup should be automatically attached or not.
public ListLedGroup(ICueDevice device, bool autoAttach = true)
: base(device, autoAttach)
{ }
///
/// Initializes a new instance of the class.
///
/// The device this ledgroup belongs to.
/// The initial LEDs of this ledgroup.
public ListLedGroup(ICueDevice device, params CorsairLed[] leds)
: this(device, true, leds)
{ }
///
/// Initializes a new instance of the class.
///
/// The device this ledgroup belongs to.
/// The initial LEDs of this ledgroup.
public ListLedGroup(ICueDevice device, IEnumerable leds)
: this(device, true, leds)
{ }
///
/// Initializes a new instance of the class.
///
/// The device this ledgroup belongs to.
/// Specifies whether this ledgroup should be automatically attached or not.
/// The initial LEDs of this ledgroup.
public ListLedGroup(ICueDevice device, bool autoAttach, IEnumerable leds)
: base(device, autoAttach)
{
AddLeds(leds);
}
///
/// Initializes a new instance of the class.
///
/// The device this ledgroup belongs to.
/// Specifies whether this ledgroup should be automatically attached or not.
/// The initial LEDs of this ledgroup.
public ListLedGroup(ICueDevice device, bool autoAttach, params CorsairLed[] leds)
: base(device, autoAttach)
{
AddLeds(leds);
}
///
/// Initializes a new instance of the class.
///
/// The device this ledgroup belongs to.
/// The IDs of the initial LEDs of this ledgroup.
public ListLedGroup(ICueDevice device, params CorsairLedId[] leds)
: this(device, true, leds)
{ }
///
/// Initializes a new instance of the class.
///
/// The device this ledgroup belongs to.
/// The IDs of the initial LEDs of this ledgroup.
public ListLedGroup(ICueDevice device, IEnumerable leds)
: this(device, true, leds)
{ }
///
/// Initializes a new instance of the class.
///
/// The device this ledgroup belongs to.
/// Specifies whether this ledgroup should be automatically attached or not.
/// The IDs of the initial LEDs of this ledgroup.
public ListLedGroup(ICueDevice device, bool autoAttach, params CorsairLedId[] leds)
: base(device, autoAttach)
{
AddLeds(leds);
}
///
/// Initializes a new instance of the class.
///
/// The device this ledgroup belongs to.
/// Specifies whether this ledgroup should be automatically attached or not.
/// The IDs of the initial LEDs of this ledgroup.
public ListLedGroup(ICueDevice device, bool autoAttach, IEnumerable leds)
: base(device, autoAttach)
{
AddLeds(leds);
}
#endregion
#region Methods
///
/// Adds the given LED(s) to the ledgroup.
///
/// The LED(s) to add.
public void AddLed(params CorsairLed[] leds)
{
AddLeds(leds);
}
///
/// Adds the given LED(s) to the ledgroup.
///
/// The ID(s) of the LED(s) to add.
public void AddLed(params CorsairLedId[] ledIds)
{
AddLeds(ledIds);
}
///
/// Adds the given LEDs to the ledgroup.
///
/// The LEDs to add.
public void AddLeds(IEnumerable leds)
{
if (leds == null) return;
foreach (CorsairLed led in leds)
if (led != null && !ContainsLed(led))
GroupLeds.Add(led);
}
///
/// Adds the given LEDs to the ledgroup.
///
/// The IDs of the LEDs to add.
public void AddLeds(IEnumerable ledIds)
{
if (ledIds == null) return;
foreach (CorsairLedId ledId in ledIds)
AddLed(Device[ledId]);
}
///
/// Removes the given LED(s) from the ledgroup.
///
/// The LED(s) to remove.
public void RemoveLed(params CorsairLed[] leds)
{
RemoveLeds(leds);
}
///
/// Removes the given LED(s) from the ledgroup.
///
/// The ID(s) of the LED(s) to remove.
public void RemoveLed(params CorsairLedId[] ledIds)
{
RemoveLeds(ledIds);
}
///
/// Removes the given LEDs from the ledgroup.
///
/// The LEDs to remove.
public void RemoveLeds(IEnumerable leds)
{
if (leds == null) return;
foreach (CorsairLed led in leds)
if (led != null)
GroupLeds.Remove(led);
}
///
/// Removes the given LEDs from the ledgroup.
///
/// The IDs of the LEDs to remove.
public void RemoveLeds(IEnumerable ledIds)
{
if (ledIds == null) return;
foreach (CorsairLedId ledId in ledIds)
RemoveLed(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(CorsairLed 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(CorsairLedId ledId)
{
return ContainsLed(Device[ledId]);
}
///
/// Merges the LEDs from the given ledgroup in this ledgroup.
///
/// The ledgroup to merge.
public void MergeLeds(ILedGroup groupToMerge)
{
foreach (CorsairLed led in groupToMerge.GetLeds())
if (!GroupLeds.Contains(led))
GroupLeds.Add(led);
}
///
/// Gets a list containing the LEDs from this group.
///
/// The list containing the LEDs.
public override IEnumerable GetLeds()
{
return GroupLeds;
}
#endregion
}
}