diff --git a/Brushes/ProfileBrush.cs b/Brushes/ProfileBrush.cs index ce0a2fb..a33af89 100644 --- a/Brushes/ProfileBrush.cs +++ b/Brushes/ProfileBrush.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Drawing; -using CUE.NET.Devices.Keyboard.Enums; -using CUE.NET.Devices.Keyboard.Keys; +using CUE.NET.Devices.Generic; +using CUE.NET.Devices.Generic.Enums; namespace CUE.NET.Brushes { @@ -17,7 +17,7 @@ namespace CUE.NET.Brushes /// protected override IBrush EffectTarget => this; - private Dictionary _keyLights; + private Dictionary _colors; #endregion @@ -27,9 +27,9 @@ namespace CUE.NET.Brushes /// Initializes a new instance of the class. /// /// The light settings of the CUE profile. - internal ProfileBrush(Dictionary keyLights) + internal ProfileBrush(Dictionary keyLights) { - this._keyLights = keyLights; + this._colors = keyLights; } #endregion @@ -44,11 +44,11 @@ namespace CUE.NET.Brushes /// The color at the specified point. protected override Color GetColorAtPoint(RectangleF rectangle, BrushRenderTarget renderTarget) { - CorsairKey key = CueSDK.KeyboardSDK[(CorsairKeyboardKeyId)renderTarget.LedId]; - if (key == null) return Color.Transparent; + CorsairLed led = CueSDK.KeyboardSDK[renderTarget.LedId]; + if (led == null) return Color.Transparent; Color color; - return !_keyLights.TryGetValue(key.KeyId, out color) ? Color.Transparent : color; + return !_colors.TryGetValue(led.Id, out color) ? Color.Transparent : color; } #endregion diff --git a/CUE.NET.csproj b/CUE.NET.csproj index 06bdcd3..ab3ba80 100644 --- a/CUE.NET.csproj +++ b/CUE.NET.csproj @@ -98,7 +98,6 @@ - diff --git a/Devices/Generic/CorsairLed.cs b/Devices/Generic/CorsairLed.cs index ea1ec22..0bfe302 100644 --- a/Devices/Generic/CorsairLed.cs +++ b/Devices/Generic/CorsairLed.cs @@ -14,7 +14,10 @@ namespace CUE.NET.Devices.Generic public class CorsairLed { #region Properties & Fields - + + /// + /// Gets the key-ID of the Led. + /// public CorsairLedId Id { get; set; } /// diff --git a/Devices/Keyboard/CorsairKeyboard.cs b/Devices/Keyboard/CorsairKeyboard.cs index a436443..52c0367 100644 --- a/Devices/Keyboard/CorsairKeyboard.cs +++ b/Devices/Keyboard/CorsairKeyboard.cs @@ -13,7 +13,6 @@ using System.Runtime.InteropServices; using CUE.NET.Brushes; using CUE.NET.Devices.Generic; using CUE.NET.Devices.Keyboard.Enums; -using CUE.NET.Devices.Keyboard.Keys; using CUE.NET.Effects; using CUE.NET.Groups; using CUE.NET.Helper; @@ -24,67 +23,10 @@ namespace CUE.NET.Devices.Keyboard /// /// Represents the SDK for a corsair keyboard. /// - public class CorsairKeyboard : AbstractCueDevice, IEnumerable + public class CorsairKeyboard : AbstractCueDevice { #region Properties & Fields - #region Indexer - - /// - /// Gets the with the specified ID. - /// - /// The ID of the key to get. - /// The key with the specified ID or null if no key is found. - public CorsairKey this[CorsairKeyboardKeyId keyId] - { - get - { - CorsairKey key; - return _keys.TryGetValue(keyId, out key) ? key : null; - } - } - - /// - /// Gets the representing the given character by calling the SDK-method 'CorsairGetLedIdForKeyName'.
- /// Note that this currently only works for letters. - ///
- /// The character of the key. - /// The key representing the given character or null if no key is found. - public CorsairKey this[char key] - { - get - { - CorsairKeyboardKeyId keyId = _CUESDK.CorsairGetLedIdForKeyName(key); - CorsairKey cKey; - return _keys.TryGetValue(keyId, out cKey) ? cKey : null; - } - } - - /// - /// Gets the at the given physical location. - /// - /// The point to get the key from. - /// The key at the given point or null if no key is found. - public new CorsairKey this[PointF location] => _keys.Values.FirstOrDefault(x => x.Led.LedRectangle.Contains(location)); - - /// - /// Gets a list of inside the given rectangle. - /// - /// The rectangle to check. - /// The minimal percentage overlay a key must have with the to be taken into the list. - /// - public new IEnumerable this[RectangleF referenceRect, float minOverlayPercentage = 0.5f] => _keys.Values - .Where(x => RectangleHelper.CalculateIntersectPercentage(x.Led.LedRectangle, referenceRect) >= minOverlayPercentage); - - #endregion - - private Dictionary _keys = new Dictionary(); - - /// - /// Gets a read-only collection containing the keys of the keyboard. - /// - public IEnumerable Keys => new ReadOnlyCollection(_keys.Values.ToList()); - /// /// Gets specific information provided by CUE for the keyboard. /// @@ -116,35 +58,11 @@ namespace CUE.NET.Devices.Keyboard for (int i = 0; i < nativeLedPositions.numberOfLed; i++) { _CorsairLedPosition ledPosition = (_CorsairLedPosition)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition)); - CorsairLed led = InitializeLed(ledPosition.ledId, new RectangleF((float)ledPosition.left, (float)ledPosition.top, (float)ledPosition.width, (float)ledPosition.height)); - _keys.Add((CorsairKeyboardKeyId)ledPosition.ledId, new CorsairKey((CorsairKeyboardKeyId)ledPosition.ledId, led)); + InitializeLed(ledPosition.ledId, new RectangleF((float)ledPosition.left, (float)ledPosition.top, (float)ledPosition.width, (float)ledPosition.height)); ptr = new IntPtr(ptr.ToInt64() + structSize); } } - - #region IEnumerable - - /// - /// Returns an enumerator that iterates over all keys of the keyboard. - /// - /// An enumerator for all keys of the keyboard. - public new IEnumerator GetEnumerator() - { - return _keys.Values.GetEnumerator(); - } - - /// - /// Returns an enumerator that iterates over all keys of the keyboard. - /// - /// An enumerator for all keys of the keyboard. - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - #endregion - #endregion } } diff --git a/Devices/Keyboard/Keys/CorsairKey.cs b/Devices/Keyboard/Keys/CorsairKey.cs deleted file mode 100644 index 34e7da4..0000000 --- a/Devices/Keyboard/Keys/CorsairKey.cs +++ /dev/null @@ -1,52 +0,0 @@ -// ReSharper disable MemberCanBePrivate.Global -// ReSharper disable UnusedAutoPropertyAccessor.Global - -using CUE.NET.Devices.Generic; -using CUE.NET.Devices.Keyboard.Enums; - -namespace CUE.NET.Devices.Keyboard.Keys -{ - /// - /// Represents a key of a corsair keyboard. - /// - public class CorsairKey - { - #region Properties & Fields - - /// - /// Gets the key-ID of the key. - /// - public CorsairKeyboardKeyId KeyId { get; } - - /// - /// Gets the LED of the key. - /// - public CorsairLed Led { get; } - - #endregion - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The key-ID of the key. - /// The LED of the key. - internal CorsairKey(CorsairKeyboardKeyId keyId, CorsairLed led) - { - this.KeyId = keyId; - this.Led = led; - } - - #endregion - - #region Operators - - public static implicit operator CorsairLed(CorsairKey key) - { - return key.Led; - } - - #endregion - } -} diff --git a/Effects/AbstractKeyGroupEffect.cs b/Effects/AbstractKeyGroupEffect.cs index e81baeb..9831a7f 100644 --- a/Effects/AbstractKeyGroupEffect.cs +++ b/Effects/AbstractKeyGroupEffect.cs @@ -1,7 +1,6 @@ // ReSharper disable MemberCanBePrivate.Global // ReSharper disable UnusedAutoPropertyAccessor.Global -using CUE.NET.Devices.Keyboard.Keys; using CUE.NET.Groups; namespace CUE.NET.Effects diff --git a/Examples/AudioAnalyzer/Example_AudioAnalyzer_full/AudioAnalyzerExample.cs b/Examples/AudioAnalyzer/Example_AudioAnalyzer_full/AudioAnalyzerExample.cs index 6d3fa65..f6c4bc2 100644 --- a/Examples/AudioAnalyzer/Example_AudioAnalyzer_full/AudioAnalyzerExample.cs +++ b/Examples/AudioAnalyzer/Example_AudioAnalyzer_full/AudioAnalyzerExample.cs @@ -5,7 +5,6 @@ using CUE.NET; using CUE.NET.Brushes; using CUE.NET.Devices.Generic.Enums; using CUE.NET.Devices.Keyboard; -using CUE.NET.Devices.Keyboard.Keys; using CUE.NET.Exceptions; using CUE.NET.Gradients; using CUE.NET.Groups; diff --git a/Profiles/CueProfileMode.cs b/Profiles/CueProfileMode.cs index 5075225..b764d73 100644 --- a/Profiles/CueProfileMode.cs +++ b/Profiles/CueProfileMode.cs @@ -4,7 +4,7 @@ using System.Drawing; using System.Linq; using System.Xml.Linq; using CUE.NET.Brushes; -using CUE.NET.Devices.Keyboard.Enums; +using CUE.NET.Devices.Generic.Enums; namespace CUE.NET.Profiles { @@ -20,7 +20,7 @@ namespace CUE.NET.Profiles ///
internal string Name { get; } - private Dictionary _keyLights; + private Dictionary _colors; #endregion @@ -32,7 +32,7 @@ namespace CUE.NET.Profiles /// The profile mode to convert. public static implicit operator ProfileBrush(CueProfileMode profile) { - return profile != null ? new ProfileBrush(profile._keyLights) : null; + return profile != null ? new ProfileBrush(profile._colors) : null; } #endregion @@ -62,7 +62,7 @@ namespace CUE.NET.Profiles return new CueProfileMode(modeRoot.Element("name").Value) { - _keyLights = modeRoot.Element("lightBackgrounds").Element("keyBgLights").Elements("lightBackground") + _colors = modeRoot.Element("lightBackgrounds").Element("keyBgLights").Elements("lightBackground") .Select(x => { string name = x.Attribute("key").Value; @@ -71,7 +71,7 @@ namespace CUE.NET.Profiles return new { - key = (CorsairKeyboardKeyId)Enum.Parse(typeof(CorsairKeyboardKeyId), name), + key = (CorsairLedId)Enum.Parse(typeof(CorsairLedId), name), color = ColorTranslator.FromHtml(x.Attribute("color").Value) }; })