1
0
mirror of https://github.com/DarthAffe/CUE.NET.git synced 2025-12-12 16:58:29 +00:00

Code cleanup

This commit is contained in:
Darth Affe 2016-09-10 18:06:07 +02:00
parent f8c537aaff
commit 8390c7da68
22 changed files with 146 additions and 116 deletions

View File

@ -1,5 +1,6 @@
// ReSharper disable VirtualMemberNeverOverriden.Global // ReSharper disable VirtualMemberNeverOverriden.Global
// ReSharper disable MemberCanBePrivate.Global // ReSharper disable MemberCanBePrivate.Global
// ReSharper disable VirtualMemberNeverOverridden.Global
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;

View File

@ -1,4 +1,5 @@
// ReSharper disable UnusedMemberInSuper.Global // ReSharper disable UnusedMemberInSuper.Global
// ReSharper disable UnusedMember.Global
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;

View File

@ -1,5 +1,6 @@
// ReSharper disable MemberCanBePrivate.Global // ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedAutoPropertyAccessor.Global // ReSharper disable UnusedAutoPropertyAccessor.Global
// ReSharper disable UnusedMember.Global
using System; using System;
using System.Drawing; using System.Drawing;

View File

@ -60,7 +60,7 @@
<Compile Include="Devices\Generic\EventArgs\UpdatingEventArgs.cs" /> <Compile Include="Devices\Generic\EventArgs\UpdatingEventArgs.cs" />
<Compile Include="Devices\Generic\LedUpateRequest.cs" /> <Compile Include="Devices\Generic\LedUpateRequest.cs" />
<Compile Include="Devices\Keyboard\Enums\BrushCalculationMode.cs" /> <Compile Include="Devices\Keyboard\Enums\BrushCalculationMode.cs" />
<Compile Include="Effects\AbstractKeyGroupEffect.cs" /> <Compile Include="Effects\AbstractLedGroupEffect.cs" />
<Compile Include="Effects\AbstractBrushEffect.cs" /> <Compile Include="Effects\AbstractBrushEffect.cs" />
<Compile Include="Effects\AbstractEffectTarget.cs" /> <Compile Include="Effects\AbstractEffectTarget.cs" />
<Compile Include="Effects\IEffectTarget.cs" /> <Compile Include="Effects\IEffectTarget.cs" />

View File

