diff --git a/Brushes/AbstractBrush.cs b/Brushes/AbstractBrush.cs
index ff8b34e..366b08e 100644
--- a/Brushes/AbstractBrush.cs
+++ b/Brushes/AbstractBrush.cs
@@ -1,5 +1,6 @@
// ReSharper disable VirtualMemberNeverOverriden.Global
// ReSharper disable MemberCanBePrivate.Global
+// ReSharper disable VirtualMemberNeverOverridden.Global
using System.Collections.Generic;
using System.Drawing;
diff --git a/Brushes/IBrush.cs b/Brushes/IBrush.cs
index e6a5003..559d186 100644
--- a/Brushes/IBrush.cs
+++ b/Brushes/IBrush.cs
@@ -1,4 +1,5 @@
// ReSharper disable UnusedMemberInSuper.Global
+// ReSharper disable UnusedMember.Global
using System.Collections.Generic;
using System.Drawing;
diff --git a/Brushes/ImageBrush.cs b/Brushes/ImageBrush.cs
index b1fdd39..d1fb66a 100644
--- a/Brushes/ImageBrush.cs
+++ b/Brushes/ImageBrush.cs
@@ -1,5 +1,6 @@
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedAutoPropertyAccessor.Global
+// ReSharper disable UnusedMember.Global
using System;
using System.Drawing;
diff --git a/CUE.NET.csproj b/CUE.NET.csproj
index 85ff435..d92255b 100644
--- a/CUE.NET.csproj
+++ b/CUE.NET.csproj
@@ -60,7 +60,7 @@
-
+
diff --git a/CueSDK.cs b/CueSDK.cs
index 0369cfd..95a1541 100644
--- a/CueSDK.cs
+++ b/CueSDK.cs
@@ -1,4 +1,5 @@
// ReSharper disable MemberCanBePrivate.Global
+// ReSharper disable UnusedMember.Global
using System.Collections.Generic;
using System.Runtime.InteropServices;
@@ -85,6 +86,7 @@ namespace CUE.NET
{
if (IsInitialized)
{
+ // ReSharper disable once SwitchStatementMissingSomeCases - everything else is true
switch (sdkType)
{
case CorsairDeviceType.Keyboard:
diff --git a/Devices/Generic/AbstractCueDevice.cs b/Devices/Generic/AbstractCueDevice.cs
index 34c7f2c..29410b1 100644
--- a/Devices/Generic/AbstractCueDevice.cs
+++ b/Devices/Generic/AbstractCueDevice.cs
@@ -1,5 +1,6 @@
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedMethodReturnValue.Global
+// ReSharper disable VirtualMemberNeverOverridden.Global
using System;
using System.Collections;
@@ -33,11 +34,6 @@ namespace CUE.NET.Devices.Generic
private Task _updateTask;
private DateTime _lastUpdate = DateTime.Now;
- ///
- /// Gets a list of attached ledgroups.
- ///
- protected LinkedList LedGroups { get; } = new LinkedList();
-
///
/// Gets generic information provided by CUE for the device.
///
@@ -77,6 +73,11 @@ namespace CUE.NET.Devices.Generic
///
public IEnumerable Leds => new ReadOnlyCollection(LedMapping.Values.ToList());
+ ///
+ /// Gets a list of attached ledgroups.
+ ///
+ protected LinkedList LedGroups { get; } = new LinkedList();
+
///
/// Gets or sets the background brush of the keyboard.
///
@@ -174,6 +175,11 @@ namespace CUE.NET.Devices.Generic
#region Methods
+ #region Initialize
+
+ ///
+ /// Initializes the LEDs of the device.
+ ///
protected abstract void InitializeLeds();
///
@@ -184,16 +190,26 @@ namespace CUE.NET.Devices.Generic
///
protected CorsairLed InitializeLed(CorsairLedId ledId, RectangleF ledRectangle)
{
- if (!LedMapping.ContainsKey(ledId))
- {
- CorsairLed led = new CorsairLed(ledId, ledRectangle);
- LedMapping.Add(ledId, led);
- return led;
- }
+ if (LedMapping.ContainsKey(ledId)) return null;
- return null;
+ CorsairLed led = new CorsairLed(ledId, ledRectangle);
+ LedMapping.Add(ledId, led);
+ return led;
}
+ ///
+ /// Resets all loaded LEDs back to default.
+ ///
+ internal void ResetLeds()
+ {
+ foreach (CorsairLed led in LedMapping.Values)
+ led.Reset();
+ }
+
+ #endregion
+
+ #region Update-Loop
+
///
/// Checks if automatic updates should occur and starts/stops the update-loop if needed.
///
@@ -240,6 +256,10 @@ namespace CUE.NET.Devices.Generic
}
}
+ #endregion
+
+ #region Update
+
///
/// Performs an update for all dirty keys, or all keys if flushLeds is set to true.
///
@@ -276,41 +296,6 @@ namespace CUE.NET.Devices.Generic
protected virtual void DeviceUpdate()
{ }
- ///
- /// Attaches the given ledgroup.
- ///
- /// The ledgroup to attach.
- /// true if the ledgroup could be attached; otherwise, false.
- public bool AttachLedGroup(ILedGroup ledGroup)
- {
- lock (LedGroups)
- {
- if (ledGroup == null || LedGroups.Contains(ledGroup)) return false;
-
- LedGroups.AddLast(ledGroup);
- return true;
- }
- }
-
- ///
- /// Detaches the given ledgroup.
- ///
- /// The ledgroup to detached.
- /// true if the ledgroup could be detached; otherwise, false.
- public bool DetachLedGroup(ILedGroup ledGroup)
- {
- lock (LedGroups)
- {
- if (ledGroup == null) return false;
-
- LinkedListNode node = LedGroups.Find(ledGroup);
- if (node == null) return false;
-
- LedGroups.Remove(node);
- return true;
- }
- }
-
///
/// Renders a ledgroup.
///
@@ -381,13 +366,43 @@ namespace CUE.NET.Devices.Generic
OnLedsUpdated(updateRequests);
}
+ #endregion
+
+ #region LedGroup
+
///
- /// Resets all loaded LEDs back to default.
+ /// Attaches the given ledgroup.
///
- internal void ResetLeds()
+ /// The ledgroup to attach.
+ /// true if the ledgroup could be attached; otherwise, false.
+ public bool AttachLedGroup(ILedGroup ledGroup)
{
- foreach (CorsairLed led in LedMapping.Values)
- led.Reset();
+ lock (LedGroups)
+ {
+ if (ledGroup == null || LedGroups.Contains(ledGroup)) return false;
+
+ LedGroups.AddLast(ledGroup);
+ return true;
+ }
+ }
+
+ ///
+ /// Detaches the given ledgroup.
+ ///
+ /// The ledgroup to detached.
+ /// true if the ledgroup could be detached; otherwise, false.
+ public bool DetachLedGroup(ILedGroup ledGroup)
+ {
+ lock (LedGroups)
+ {
+ if (ledGroup == null) return false;
+
+ LinkedListNode node = LedGroups.Find(ledGroup);
+ if (node == null) return false;
+
+ LedGroups.Remove(node);
+ return true;
+ }
}
///
@@ -399,32 +414,34 @@ namespace CUE.NET.Devices.Generic
return Leds;
}
+ #endregion
+
#region Effects
///
- /// 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.
///
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.");
}
///
- /// 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.
///
/// The effect to add.
public void AddEffect(IEffect 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.");
}
///
- /// 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.
///
/// The effect to remove.
public void RemoveEffect(IEffect 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
diff --git a/Devices/Generic/Enums/CorsairLedId.cs b/Devices/Generic/Enums/CorsairLedId.cs
index a19b648..9db5ac4 100644
--- a/Devices/Generic/Enums/CorsairLedId.cs
+++ b/Devices/Generic/Enums/CorsairLedId.cs
@@ -1,4 +1,6 @@
-namespace CUE.NET.Devices.Generic.Enums
+// ReSharper disable InconsistentNaming
+
+namespace CUE.NET.Devices.Generic.Enums
{
///
/// Contains list of all LEDs available for all corsair devices.
diff --git a/Devices/Generic/Enums/UpdateMode.cs b/Devices/Generic/Enums/UpdateMode.cs
index 24be91d..a5139c4 100644
--- a/Devices/Generic/Enums/UpdateMode.cs
+++ b/Devices/Generic/Enums/UpdateMode.cs
@@ -1,6 +1,4 @@
-using CUE.NET.Effects;
-
-namespace CUE.NET.Devices.Generic.Enums
+namespace CUE.NET.Devices.Generic.Enums
{
///
/// Contains list of available update modes.
@@ -8,12 +6,12 @@ namespace CUE.NET.Devices.Generic.Enums
public enum UpdateMode
{
///
- /// The device will not perform automatic updates. Updates will only occur if is called.
+ /// The device will not perform automatic updates. Updates will only occur if is called.
///
Manual,
///
- /// The device will perform automatic updates at the rate set in .
+ /// The device will perform automatic updates at the rate set in .
///
Continuous
}
diff --git a/Devices/Headset/CorsairHeadset.cs b/Devices/Headset/CorsairHeadset.cs
index 87439c5..1486125 100644
--- a/Devices/Headset/CorsairHeadset.cs
+++ b/Devices/Headset/CorsairHeadset.cs
@@ -4,7 +4,6 @@
using System.Drawing;
using CUE.NET.Devices.Generic;
-using CUE.NET.Devices.Generic.Enums;
using CUE.NET.Devices.Headset.Enums;
namespace CUE.NET.Devices.Headset
@@ -39,6 +38,9 @@ namespace CUE.NET.Devices.Headset
#region Methods
+ ///
+ /// Initializes the LEDs of the device.
+ ///
protected override void InitializeLeds()
{
InitializeLed(CorsairHeadsetLedId.LeftLogo, new RectangleF(0, 0, 1, 1));
diff --git a/Devices/Keyboard/CorsairKeyboard.cs b/Devices/Keyboard/CorsairKeyboard.cs
index 52c0367..557e142 100644
--- a/Devices/Keyboard/CorsairKeyboard.cs
+++ b/Devices/Keyboard/CorsairKeyboard.cs
@@ -4,18 +4,9 @@
// ReSharper disable UnusedMember.Global
using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
using System.Drawing;
-using System.Linq;
using System.Runtime.InteropServices;
-using CUE.NET.Brushes;
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;
namespace CUE.NET.Devices.Keyboard
@@ -50,6 +41,9 @@ namespace CUE.NET.Devices.Keyboard
#region Methods
+ ///
+ /// Initializes the LEDs of the device.
+ ///
protected override void InitializeLeds()
{
_CorsairLedPositions nativeLedPositions = (_CorsairLedPositions)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositions(), typeof(_CorsairLedPositions));
@@ -63,6 +57,7 @@ namespace CUE.NET.Devices.Keyboard
ptr = new IntPtr(ptr.ToInt64() + structSize);
}
}
+
#endregion
}
}
diff --git a/Devices/Keyboard/Enums/BrushCalculationMode.cs b/Devices/Keyboard/Enums/BrushCalculationMode.cs
index 26fec22..f8d4dd7 100644
--- a/Devices/Keyboard/Enums/BrushCalculationMode.cs
+++ b/Devices/Keyboard/Enums/BrushCalculationMode.cs
@@ -6,7 +6,7 @@
public enum BrushCalculationMode
{
///
- /// 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.
///
Relative,
///
diff --git a/Devices/Mouse/CorsairMouse.cs b/Devices/Mouse/CorsairMouse.cs
index 6049c16..7eaad8e 100644
--- a/Devices/Mouse/CorsairMouse.cs
+++ b/Devices/Mouse/CorsairMouse.cs
@@ -4,7 +4,6 @@
using System.Drawing;
using CUE.NET.Devices.Generic;
-using CUE.NET.Devices.Generic.Enums;
using CUE.NET.Devices.Mouse.Enums;
using CUE.NET.Exceptions;
@@ -40,6 +39,9 @@ namespace CUE.NET.Devices.Mouse
#region Methods
+ ///
+ /// Initializes the LEDs of the device.
+ ///
protected override void InitializeLeds()
{
switch (MouseDeviceInfo.PhysicalLayout)
diff --git a/Devices/Mousemat/CorsairMousemat.cs b/Devices/Mousemat/CorsairMousemat.cs
index 8d4c1f7..0d76ad0 100644
--- a/Devices/Mousemat/CorsairMousemat.cs
+++ b/Devices/Mousemat/CorsairMousemat.cs
@@ -3,9 +3,7 @@
// ReSharper disable UnusedMember.Global
using System;
-using System.Collections;
using System.Collections.Generic;
-using System.Collections.ObjectModel;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
@@ -46,6 +44,9 @@ namespace CUE.NET.Devices.Mousemat
#region Methods
+ ///
+ /// Initializes the LEDs of the device.
+ ///
protected override void InitializeLeds()
{
int deviceCount = _CUESDK.CorsairGetDeviceCount();
diff --git a/Effects/AbstractEffectTarget.cs b/Effects/AbstractEffectTarget.cs
index 9147ae3..d075000 100644
--- a/Effects/AbstractEffectTarget.cs
+++ b/Effects/AbstractEffectTarget.cs
@@ -14,7 +14,7 @@ namespace CUE.NET.Effects
where T : IEffectTarget
{
#region Properties & Fields
-
+
private IList _effectTimes = new List();
///
@@ -68,11 +68,10 @@ namespace CUE.NET.Effects
/// The effect to add.
public void AddEffect(IEffect effect)
{
- if (_effectTimes.All(x => x.Effect != effect))
- {
- effect.OnAttach(EffectTarget);
- _effectTimes.Add(new EffectTimeContainer(effect, -1));
- }
+ if (_effectTimes.Any(x => x.Effect == effect)) return;
+
+ effect.OnAttach(EffectTarget);
+ _effectTimes.Add(new EffectTimeContainer(effect, -1));
}
///
@@ -82,11 +81,10 @@ namespace CUE.NET.Effects
public void RemoveEffect(IEffect effect)
{
EffectTimeContainer effectTimeToRemove = _effectTimes.FirstOrDefault(x => x.Effect == effect);
- if (effectTimeToRemove != null)
- {
- effect.OnDetach(EffectTarget);
- _effectTimes.Remove(effectTimeToRemove);
- }
+ if (effectTimeToRemove == null) return;
+
+ effect.OnDetach(EffectTarget);
+ _effectTimes.Remove(effectTimeToRemove);
}
#endregion
diff --git a/Effects/AbstractKeyGroupEffect.cs b/Effects/AbstractLedGroupEffect.cs
similarity index 93%
rename from Effects/AbstractKeyGroupEffect.cs
rename to Effects/AbstractLedGroupEffect.cs
index 9831a7f..188f93e 100644
--- a/Effects/AbstractKeyGroupEffect.cs
+++ b/Effects/AbstractLedGroupEffect.cs
@@ -1,5 +1,6 @@
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedAutoPropertyAccessor.Global
+// ReSharper disable UnusedMember.Global
using CUE.NET.Groups;
@@ -8,7 +9,7 @@ namespace CUE.NET.Effects
///
/// Represents a basic effect targeting an .
///
- public abstract class AbstractKeyGroupEffect : IEffect
+ public abstract class AbstractLedGroupEffect : IEffect
{
#region Properties & Fields
diff --git a/Effects/IEffect.cs b/Effects/IEffect.cs
index eb4a663..1e12496 100644
--- a/Effects/IEffect.cs
+++ b/Effects/IEffect.cs
@@ -1,5 +1,6 @@
// ReSharper disable UnusedMember.Global
// ReSharper disable UnusedMemberInSuper.Global
+// ReSharper disable UnusedParameter.Global
namespace CUE.NET.Effects
{
diff --git a/Effects/IEffectTarget.cs b/Effects/IEffectTarget.cs
index ba08ae2..119ce46 100644
--- a/Effects/IEffectTarget.cs
+++ b/Effects/IEffectTarget.cs
@@ -1,4 +1,6 @@
-namespace CUE.NET.Effects
+// ReSharper disable UnusedMember.Global
+
+namespace CUE.NET.Effects
{
///
/// Represents a basic effect-target.
diff --git a/Groups/AbstractLedGroup.cs b/Groups/AbstractLedGroup.cs
index 6ce4091..39a867e 100644
--- a/Groups/AbstractLedGroup.cs
+++ b/Groups/AbstractLedGroup.cs
@@ -8,7 +8,7 @@ using CUE.NET.Groups.Extensions;
namespace CUE.NET.Groups
{
///
- /// Represents a basic keygroup.
+ /// Represents a basic ledgroup.
///
public abstract class AbstractLedGroup : AbstractEffectTarget, ILedGroup
{
@@ -30,7 +30,7 @@ namespace CUE.NET.Groups
public IBrush Brush { get; set; }
///
- /// 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)
///
public int ZIndex { get; set; } = 0;
diff --git a/Groups/Extensions/LedGroupExtension.cs b/Groups/Extensions/LedGroupExtension.cs
index 56c3667..d408d92 100644
--- a/Groups/Extensions/LedGroupExtension.cs
+++ b/Groups/Extensions/LedGroupExtension.cs
@@ -16,7 +16,7 @@ namespace CUE.NET.Groups.Extensions
///
/// The to convert.
/// The converted .
- public static ListLedGroup ToSimpleKeyGroup(this AbstractLedGroup ledGroup)
+ public static ListLedGroup ToSimpleLedGroup(this AbstractLedGroup ledGroup)
{
ListLedGroup simpleLedGroup = ledGroup as ListLedGroup;
if (simpleLedGroup == null)
@@ -35,7 +35,7 @@ namespace CUE.NET.Groups.Extensions
/// The new .
public static ListLedGroup Exclude(this AbstractLedGroup ledGroup, params CorsairLedId[] ledIds)
{
- ListLedGroup simpleLedGroup = ledGroup.ToSimpleKeyGroup();
+ ListLedGroup simpleLedGroup = ledGroup.ToSimpleLedGroup();
foreach (CorsairLedId ledId in ledIds)
simpleLedGroup.RemoveLed(ledId);
return simpleLedGroup;
@@ -49,7 +49,7 @@ namespace CUE.NET.Groups.Extensions
/// The new .
public static ListLedGroup Exclude(this AbstractLedGroup ledGroup, params CorsairLed[] ledIds)
{
- ListLedGroup simpleLedGroup = ledGroup.ToSimpleKeyGroup();
+ ListLedGroup simpleLedGroup = ledGroup.ToSimpleLedGroup();
foreach (CorsairLed led in ledIds)
simpleLedGroup.RemoveLed(led);
return simpleLedGroup;
diff --git a/Groups/ILedGroup.cs b/Groups/ILedGroup.cs
index 27d3528..7b483c5 100644
--- a/Groups/ILedGroup.cs
+++ b/Groups/ILedGroup.cs
@@ -16,7 +16,7 @@ namespace CUE.NET.Groups
IBrush Brush { get; set; }
///
- /// 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)
///
int ZIndex { get; set; }
diff --git a/Groups/ListLedGroup.cs b/Groups/ListLedGroup.cs
index 1160dee..03991da 100644
--- a/Groups/ListLedGroup.cs
+++ b/Groups/ListLedGroup.cs
@@ -126,10 +126,10 @@ namespace CUE.NET.Groups
///
/// Adds the given LED(s) to the ledgroup.
///
- /// The LED(s) to add.
- public void AddLed(params CorsairLed[] LEDs)
+ /// The LED(s) to add.
+ public void AddLed(params CorsairLed[] leds)
{
- AddLeds(LEDs);
+ AddLeds(leds);
}
///
@@ -147,10 +147,11 @@ namespace CUE.NET.Groups
/// The LEDs to add.
public void AddLeds(IEnumerable leds)
{
- if (leds != null)
- foreach (CorsairLed led in leds)
- if (led != null && !ContainsLed(led))
- GroupLeds.Add(led);
+ if (leds == null) return;
+
+ foreach (CorsairLed led in leds)
+ if (led != null && !ContainsLed(led))
+ GroupLeds.Add(led);
}
///
@@ -159,9 +160,10 @@ namespace CUE.NET.Groups
/// The IDs of the LEDs to add.
public void AddLeds(IEnumerable ledIds)
{
- if (ledIds != null)
- foreach (CorsairLedId ledId in ledIds)
- AddLed(Device[ledId]);
+ if (ledIds == null) return;
+
+ foreach (CorsairLedId ledId in ledIds)
+ AddLed(Device[ledId]);
}
///
@@ -188,10 +190,11 @@ namespace CUE.NET.Groups
/// The LEDs to remove.
public void RemoveLeds(IEnumerable leds)
{
- if (leds != null)
- foreach (CorsairLed led in leds)
- if (led != null)
- GroupLeds.Remove(led);
+ if (leds == null) return;
+
+ foreach (CorsairLed led in leds)
+ if (led != null)
+ GroupLeds.Remove(led);
}
///
@@ -200,9 +203,10 @@ namespace CUE.NET.Groups
/// The IDs of the LEDs to remove.
public void RemoveLeds(IEnumerable ledIds)
{
- if (ledIds != null)
- foreach (CorsairLedId ledId in ledIds)
- RemoveLed(Device[ledId]);
+ if (ledIds == null) return;
+
+ foreach (CorsairLedId ledId in ledIds)
+ RemoveLed(Device[ledId]);
}
///
diff --git a/Native/_CUESDK.cs b/Native/_CUESDK.cs
index 67c0805..12735f7 100644
--- a/Native/_CUESDK.cs
+++ b/Native/_CUESDK.cs
@@ -1,7 +1,9 @@
-using System;
+// ReSharper disable UnusedMethodReturnValue.Global
+// ReSharper disable UnusedMember.Global
+
+using System;
using System.Runtime.InteropServices;
using CUE.NET.Devices.Generic.Enums;
-using CUE.NET.Devices.Keyboard.Enums;
namespace CUE.NET.Native
{