mirror of
https://github.com/DarthAffe/CUE.NET.git
synced 2025-12-12 16:58:29 +00:00
Added even more xml-comments
This commit is contained in:
parent
6de1087c1f
commit
5fc7abc9db
@ -99,6 +99,7 @@ namespace CUE.NET.Devices.Generic
|
||||
/// <summary>
|
||||
/// Checks if automatic updates should occur and starts/stops the update-loop if needed.
|
||||
/// </summary>
|
||||
/// <exception cref="ArgumentOutOfRangeException">Thrown if the requested update-mode is not available.</exception>
|
||||
protected async void CheckUpdateLoop()
|
||||
{
|
||||
bool shouldRun;
|
||||
|
||||
@ -24,7 +24,6 @@ namespace CUE.NET.Devices.Headset
|
||||
/// </summary>
|
||||
/// <param name="ledId">The ID of the LED to get.</param>
|
||||
/// <returns>The LED with the specified ID.</returns>
|
||||
/// <exception cref="System.ArgumentNullException" accessor="get"><paramref name="ledId" /> is null.</exception>
|
||||
public CorsairLed this[CorsairHeadsetLedId ledId]
|
||||
{
|
||||
get
|
||||
@ -42,7 +41,7 @@ namespace CUE.NET.Devices.Headset
|
||||
public CorsairHeadsetDeviceInfo HeadsetDeviceInfo { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if the headset has an active effect to deal with.
|
||||
/// Gets a value indicating if the headset has an active effect to deal with or not.
|
||||
/// </summary>
|
||||
protected override bool HasEffect => false;
|
||||
|
||||
|
||||
@ -30,6 +30,7 @@ namespace CUE.NET.Devices
|
||||
/// </summary>
|
||||
float UpdateFrequency { get; set; }
|
||||
|
||||
// ReSharper disable once EventNeverSubscribedTo.Global
|
||||
/// <summary>
|
||||
/// Occurs when a catched exception is thrown inside the device.
|
||||
/// </summary>
|
||||
|
||||
@ -2,6 +2,9 @@
|
||||
|
||||
namespace CUE.NET.Devices
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents generic device information.
|
||||
/// </summary>
|
||||
public interface IDeviceInfo
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@ -3,17 +3,32 @@ using CUE.NET.Helper;
|
||||
|
||||
namespace CUE.NET.Devices.Keyboard.Brushes
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a basic brush.
|
||||
/// </summary>
|
||||
public abstract class AbstractBrush : IBrush
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the overall percentage brightness of the brush.
|
||||
/// </summary>
|
||||
public float Brightness { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the overall percentage opacity of the brush.
|
||||
/// </summary>
|
||||
public float Opacity { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AbstractBrush"/> class.
|
||||
/// </summary>
|
||||
/// <param name="brightness">The overall percentage brightness of the brush. (default: 1f)</param>
|
||||
/// <param name="opacity">The overall percentage opacity of the brush. (default: 1f)</param>
|
||||
protected AbstractBrush(float brightness = 1f, float opacity = 1f)
|
||||
{
|
||||
this.Brightness = brightness;
|
||||
@ -24,8 +39,20 @@ namespace CUE.NET.Devices.Keyboard.Brushes
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Gets the color at an specific point assuming the brush is drawn into the given rectangle.
|
||||
/// </summary>
|
||||
/// <param name="rectangle">The rectangle in which the brush should be drawn.</param>
|
||||
/// <param name="point">The point from which the color should be taken.</param>
|
||||
/// <returns>The color at the specified point.</returns>
|
||||
public abstract Color GetColorAtPoint(RectangleF rectangle, PointF point);
|
||||
|
||||
/// <summary>
|
||||
/// Finalizes the color by appliing the overall brightness and opacity.<br/>
|
||||
/// This method should always be the last call of a <see cref="GetColorAtPoint" /> implementation.
|
||||
/// </summary>
|
||||
/// <param name="color">The color to finalize.</param>
|
||||
/// <returns>The finalized color.</returns>
|
||||
protected virtual Color FinalizeColor(Color color)
|
||||
{
|
||||
// Since we use HSV to calculate there is no way to make a color 'brighter' than 100%
|
||||
|
||||
@ -6,19 +6,32 @@ using System.Linq;
|
||||
|
||||
namespace CUE.NET.Devices.Keyboard.Brushes.Gradient
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a basic gradient.
|
||||
/// </summary>
|
||||
public abstract class AbstractGradient : IGradient
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of the stops used by this gradient.
|
||||
/// </summary>
|
||||
public IList<GradientStop> GradientStops { get; } = new List<GradientStop>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AbstractGradient"/> class.
|
||||
/// </summary>
|
||||
protected AbstractGradient()
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AbstractGradient"/> class.
|
||||
/// </summary>
|
||||
/// <param name="gradientStops">The stops with which the gradient should be initialized.</param>
|
||||
protected AbstractGradient(params GradientStop[] gradientStops)
|
||||
{
|
||||
foreach (GradientStop gradientStop in gradientStops)
|
||||
@ -29,6 +42,11 @@ namespace CUE.NET.Devices.Keyboard.Brushes.Gradient
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Clips the offset and ensures, that it is inside the bounds of the stop list.
|
||||
/// </summary>
|
||||
/// <param name="offset"></param>
|
||||
/// <returns></returns>
|
||||
protected float ClipOffset(float offset)
|
||||
{
|
||||
float max = GradientStops.Max(n => n.Offset);
|
||||
@ -42,6 +60,11 @@ namespace CUE.NET.Devices.Keyboard.Brushes.Gradient
|
||||
return offset;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the color of the gradient on the specified offset.
|
||||
/// </summary>
|
||||
/// <param name="offset">The percentage offset to take the color from.</param>
|
||||
/// <returns>The color at the specific offset.</returns>
|
||||
public abstract Color GetColor(float offset);
|
||||
|
||||
#endregion
|
||||
|
||||
@ -5,18 +5,32 @@ using System.Drawing;
|
||||
|
||||
namespace CUE.NET.Devices.Keyboard.Brushes.Gradient
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a stop on a gradient.
|
||||
/// </summary>
|
||||
public class GradientStop
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the percentage offset to place this stop. This should be inside the range of [0..1] but it's not necessary.
|
||||
/// </summary>
|
||||
public float Offset { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the stop.
|
||||
/// </summary>
|
||||
public Color Color { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GradientStop"/> class.
|
||||
/// </summary>
|
||||
/// <param name="offset">The percentage offset to place this stop.</param>
|
||||
/// <param name="color">The color of the stop.</param>
|
||||
public GradientStop(float offset, Color color)
|
||||
{
|
||||
this.Offset = offset;
|
||||
|
||||
@ -2,8 +2,16 @@
|
||||
|
||||
namespace CUE.NET.Devices.Keyboard.Brushes.Gradient
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a basic gradient.
|
||||
/// </summary>
|
||||
public interface IGradient
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the color of the gradient on the specified offset.
|
||||
/// </summary>
|
||||
/// <param name="offset">The percentage offset to take the color from.</param>
|
||||
/// <returns>The color at the specific offset.</returns>
|
||||
Color GetColor(float offset);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,13 +3,23 @@ using System.Linq;
|
||||
|
||||
namespace CUE.NET.Devices.Keyboard.Brushes.Gradient
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a linear interpolated gradient with n stops.
|
||||
/// </summary>
|
||||
public class LinearGradient : AbstractGradient
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LinearGradient"/> class.
|
||||
/// </summary>
|
||||
public LinearGradient()
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LinearGradient"/> class.
|
||||
/// </summary>
|
||||
/// <param name="gradientStops">The stops with which the gradient should be initialized.</param>
|
||||
public LinearGradient(params GradientStop[] gradientStops)
|
||||
: base(gradientStops)
|
||||
{ }
|
||||
@ -18,6 +28,11 @@ namespace CUE.NET.Devices.Keyboard.Brushes.Gradient
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Gets the linear interpolated color at the given offset.
|
||||
/// </summary>
|
||||
/// <param name="offset">The percentage offset to take the color from.</param>
|
||||
/// <returns>The color at the specific offset.</returns>
|
||||
public override Color GetColor(float offset)
|
||||
{
|
||||
if (!GradientStops.Any()) return Color.Transparent;
|
||||
|
||||
@ -5,17 +5,33 @@ using CUE.NET.Helper;
|
||||
|
||||
namespace CUE.NET.Devices.Keyboard.Brushes.Gradient
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a rainbow gradient which circles through all color colors of the HUE-color-space.<br />
|
||||
/// See <see cref="http://upload.wikimedia.org/wikipedia/commons/a/ad/HueScale.svg" /> as reference
|
||||
/// </summary>
|
||||
public class RainbowGradient : IGradient
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the hue (in degrees) to start from.
|
||||
/// </summary>
|
||||
public float StartHue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the hue (in degrees) to end the with.
|
||||
/// </summary>
|
||||
public float EndHue { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RainbowGradient"/> class.
|
||||
/// </summary>
|
||||
/// <param name="startHue">The hue (in degrees) to start from (default: 0)</param>
|
||||
/// <param name="endHue">The hue (in degrees) to end with (default: 360)</param>
|
||||
public RainbowGradient(float startHue = 0f, float endHue = 360f)
|
||||
{
|
||||
this.StartHue = startHue;
|
||||
@ -28,6 +44,11 @@ namespace CUE.NET.Devices.Keyboard.Brushes.Gradient
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Gets the color on the rainbow at the given offset.
|
||||
/// </summary>
|
||||
/// <param name="offset">The percentage offset to take the color from.</param>
|
||||
/// <returns>The color at the specific offset.</returns>
|
||||
public Color GetColor(float offset)
|
||||
{
|
||||
float range = EndHue - StartHue;
|
||||
|
||||
@ -2,11 +2,27 @@ using System.Drawing;
|
||||
|
||||
namespace CUE.NET.Devices.Keyboard.Brushes
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a basic brush.
|
||||
/// </summary>
|
||||
public interface IBrush
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the overall percentage brightness of the brush.
|
||||
/// </summary>
|
||||
float Brightness { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the overall percentage opacity of the brush.
|
||||
/// </summary>
|
||||
float Opacity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the color at an specific point assuming the brush is drawn into the given rectangle.
|
||||
/// </summary>
|
||||
/// <param name="rectangle">The rectangle in which the brush should be drawn.</param>
|
||||
/// <param name="point">The point from which the color should be taken.</param>
|
||||
/// <returns>The color at the specified point.</returns>
|
||||
Color GetColorAtPoint(RectangleF rectangle, PointF point);
|
||||
}
|
||||
}
|
||||
@ -9,26 +9,52 @@ using CUE.NET.Helper;
|
||||
|
||||
namespace CUE.NET.Devices.Keyboard.Brushes
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a brush drawing a linear gradient.
|
||||
/// </summary>
|
||||
public class LinearGradientBrush : AbstractBrush
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the start point (as percentage in the range [0..1]) of the gradient drawn by the brush. (default: 0f, 0.5f)
|
||||
/// </summary>
|
||||
public PointF StartPoint { get; set; } = new PointF(0f, 0.5f);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the end point (as percentage in the range [0..1]) of the gradient drawn by the brush. (default: 1f, 0.5f)
|
||||
/// </summary>
|
||||
public PointF EndPoint { get; set; } = new PointF(1f, 0.5f);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the gradient drawn by the brush. If null it will default to full transparent.
|
||||
/// </summary>
|
||||
public IGradient Gradient { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LinearGradientBrush"/> class.
|
||||
/// </summary>
|
||||
public LinearGradientBrush()
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LinearGradientBrush"/> class.
|
||||
/// </summary>
|
||||
/// <param name="gradient">The gradient drawn by the brush.</param>
|
||||
public LinearGradientBrush(IGradient gradient)
|
||||
{
|
||||
this.Gradient = gradient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LinearGradientBrush"/> class.
|
||||
/// </summary>
|
||||
/// <param name="startPoint">The start point (as percentage in the range [0..1]).</param>
|
||||
/// <param name="endPoint">The end point (as percentage in the range [0..1]).</param>
|
||||
/// <param name="gradient">The gradient drawn by the brush.</param>
|
||||
public LinearGradientBrush(PointF startPoint, PointF endPoint, IGradient gradient)
|
||||
{
|
||||
this.StartPoint = startPoint;
|
||||
@ -40,6 +66,12 @@ namespace CUE.NET.Devices.Keyboard.Brushes
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Gets the color at an specific point assuming the brush is drawn into the given rectangle.
|
||||
/// </summary>
|
||||
/// <param name="rectangle">The rectangle in which the brush should be drawn.</param>
|
||||
/// <param name="point">The point from which the color should be taken.</param>
|
||||
/// <returns>The color at the specified point.</returns>
|
||||
public override Color GetColorAtPoint(RectangleF rectangle, PointF point)
|
||||
{
|
||||
if (Gradient == null) return Color.Transparent;
|
||||
|
||||
@ -8,25 +8,47 @@ using CUE.NET.Helper;
|
||||
|
||||
namespace CUE.NET.Devices.Keyboard.Brushes
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a brush drawing a radial gradient around a center point.
|
||||
/// </summary>
|
||||
public class RadialGradientBrush : AbstractBrush
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the center point (as percentage in the range [0..1]) around which the brush should be drawn.
|
||||
/// </summary>
|
||||
public PointF Center { get; set; } = new PointF(0.5f, 0.5f);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the gradient drawn by the brush. If null it will default to full transparent.
|
||||
/// </summary>
|
||||
public IGradient Gradient { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RadialGradientBrush"/> class.
|
||||
/// </summary>
|
||||
public RadialGradientBrush()
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RadialGradientBrush"/> class.
|
||||
/// </summary>
|
||||
/// <param name="gradient">The gradient drawn by the brush.</param>
|
||||
public RadialGradientBrush(IGradient gradient)
|
||||
{
|
||||
this.Gradient = gradient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RadialGradientBrush"/> class.
|
||||
/// </summary>
|
||||
/// <param name="center">The center point (as percentage in the range [0..1]).</param>
|
||||
/// <param name="gradient">The gradient drawn by the brush.</param>
|
||||
public RadialGradientBrush(PointF center, IGradient gradient)
|
||||
{
|
||||
this.Center = center;
|
||||
@ -37,6 +59,12 @@ namespace CUE.NET.Devices.Keyboard.Brushes
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Gets the color at an specific point assuming the brush is drawn into the given rectangle.
|
||||
/// </summary>
|
||||
/// <param name="rectangle">The rectangle in which the brush should be drawn.</param>
|
||||
/// <param name="point">The point from which the color should be taken.</param>
|
||||
/// <returns>The color at the specified point.</returns>
|
||||
public override Color GetColorAtPoint(RectangleF rectangle, PointF point)
|
||||
{
|
||||
PointF centerPoint = new PointF(rectangle.X + rectangle.Width * Center.X, rectangle.Y + rectangle.Height * Center.Y);
|
||||
|
||||
@ -5,6 +5,10 @@ using CUE.NET.Helper;
|
||||
namespace CUE.NET.Devices.Keyboard.Brushes
|
||||
{
|
||||
//TODO DarthAffe 30.09.2015: Like this the brush seems kinda useless. Think about making it cool.
|
||||
|
||||
/// <summary>
|
||||
/// Represents a brush drawing random colors.
|
||||
/// </summary>
|
||||
public class RandomColorBrush : AbstractBrush
|
||||
{
|
||||
#region Properties & Fields
|
||||
@ -15,6 +19,12 @@ namespace CUE.NET.Devices.Keyboard.Brushes
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Gets a random color.
|
||||
/// </summary>
|
||||
/// <param name="rectangle">This value isn't used.</param>
|
||||
/// <param name="point">This value isn't used.</param>
|
||||
/// <returns>A random color.</returns>
|
||||
public override Color GetColorAtPoint(RectangleF rectangle, PointF point)
|
||||
{
|
||||
return FinalizeColor(ColorHelper.ColorFromHSV((float)_random.NextDouble() * 360f, 1, 1));
|
||||
|
||||
@ -1,19 +1,30 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
|
||||
|
||||
using System.Drawing;
|
||||
|
||||
namespace CUE.NET.Devices.Keyboard.Brushes
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a brush drawing only a single color.
|
||||
/// </summary>
|
||||
public class SolidColorBrush : AbstractBrush
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color drawn by the brush.
|
||||
/// </summary>
|
||||
public Color Color { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SolidColorBrush"/> class.
|
||||
/// </summary>
|
||||
/// <param name="color">The color drawn by the brush.</param>
|
||||
public SolidColorBrush(Color color)
|
||||
{
|
||||
this.Color = color;
|
||||
@ -23,6 +34,12 @@ namespace CUE.NET.Devices.Keyboard.Brushes
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Color" /> of the brush.
|
||||
/// </summary>
|
||||
/// <param name="rectangle">This value isn't used.</param>
|
||||
/// <param name="point">This value isn't used.</param>
|
||||
/// <returns>The <see cref="Color" /> of the brush.</returns>
|
||||
public override Color GetColorAtPoint(RectangleF rectangle, PointF point)
|
||||
{
|
||||
return FinalizeColor(Color);
|
||||
|
||||
@ -19,12 +19,20 @@ using CUE.NET.Native;
|
||||
|
||||
namespace CUE.NET.Devices.Keyboard
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the SDK for a corsair keyboard.
|
||||
/// </summary>
|
||||
public class CorsairKeyboard : AbstractCueDevice, IEnumerable<CorsairKey>, IKeyGroup
|
||||
{
|
||||
#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
|
||||
@ -34,10 +42,35 @@ namespace CUE.NET.Devices.Keyboard
|
||||
}
|
||||
}
|
||||
|
||||
public CorsairKey this[char key] => this[_CUESDK.CorsairGetLedIdForKeyName(key)];
|
||||
/// <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 CorsairKey this[PointF location] => _keys.Values.FirstOrDefault(x => x.KeyRectangle.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 IEnumerable<CorsairKey> this[RectangleF referenceRect, float minOverlayPercentage = 0.5f] => _keys.Values.Where(x => RectangleHelper.CalculateIntersectPercentage(x.KeyRectangle, referenceRect) >= minOverlayPercentage);
|
||||
|
||||
#endregion
|
||||
@ -46,13 +79,36 @@ namespace CUE.NET.Devices.Keyboard
|
||||
private readonly LinkedList<EffectTimeContainer> _effects = new LinkedList<EffectTimeContainer>();
|
||||
|
||||
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>
|
||||
public CorsairKeyboardDeviceInfo KeyboardDeviceInfo { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the rectangle containing all keys of the keyboard.
|
||||
/// </summary>
|
||||
public RectangleF KeyboardRectangle { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the background brush of the keyboard.
|
||||
/// </summary>
|
||||
public IBrush Brush { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the z-index of the background brush of the keyboard.<br />
|
||||
/// This value has absolutely no effect.
|
||||
/// </summary>
|
||||
public int ZIndex { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating if the keyboard has an active effect to deal with or not.
|
||||
/// </summary>
|
||||
protected override bool HasEffect
|
||||
{
|
||||
get
|
||||
@ -66,6 +122,10 @@ namespace CUE.NET.Devices.Keyboard
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CorsairKeyboard"/> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The specific information provided by CUE for the keyboard</param>
|
||||
internal CorsairKeyboard(CorsairKeyboardDeviceInfo info)
|
||||
: base(info)
|
||||
{
|
||||
@ -81,6 +141,10 @@ namespace CUE.NET.Devices.Keyboard
|
||||
|
||||
#region Update
|
||||
|
||||
/// <summary>
|
||||
/// Updates all groups and effects and perform an update for all dirty keys, or all keys if flushLeds is set to true.
|
||||
/// </summary>
|
||||
/// <param name="flushLeds">Specifies whether all keys (including clean ones) should be updated.</param>
|
||||
public override void Update(bool flushLeds = false)
|
||||
{
|
||||
UpdateKeyGroups();
|
||||
@ -153,6 +217,11 @@ namespace CUE.NET.Devices.Keyboard
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Attaches the given keygroup.
|
||||
/// </summary>
|
||||
/// <param name="keyGroup">The keygroup to attach.</param>
|
||||
/// <returns><c>true</c> if the keygroup could be attached; otherwise, <c>false</c>.</returns>
|
||||
public bool AttachKeyGroup(IKeyGroup keyGroup)
|
||||
{
|
||||
lock (_keyGroups)
|
||||
@ -164,6 +233,11 @@ namespace CUE.NET.Devices.Keyboard
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Detaches the given keygroup.
|
||||
/// </summary>
|
||||
/// <param name="keyGroup">The keygroup to detached.</param>
|
||||
/// <returns><c>true</c> if the keygroup could be detached; otherwise, <c>false</c>.</returns>
|
||||
public bool DetachKeyGroup(IKeyGroup keyGroup)
|
||||
{
|
||||
lock (_keyGroups)
|
||||
@ -178,6 +252,11 @@ namespace CUE.NET.Devices.Keyboard
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attaches the given effect.
|
||||
/// </summary>
|
||||
/// <param name="effect">The effect to attach.</param>
|
||||
/// <returns><c>true</c> if the effect could be attached; otherwise, <c>false</c>.</returns>
|
||||
public bool AttachEffect(IEffect effect)
|
||||
{
|
||||
bool retVal = false;
|
||||
@ -195,6 +274,11 @@ namespace CUE.NET.Devices.Keyboard
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Detaches the given effect.
|
||||
/// </summary>
|
||||
/// <param name="effect">The effect to detached.</param>
|
||||
/// <returns><c>true</c> if the effect could be detached; otherwise, <c>false</c>.</returns>
|
||||
public bool DetachEffect(IEffect effect)
|
||||
{
|
||||
bool retVal = false;
|
||||
@ -233,6 +317,10 @@ namespace CUE.NET.Devices.Keyboard
|
||||
|
||||
#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 IEnumerator<CorsairKey> GetEnumerator()
|
||||
{
|
||||
return _keys.Values.GetEnumerator();
|
||||
|
||||
@ -7,17 +7,20 @@ using CUE.NET.Native;
|
||||
|
||||
namespace CUE.NET.Devices.Keyboard
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents specific information for a CUE keyboard.
|
||||
/// </summary>
|
||||
public class CorsairKeyboardDeviceInfo : GenericDeviceInfo
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Physical layout of the keyboard.
|
||||
/// Gets the physical layout of the keyboard.
|
||||
/// </summary>
|
||||
public CorsairPhysicalKeyboardLayout PhysicalLayout { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Logical layout of the keyboard as set in CUE settings.
|
||||
/// Gets the logical layout of the keyboard as set in CUE settings.
|
||||
/// </summary>
|
||||
public CorsairLogicalKeyboardLayout LogicalLayout { get; private set; }
|
||||
|
||||
|
||||
@ -7,32 +7,61 @@ using CUE.NET.Devices.Keyboard.Keys;
|
||||
|
||||
namespace CUE.NET.Devices.Keyboard.Effects
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a basic effect.
|
||||
/// </summary>
|
||||
public abstract class AbstractEffect : IEffect
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the list of keys to which the effect applies.
|
||||
/// </summary>
|
||||
public IEnumerable<CorsairKey> KeyList { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the brush which is drawn by the effect.
|
||||
/// </summary>
|
||||
public abstract IBrush EffectBrush { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the z-index of the brush to allow ordering them before drawing. (lowest first) (default: 0)
|
||||
/// </summary>
|
||||
public int ZIndex { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets if this effect has finished all of his work.
|
||||
/// </summary>
|
||||
public bool IsDone { get; protected set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Sets the list of keys to which the effect applies.
|
||||
/// </summary>
|
||||
/// <param name="keyGroup"></param>
|
||||
public void SetTarget(IKeyGroup keyGroup)
|
||||
{
|
||||
KeyList = keyGroup.Keys.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the effect.
|
||||
/// </summary>
|
||||
/// <param name="deltaTime">The elapsed time (in seconds) since the last update.</param>
|
||||
public abstract void Update(float deltaTime);
|
||||
|
||||
/// <summary>
|
||||
/// Hook which is called when the effect is attached to a keyboard.
|
||||
/// </summary>
|
||||
public virtual void OnAttach()
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Hook which is called when the effect is detached from a keyboard.
|
||||
/// </summary>
|
||||
public virtual void OnDetach()
|
||||
{ }
|
||||
|
||||
|
||||
@ -3,20 +3,37 @@
|
||||
|
||||
namespace CUE.NET.Devices.Keyboard.Effects
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a wrapped effect with additional time information.
|
||||
/// </summary>
|
||||
internal class EffectTimeContainer
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the wrapped effect.
|
||||
/// </summary>
|
||||
internal IEffect Effect { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the tick-count from the last time the effect was updated.
|
||||
/// </summary>
|
||||
internal long TicksAtLastUpdate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the z-index of the effect.
|
||||
/// </summary>
|
||||
internal int ZIndex => Effect?.ZIndex ?? 0;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="EffectTimeContainer"/> class.
|
||||
/// </summary>
|
||||
/// <param name="effect">The wrapped effect.</param>
|
||||
/// <param name="ticksAtLastUpdate">The tick-count from the last time the effect was updated.</param>
|
||||
internal EffectTimeContainer(IEffect effect, long ticksAtLastUpdate)
|
||||
{
|
||||
this.Effect = effect;
|
||||
|
||||
@ -7,23 +7,61 @@ using CUE.NET.Devices.Keyboard.Brushes;
|
||||
|
||||
namespace CUE.NET.Devices.Keyboard.Effects
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an effect which allows to flash an brush by modifying his opacity.
|
||||
/// </summary>
|
||||
public class FlashEffect : AbstractEffect
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets the brush which is drawn by the effect.
|
||||
/// </summary>
|
||||
public override IBrush EffectBrush { get; }
|
||||
|
||||
// Settings are close to a synthesizer envelope (sustain is different for consequent naming): https://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope
|
||||
/// <summary>
|
||||
/// Gets or sets the attack-time (in seconds) of the effect. (default: 0.2f)<br />
|
||||
/// This is close to a synthesizer envelope. (See <see cref="http://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope" /> as reference)
|
||||
/// </summary>
|
||||
public float Attack { get; set; } = 0.2f;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the decay-time (in seconds) of the effect. (default: 0f)<br />
|
||||
/// This is close to a synthesizer envelope. (See <see cref="http://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope" /> as reference)
|
||||
/// </summary>
|
||||
public float Decay { get; set; } = 0f;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the sustain-time (in seconds) of the effect. (default: 0.3f)<br />
|
||||
/// This is close to a synthesizer envelope. (See <see cref="http://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope" /> as reference)<br />
|
||||
/// Note that this value for naming reasons represents the time NOT the level.
|
||||
/// </summary>
|
||||
public float Sustain { get; set; } = 0.3f;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the release-time (in seconds) of the effect. (default: 0.2f)<br />
|
||||
/// This is close to a synthesizer envelope. (See <see cref="http://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope" /> as reference)
|
||||
/// </summary>
|
||||
public float Release { get; set; } = 0.2f;
|
||||
|
||||
public float SustainValue { get; set; } = 1f;
|
||||
/// <summary>
|
||||
/// Gets or sets the level to which the oppacity (percentage) should raise in the attack-cycle. (default: 1f);
|
||||
/// </summary>
|
||||
public float AttackValue { get; set; } = 1f;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the level at which the oppacity (percentage) should stay in the sustain-cycle. (default: 1f);
|
||||
/// </summary>
|
||||
public float SustainValue { get; set; } = 1f;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the interval (in seconds) in which the effect should repeat (if repetition is enabled). (default: 1f)
|
||||
/// </summary>
|
||||
public float Interval { get; set; } = 1f;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the amount of repetitions the effect should do until it's finished. Zero means infinite. (default: 0f)
|
||||
/// </summary>
|
||||
public int Repetitions { get; set; } = 0;
|
||||
|
||||
private ADSRPhase _currentPhase;
|
||||
@ -34,10 +72,18 @@ namespace CUE.NET.Devices.Keyboard.Effects
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FlashEffect"/> class.
|
||||
/// </summary>
|
||||
/// <param name="flashColor">The color from which a <see cref="SolidColorBrush" /> should be created and used by this effect.</param>
|
||||
public FlashEffect(Color flashColor)
|
||||
: this(new SolidColorBrush(flashColor))
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FlashEffect"/> class.
|
||||
/// </summary>
|
||||
/// <param name="effectBrush">The brush which should be used by this effect,</param>
|
||||
public FlashEffect(IBrush effectBrush)
|
||||
{
|
||||
this.EffectBrush = effectBrush;
|
||||
@ -47,6 +93,10 @@ namespace CUE.NET.Devices.Keyboard.Effects
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Updates the effect.
|
||||
/// </summary>
|
||||
/// <param name="deltaTime">The elapsed time (in seconds) since the last update.</param>
|
||||
public override void Update(float deltaTime)
|
||||
{
|
||||
_currentPhaseValue -= deltaTime;
|
||||
@ -101,6 +151,9 @@ namespace CUE.NET.Devices.Keyboard.Effects
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the effect.
|
||||
/// </summary>
|
||||
public override void OnAttach()
|
||||
{
|
||||
base.OnAttach();
|
||||
|
||||
@ -4,26 +4,51 @@ using CUE.NET.Devices.Keyboard.Keys;
|
||||
|
||||
namespace CUE.NET.Devices.Keyboard.Effects
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a basic effect.
|
||||
/// </summary>
|
||||
public interface IEffect
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the list of keys to which the effect applies.
|
||||
/// </summary>
|
||||
IEnumerable<CorsairKey> KeyList { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the brush which is drawn by the effect.
|
||||
/// </summary>
|
||||
IBrush EffectBrush { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the z-index of the effect to allow ordering them before drawing. (lowest first) (default: 0)
|
||||
/// </summary>
|
||||
int ZIndex { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets if this effect has finished all of his work.
|
||||
/// </summary>
|
||||
bool IsDone { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Updates the effect.
|
||||
/// </summary>
|
||||
/// <param name="deltaTime">The elapsed time (in seconds) since the last update.</param>
|
||||
void Update(float deltaTime);
|
||||
|
||||
/// <summary>
|
||||
/// Hook which is called when the effect is attached to a keyboard.
|
||||
/// </summary>
|
||||
void OnAttach();
|
||||
|
||||
/// <summary>
|
||||
/// Hook which is called when the effect is detached from a keyboard.
|
||||
/// </summary>
|
||||
void OnDetach();
|
||||
|
||||
#endregion
|
||||
|
||||
@ -3,6 +3,9 @@
|
||||
|
||||
namespace CUE.NET.Devices.Keyboard.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains list of all LEDs available for corsair keyboards.
|
||||
/// </summary>
|
||||
public enum CorsairKeyboardKeyId
|
||||
{
|
||||
Invalid = 0,
|
||||
|
||||
@ -6,8 +6,16 @@ using CUE.NET.Devices.Keyboard.Keys;
|
||||
|
||||
namespace CUE.NET.Devices.Keyboard.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Offers some extensions and helper-methods for keygroup related things.
|
||||
/// </summary>
|
||||
public static class KeyGroupExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts the given <see cref="BaseKeyGroup" /> to a <see cref="ListKeyGroup" />.
|
||||
/// </summary>
|
||||
/// <param name="keyGroup">The <see cref="BaseKeyGroup" /> to convert.</param>
|
||||
/// <returns>The converted <see cref="ListKeyGroup" />.</returns>
|
||||
public static ListKeyGroup ToSimpleKeyGroup(this BaseKeyGroup keyGroup)
|
||||
{
|
||||
ListKeyGroup simpleKeyGroup = keyGroup as ListKeyGroup;
|
||||
@ -19,6 +27,12 @@ namespace CUE.NET.Devices.Keyboard.Extensions
|
||||
return simpleKeyGroup;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a new <see cref="ListKeyGroup" /> which contains all keys from the given keygroup excluding the specified ones.
|
||||
/// </summary>
|
||||
/// <param name="keyGroup">The base keygroup.</param>
|
||||
/// <param name="keyIds">The ids of the keys to exclude.</param>
|
||||
/// <returns>The new <see cref="ListKeyGroup" />.</returns>
|
||||
public static ListKeyGroup Exclude(this BaseKeyGroup keyGroup, params CorsairKeyboardKeyId[] keyIds)
|
||||
{
|
||||
ListKeyGroup simpleKeyGroup = keyGroup.ToSimpleKeyGroup();
|
||||
@ -27,6 +41,12 @@ namespace CUE.NET.Devices.Keyboard.Extensions
|
||||
return simpleKeyGroup;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a new <see cref="ListKeyGroup" /> which contains all keys from the given keygroup excluding the specified ones.
|
||||
/// </summary>
|
||||
/// <param name="keyGroup">The base keygroup.</param>
|
||||
/// <param name="keyIds">The keys to exclude.</param>
|
||||
/// <returns>The new <see cref="ListKeyGroup" />.</returns>
|
||||
public static ListKeyGroup Exclude(this BaseKeyGroup keyGroup, params CorsairKey[] keyIds)
|
||||
{
|
||||
ListKeyGroup simpleKeyGroup = keyGroup.ToSimpleKeyGroup();
|
||||
@ -36,11 +56,21 @@ namespace CUE.NET.Devices.Keyboard.Extensions
|
||||
}
|
||||
|
||||
// ReSharper disable once UnusedMethodReturnValue.Global
|
||||
/// <summary>
|
||||
/// Attaches the given keygroup to the keyboard.
|
||||
/// </summary>
|
||||
/// <param name="keyGroup">The keygroup to attach.</param>
|
||||
/// <returns><c>true</c> if the keygroup could be attached; otherwise, <c>false</c>.</returns>
|
||||
public static bool Attach(this BaseKeyGroup keyGroup)
|
||||
{
|
||||
return keyGroup.Keyboard?.AttachKeyGroup(keyGroup) ?? false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Detaches the given keygroup from the keyboard.
|
||||
/// </summary>
|
||||
/// <param name="keyGroup">The keygroup to attach.</param>
|
||||
/// <returns><c>true</c> if the keygroup could be detached; otherwise, <c>false</c>.</returns>
|
||||
public static bool Detach(this BaseKeyGroup keyGroup)
|
||||
{
|
||||
return keyGroup.Keyboard?.DetachKeyGroup(keyGroup) ?? false;
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -26,7 +26,6 @@ namespace CUE.NET.Devices.Mouse
|
||||
/// </summary>
|
||||
/// <param name="ledId">The ID of the LED to get.</param>
|
||||
/// <returns>The LED with the specified ID.</returns>
|
||||
/// <exception cref="System.ArgumentNullException" accessor="get"><paramref name="ledId" /> is null.</exception>
|
||||
public CorsairLed this[CorsairMouseLedId ledId]
|
||||
{
|
||||
get
|
||||
@ -44,7 +43,7 @@ namespace CUE.NET.Devices.Mouse
|
||||
public CorsairMouseDeviceInfo MouseDeviceInfo { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if the mouse has an active effect to deal with.
|
||||
/// Gets a value indicating if the mouse has an active effect to deal with or not.
|
||||
/// </summary>
|
||||
protected override bool HasEffect => false;
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ namespace CUE.NET.Devices.Mouse
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Physical layout of the mouse.
|
||||
/// Gets the physical layout of the mouse.
|
||||
/// </summary>
|
||||
public CorsairPhysicalMouseLayout PhysicalLayout { get; private set; }
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user