@ -1,4 +1,5 @@
// ReSharper disable MemberCanBePrivate.Global // ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedMember.Global
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@ -85,6 +86,7 @@ namespace CUE.NET
{ {
if (IsInitialized) if (IsInitialized)
{ {
// ReSharper disable once SwitchStatementMissingSomeCases - everything else is true
switch (sdkType) switch (sdkType)
{ {
case CorsairDeviceType.Keyboard: case CorsairDeviceType.Keyboard:

View File

@ -1,5 +1,6 @@
// ReSharper disable MemberCanBePrivate.Global // ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedMethodReturnValue.Global // ReSharper disable UnusedMethodReturnValue.Global
// ReSharper disable VirtualMemberNeverOverridden.Global
using System; using System;
using System.Collections; using System.Collections;
@ -33,11 +34,6 @@ namespace CUE.NET.Devices.Generic
private Task _updateTask; private Task _updateTask;
private DateTime _lastUpdate = DateTime.Now; private DateTime _lastUpdate = DateTime.Now;
/// <summary>
/// Gets a list of attached ledgroups.
/// </summary>
protected LinkedList<ILedGroup> LedGroups { get; } = new LinkedList<ILedGroup>();
/// <summary> /// <summary>
/// Gets generic information provided by CUE for the device. /// Gets generic information provided by CUE for the device.
/// </summary> /// </summary>
@ -77,6 +73,11 @@ namespace CUE.NET.Devices.Generic
/// </summary> /// </summary>
public IEnumerable<CorsairLed> Leds => new ReadOnlyCollection<CorsairLed>(LedMapping.Values.ToList()); public IEnumerable<CorsairLed> Leds => new ReadOnlyCollection<CorsairLed>(LedMapping.Values.ToList());
/// <summary>
/// Gets a list of attached ledgroups.
/// </summary>
protected LinkedList<ILedGroup> LedGroups { get; } = new LinkedList<ILedGroup>();
/// <summary> /// <summary>
/// Gets or sets the background brush of the keyboard. /// Gets or sets the background brush of the keyboard.
/// </summary> /// </summary>
@ -174,6 +175,11 @@ namespace CUE.NET.Devices.Generic
#region Methods #region Methods
#region Initialize
/// <summary>
/// Initializes the LEDs of the device.
/// </summary>
protected abstract void InitializeLeds(); protected abstract void InitializeLeds();
/// <summary> /// <summary>
@ -184,16 +190,26 @@ namespace CUE.NET.Devices.Generic
/// <returns></returns> /// <returns></returns>
protected CorsairLed InitializeLed(CorsairLedId ledId, RectangleF ledRectangle) protected CorsairLed InitializeLed(CorsairLedId ledId, RectangleF ledRectangle)
{ {
if (!LedMapping.ContainsKey(ledId)) if (LedMapping.ContainsKey(ledId)) return null;
{
CorsairLed led = new CorsairLed(ledId, ledRectangle);
LedMapping.Add(ledId, led);
return led;
}
return null; CorsairLed led = new CorsairLed(ledId, ledRectangle);
LedMapping.Add(ledId, led);
return led;
} }
/// <summary>
/// Resets all loaded LEDs back to default.
/// </summary>
internal void ResetLeds()
{
foreach (CorsairLed led in LedMapping.Values)
led.Reset();
}
#endregion
#region Update-Loop
/// <summary> /// <summary>
/// Checks if automatic updates should occur and starts/stops the update-loop if needed. /// Checks if automatic updates should occur and starts/stops the update-loop if needed.
/// </summary> /// </summary>
@ -240,6 +256,10 @@ namespace CUE.NET.Devices.Generic
} }
} }
#endregion
#region Update
/// <summary> /// <summary>
/// Performs an update for all dirty keys, or all keys if flushLeds is set to true. /// Performs an update for all dirty keys, or all keys if flushLeds is set to true.
/// </summary> /// </summary>
@ -276,41 +296,6 @@ namespace CUE.NET.Devices.Generic
protected virtual void DeviceUpdate() protected virtual void DeviceUpdate()
{ } { }
/// <summary>
/// Attaches the given ledgroup.
/// </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 bool AttachLedGroup(ILedGroup ledGroup)
{
lock (LedGroups)
{
if (ledGroup == null || LedGroups.Contains(ledGroup)) return false;
LedGroups.AddLast(ledGroup);
return true;
}
}
/// <summary>
/// Detaches the given ledgroup.
/// </summary>
/// <param name="ledGroup">The ledgroup to detached.</param>
/// <returns><c>true</c> if the ledgroup could be detached; otherwise, <c>false</c>.</returns>
public bool DetachLedGroup(ILedGroup ledGroup)
{
lock (LedGroups)
{
if (ledGroup == null) return false;
LinkedListNode<ILedGroup> node = LedGroups.Find(ledGroup);
if (node == null) return false;
LedGroups.Remove(node);
return true;
}
}
/// <summary> /// <summary>
/// Renders a ledgroup. /// Renders a ledgroup.
/// </summary> /// </summary>
@ -381,13 +366,43 @@ namespace CUE.NET.Devices.Generic
OnLedsUpdated(updateRequests); OnLedsUpdated(updateRequests);
} }
#endregion
#region LedGroup
/// <summary> /// <summary>
/// Resets all loaded LEDs back to default. /// Attaches the given ledgroup.
/// </summary> /// </summary>
internal void ResetLeds() /// <param name="ledGroup">The ledgroup to attach.</param>
/// <returns><c>true</c> if the ledgroup could be attached; otherwise, <c>false</c>.</returns>
public bool AttachLedGroup(ILedGroup ledGroup)
{ {
foreach (CorsairLed led in LedMapping.Values) lock (LedGroups)
led.Reset(); {
if (ledGroup == null || LedGroups.Contains(ledGroup)) return false;
LedGroups.AddLast(ledGroup);
return true;
}
}
/// <summary>
/// Detaches the given ledgroup.
/// </summary>
/// <param name="ledGroup">The ledgroup to detached.</param>
/// <returns><c>true</c> if the ledgroup could be detached; otherwise, <c>false</c>.</returns>
public bool DetachLedGroup(ILedGroup ledGroup)
{
lock (LedGroups)
{
if (ledGroup == null) return false;
LinkedListNode<ILedGroup> node = LedGroups.Find(ledGroup);
if (node == null) return false;
LedGroups.Remove(node);
return true;
}
} }
/// <summary> /// <summary>
@ -399,32 +414,34 @@ namespace CUE.NET.Devices.Generic
return Leds; return Leds;
} }
#endregion
#region Effects #region Effects
/// <summary> /// <summary>
/// NOT IMPLEMENTED: Effects can't be applied directly to the device. Add it to the Brush or create a keygroup instead. /// NOT IMPLEMENTED: Effects can't be applied directly to the device. Add it to the Brush or create a ledgroup instead.
/// </summary> /// </summary>
public void UpdateEffects() public void UpdateEffects()
{ {
throw new NotSupportedException("Effects can't be applied directly to the device. Add it to the Brush or create a keygroup instead."); throw new NotSupportedException("Effects can't be applied directly to the device. Add it to the Brush or create a ledgroup instead.");
} }
/// <summary> /// <summary>
/// NOT IMPLEMENTED: Effects can't be applied directly to the device. Add it to the Brush or create a keygroup instead. /// NOT IMPLEMENTED: Effects can't be applied directly to the device. Add it to the Brush or create a ledgroup instead.
/// </summary> /// </summary>
/// <param name="effect">The effect to add.</param> /// <param name="effect">The effect to add.</param>
public void AddEffect(IEffect<ILedGroup> effect) public void AddEffect(IEffect<ILedGroup> effect)
{ {
throw new NotSupportedException("Effects can't be applied directly to the device. Add it to the Brush or create a keygroup instead."); throw new NotSupportedException("Effects can't be applied directly to the device. Add it to the Brush or create a ledgroup instead.");
} }
/// <summary> /// <summary>
/// NOT IMPLEMENTED: Effects can't be applied directly to the device. Add it to the Brush or create a keygroup instead. /// NOT IMPLEMENTED: Effects can't be applied directly to the device. Add it to the Brush or create a ledgroup instead.
/// </summary> /// </summary>
/// <param name="effect">The effect to remove.</param> /// <param name="effect">The effect to remove.</param>
public void RemoveEffect(IEffect<ILedGroup> effect) public void RemoveEffect(IEffect<ILedGroup> effect)
{ {
throw new NotSupportedException("Effects can't be applied directly to the device. Add it to the Brush or create a keygroup instead."); throw new NotSupportedException("Effects can't be applied directly to the device. Add it to the Brush or create a ledgroup instead.");
} }
#endregion #endregion

