mirror of
https://github.com/DarthAffe/CUE.NET.git
synced 2026-11-10 20:46:24 +00:00
Refactored to do everything based on LEDs.
This will adapt the devices and reduces the importance of the "special case keyboard"
This commit is contained in:
1 parent
bfe51add66
commit
5a018d0743
24 files changed
+847
-894
No files matched your search
@@ -0,0 +1,66 @@
|
||||
using System.Collections.Generic;
|
||||
using CUE.NET.Brushes;
|
||||
using CUE.NET.Devices;
|
||||
using CUE.NET.Devices.Generic;
|
||||
using CUE.NET.Effects;
|
||||
using CUE.NET.Groups.Extensions;
|
||||
|
||||
namespace CUE.NET.Groups
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a basic keygroup.
|
||||
/// </summary>
|
||||
public abstract class AbstractLedGroup : AbstractEffectTarget<ILedGroup>, ILedGroup
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets the strongly-typed target used for the effect.
|
||||
/// </summary>
|
||||
protected override ILedGroup EffectTarget => this;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the device this ledgroup belongs to.
|
||||
/// </summary>
|
||||
public ICueDevice Device { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the brush which should be drawn over this group.
|
||||
/// </summary>
|
||||
public IBrush Brush { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the z-index of this keygroup to allow ordering them before drawing. (lowest first) (default: 0)
|
||||
/// </summary>
|
||||
public int ZIndex { get; set; } = 0;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AbstractLedGroup"/> class.
|
||||
/// </summary>
|
||||
/// <param name="device">The device this ledgroup belongs to.</param>
|
||||
/// <param name="autoAttach">Specifies whether this group should be automatically attached or not.</param>
|
||||
protected AbstractLedGroup(ICueDevice device, bool autoAttach = true)
|
||||
{
|
||||
this.Device = device;
|
||||
|
||||
if (autoAttach)
|
||||
this.Attach();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list containing all LEDs of this group.
|
||||
/// </summary>
|
||||
/// <returns>The list containing all LEDs of this group.</returns>
|
||||
public abstract IEnumerable<CorsairLed> GetLeds();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using CUE.NET.Devices.Generic;
|
||||
using CUE.NET.Devices.Generic.Enums;
|
||||
|
||||
namespace CUE.NET.Groups.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Offers some extensions and helper-methods for ledgroup related things.
|
||||
/// </summary>
|
||||
public static class LedGroupExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts the given <see cref="AbstractLedGroup" /> to a <see cref="ListLedGroup" />.
|
||||
/// </summary>
|
||||
/// <param name="ledGroup">The <see cref="AbstractLedGroup" /> to convert.</param>
|
||||
/// <returns>The converted <see cref="ListLedGroup" />.</returns>
|
||||
public static ListLedGroup ToSimpleKeyGroup(this AbstractLedGroup ledGroup)
|
||||
{
|
||||
ListLedGroup simpleLedGroup = ledGroup as ListLedGroup;
|
||||
if (simpleLedGroup == null)
|
||||
{
|
||||
bool wasAttached = ledGroup.Detach();
|
||||
simpleLedGroup = new ListLedGroup(ledGroup.Device, wasAttached, ledGroup.GetLeds()) { Brush = ledGroup.Brush };
|
||||
}
|
||||
return simpleLedGroup;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a new <see cref="ListLedGroup" /> which contains all LEDs from the given ledgroup excluding the specified ones.
|
||||
/// </summary>
|
||||
/// <param name="ledGroup">The base ledgroup.</param>
|
||||
/// <param name="ledIds">The ids of the LEDs to exclude.</param>
|
||||
/// <returns>The new <see cref="ListLedGroup" />.</returns>
|
||||
public static ListLedGroup Exclude(this AbstractLedGroup ledGroup, params CorsairLedId[] ledIds)
|
||||
{
|
||||
ListLedGroup simpleLedGroup = ledGroup.ToSimpleKeyGroup();
|
||||
foreach (CorsairLedId ledId in ledIds)
|
||||
simpleLedGroup.RemoveLed(ledId);
|
||||
return simpleLedGroup;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a new <see cref="ListLedGroup" /> which contains all LEDs from the given ledgroup excluding the specified ones.
|
||||
/// </summary>
|
||||
/// <param name="ledGroup">The base ledgroup.</param>
|
||||
/// <param name="ledIds">The LEDs to exclude.</param>
|
||||
/// <returns>The new <see cref="ListLedGroup" />.</returns>
|
||||
public static ListLedGroup Exclude(this AbstractLedGroup ledGroup, params CorsairLed[] ledIds)
|
||||
{
|
||||
ListLedGroup simpleLedGroup = ledGroup.ToSimpleKeyGroup();
|
||||
foreach (CorsairLed led in ledIds)
|
||||
simpleLedGroup.RemoveLed(led);
|
||||
return simpleLedGroup;
|
||||
}
|
||||
|
||||
// ReSharper disable once UnusedMethodReturnValue.Global
|
||||
/// <summary>
|
||||
/// Attaches the given ledgroup to the device.
|
||||
/// </summary>
|
||||
/// <param name="ledGroup">The ledgroup to attach.</param>
|
||||
/// <returns><c>true</c> if the ledgroup could be attached; otherwise, <c>false</c>.</returns>
|
||||
public static bool Attach(this AbstractLedGroup ledGroup)
|
||||
{
|
||||
return ledGroup.Device?.AttachLedGroup(ledGroup) ?? false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Detaches the given ledgroup from the device.
|
||||
/// </summary>
|
||||
/// <param name="ledGroup">The ledgroup to attach.</param>
|
||||
/// <returns><c>true</c> if the ledgroup could be detached; otherwise, <c>false</c>.</returns>
|
||||
public static bool Detach(this AbstractLedGroup ledGroup)
|
||||
{
|
||||
return ledGroup.Device?.DetachLedGroup(ledGroup) ?? false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// ReSharper disable UnusedMemberInSuper.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using System.Collections.Generic;
|
||||
using CUE.NET.Brushes;
|
||||
using CUE.NET.Devices.Generic;
|
||||
using CUE.NET.Effects;
|
||||
|
||||
namespace CUE.NET.Groups
|
||||
{
|
||||
public interface ILedGroup : IEffectTarget<ILedGroup>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the brush which should be drawn over this group.
|
||||
/// </summary>
|
||||
IBrush Brush { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the z-index of this keygroup to allow ordering them before drawing. (lowest first) (default: 0)
|
||||
/// </summary>
|
||||
int ZIndex { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list containing all LEDs of this group.
|
||||
/// </summary>
|
||||
/// <returns>The list containing all LEDs of this group.</returns>
|
||||
IEnumerable<CorsairLed> GetLeds();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
// 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
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a ledgroup containing arbitrary LEDs.
|
||||
/// </summary>
|
||||
public class ListLedGroup : AbstractLedGroup
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
protected override ILedGroup EffectTarget => this;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list containing the LEDs of this ledgroup.
|
||||
/// </summary>
|
||||
protected IList<CorsairLed> GroupLeds { get; } = new List<CorsairLed>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ListLedGroup"/> class.
|
||||
/// </summary>
|
||||
/// <param name="device">The device this ledgroup belongs to.</param>
|
||||
/// <param name="autoAttach">Specifies whether this ledgroup should be automatically attached or not.</param>
|
||||
public ListLedGroup(ICueDevice device, bool autoAttach = true)
|
||||
: base(device, autoAttach)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ListLedGroup"/> class.
|
||||
/// </summary>
|
||||
/// <param name="device">The device this ledgroup belongs to.</param>
|
||||
/// <param name="leds">The initial LEDs of this ledgroup.</param>
|
||||
public ListLedGroup(ICueDevice device, params CorsairLed[] leds)
|
||||
: this(device, true, leds)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ListLedGroup"/> class.
|
||||
/// </summary>
|
||||
/// <param name="device">The device this ledgroup belongs to.</param>
|
||||
/// <param name="leds">The initial LEDs of this ledgroup.</param>
|
||||
public ListLedGroup(ICueDevice device, IEnumerable<CorsairLed> leds)
|
||||
: this(device, true, leds)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ListLedGroup"/> class.
|
||||
/// </summary>
|
||||
/// <param name="device">The device this ledgroup belongs to.</param>
|
||||
/// <param name="autoAttach">Specifies whether this ledgroup should be automatically attached or not.</param>
|
||||
/// <param name="leds">The initial LEDs of this ledgroup.</param>
|
||||
public ListLedGroup(ICueDevice device, bool autoAttach, IEnumerable<CorsairLed> leds)
|
||||
: base(device, autoAttach)
|
||||
{
|
||||
AddLeds(leds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ListLedGroup"/> class.
|
||||
/// </summary>
|
||||
/// <param name="device">The device this ledgroup belongs to.</param>
|
||||
/// <param name="autoAttach">Specifies whether this ledgroup should be automatically attached or not.</param>
|
||||
/// <param name="leds">The initial LEDs of this ledgroup.</param>
|
||||
public ListLedGroup(ICueDevice device, bool autoAttach, params CorsairLed[] leds)
|
||||
: base(device, autoAttach)
|
||||
{
|
||||
AddLeds(leds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ListLedGroup"/> class.
|
||||
/// </summary>
|
||||
/// <param name="device">The device this ledgroup belongs to.</param>
|
||||
/// <param name="leds">The IDs of the initial LEDs of this ledgroup.</param>
|
||||
public ListLedGroup(ICueDevice device, params CorsairLedId[] leds)
|
||||
: this(device, true, leds)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ListLedGroup"/> class.
|
||||
/// </summary>
|
||||
/// <param name="device">The device this ledgroup belongs to.</param>
|
||||
/// <param name="leds">The IDs of the initial LEDs of this ledgroup.</param>
|
||||
public ListLedGroup(ICueDevice device, IEnumerable<CorsairLedId> leds)
|
||||
: this(device, true, leds)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ListLedGroup"/> class.
|
||||
/// </summary>
|
||||
/// <param name="device">The device this ledgroup belongs to.</param>
|
||||
/// <param name="autoAttach">Specifies whether this ledgroup should be automatically attached or not.</param>
|
||||
/// <param name="leds">The IDs of the initial LEDs of this ledgroup.</param>
|
||||
public ListLedGroup(ICueDevice device, bool autoAttach, params CorsairLedId[] leds)
|
||||
: base(device, autoAttach)
|
||||
{
|
||||
AddLeds(leds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ListLedGroup"/> class.
|
||||
/// </summary>
|
||||
/// <param name="device">The device this ledgroup belongs to.</param>
|
||||
/// <param name="autoAttach">Specifies whether this ledgroup should be automatically attached or not.</param>
|
||||
/// <param name="leds">The IDs of the initial LEDs of this ledgroup.</param>
|
||||
public ListLedGroup(ICueDevice device, bool autoAttach, IEnumerable<CorsairLedId> leds)
|
||||
: base(device, autoAttach)
|
||||
{
|
||||
AddLeds(leds);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Adds the given LED(s) to the ledgroup.
|
||||
/// </summary>
|
||||
/// <param name="LEDs">The LED(s) to add.</param>
|
||||
public void AddLed(params CorsairLed[] LEDs)
|
||||
{
|
||||
AddLeds(LEDs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the given LED(s) to the ledgroup.
|
||||
/// </summary>
|
||||
/// <param name="ledIds">The ID(s) of the LED(s) to add.</param>
|
||||
public void AddLed(params CorsairLedId[] ledIds)
|
||||
{
|
||||
AddLeds(ledIds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the given LEDs to the ledgroup.
|
||||
/// </summary>
|
||||
/// <param name="leds">The LEDs to add.</param>
|
||||
public void AddLeds(IEnumerable<CorsairLed> leds)
|
||||
{
|
||||
if (leds != null)
|
||||
foreach (CorsairLed led in leds)
|
||||
if (led != null && !ContainsLed(led))
|
||||
GroupLeds.Add(led);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the given LEDs to the ledgroup.
|
||||
/// </summary>
|
||||
/// <param name="ledIds">The IDs of the LEDs to add.</param>
|
||||
public void AddLeds(IEnumerable<CorsairLedId> ledIds)
|
||||
{
|
||||
if (ledIds != null)
|
||||
foreach (CorsairLedId ledId in ledIds)
|
||||
AddLed(Device[ledId]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the given LED(s) from the ledgroup.
|
||||
/// </summary>
|
||||
/// <param name="leds">The LED(s) to remove.</param>
|
||||
public void RemoveLed(params CorsairLed[] leds)
|
||||
{
|
||||
RemoveLeds(leds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the given LED(s) from the ledgroup.
|
||||
/// </summary>
|
||||
/// <param name="ledIds">The ID(s) of the LED(s) to remove.</param>
|
||||
public void RemoveLed(params CorsairLedId[] ledIds)
|
||||
{
|
||||
RemoveLeds(ledIds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the given LEDs from the ledgroup.
|
||||
/// </summary>
|
||||
/// <param name="leds">The LEDs to remove.</param>
|
||||
public void RemoveLeds(IEnumerable<CorsairLed> leds)
|
||||
{
|
||||
if (leds != null)
|
||||
foreach (CorsairLed led in leds)
|
||||
if (led != null)
|
||||
GroupLeds.Remove(led);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the given LEDs from the ledgroup.
|
||||
/// </summary>
|
||||
/// <param name="ledIds">The IDs of the LEDs to remove.</param>
|
||||
public void RemoveLeds(IEnumerable<CorsairLedId> ledIds)
|
||||
{
|
||||
if (ledIds != null)
|
||||
foreach (CorsairLedId ledId in ledIds)
|
||||
RemoveLed(Device[ledId]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a given LED is contained by this ledgroup.
|
||||
/// </summary>
|
||||
/// <param name="led">The LED which should be checked.</param>
|
||||
/// <returns><c>true</c> if the LED is contained by this ledgroup; otherwise, <c>false</c>.</returns>
|
||||
public bool ContainsLed(CorsairLed led)
|
||||
{
|
||||
return led != null && GroupLeds.Contains(led);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a given LED is contained by this ledgroup.
|
||||
/// </summary>
|
||||
/// <param name="ledId">The ID of the LED which should be checked.</param>
|
||||
/// <returns><c>true</c> if the LED is contained by this ledgroup; otherwise, <c>false</c>.</returns>
|
||||
public bool ContainsLed(CorsairLedId ledId)
|
||||
{
|
||||
return ContainsLed(Device[ledId]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Merges the LEDs from the given ledgroup in this ledgroup.
|
||||
/// </summary>
|
||||
/// <param name="groupToMerge">The ledgroup to merge.</param>
|
||||
public void MergeLeds(ILedGroup groupToMerge)
|
||||
{
|
||||
foreach (CorsairLed led in groupToMerge.GetLeds())
|
||||
if (!GroupLeds.Contains(led))
|
||||
GroupLeds.Add(led);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list containing the LEDs from this group.
|
||||
/// </summary>
|
||||
/// <returns>The list containing the LEDs.</returns>
|
||||
public override IEnumerable<CorsairLed> GetLeds()
|
||||
{
|
||||
return GroupLeds;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using CUE.NET.Devices;
|
||||
using CUE.NET.Devices.Generic;
|
||||
using CUE.NET.Devices.Generic.Enums;
|
||||
using CUE.NET.Helper;
|
||||
|
||||
namespace CUE.NET.Groups
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a ledgroup containing LEDs which physically lay inside a rectangle.
|
||||
/// </summary>
|
||||
public class RectangleLedGroup : AbstractLedGroup
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
private IList<CorsairLed> _ledCache;
|
||||
|
||||
private RectangleF _rectangle;
|
||||
/// <summary>
|
||||
/// Gets or sets the rectangle the LEDs should be taken from.
|
||||
/// </summary>
|
||||
public RectangleF Rectangle
|
||||
{
|
||||
get { return _rectangle; }
|
||||
set
|
||||
{
|
||||
_rectangle = value;
|
||||
_ledCache = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the minimal percentage overlay a LED must have with the <see cref="Rectangle" /> to be taken into the ledgroup.
|
||||
/// </summary>
|
||||
public float MinOverlayPercentage { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RectangleLedGroup"/> class.
|
||||
/// </summary>
|
||||
/// <param name="device">The device this ledgroup belongs to.</param>
|
||||
/// <param name="fromLed">They ID of the first LED to calculate the rectangle of this ledgroup from.</param>
|
||||
/// <param name="toLed">They ID of the second LED to calculate the rectangle of this ledgroup from.</param>
|
||||
/// <param name="minOverlayPercentage">(optional) The minimal percentage overlay a LED must have with the <see cref="Rectangle" /> to be taken into the ledgroup. (default: 0.5f)</param>
|
||||
/// <param name="autoAttach">(optional) Specifies whether this group should be automatically attached or not. (default: true)</param>
|
||||
public RectangleLedGroup(ICueDevice device, CorsairLedId fromLed, CorsairLedId toLed, float minOverlayPercentage = 0.5f, bool autoAttach = true)
|
||||
: this(device, device[fromLed], device[toLed], minOverlayPercentage, autoAttach)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RectangleLedGroup"/> class.
|
||||
/// </summary>
|
||||
/// <param name="device">The device this ledgroup belongs to.</param>
|
||||
/// <param name="fromLed">They first LED to calculate the rectangle of this ledgroup from.</param>
|
||||
/// <param name="toLed">They second LED to calculate the rectangle of this ledgroup from.</param>
|
||||
/// <param name="minOverlayPercentage">(optional) The minimal percentage overlay a LED must have with the <see cref="Rectangle" /> to be taken into the ledgroup. (default: 0.5f)</param>
|
||||
/// <param name="autoAttach">(optional) Specifies whether this group should be automatically attached or not. (default: true)</param>
|
||||
public RectangleLedGroup(ICueDevice device, CorsairLed fromLed, CorsairLed toLed, float minOverlayPercentage = 0.5f, bool autoAttach = true)
|
||||
: this(device, RectangleHelper.CreateRectangleFromRectangles(fromLed.LedRectangle, toLed.LedRectangle), minOverlayPercentage, autoAttach)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RectangleLedGroup"/> class.
|
||||
/// </summary>
|
||||
/// <param name="device">The device this ledgroup belongs to.</param>
|
||||
/// <param name="fromPoint">They first point to calculate the rectangle of this ledgroup from.</param>
|
||||
/// <param name="toPoint">They second point to calculate the rectangle of this ledgroup from.</param>
|
||||
/// <param name="minOverlayPercentage">(optional) The minimal percentage overlay a LED must have with the <see cref="Rectangle" /> to be taken into the ledgroup. (default: 0.5f)</param>
|
||||
/// <param name="autoAttach">(optional) Specifies whether this group should be automatically attached or not. (default: true)</param>
|
||||
public RectangleLedGroup(ICueDevice device, PointF fromPoint, PointF toPoint, float minOverlayPercentage = 0.5f, bool autoAttach = true)
|
||||
: this(device, RectangleHelper.CreateRectangleFromPoints(fromPoint, toPoint), minOverlayPercentage, autoAttach)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RectangleLedGroup"/> class.
|
||||
/// </summary>
|
||||
/// <param name="device">The device this ledgroup belongs to.</param>
|
||||
/// <param name="rectangle">The rectangle of this ledgroup.</param>
|
||||
/// <param name="minOverlayPercentage">(optional) The minimal percentage overlay a LED must have with the <see cref="Rectangle" /> to be taken into the ledgroup. (default: 0.5f)</param>
|
||||
/// <param name="autoAttach">(optional) Specifies whether this group should be automatically attached or not. (default: true)</param>
|
||||
public RectangleLedGroup(ICueDevice device, RectangleF rectangle, float minOverlayPercentage = 0.5f, bool autoAttach = true)
|
||||
: base(device, autoAttach)
|
||||
{
|
||||
this.Rectangle = rectangle;
|
||||
this.MinOverlayPercentage = minOverlayPercentage;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public override IEnumerable<CorsairLed> GetLeds()
|
||||
{
|
||||
return _ledCache ?? (_ledCache = Device.Where(x => RectangleHelper.CalculateIntersectPercentage(x.LedRectangle, Rectangle) >= MinOverlayPercentage).ToList());
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user