mirror of
https://github.com/DarthAffe/CUE.NET.git
synced 2026-11-11 13:06:24 +00:00
Added even more xml-comments
This commit is contained in:
1 parent
6de1087c1f
commit
5fc7abc9db
30 files changed
+639
-17
No files matched your search
@@ -5,22 +5,42 @@ using CUE.NET.Devices.Keyboard.Extensions;
|
||||
|
||||
namespace CUE.NET.Devices.Keyboard.Keys
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a basic keygroup.
|
||||
/// </summary>
|
||||
public abstract class BaseKeyGroup : IKeyGroup
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets the keyboard this keygroup belongs to.
|
||||
/// </summary>
|
||||
internal CorsairKeyboard Keyboard { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a read-only collection containing the keys from this group.
|
||||
/// </summary>
|
||||
public IEnumerable<CorsairKey> Keys => new ReadOnlyCollection<CorsairKey>(GetGroupKeys());
|
||||
|
||||
/// <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="BaseKeyGroup"/> class.
|
||||
/// </summary>
|
||||
/// <param name="keyboard">The keyboard this keygroup belongs to.</param>
|
||||
/// <param name="autoAttach">Specifies whether this group should be automatically attached or not.</param>
|
||||
protected BaseKeyGroup(CorsairKeyboard keyboard, bool autoAttach = true)
|
||||
{
|
||||
this.Keyboard = keyboard;
|
||||
@@ -29,6 +49,10 @@ namespace CUE.NET.Devices.Keyboard.Keys
|
||||
this.Attach();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list containing the keys from this group.
|
||||
/// </summary>
|
||||
/// <returns>The list containing the keys.</returns>
|
||||
protected abstract IList<CorsairKey> GetGroupKeys();
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -7,18 +7,38 @@ 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; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a rectangle representing the physical location of the key.
|
||||
/// </summary>
|
||||
public RectangleF KeyRectangle { 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>
|
||||
/// <param name="keyRectangle">The rectangle representing the physical location of the key.</param>
|
||||
internal CorsairKey(CorsairKeyboardKeyId keyId, CorsairLed led, RectangleF keyRectangle)
|
||||
{
|
||||
this.KeyId = keyId;
|
||||
@@ -27,9 +47,5 @@ namespace CUE.NET.Devices.Keyboard.Keys
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,19 @@ namespace CUE.NET.Devices.Keyboard.Keys
|
||||
{
|
||||
public interface IKeyGroup
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a read-only collection containing the keys from this group.
|
||||
/// </summary>
|
||||
IEnumerable<CorsairKey> Keys { get; }
|
||||
|
||||
/// <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; }
|
||||
}
|
||||
}
|
||||
@@ -5,34 +5,67 @@ using CUE.NET.Devices.Keyboard.Enums;
|
||||
|
||||
namespace CUE.NET.Devices.Keyboard.Keys
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a keygroup containing arbitrary keys.
|
||||
/// </summary>
|
||||
public class ListKeyGroup : BaseKeyGroup
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list containing the keys of this keygroup.
|
||||
/// </summary>
|
||||
protected IList<CorsairKey> GroupKeys { get; } = new List<CorsairKey>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ListKeyGroup"/> class.
|
||||
/// </summary>
|
||||
/// <param name="keyboard">The keyboard this keygroup belongs to.</param>
|
||||
/// <param name="autoAttach">Specifies whether this keygroup should be automatically attached or not.</param>
|
||||
public ListKeyGroup(CorsairKeyboard keyboard, bool autoAttach = true)
|
||||
: base(keyboard, autoAttach)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ListKeyGroup"/> class.
|
||||
/// </summary>
|
||||
/// <param name="keyboard">The keyboard this keygroup belongs to.</param>
|
||||
/// <param name="keys">The initial keys of this keygroup.</param>
|
||||
public ListKeyGroup(CorsairKeyboard keyboard, params CorsairKey[] keys)
|
||||
: this(keyboard, true, keys)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ListKeyGroup"/> class.
|
||||
/// </summary>
|
||||
/// <param name="keyboard">The keyboard this keygroup belongs to.</param>
|
||||
/// <param name="autoAttach">Specifies whether this keygroup should be automatically attached or not.</param>
|
||||
/// <param name="keys">The initial keys of this keygroup.</param>
|
||||
public ListKeyGroup(CorsairKeyboard keyboard, bool autoAttach, params CorsairKey[] keys)
|
||||
: base(keyboard, autoAttach)
|
||||
{
|
||||
AddKey(keys);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ListKeyGroup"/> class.
|
||||
/// </summary>
|
||||
/// <param name="keyboard">The keyboard this keygroup belongs to.</param>
|
||||
/// <param name="keys">The IDs of the initial keys of this keygroup.</param>
|
||||
public ListKeyGroup(CorsairKeyboard keyboard, params CorsairKeyboardKeyId[] keys)
|
||||
: this(keyboard, true, keys)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ListKeyGroup"/> class.
|
||||
/// </summary>
|
||||
/// <param name="keyboard">The keyboard this keygroup belongs to.</param>
|
||||
/// <param name="autoAttach">Specifies whether this keygroup should be automatically attached or not.</param>
|
||||
/// <param name="keys">The IDs of the initial keys of this keygroup.</param>
|
||||
public ListKeyGroup(CorsairKeyboard keyboard, bool autoAttach, params CorsairKeyboardKeyId[] keys)
|
||||
: base(keyboard, autoAttach)
|
||||
{
|
||||
@@ -43,6 +76,10 @@ namespace CUE.NET.Devices.Keyboard.Keys
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Adds the given key(s) to the keygroup.
|
||||
/// </summary>
|
||||
/// <param name="keys">The key(s) to add.</param>
|
||||
public void AddKey(params CorsairKey[] keys)
|
||||
{
|
||||
if (keys != null)
|
||||
@@ -52,6 +89,10 @@ namespace CUE.NET.Devices.Keyboard.Keys
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the given key(s) to the keygroup.
|
||||
/// </summary>
|
||||
/// <param name="keyIds">The ID(s) of the key(s) to add.</param>
|
||||
public void AddKey(params CorsairKeyboardKeyId[] keyIds)
|
||||
{
|
||||
if (keyIds != null)
|
||||
@@ -59,6 +100,10 @@ namespace CUE.NET.Devices.Keyboard.Keys
|
||||
AddKey(Keyboard[keyId]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the given key(s) from the keygroup.
|
||||
/// </summary>
|
||||
/// <param name="keys">The key(s) to remove.</param>
|
||||
public void RemoveKey(params CorsairKey[] keys)
|
||||
{
|
||||
if (keys != null)
|
||||
@@ -67,6 +112,10 @@ namespace CUE.NET.Devices.Keyboard.Keys
|
||||
GroupKeys.Remove(key);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the given key(s) from the keygroup.
|
||||
/// </summary>
|
||||
/// <param name="keyIds">The ID(s) of the key(s) to remove.</param>
|
||||
public void RemoveKey(params CorsairKeyboardKeyId[] keyIds)
|
||||
{
|
||||
if (keyIds != null)
|
||||
@@ -74,16 +123,30 @@ namespace CUE.NET.Devices.Keyboard.Keys
|
||||
RemoveKey(Keyboard[keyId]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a given key is contained by this keygroup.
|
||||
/// </summary>
|
||||
/// <param name="key">The key which should be checked.</param>
|
||||
/// <returns><c>true</c> if the key is contained by this keygroup; otherwise, <c>false</c>.</returns>
|
||||
public bool ContainsKey(CorsairKey key)
|
||||
{
|
||||
return key != null && GroupKeys.Contains(key);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a given key is contained by this keygroup.
|
||||
/// </summary>
|
||||
/// <param name="keyId">The ID of the key which should be checked.</param>
|
||||
/// <returns><c>true</c> if the key is contained by this keygroup; otherwise, <c>false</c>.</returns>
|
||||
public bool ContainsKey(CorsairKeyboardKeyId keyId)
|
||||
{
|
||||
return ContainsKey(Keyboard[keyId]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Merges the keys from the given keygroup in this keygroup.
|
||||
/// </summary>
|
||||
/// <param name="groupToMerge">The keygroup to merge.</param>
|
||||
public void MergeKeys(IKeyGroup groupToMerge)
|
||||
{
|
||||
foreach (CorsairKey key in groupToMerge.Keys)
|
||||
@@ -91,7 +154,10 @@ namespace CUE.NET.Devices.Keyboard.Keys
|
||||
GroupKeys.Add(key);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list containing the keys from this group.
|
||||
/// </summary>
|
||||
/// <returns>The list containing the keys.</returns>
|
||||
protected override IList<CorsairKey> GetGroupKeys()
|
||||
{
|
||||
return GroupKeys;
|
||||
|
||||
@@ -9,29 +9,70 @@ using CUE.NET.Helper;
|
||||
|
||||
namespace CUE.NET.Devices.Keyboard.Keys
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a keygroup containing keys which physically lay inside a rectangle.
|
||||
/// </summary>
|
||||
public class RectangleKeyGroup : BaseKeyGroup
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the rectangle the keys should be taken from.
|
||||
/// </summary>
|
||||
public RectangleF Rectangle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the minimal percentage overlay a key must have with the <see cref="Rectangle" /> to be taken into the keygroup.
|
||||
/// </summary>
|
||||
public float MinOverlayPercentage { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RectangleKeyGroup"/> class.
|
||||
/// </summary>
|
||||
/// <param name="keyboard">The keyboard this keygroup belongs to.</param>
|
||||
/// <param name="fromKey">They ID of the first key to calculate the rectangle of this keygroup from.</param>
|
||||
/// <param name="toKey">They ID of the second key to calculate the rectangle of this keygroup from.</param>
|
||||
/// <param name="minOverlayPercentage">(optional) The minimal percentage overlay a key must have with the <see cref="Rectangle" /> to be taken into the keygroup. (default: 0.5f)</param>
|
||||
/// <param name="autoAttach">(optional) Specifies whether this group should be automatically attached or not. (default: true)</param>
|
||||
public RectangleKeyGroup(CorsairKeyboard keyboard, CorsairKeyboardKeyId fromKey, CorsairKeyboardKeyId toKey, float minOverlayPercentage = 0.5f, bool autoAttach = true)
|
||||
: this(keyboard, keyboard[fromKey], keyboard[toKey], minOverlayPercentage, autoAttach)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RectangleKeyGroup"/> class.
|
||||
/// </summary>
|
||||
/// <param name="keyboard">The keyboard this keygroup belongs to.</param>
|
||||
/// <param name="fromKey">They first key to calculate the rectangle of this keygroup from.</param>
|
||||
/// <param name="toKey">They second key to calculate the rectangle of this keygroup from.</param>
|
||||
/// <param name="minOverlayPercentage">(optional) The minimal percentage overlay a key must have with the <see cref="Rectangle" /> to be taken into the keygroup. (default: 0.5f)</param>
|
||||
/// <param name="autoAttach">(optional) Specifies whether this group should be automatically attached or not. (default: true)</param>
|
||||
public RectangleKeyGroup(CorsairKeyboard keyboard, CorsairKey fromKey, CorsairKey toKey, float minOverlayPercentage = 0.5f, bool autoAttach = true)
|
||||
: this(keyboard, RectangleHelper.CreateRectangleFromRectangles(fromKey.KeyRectangle, toKey.KeyRectangle), minOverlayPercentage, autoAttach)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RectangleKeyGroup"/> class.
|
||||
/// </summary>
|
||||
/// <param name="keyboard">The keyboard this keygroup belongs to.</param>
|
||||
/// <param name="fromPoint">They first point to calculate the rectangle of this keygroup from.</param>
|
||||
/// <param name="toPoint">They second point to calculate the rectangle of this keygroup from.</param>
|
||||
/// <param name="minOverlayPercentage">(optional) The minimal percentage overlay a key must have with the <see cref="Rectangle" /> to be taken into the keygroup. (default: 0.5f)</param>
|
||||
/// <param name="autoAttach">(optional) Specifies whether this group should be automatically attached or not. (default: true)</param>
|
||||
public RectangleKeyGroup(CorsairKeyboard keyboard, PointF fromPoint, PointF toPoint, float minOverlayPercentage = 0.5f, bool autoAttach = true)
|
||||
: this(keyboard, RectangleHelper.CreateRectangleFromPoints(fromPoint, toPoint), minOverlayPercentage, autoAttach)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RectangleKeyGroup"/> class.
|
||||
/// </summary>
|
||||
/// <param name="keyboard">The keyboard this keygroup belongs to.</param>
|
||||
/// <param name="rectangle">The rectangle of this keygroup.</param>
|
||||
/// <param name="minOverlayPercentage">(optional) The minimal percentage overlay a key must have with the <see cref="Rectangle" /> to be taken into the keygroup. (default: 0.5f)</param>
|
||||
/// <param name="autoAttach">(optional) Specifies whether this group should be automatically attached or not. (default: true)</param>
|
||||
public RectangleKeyGroup(CorsairKeyboard keyboard, RectangleF rectangle, float minOverlayPercentage = 0.5f, bool autoAttach = true)
|
||||
: base(keyboard, autoAttach)
|
||||
{
|
||||
@@ -43,6 +84,10 @@ namespace CUE.NET.Devices.Keyboard.Keys
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list containing the keys from this group.
|
||||
/// </summary>
|
||||
/// <returns>The list containing the keys.</returns>
|
||||
protected override IList<CorsairKey> GetGroupKeys()
|
||||
{
|
||||
return Keyboard.Where(x => RectangleHelper.CalculateIntersectPercentage(x.KeyRectangle, Rectangle) >= MinOverlayPercentage).ToList();
|
||||
|
||||
Reference in new issue
Block a user