View File

@ -1,4 +1,6 @@
namespace CUE.NET.Devices.Generic.Enums // ReSharper disable InconsistentNaming
namespace CUE.NET.Devices.Generic.Enums
{ {
/// <summary> /// <summary>
/// Contains list of all LEDs available for all corsair devices. /// Contains list of all LEDs available for all corsair devices.

View File

@ -1,6 +1,4 @@
using CUE.NET.Effects; namespace CUE.NET.Devices.Generic.Enums
namespace CUE.NET.Devices.Generic.Enums
{ {
/// <summary> /// <summary>
/// Contains list of available update modes. /// Contains list of available update modes.
@ -8,12 +6,12 @@ namespace CUE.NET.Devices.Generic.Enums
public enum UpdateMode public enum UpdateMode
{ {
/// <summary> /// <summary>
/// The device will not perform automatic updates. Updates will only occur if <see cref="CUE.NET.Devices.ICueDevice.Update" /> is called. /// The device will not perform automatic updates. Updates will only occur if <see cref="ICueDevice.Update" /> is called.
/// </summary> /// </summary>
Manual, Manual,
/// <summary> /// <summary>
/// The device will perform automatic updates at the rate set in <see cref="CUE.NET.Devices.ICueDevice.UpdateFrequency" />. /// The device will perform automatic updates at the rate set in <see cref="ICueDevice.UpdateFrequency" />.
/// </summary> /// </summary>
Continuous Continuous
} }

View File

@ -4,7 +4,6 @@
using System.Drawing; using System.Drawing;
using CUE.NET.Devices.Generic; using CUE.NET.Devices.Generic;
using CUE.NET.Devices.Generic.Enums;
using CUE.NET.Devices.Headset.Enums; using CUE.NET.Devices.Headset.Enums;
namespace CUE.NET.Devices.Headset namespace CUE.NET.Devices.Headset
@ -39,6 +38,9 @@ namespace CUE.NET.Devices.Headset
#region Methods #region Methods
/// <summary>
/// Initializes the LEDs of the device.
/// </summary>
protected override void InitializeLeds() protected override void InitializeLeds()
{ {
InitializeLed(CorsairHeadsetLedId.LeftLogo, new RectangleF(0, 0, 1, 1)); InitializeLed(CorsairHeadsetLedId.LeftLogo, new RectangleF(0, 0, 1, 1));

View File

@ -4,18 +4,9 @@
// ReSharper disable UnusedMember.Global // ReSharper disable UnusedMember.Global
using System; using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing; using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using CUE.NET.Brushes;
using CUE.NET.Devices.Generic; using CUE.NET.Devices.Generic;
using CUE.NET.Devices.Keyboard.Enums;
using CUE.NET.Effects;
using CUE.NET.Groups;
using CUE.NET.Helper;
using CUE.NET.Native; using CUE.NET.Native;
namespace CUE.NET.Devices.Keyboard namespace CUE.NET.Devices.Keyboard
@ -50,6 +41,9 @@ namespace CUE.NET.Devices.Keyboard
#region Methods #region Methods
/// <summary>
/// Initializes the LEDs of the device.
/// </summary>
protected override void InitializeLeds() protected override void InitializeLeds()
{ {
_CorsairLedPositions nativeLedPositions = (_CorsairLedPositions)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositions(), typeof(_CorsairLedPositions)); _CorsairLedPositions nativeLedPositions = (_CorsairLedPositions)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositions(), typeof(_CorsairLedPositions));
@ -63,6 +57,7 @@ namespace CUE.NET.Devices.Keyboard
ptr = new IntPtr(ptr.ToInt64() + structSize); ptr = new IntPtr(ptr.ToInt64() + structSize);
} }
} }
#endregion #endregion
} }
} }

