diff --git a/Devices/Generic/AbstractCueDevice.cs b/Devices/Generic/AbstractCueDevice.cs index abfde01..6a9fbc3 100644 --- a/Devices/Generic/AbstractCueDevice.cs +++ b/Devices/Generic/AbstractCueDevice.cs @@ -99,6 +99,7 @@ namespace CUE.NET.Devices.Generic /// /// Checks if automatic updates should occur and starts/stops the update-loop if needed. /// + /// Thrown if the requested update-mode is not available. protected async void CheckUpdateLoop() { bool shouldRun; diff --git a/Devices/Headset/CorsairHeadset.cs b/Devices/Headset/CorsairHeadset.cs index 85e8a6b..9e4f826 100644 --- a/Devices/Headset/CorsairHeadset.cs +++ b/Devices/Headset/CorsairHeadset.cs @@ -24,7 +24,6 @@ namespace CUE.NET.Devices.Headset /// /// The ID of the LED to get. /// The LED with the specified ID. - /// is null. public CorsairLed this[CorsairHeadsetLedId ledId] { get @@ -42,7 +41,7 @@ namespace CUE.NET.Devices.Headset public CorsairHeadsetDeviceInfo HeadsetDeviceInfo { get; } /// - /// 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. /// protected override bool HasEffect => false; diff --git a/Devices/ICueDevice.cs b/Devices/ICueDevice.cs index f9ee0e8..2ad8a14 100644 --- a/Devices/ICueDevice.cs +++ b/Devices/ICueDevice.cs @@ -30,6 +30,7 @@ namespace CUE.NET.Devices /// float UpdateFrequency { get; set; } + // ReSharper disable once EventNeverSubscribedTo.Global /// /// Occurs when a catched exception is thrown inside the device. /// diff --git a/Devices/IDeviceInfo.cs b/Devices/IDeviceInfo.cs index e17053d..4034ae8 100644 --- a/Devices/IDeviceInfo.cs +++ b/Devices/IDeviceInfo.cs @@ -2,6 +2,9 @@ namespace CUE.NET.Devices { + /// + /// Represents generic device information. + /// public interface IDeviceInfo { /// diff --git a/Devices/Keyboard/Brushes/AbstractBrush.cs b/Devices/Keyboard/Brushes/AbstractBrush.cs index 40daba7..300fbc5 100644 --- a/Devices/Keyboard/Brushes/AbstractBrush.cs +++ b/Devices/Keyboard/Brushes/AbstractBrush.cs @@ -3,17 +3,32 @@ using CUE.NET.Helper; namespace CUE.NET.Devices.Keyboard.Brushes { + /// + /// Represents a basic brush. + /// public abstract class AbstractBrush : IBrush { #region Properties & Fields + /// + /// Gets or sets the overall percentage brightness of the brush. + /// public float Brightness { get; set; } + + /// + /// Gets or sets the overall percentage opacity of the brush. + /// public float Opacity { get; set; } #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The overall percentage brightness of the brush. (default: 1f) + /// The overall percentage opacity of the brush. (default: 1f) protected AbstractBrush(float brightness = 1f, float opacity = 1f) { this.Brightness = brightness; @@ -24,8 +39,20 @@ namespace CUE.NET.Devices.Keyboard.Brushes #region Methods + /// + /// Gets the color at an specific point assuming the brush is drawn into the given rectangle. + /// + /// The rectangle in which the brush should be drawn. + /// The point from which the color should be taken. + /// The color at the specified point. public abstract Color GetColorAtPoint(RectangleF rectangle, PointF point); + /// + /// Finalizes the color by appliing the overall brightness and opacity.
+ /// This method should always be the last call of a implementation. + ///
+ /// The color to finalize. + /// The finalized color. protected virtual Color FinalizeColor(Color color) { // Since we use HSV to calculate there is no way to make a color 'brighter' than 100% diff --git a/Devices/Keyboard/Brushes/Gradient/AbstractGradient.cs b/Devices/Keyboard/Brushes/Gradient/AbstractGradient.cs index cb1bd64..f6e429b 100644 --- a/Devices/Keyboard/Brushes/Gradient/AbstractGradient.cs +++ b/Devices/Keyboard/Brushes/Gradient/AbstractGradient.cs @@ -6,19 +6,32 @@ using System.Linq; namespace CUE.NET.Devices.Keyboard.Brushes.Gradient { + /// + /// Represents a basic gradient. + /// public abstract class AbstractGradient : IGradient { #region Properties & Fields + /// + /// Gets a list of the stops used by this gradient. + /// public IList GradientStops { get; } = new List(); #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// protected AbstractGradient() { } + /// + /// Initializes a new instance of the class. + /// + /// The stops with which the gradient should be initialized. protected AbstractGradient(params GradientStop[] gradientStops) { foreach (GradientStop gradientStop in gradientStops) @@ -29,6 +42,11 @@ namespace CUE.NET.Devices.Keyboard.Brushes.Gradient #region Methods + /// + /// Clips the offset and ensures, that it is inside the bounds of the stop list. + /// + /// + /// 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; } + /// + /// Gets the color of the gradient on the specified offset. + /// + /// The percentage offset to take the color from. + /// The color at the specific offset. public abstract Color GetColor(float offset); #endregion diff --git a/Devices/Keyboard/Brushes/Gradient/GradientStop.cs b/Devices/Keyboard/Brushes/Gradient/GradientStop.cs index 8ddd9db..06ade36 100644 --- a/Devices/Keyboard/Brushes/Gradient/GradientStop.cs +++ b/Devices/Keyboard/Brushes/Gradient/GradientStop.cs @@ -5,18 +5,32 @@ using System.Drawing; namespace CUE.NET.Devices.Keyboard.Brushes.Gradient { + /// + /// Represents a stop on a gradient. + /// public class GradientStop { #region Properties & Fields + /// + /// Gets or sets the percentage offset to place this stop. This should be inside the range of [0..1] but it's not necessary. + /// public float Offset { get; set; } + /// + /// Gets or sets the color of the stop. + /// public Color Color { get; set; } #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The percentage offset to place this stop. + /// The color of the stop. public GradientStop(float offset, Color color) { this.Offset = offset; diff --git a/Devices/Keyboard/Brushes/Gradient/IGradient.cs b/Devices/Keyboard/Brushes/Gradient/IGradient.cs index b5cc9ff..c30c8ec 100644 --- a/Devices/Keyboard/Brushes/Gradient/IGradient.cs +++ b/Devices/Keyboard/Brushes/Gradient/IGradient.cs @@ -2,8 +2,16 @@ namespace CUE.NET.Devices.Keyboard.Brushes.Gradient { + /// + /// Represents a basic gradient. + /// public interface IGradient { + /// + /// Gets the color of the gradient on the specified offset. + /// + /// The percentage offset to take the color from. + /// The color at the specific offset. Color GetColor(float offset); } } diff --git a/Devices/Keyboard/Brushes/Gradient/LinearGradient.cs b/Devices/Keyboard/Brushes/Gradient/LinearGradient.cs index 5af52db..2057e01 100644 --- a/Devices/Keyboard/Brushes/Gradient/LinearGradient.cs +++ b/Devices/Keyboard/Brushes/Gradient/LinearGradient.cs @@ -3,13 +3,23 @@ using System.Linq; namespace CUE.NET.Devices.Keyboard.Brushes.Gradient { + /// + /// Represents a linear interpolated gradient with n stops. + /// public class LinearGradient : AbstractGradient { #region Constructors + /// + /// Initializes a new instance of the class. + /// public LinearGradient() { } + /// + /// Initializes a new instance of the class. + /// + /// The stops with which the gradient should be initialized. public LinearGradient(params GradientStop[] gradientStops) : base(gradientStops) { } @@ -18,6 +28,11 @@ namespace CUE.NET.Devices.Keyboard.Brushes.Gradient #region Methods + /// + /// Gets the linear interpolated color at the given offset. + /// + /// The percentage offset to take the color from. + /// The color at the specific offset. public override Color GetColor(float offset) { if (!GradientStops.Any()) return Color.Transparent; diff --git a/Devices/Keyboard/Brushes/Gradient/RainbowGradient.cs b/Devices/Keyboard/Brushes/Gradient/RainbowGradient.cs index b777955..dd86986 100644 --- a/Devices/Keyboard/Brushes/Gradient/RainbowGradient.cs +++ b/Devices/Keyboard/Brushes/Gradient/RainbowGradient.cs @@ -5,17 +5,33 @@ using CUE.NET.Helper; namespace CUE.NET.Devices.Keyboard.Brushes.Gradient { + /// + /// Represents a rainbow gradient which circles through all color colors of the HUE-color-space.
+ /// See as reference + ///
public class RainbowGradient : IGradient { #region Properties & Fields + /// + /// Gets or sets the hue (in degrees) to start from. + /// public float StartHue { get; set; } + + /// + /// Gets or sets the hue (in degrees) to end the with. + /// public float EndHue { get; set; } #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The hue (in degrees) to start from (default: 0) + /// The hue (in degrees) to end with (default: 360) public RainbowGradient(float startHue = 0f, float endHue = 360f) { this.StartHue = startHue; @@ -28,6 +44,11 @@ namespace CUE.NET.Devices.Keyboard.Brushes.Gradient #endregion + /// + /// Gets the color on the rainbow at the given offset. + /// + /// The percentage offset to take the color from. + /// The color at the specific offset. public Color GetColor(float offset) { float range = EndHue - StartHue; diff --git a/Devices/Keyboard/Brushes/IBrush.cs b/Devices/Keyboard/Brushes/IBrush.cs index de0bcd4..4e3bf98 100644 --- a/Devices/Keyboard/Brushes/IBrush.cs +++ b/Devices/Keyboard/Brushes/IBrush.cs @@ -2,11 +2,27 @@ using System.Drawing; namespace CUE.NET.Devices.Keyboard.Brushes { + /// + /// Represents a basic brush. + /// public interface IBrush { + /// + /// Gets or sets the overall percentage brightness of the brush. + /// float Brightness { get; set; } + + /// + /// Gets or sets the overall percentage opacity of the brush. + /// float Opacity { get; set; } + /// + /// Gets the color at an specific point assuming the brush is drawn into the given rectangle. + /// + /// The rectangle in which the brush should be drawn. + /// The point from which the color should be taken. + /// The color at the specified point. Color GetColorAtPoint(RectangleF rectangle, PointF point); } } \ No newline at end of file diff --git a/Devices/Keyboard/Brushes/LinearGradientBrush.cs b/Devices/Keyboard/Brushes/LinearGradientBrush.cs index 741d4e6..a7bde7f 100644 --- a/Devices/Keyboard/Brushes/LinearGradientBrush.cs +++ b/Devices/Keyboard/Brushes/LinearGradientBrush.cs @@ -9,26 +9,52 @@ using CUE.NET.Helper; namespace CUE.NET.Devices.Keyboard.Brushes { + /// + /// Represents a brush drawing a linear gradient. + /// public class LinearGradientBrush : AbstractBrush { #region Properties & Fields + /// + /// Gets or sets the start point (as percentage in the range [0..1]) of the gradient drawn by the brush. (default: 0f, 0.5f) + /// public PointF StartPoint { get; set; } = new PointF(0f, 0.5f); + + /// + /// Gets or sets the end point (as percentage in the range [0..1]) of the gradient drawn by the brush. (default: 1f, 0.5f) + /// public PointF EndPoint { get; set; } = new PointF(1f, 0.5f); + + /// + /// Gets or sets the gradient drawn by the brush. If null it will default to full transparent. + /// public IGradient Gradient { get; set; } #endregion #region Constructor + /// + /// Initializes a new instance of the class. + /// public LinearGradientBrush() { } + /// + /// Initializes a new instance of the class. + /// + /// The gradient drawn by the brush. public LinearGradientBrush(IGradient gradient) { this.Gradient = gradient; } - + /// + /// Initializes a new instance of the class. + /// + /// The start point (as percentage in the range [0..1]). + /// The end point (as percentage in the range [0..1]). + /// The gradient drawn by the brush. public LinearGradientBrush(PointF startPoint, PointF endPoint, IGradient gradient) { this.StartPoint = startPoint; @@ -40,6 +66,12 @@ namespace CUE.NET.Devices.Keyboard.Brushes #region Methods + /// + /// Gets the color at an specific point assuming the brush is drawn into the given rectangle. + /// + /// The rectangle in which the brush should be drawn. + /// The point from which the color should be taken. + /// The color at the specified point. public override Color GetColorAtPoint(RectangleF rectangle, PointF point) { if (Gradient == null) return Color.Transparent; diff --git a/Devices/Keyboard/Brushes/RadialGradientBrush.cs b/Devices/Keyboard/Brushes/RadialGradientBrush.cs index c284d0a..b5a0225 100644 --- a/Devices/Keyboard/Brushes/RadialGradientBrush.cs +++ b/Devices/Keyboard/Brushes/RadialGradientBrush.cs @@ -8,25 +8,47 @@ using CUE.NET.Helper; namespace CUE.NET.Devices.Keyboard.Brushes { + /// + /// Represents a brush drawing a radial gradient around a center point. + /// public class RadialGradientBrush : AbstractBrush { #region Properties & Fields + /// + /// Gets or sets the center point (as percentage in the range [0..1]) around which the brush should be drawn. + /// public PointF Center { get; set; } = new PointF(0.5f, 0.5f); + + /// + /// Gets or sets the gradient drawn by the brush. If null it will default to full transparent. + /// public IGradient Gradient { get; set; } #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// public RadialGradientBrush() { } + /// + /// Initializes a new instance of the class. + /// + /// The gradient drawn by the brush. public RadialGradientBrush(IGradient gradient) { this.Gradient = gradient; } + /// + /// Initializes a new instance of the class. + /// + /// The center point (as percentage in the range [0..1]). + /// The gradient drawn by the brush. public RadialGradientBrush(PointF center, IGradient gradient) { this.Center = center; @@ -37,6 +59,12 @@ namespace CUE.NET.Devices.Keyboard.Brushes #region Methods + /// + /// Gets the color at an specific point assuming the brush is drawn into the given rectangle. + /// + /// The rectangle in which the brush should be drawn. + /// The point from which the color should be taken. + /// The color at the specified point. public override Color GetColorAtPoint(RectangleF rectangle, PointF point) { PointF centerPoint = new PointF(rectangle.X + rectangle.Width * Center.X, rectangle.Y + rectangle.Height * Center.Y); diff --git a/Devices/Keyboard/Brushes/RandomColorBrush.cs b/Devices/Keyboard/Brushes/RandomColorBrush.cs index c8ff304..09f4fc4 100644 --- a/Devices/Keyboard/Brushes/RandomColorBrush.cs +++ b/Devices/Keyboard/Brushes/RandomColorBrush.cs @@ -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. + + /// + /// Represents a brush drawing random colors. + /// public class RandomColorBrush : AbstractBrush { #region Properties & Fields @@ -15,6 +19,12 @@ namespace CUE.NET.Devices.Keyboard.Brushes #region Methods + /// + /// Gets a random color. + /// + /// This value isn't used. + /// This value isn't used. + /// A random color. public override Color GetColorAtPoint(RectangleF rectangle, PointF point) { return FinalizeColor(ColorHelper.ColorFromHSV((float)_random.NextDouble() * 360f, 1, 1)); diff --git a/Devices/Keyboard/Brushes/SolidColorBrush.cs b/Devices/Keyboard/Brushes/SolidColorBrush.cs index 79899b3..2a2c7a4 100644 --- a/Devices/Keyboard/Brushes/SolidColorBrush.cs +++ b/Devices/Keyboard/Brushes/SolidColorBrush.cs @@ -1,19 +1,30 @@ // ReSharper disable MemberCanBePrivate.Global +// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global using System.Drawing; namespace CUE.NET.Devices.Keyboard.Brushes { + /// + /// Represents a brush drawing only a single color. + /// public class SolidColorBrush : AbstractBrush { #region Properties & Fields + /// + /// Gets or sets the color drawn by the brush. + /// public Color Color { get; set; } #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The color drawn by the brush. public SolidColorBrush(Color color) { this.Color = color; @@ -23,6 +34,12 @@ namespace CUE.NET.Devices.Keyboard.Brushes #region Methods + /// + /// Returns the of the brush. + /// + /// This value isn't used. + /// This value isn't used. + /// The of the brush. public override Color GetColorAtPoint(RectangleF rectangle, PointF point) { return FinalizeColor(Color); diff --git a/Devices/Keyboard/CorsairKeyboard.cs b/Devices/Keyboard/CorsairKeyboard.cs index a48dc75..642c239 100644 --- a/Devices/Keyboard/CorsairKeyboard.cs +++ b/Devices/Keyboard/CorsairKeyboard.cs @@ -19,12 +19,20 @@ using CUE.NET.Native; namespace CUE.NET.Devices.Keyboard { + /// + /// Represents the SDK for a corsair keyboard. + /// public class CorsairKeyboard : AbstractCueDevice, IEnumerable, IKeyGroup { #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 @@ -34,10 +42,35 @@ namespace CUE.NET.Devices.Keyboard } } - public CorsairKey this[char key] => this[_CUESDK.CorsairGetLedIdForKeyName(key)]; + /// + /// 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 CorsairKey this[PointF location] => _keys.Values.FirstOrDefault(x => x.KeyRectangle.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 IEnumerable 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 _effects = new LinkedList(); 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. + /// public CorsairKeyboardDeviceInfo KeyboardDeviceInfo { get; } + + /// + /// Gets the rectangle containing all keys of the keyboard. + /// public RectangleF KeyboardRectangle { get; private set; } + + /// + /// Gets or sets the background brush of the keyboard. + /// public IBrush Brush { get; set; } + + /// + /// Gets or sets the z-index of the background brush of the keyboard.
+ /// This value has absolutely no effect. + ///
public int ZIndex { get; set; } = 0; + /// + /// Gets a value indicating if the keyboard has an active effect to deal with or not. + /// protected override bool HasEffect { get @@ -66,6 +122,10 @@ namespace CUE.NET.Devices.Keyboard #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The specific information provided by CUE for the keyboard internal CorsairKeyboard(CorsairKeyboardDeviceInfo info) : base(info) { @@ -81,6 +141,10 @@ namespace CUE.NET.Devices.Keyboard #region Update + /// + /// Updates all groups and effects and perform an update for all dirty keys, or all keys if flushLeds is set to true. + /// + /// Specifies whether all keys (including clean ones) should be updated. public override void Update(bool flushLeds = false) { UpdateKeyGroups(); @@ -153,6 +217,11 @@ namespace CUE.NET.Devices.Keyboard #endregion + /// + /// Attaches the given keygroup. + /// + /// The keygroup to attach. + /// true if the keygroup could be attached; otherwise, false. public bool AttachKeyGroup(IKeyGroup keyGroup) { lock (_keyGroups) @@ -164,6 +233,11 @@ namespace CUE.NET.Devices.Keyboard } } + /// + /// Detaches the given keygroup. + /// + /// The keygroup to detached. + /// true if the keygroup could be detached; otherwise, false. public bool DetachKeyGroup(IKeyGroup keyGroup) { lock (_keyGroups) @@ -178,6 +252,11 @@ namespace CUE.NET.Devices.Keyboard } } + /// + /// Attaches the given effect. + /// + /// The effect to attach. + /// true if the effect could be attached; otherwise, false. public bool AttachEffect(IEffect effect) { bool retVal = false; @@ -195,6 +274,11 @@ namespace CUE.NET.Devices.Keyboard return retVal; } + /// + /// Detaches the given effect. + /// + /// The effect to detached. + /// true if the effect could be detached; otherwise, false. public bool DetachEffect(IEffect effect) { bool retVal = false; @@ -233,6 +317,10 @@ namespace CUE.NET.Devices.Keyboard #region IEnumerable + /// + /// Returns an enumerator that iterates over all keys of the keyboard. + /// + /// An enumerator for all keys of the keyboard. public IEnumerator GetEnumerator() { return _keys.Values.GetEnumerator(); diff --git a/Devices/Keyboard/CorsairKeyboardDeviceInfo.cs b/Devices/Keyboard/CorsairKeyboardDeviceInfo.cs index 19adc41..b52af96 100644 --- a/Devices/Keyboard/CorsairKeyboardDeviceInfo.cs +++ b/Devices/Keyboard/CorsairKeyboardDeviceInfo.cs @@ -7,17 +7,20 @@ using CUE.NET.Native; namespace CUE.NET.Devices.Keyboard { + /// + /// Represents specific information for a CUE keyboard. + /// public class CorsairKeyboardDeviceInfo : GenericDeviceInfo { #region Properties & Fields /// - /// Physical layout of the keyboard. + /// Gets the physical layout of the keyboard. /// public CorsairPhysicalKeyboardLayout PhysicalLayout { get; private set; } /// - /// Logical layout of the keyboard as set in CUE settings. + /// Gets the logical layout of the keyboard as set in CUE settings. /// public CorsairLogicalKeyboardLayout LogicalLayout { get; private set; } diff --git a/Devices/Keyboard/Effects/AbstractEffect.cs b/Devices/Keyboard/Effects/AbstractEffect.cs index ebc8bf7..51569e5 100644 --- a/Devices/Keyboard/Effects/AbstractEffect.cs +++ b/Devices/Keyboard/Effects/AbstractEffect.cs @@ -7,32 +7,61 @@ using CUE.NET.Devices.Keyboard.Keys; namespace CUE.NET.Devices.Keyboard.Effects { + /// + /// Represents a basic effect. + /// public abstract class AbstractEffect : IEffect { #region Properties & Fields + /// + /// Gets or sets the list of keys to which the effect applies. + /// public IEnumerable KeyList { get; protected set; } + /// + /// Gets the brush which is drawn by the effect. + /// public abstract IBrush EffectBrush { get; } + /// + /// Gets or sets the z-index of the brush to allow ordering them before drawing. (lowest first) (default: 0) + /// public int ZIndex { get; set; } = 0; + /// + /// Gets or sets if this effect has finished all of his work. + /// public bool IsDone { get; protected set; } #endregion #region Methods + /// + /// Sets the list of keys to which the effect applies. + /// + /// public void SetTarget(IKeyGroup keyGroup) { KeyList = keyGroup.Keys.ToList(); } + /// + /// Updates the effect. + /// + /// The elapsed time (in seconds) since the last update. public abstract void Update(float deltaTime); + /// + /// Hook which is called when the effect is attached to a keyboard. + /// public virtual void OnAttach() { } + /// + /// Hook which is called when the effect is detached from a keyboard. + /// public virtual void OnDetach() { } diff --git a/Devices/Keyboard/Effects/EffectTimeContainer.cs b/Devices/Keyboard/Effects/EffectTimeContainer.cs index 643d9f3..9a2a963 100644 --- a/Devices/Keyboard/Effects/EffectTimeContainer.cs +++ b/Devices/Keyboard/Effects/EffectTimeContainer.cs @@ -3,20 +3,37 @@ namespace CUE.NET.Devices.Keyboard.Effects { + /// + /// Represents a wrapped effect with additional time information. + /// internal class EffectTimeContainer { #region Properties & Fields + /// + /// Gets or sets the wrapped effect. + /// internal IEffect Effect { get; set; } + /// + /// Gets or sets the tick-count from the last time the effect was updated. + /// internal long TicksAtLastUpdate { get; set; } + /// + /// Gets the z-index of the effect. + /// internal int ZIndex => Effect?.ZIndex ?? 0; #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The wrapped effect. + /// The tick-count from the last time the effect was updated. internal EffectTimeContainer(IEffect effect, long ticksAtLastUpdate) { this.Effect = effect; diff --git a/Devices/Keyboard/Effects/FlashEffect.cs b/Devices/Keyboard/Effects/FlashEffect.cs index 3a538db..93d6a7d 100644 --- a/Devices/Keyboard/Effects/FlashEffect.cs +++ b/Devices/Keyboard/Effects/FlashEffect.cs @@ -7,23 +7,61 @@ using CUE.NET.Devices.Keyboard.Brushes; namespace CUE.NET.Devices.Keyboard.Effects { + /// + /// Represents an effect which allows to flash an brush by modifying his opacity. + /// public class FlashEffect : AbstractEffect { #region Properties & Fields + /// + /// Gets the brush which is drawn by the effect. + /// 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 + /// + /// Gets or sets the attack-time (in seconds) of the effect. (default: 0.2f)
+ /// This is close to a synthesizer envelope. (See as reference) + ///
public float Attack { get; set; } = 0.2f; + + /// + /// Gets or sets the decay-time (in seconds) of the effect. (default: 0f)
+ /// This is close to a synthesizer envelope. (See as reference) + ///
public float Decay { get; set; } = 0f; + + /// + /// Gets or sets the sustain-time (in seconds) of the effect. (default: 0.3f)
+ /// This is close to a synthesizer envelope. (See as reference)
+ /// Note that this value for naming reasons represents the time NOT the level. + ///
public float Sustain { get; set; } = 0.3f; + + /// + /// Gets or sets the release-time (in seconds) of the effect. (default: 0.2f)
+ /// This is close to a synthesizer envelope. (See as reference) + ///
public float Release { get; set; } = 0.2f; - public float SustainValue { get; set; } = 1f; + /// + /// Gets or sets the level to which the oppacity (percentage) should raise in the attack-cycle. (default: 1f); + /// public float AttackValue { get; set; } = 1f; + /// + /// Gets or sets the level at which the oppacity (percentage) should stay in the sustain-cycle. (default: 1f); + /// + public float SustainValue { get; set; } = 1f; + + /// + /// Gets or sets the interval (in seconds) in which the effect should repeat (if repetition is enabled). (default: 1f) + /// public float Interval { get; set; } = 1f; + /// + /// Gets or sets the amount of repetitions the effect should do until it's finished. Zero means infinite. (default: 0f) + /// public int Repetitions { get; set; } = 0; private ADSRPhase _currentPhase; @@ -34,10 +72,18 @@ namespace CUE.NET.Devices.Keyboard.Effects #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The color from which a should be created and used by this effect. public FlashEffect(Color flashColor) : this(new SolidColorBrush(flashColor)) { } + /// + /// Initializes a new instance of the class. + /// + /// The brush which should be used by this effect, public FlashEffect(IBrush effectBrush) { this.EffectBrush = effectBrush; @@ -47,6 +93,10 @@ namespace CUE.NET.Devices.Keyboard.Effects #region Methods + /// + /// Updates the effect. + /// + /// The elapsed time (in seconds) since the last update. public override void Update(float deltaTime) { _currentPhaseValue -= deltaTime; @@ -101,6 +151,9 @@ namespace CUE.NET.Devices.Keyboard.Effects } } + /// + /// Resets the effect. + /// public override void OnAttach() { base.OnAttach(); diff --git a/Devices/Keyboard/Effects/IEffect.cs b/Devices/Keyboard/Effects/IEffect.cs index 1805ba6..8cf4a6a 100644 --- a/Devices/Keyboard/Effects/IEffect.cs +++ b/Devices/Keyboard/Effects/IEffect.cs @@ -4,26 +4,51 @@ using CUE.NET.Devices.Keyboard.Keys; namespace CUE.NET.Devices.Keyboard.Effects { + /// + /// Represents a basic effect. + /// public interface IEffect { #region Properties & Fields + /// + /// Gets or sets the list of keys to which the effect applies. + /// IEnumerable KeyList { get; } + /// + /// Gets the brush which is drawn by the effect. + /// IBrush EffectBrush { get; } + /// + /// Gets or sets the z-index of the effect to allow ordering them before drawing. (lowest first) (default: 0) + /// int ZIndex { get; set; } + /// + /// Gets or sets if this effect has finished all of his work. + /// bool IsDone { get; } #endregion #region Methods - + + /// + /// Updates the effect. + /// + /// The elapsed time (in seconds) since the last update. void Update(float deltaTime); + /// + /// Hook which is called when the effect is attached to a keyboard. + /// void OnAttach(); + /// + /// Hook which is called when the effect is detached from a keyboard. + /// void OnDetach(); #endregion diff --git a/Devices/Keyboard/Enums/CorsairKeyboardKeyId.cs b/Devices/Keyboard/Enums/CorsairKeyboardKeyId.cs index 63d7677..dd04a60 100644 --- a/Devices/Keyboard/Enums/CorsairKeyboardKeyId.cs +++ b/Devices/Keyboard/Enums/CorsairKeyboardKeyId.cs @@ -3,6 +3,9 @@ namespace CUE.NET.Devices.Keyboard.Enums { + /// + /// Contains list of all LEDs available for corsair keyboards. + /// public enum CorsairKeyboardKeyId { Invalid = 0, diff --git a/Devices/Keyboard/Extensions/KeyGroupExtension.cs b/Devices/Keyboard/Extensions/KeyGroupExtension.cs index 73abff3..e1f5976 100644 --- a/Devices/Keyboard/Extensions/KeyGroupExtension.cs +++ b/Devices/Keyboard/Extensions/KeyGroupExtension.cs @@ -6,8 +6,16 @@ using CUE.NET.Devices.Keyboard.Keys; namespace CUE.NET.Devices.Keyboard.Extensions { + /// + /// Offers some extensions and helper-methods for keygroup related things. + /// public static class KeyGroupExtension { + /// + /// Converts the given to a . + /// + /// The to convert. + /// The converted . public static ListKeyGroup ToSimpleKeyGroup(this BaseKeyGroup keyGroup) { ListKeyGroup simpleKeyGroup = keyGroup as ListKeyGroup; @@ -19,6 +27,12 @@ namespace CUE.NET.Devices.Keyboard.Extensions return simpleKeyGroup; } + /// + /// Returns a new which contains all keys from the given keygroup excluding the specified ones. + /// + /// The base keygroup. + /// The ids of the keys to exclude. + /// The new . 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; } + /// + /// Returns a new which contains all keys from the given keygroup excluding the specified ones. + /// + /// The base keygroup. + /// The keys to exclude. + /// The new . 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 + /// + /// Attaches the given keygroup to the keyboard. + /// + /// The keygroup to attach. + /// true if the keygroup could be attached; otherwise, false. public static bool Attach(this BaseKeyGroup keyGroup) { return keyGroup.Keyboard?.AttachKeyGroup(keyGroup) ?? false; } + /// + /// Detaches the given keygroup from the keyboard. + /// + /// The keygroup to attach. + /// true if the keygroup could be detached; otherwise, false. public static bool Detach(this BaseKeyGroup keyGroup) { return keyGroup.Keyboard?.DetachKeyGroup(keyGroup) ?? false; diff --git a/Devices/Keyboard/Keys/BaseKeyGroup.cs b/Devices/Keyboard/Keys/BaseKeyGroup.cs index 6e8eb70..b968e40 100644 --- a/Devices/Keyboard/Keys/BaseKeyGroup.cs +++ b/Devices/Keyboard/Keys/BaseKeyGroup.cs @@ -5,22 +5,42 @@ using CUE.NET.Devices.Keyboard.Extensions; namespace CUE.NET.Devices.Keyboard.Keys { + /// + /// Represents a basic keygroup. + /// public abstract class BaseKeyGroup : IKeyGroup { #region Properties & Fields + /// + /// Gets the keyboard this keygroup belongs to. + /// internal CorsairKeyboard Keyboard { get; } + /// + /// Gets a read-only collection containing the keys from this group. + /// public IEnumerable Keys => new ReadOnlyCollection(GetGroupKeys()); + /// + /// Gets or sets the brush which should be drawn over this group. + /// public IBrush Brush { get; set; } + /// + /// Gets or sets the z-index of this keygroup to allow ordering them before drawing. (lowest first) (default: 0) + /// public int ZIndex { get; set; } = 0; #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The keyboard this keygroup belongs to. + /// Specifies whether this group should be automatically attached or not. protected BaseKeyGroup(CorsairKeyboard keyboard, bool autoAttach = true) { this.Keyboard = keyboard; @@ -29,6 +49,10 @@ namespace CUE.NET.Devices.Keyboard.Keys this.Attach(); } + /// + /// Gets a list containing the keys from this group. + /// + /// The list containing the keys. protected abstract IList GetGroupKeys(); #endregion diff --git a/Devices/Keyboard/Keys/CorsairKey.cs b/Devices/Keyboard/Keys/CorsairKey.cs index aaa6705..1cb799f 100644 --- a/Devices/Keyboard/Keys/CorsairKey.cs +++ b/Devices/Keyboard/Keys/CorsairKey.cs @@ -7,18 +7,38 @@ 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; } + + /// + /// Gets a rectangle representing the physical location of the key. + /// public RectangleF KeyRectangle { get; } #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The key-ID of the key. + /// The LED of the key. + /// The rectangle representing the physical location of the key. 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 } } diff --git a/Devices/Keyboard/Keys/IKeyGroup.cs b/Devices/Keyboard/Keys/IKeyGroup.cs index eb270e9..ff23029 100644 --- a/Devices/Keyboard/Keys/IKeyGroup.cs +++ b/Devices/Keyboard/Keys/IKeyGroup.cs @@ -5,10 +5,19 @@ namespace CUE.NET.Devices.Keyboard.Keys { public interface IKeyGroup { + /// + /// Gets a read-only collection containing the keys from this group. + /// IEnumerable Keys { get; } + /// + /// Gets or sets the brush which should be drawn over this group. + /// IBrush Brush { get; set; } + /// + /// Gets or sets the z-index of this keygroup to allow ordering them before drawing. (lowest first) (default: 0) + /// int ZIndex { get; set; } } } diff --git a/Devices/Keyboard/Keys/ListKeyGroup.cs b/Devices/Keyboard/Keys/ListKeyGroup.cs index 5d95aae..bafae08 100644 --- a/Devices/Keyboard/Keys/ListKeyGroup.cs +++ b/Devices/Keyboard/Keys/ListKeyGroup.cs @@ -5,34 +5,67 @@ using CUE.NET.Devices.Keyboard.Enums; namespace CUE.NET.Devices.Keyboard.Keys { + /// + /// Represents a keygroup containing arbitrary keys. + /// public class ListKeyGroup : BaseKeyGroup { #region Properties & Fields + /// + /// Gets the list containing the keys of this keygroup. + /// protected IList GroupKeys { get; } = new List(); #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The keyboard this keygroup belongs to. + /// Specifies whether this keygroup should be automatically attached or not. public ListKeyGroup(CorsairKeyboard keyboard, bool autoAttach = true) : base(keyboard, autoAttach) { } + /// + /// Initializes a new instance of the class. + /// + /// The keyboard this keygroup belongs to. + /// The initial keys of this keygroup. public ListKeyGroup(CorsairKeyboard keyboard, params CorsairKey[] keys) : this(keyboard, true, keys) { } + /// + /// Initializes a new instance of the class. + /// + /// The keyboard this keygroup belongs to. + /// Specifies whether this keygroup should be automatically attached or not. + /// The initial keys of this keygroup. public ListKeyGroup(CorsairKeyboard keyboard, bool autoAttach, params CorsairKey[] keys) : base(keyboard, autoAttach) { AddKey(keys); } + /// + /// Initializes a new instance of the class. + /// + /// The keyboard this keygroup belongs to. + /// The IDs of the initial keys of this keygroup. public ListKeyGroup(CorsairKeyboard keyboard, params CorsairKeyboardKeyId[] keys) : this(keyboard, true, keys) { } + /// + /// Initializes a new instance of the class. + /// + /// The keyboard this keygroup belongs to. + /// Specifies whether this keygroup should be automatically attached or not. + /// The IDs of the initial keys of this keygroup. public ListKeyGroup(CorsairKeyboard keyboard, bool autoAttach, params CorsairKeyboardKeyId[] keys) : base(keyboard, autoAttach) { @@ -43,6 +76,10 @@ namespace CUE.NET.Devices.Keyboard.Keys #region Methods + /// + /// Adds the given key(s) to the keygroup. + /// + /// The key(s) to add. public void AddKey(params CorsairKey[] keys) { if (keys != null) @@ -52,6 +89,10 @@ namespace CUE.NET.Devices.Keyboard.Keys } + /// + /// Adds the given key(s) to the keygroup. + /// + /// The ID(s) of the key(s) to add. public void AddKey(params CorsairKeyboardKeyId[] keyIds) { if (keyIds != null) @@ -59,6 +100,10 @@ namespace CUE.NET.Devices.Keyboard.Keys AddKey(Keyboard[keyId]); } + /// + /// Removes the given key(s) from the keygroup. + /// + /// The key(s) to remove. public void RemoveKey(params CorsairKey[] keys) { if (keys != null) @@ -67,6 +112,10 @@ namespace CUE.NET.Devices.Keyboard.Keys GroupKeys.Remove(key); } + /// + /// Removes the given key(s) from the keygroup. + /// + /// The ID(s) of the key(s) to remove. public void RemoveKey(params CorsairKeyboardKeyId[] keyIds) { if (keyIds != null) @@ -74,16 +123,30 @@ namespace CUE.NET.Devices.Keyboard.Keys RemoveKey(Keyboard[keyId]); } + /// + /// Checks if a given key is contained by this keygroup. + /// + /// The key which should be checked. + /// true if the key is contained by this keygroup; otherwise, false. public bool ContainsKey(CorsairKey key) { return key != null && GroupKeys.Contains(key); } + /// + /// Checks if a given key is contained by this keygroup. + /// + /// The ID of the key which should be checked. + /// true if the key is contained by this keygroup; otherwise, false. public bool ContainsKey(CorsairKeyboardKeyId keyId) { return ContainsKey(Keyboard[keyId]); } + /// + /// Merges the keys from the given keygroup in this keygroup. + /// + /// The keygroup to merge. public void MergeKeys(IKeyGroup groupToMerge) { foreach (CorsairKey key in groupToMerge.Keys) @@ -91,7 +154,10 @@ namespace CUE.NET.Devices.Keyboard.Keys GroupKeys.Add(key); } - + /// + /// Gets a list containing the keys from this group. + /// + /// The list containing the keys. protected override IList GetGroupKeys() { return GroupKeys; diff --git a/Devices/Keyboard/Keys/RectangleKeyGroup.cs b/Devices/Keyboard/Keys/RectangleKeyGroup.cs index f29708f..2d187dd 100644 --- a/Devices/Keyboard/Keys/RectangleKeyGroup.cs +++ b/Devices/Keyboard/Keys/RectangleKeyGroup.cs @@ -9,29 +9,70 @@ using CUE.NET.Helper; namespace CUE.NET.Devices.Keyboard.Keys { + /// + /// Represents a keygroup containing keys which physically lay inside a rectangle. + /// public class RectangleKeyGroup : BaseKeyGroup { #region Properties & Fields + /// + /// Gets or sets the rectangle the keys should be taken from. + /// public RectangleF Rectangle { get; set; } + + /// + /// Gets or sets the minimal percentage overlay a key must have with the to be taken into the keygroup. + /// public float MinOverlayPercentage { get; set; } #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The keyboard this keygroup belongs to. + /// They ID of the first key to calculate the rectangle of this keygroup from. + /// They ID of the second key to calculate the rectangle of this keygroup from. + /// (optional) The minimal percentage overlay a key must have with the to be taken into the keygroup. (default: 0.5f) + /// (optional) Specifies whether this group should be automatically attached or not. (default: true) public RectangleKeyGroup(CorsairKeyboard keyboard, CorsairKeyboardKeyId fromKey, CorsairKeyboardKeyId toKey, float minOverlayPercentage = 0.5f, bool autoAttach = true) : this(keyboard, keyboard[fromKey], keyboard[toKey], minOverlayPercentage, autoAttach) { } + /// + /// Initializes a new instance of the class. + /// + /// The keyboard this keygroup belongs to. + /// They first key to calculate the rectangle of this keygroup from. + /// They second key to calculate the rectangle of this keygroup from. + /// (optional) The minimal percentage overlay a key must have with the to be taken into the keygroup. (default: 0.5f) + /// (optional) Specifies whether this group should be automatically attached or not. (default: true) 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) { } + /// + /// Initializes a new instance of the class. + /// + /// The keyboard this keygroup belongs to. + /// They first point to calculate the rectangle of this keygroup from. + /// They second point to calculate the rectangle of this keygroup from. + /// (optional) The minimal percentage overlay a key must have with the to be taken into the keygroup. (default: 0.5f) + /// (optional) Specifies whether this group should be automatically attached or not. (default: true) public RectangleKeyGroup(CorsairKeyboard keyboard, PointF fromPoint, PointF toPoint, float minOverlayPercentage = 0.5f, bool autoAttach = true) : this(keyboard, RectangleHelper.CreateRectangleFromPoints(fromPoint, toPoint), minOverlayPercentage, autoAttach) { } + /// + /// Initializes a new instance of the class. + /// + /// The keyboard this keygroup belongs to. + /// The rectangle of this keygroup. + /// (optional) The minimal percentage overlay a key must have with the to be taken into the keygroup. (default: 0.5f) + /// (optional) Specifies whether this group should be automatically attached or not. (default: true) 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 + /// + /// Gets a list containing the keys from this group. + /// + /// The list containing the keys. protected override IList GetGroupKeys() { return Keyboard.Where(x => RectangleHelper.CalculateIntersectPercentage(x.KeyRectangle, Rectangle) >= MinOverlayPercentage).ToList(); diff --git a/Devices/Mouse/CorsairMouse.cs b/Devices/Mouse/CorsairMouse.cs index b1c5129..944b769 100644 --- a/Devices/Mouse/CorsairMouse.cs +++ b/Devices/Mouse/CorsairMouse.cs @@ -26,7 +26,6 @@ namespace CUE.NET.Devices.Mouse ///
/// The ID of the LED to get. /// The LED with the specified ID. - /// is null. public CorsairLed this[CorsairMouseLedId ledId] { get @@ -44,7 +43,7 @@ namespace CUE.NET.Devices.Mouse public CorsairMouseDeviceInfo MouseDeviceInfo { get; } /// - /// 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. /// protected override bool HasEffect => false; diff --git a/Devices/Mouse/CorsairMouseDeviceInfo.cs b/Devices/Mouse/CorsairMouseDeviceInfo.cs index fd13ffd..fe5a55e 100644 --- a/Devices/Mouse/CorsairMouseDeviceInfo.cs +++ b/Devices/Mouse/CorsairMouseDeviceInfo.cs @@ -15,7 +15,7 @@ namespace CUE.NET.Devices.Mouse #region Properties & Fields /// - /// Physical layout of the mouse. + /// Gets the physical layout of the mouse. /// public CorsairPhysicalMouseLayout PhysicalLayout { get; private set; }