Removed CorsairKey since it wasn't of any use anyway

This commit is contained in:
DarthAffe committed 2016-09-10 17:34:32 +02:00
1 parent 5a018d0743
commit 223c0e8886
8 files changed
+19 -153

No files matched your search

+4 -1
View File
@@ -14,7 +14,10 @@ namespace CUE.NET.Devices.Generic
public class CorsairLed
{
#region Properties & Fields
/// <summary>
/// Gets the key-ID of the Led.
/// </summary>
public CorsairLedId Id { get; set; }
/// <summary>
+2 -84
View File
@@ -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
/// <summary>
/// Represents the SDK for a corsair keyboard.
/// </summary>
public class CorsairKeyboard : AbstractCueDevice, IEnumerable<CorsairKey>
public class CorsairKeyboard : AbstractCueDevice
{
#region Properties & Fields
#region Indexer
/// <summary>
/// Gets the <see cref="CorsairKey" /> with the specified ID.
/// </summary>
/// <param name="keyId">The ID of the key to get.</param>
/// <returns>The key with the specified ID or null if no key is found.</returns>
public CorsairKey this[CorsairKeyboardKeyId keyId]
{
get
{
CorsairKey key;
return _keys.TryGetValue(keyId, out key) ? key : null;
}
}
/// <summary>
/// Gets the <see cref="CorsairKey" /> representing the given character by calling the SDK-method 'CorsairGetLedIdForKeyName'.<br />
/// Note that this currently only works for letters.
/// </summary>
/// <param name="key">The character of the key.</param>
/// <returns>The key representing the given character or null if no key is found.</returns>
public CorsairKey this[char key]
{
get
{
CorsairKeyboardKeyId keyId = _CUESDK.CorsairGetLedIdForKeyName(key);
CorsairKey cKey;
return _keys.TryGetValue(keyId, out cKey) ? cKey : null;
}
}
/// <summary>
/// Gets the <see cref="CorsairKey" /> at the given physical location.
/// </summary>
/// <param name="location">The point to get the key from.</param>
/// <returns>The key at the given point or null if no key is found.</returns>
public new CorsairKey this[PointF location] => _keys.Values.FirstOrDefault(x => x.Led.LedRectangle.Contains(location));
/// <summary>
/// Gets a list of <see cref="CorsairKey" /> inside the given rectangle.
/// </summary>
/// <param name="referenceRect">The rectangle to check.</param>
/// <param name="minOverlayPercentage">The minimal percentage overlay a key must have with the <see cref="Rectangle" /> to be taken into the list.</param>
/// <returns></returns>
public new IEnumerable<CorsairKey> this[RectangleF referenceRect, float minOverlayPercentage = 0.5f] => _keys.Values
.Where(x => RectangleHelper.CalculateIntersectPercentage(x.Led.LedRectangle, referenceRect) >= minOverlayPercentage);
#endregion
private Dictionary<CorsairKeyboardKeyId, CorsairKey> _keys = new Dictionary<CorsairKeyboardKeyId, CorsairKey>();
/// <summary>
/// Gets a read-only collection containing the keys of the keyboard.
/// </summary>
public IEnumerable<CorsairKey> Keys => new ReadOnlyCollection<CorsairKey>(_keys.Values.ToList());
/// <summary>
/// Gets specific information provided by CUE for the keyboard.
/// </summary>
@@ -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
/// <summary>
/// Returns an enumerator that iterates over all keys of the keyboard.
/// </summary>
/// <returns>An enumerator for all keys of the keyboard.</returns>
public new IEnumerator<CorsairKey> GetEnumerator()
{
return _keys.Values.GetEnumerator();
}
/// <summary>
/// Returns an enumerator that iterates over all keys of the keyboard.
/// </summary>
/// <returns>An enumerator for all keys of the keyboard.</returns>
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
#endregion
#endregion
}
}
-52
View File
@@ -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
{
/// <summary>
/// Represents a key of a corsair keyboard.
/// </summary>
public class CorsairKey
{
#region Properties & Fields
/// <summary>
/// Gets the key-ID of the key.
/// </summary>
public CorsairKeyboardKeyId KeyId { get; }
/// <summary>
/// Gets the LED of the key.
/// </summary>
public CorsairLed Led { get; }
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="CorsairKey"/> class.
/// </summary>
/// <param name="keyId">The key-ID of the key.</param>
/// <param name="led">The LED of the key.</param>
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
}
}