View File

@ -6,7 +6,7 @@
public enum BrushCalculationMode public enum BrushCalculationMode
{ {
/// <summary> /// <summary>
/// The calculation rectangle for brushes will be the rectangle around the keygroup the brush is applied to. /// The calculation rectangle for brushes will be the rectangle around the ledgroup the brush is applied to.
/// </summary> /// </summary>
Relative, Relative,
/// <summary> /// <summary>

View File

@ -4,7 +4,6 @@
using System.Drawing; using System.Drawing;
using CUE.NET.Devices.Generic; using CUE.NET.Devices.Generic;
using CUE.NET.Devices.Generic.Enums;
using CUE.NET.Devices.Mouse.Enums; using CUE.NET.Devices.Mouse.Enums;
using CUE.NET.Exceptions; using CUE.NET.Exceptions;
@ -40,6 +39,9 @@ namespace CUE.NET.Devices.Mouse
#region Methods #region Methods
/// <summary>
/// Initializes the LEDs of the device.
/// </summary>
protected override void InitializeLeds() protected override void InitializeLeds()
{ {
switch (MouseDeviceInfo.PhysicalLayout) switch (MouseDeviceInfo.PhysicalLayout)

View File

@ -3,9 +3,7 @@
// ReSharper disable UnusedMember.Global // ReSharper disable UnusedMember.Global
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@ -46,6 +44,9 @@ namespace CUE.NET.Devices.Mousemat
#region Methods #region Methods
/// <summary>
/// Initializes the LEDs of the device.
/// </summary>
protected override void InitializeLeds() protected override void InitializeLeds()
{ {
int deviceCount = _CUESDK.CorsairGetDeviceCount(); int deviceCount = _CUESDK.CorsairGetDeviceCount();

View File

@ -14,7 +14,7 @@ namespace CUE.NET.Effects
where T : IEffectTarget<T> where T : IEffectTarget<T>
{ {
#region Properties & Fields #region Properties & Fields
private IList<EffectTimeContainer> _effectTimes = new List<EffectTimeContainer>(); private IList<EffectTimeContainer> _effectTimes = new List<EffectTimeContainer>();
/// <summary> /// <summary>
@ -68,11 +68,10 @@ namespace CUE.NET.Effects
/// <param name="effect">The effect to add.</param> /// <param name="effect">The effect to add.</param>
public void AddEffect(IEffect<T> effect) public void AddEffect(IEffect<T> effect)
{ {
if (_effectTimes.All(x => x.Effect != effect)) if (_effectTimes.Any(x => x.Effect == effect)) return;
{
effect.OnAttach(EffectTarget); effect.OnAttach(EffectTarget);
_effectTimes.Add(new EffectTimeContainer(effect, -1)); _effectTimes.Add(new EffectTimeContainer(effect, -1));
}
} }
/// <summary> /// <summary>
@ -82,11 +81,10 @@ namespace CUE.NET.Effects
public void RemoveEffect(IEffect<T> effect) public void RemoveEffect(IEffect<T> effect)
{ {
EffectTimeContainer effectTimeToRemove = _effectTimes.FirstOrDefault(x => x.Effect == effect); EffectTimeContainer effectTimeToRemove = _effectTimes.FirstOrDefault(x => x.Effect == effect);
if (effectTimeToRemove != null) if (effectTimeToRemove == null) return;
{
effect.OnDetach(EffectTarget); effect.OnDetach(EffectTarget);
_effectTimes.Remove(effectTimeToRemove); _effectTimes.Remove(effectTimeToRemove);
}
} }
#endregion #endregion

View File

@ -1,5 +1,6 @@
// ReSharper disable MemberCanBePrivate.Global // ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedAutoPropertyAccessor.Global // ReSharper disable UnusedAutoPropertyAccessor.Global
// ReSharper disable UnusedMember.Global
using CUE.NET.Groups; using CUE.NET.Groups;
@ -8,7 +9,7 @@ namespace CUE.NET.Effects
/// <summary> /// <summary>
/// Represents a basic effect targeting an <see cref="ILedGroup"/>. /// Represents a basic effect targeting an <see cref="ILedGroup"/>.
/// </summary> /// </summary>
public abstract class AbstractKeyGroupEffect : IEffect<ILedGroup> public abstract class AbstractLedGroupEffect : IEffect<ILedGroup>
{ {
#region Properties & Fields #region Properties & Fields

View File

@ -1,5 +1,6 @@
// ReSharper disable UnusedMember.Global // ReSharper disable UnusedMember.Global
// ReSharper disable UnusedMemberInSuper.Global // ReSharper disable UnusedMemberInSuper.Global
// ReSharper disable UnusedParameter.Global
namespace CUE.NET.Effects namespace CUE.NET.Effects
{ {

View File

@ -1,4 +1,6 @@
namespace CUE.NET.Effects // ReSharper disable UnusedMember.Global
namespace CUE.NET.Effects
{ {
/// <summary> /// <summary>
/// Represents a basic effect-target. /// Represents a basic effect-target.

View File

@ -8,7 +8,7 @@ using CUE.NET.Groups.Extensions;
namespace CUE.NET.Groups namespace CUE.NET.Groups
{ {
/// <summary> /// <summary>
/// Represents a basic keygroup. /// Represents a basic ledgroup.
/// </summary> /// </summary>
public abstract class AbstractLedGroup : AbstractEffectTarget<ILedGroup>, ILedGroup public abstract class AbstractLedGroup : AbstractEffectTarget<ILedGroup>, ILedGroup
{ {
@ -30,7 +30,7 @@ namespace CUE.NET.Groups
public IBrush Brush { get; set; } public IBrush Brush { get; set; }
/// <summary> /// <summary>
/// Gets or sets the z-index of this keygroup to allow ordering them before drawing. (lowest first) (default: 0) /// Gets or sets the z-index of this ledgroup to allow ordering them before drawing. (lowest first) (default: 0)
/// </summary> /// </summary>
public int ZIndex { get; set; } = 0; public int ZIndex { get; set; } = 0;

View File

@ -16,7 +16,7 @@ namespace CUE.NET.Groups.Extensions
/// </summary> /// </summary>
/// <param name="ledGroup">The <see cref="AbstractLedGroup" /> to convert.</param> /// <param name="ledGroup">The <see cref="AbstractLedGroup" /> to convert.</param>
/// <returns>The converted <see cref="ListLedGroup" />.</returns> /// <returns>The converted <see cref="ListLedGroup" />.</returns>
public static ListLedGroup ToSimpleKeyGroup(this AbstractLedGroup ledGroup) public static ListLedGroup ToSimpleLedGroup(this AbstractLedGroup ledGroup)
{ {
ListLedGroup simpleLedGroup = ledGroup as ListLedGroup; ListLedGroup simpleLedGroup = ledGroup as ListLedGroup;
if (simpleLedGroup == null) if (simpleLedGroup == null)
@ -35,7 +35,7 @@ namespace CUE.NET.Groups.Extensions
/// <returns>The new <see cref="ListLedGroup" />.</returns> /// <returns>The new <see cref="ListLedGroup" />.</returns>
public static ListLedGroup Exclude(this AbstractLedGroup ledGroup, params CorsairLedId[] ledIds) public static ListLedGroup Exclude(this AbstractLedGroup ledGroup, params CorsairLedId[] ledIds)
{ {
ListLedGroup simpleLedGroup = ledGroup.ToSimpleKeyGroup(); ListLedGroup simpleLedGroup = ledGroup.ToSimpleLedGroup();
foreach (CorsairLedId ledId in ledIds) foreach (CorsairLedId ledId in ledIds)
simpleLedGroup.RemoveLed(ledId); simpleLedGroup.RemoveLed(ledId);
return simpleLedGroup; return simpleLedGroup;
@ -49,7 +49,7 @@ namespace CUE.NET.Groups.Extensions
/// <returns>The new <see cref="ListLedGroup" />.</returns> /// <returns>The new <see cref="ListLedGroup" />.</returns>
public static ListLedGroup Exclude(this AbstractLedGroup ledGroup, params CorsairLed[] ledIds) public static ListLedGroup Exclude(this AbstractLedGroup ledGroup, params CorsairLed[] ledIds)
{ {
ListLedGroup simpleLedGroup = ledGroup.ToSimpleKeyGroup(); ListLedGroup simpleLedGroup = ledGroup.ToSimpleLedGroup();
foreach (CorsairLed led in ledIds) foreach (CorsairLed led in ledIds)
simpleLedGroup.RemoveLed(led); simpleLedGroup.RemoveLed(led);
return simpleLedGroup; return simpleLedGroup;

View File

@ -16,7 +16,7 @@ namespace CUE.NET.Groups
IBrush Brush { get; set; } IBrush Brush { get; set; }
/// <summary> /// <summary>
/// Gets or sets the z-index of this keygroup to allow ordering them before drawing. (lowest first) (default: 0) /// Gets or sets the z-index of this ledgroup to allow ordering them before drawing. (lowest first) (default: 0)
/// </summary> /// </summary>
int ZIndex { get; set; } int ZIndex { get; set; }

View File

@ -126,10 +126,10 @@ namespace CUE.NET.Groups
/// <summary> /// <summary>
/// Adds the given LED(s) to the ledgroup. /// Adds the given LED(s) to the ledgroup.
/// </summary> /// </summary>
/// <param name="LEDs">The LED(s) to add.</param> /// <param name="leds">The LED(s) to add.</param>
public void AddLed(params CorsairLed[] LEDs) public void AddLed(params CorsairLed[] leds)
{ {
AddLeds(LEDs); AddLeds(leds);
} }
/// <summary> /// <summary>
@ -147,10 +147,11 @@ namespace CUE.NET.Groups
/// <param name="leds">The LEDs to add.</param> /// <param name="leds">The LEDs to add.</param>
public void AddLeds(IEnumerable<CorsairLed> leds) public void AddLeds(IEnumerable<CorsairLed> leds)
{ {
if (leds != null) if (leds == null) return;
foreach (CorsairLed led in leds)
if (led != null && !ContainsLed(led)) foreach (CorsairLed led in leds)
GroupLeds.Add(led); if (led != null && !ContainsLed(led))
GroupLeds.Add(led);
} }
/// <summary> /// <summary>
@ -159,9 +160,10 @@ namespace CUE.NET.Groups
/// <param name="ledIds">The IDs of the LEDs to add.</param> /// <param name="ledIds">The IDs of the LEDs to add.</param>
public void AddLeds(IEnumerable<CorsairLedId> ledIds) public void AddLeds(IEnumerable<CorsairLedId> ledIds)
{ {
if (ledIds != null) if (ledIds == null) return;
foreach (CorsairLedId ledId in ledIds)
AddLed(Device[ledId]); foreach (CorsairLedId ledId in ledIds)
AddLed(Device[ledId]);
} }
/// <summary> /// <summary>
@ -188,10 +190,11 @@ namespace CUE.NET.Groups
/// <param name="leds">The LEDs to remove.</param> /// <param name="leds">The LEDs to remove.</param>
public void RemoveLeds(IEnumerable<CorsairLed> leds) public void RemoveLeds(IEnumerable<CorsairLed> leds)
{ {
if (leds != null) if (leds == null) return;
foreach (CorsairLed led in leds)
if (led != null) foreach (CorsairLed led in leds)
GroupLeds.Remove(led); if (led != null)
GroupLeds.Remove(led);
} }
/// <summary> /// <summary>
@ -200,9 +203,10 @@ namespace CUE.NET.Groups
/// <param name="ledIds">The IDs of the LEDs to remove.</param> /// <param name="ledIds">The IDs of the LEDs to remove.</param>
public void RemoveLeds(IEnumerable<CorsairLedId> ledIds) public void RemoveLeds(IEnumerable<CorsairLedId> ledIds)
{ {
if (ledIds != null) if (ledIds == null) return;
foreach (CorsairLedId ledId in ledIds)
RemoveLed(Device[ledId]); foreach (CorsairLedId ledId in ledIds)
RemoveLed(Device[ledId]);
} }
/// <summary> /// <summary>

View File

@ -1,7 +1,9 @@
using System; // ReSharper disable UnusedMethodReturnValue.Global
// ReSharper disable UnusedMember.Global
using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using CUE.NET.Devices.Generic.Enums; using CUE.NET.Devices.Generic.Enums;
using CUE.NET.Devices.Keyboard.Enums;
namespace CUE.NET.Native namespace CUE.NET.Native
{ {