Fixed some code-issues

This commit is contained in:
DarthAffe committed 2017-01-05 16:37:00 +01:00
1 parent 8523a4ddb3
commit 925e02f146
31 files changed
+223 -16

No files matched your search

+1 -1
View File
@@ -396,7 +396,7 @@ namespace CUE.NET.Devices.Generic
{
long lastUpdateTicks = _lastUpdate.Ticks;
_lastUpdate = DateTime.Now;
Updating?.Invoke(this, new UpdatingEventArgs((float)((DateTime.Now.Ticks - lastUpdateTicks) / 10000000f)));
Updating?.Invoke(this, new UpdatingEventArgs((DateTime.Now.Ticks - lastUpdateTicks) / 10000000f));
}
catch
{
+81 -2
View File
@@ -2,35 +2,77 @@
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
// ReSharper disable UnusedMember.Global
using System.Diagnostics;
using System.Drawing;
namespace CUE.NET.Devices.Generic
{
/// <summary>
/// Represents an ARGB (alpha, red, green, blue) color used by CUE.NET.
/// </summary>
[DebuggerDisplay("[A: {A}, R: {R}, G: {G}, B: {B}]")]
public class CorsairColor
{
#region Constants
/// <summary>
/// Gets an transparent color [A: 0, R: 0, G: 0, B: 0]
/// </summary>
public static CorsairColor Transparent => Color.Transparent;
#endregion
#region Properties & Fields
/// <summary>
/// Gets or sets the alpha component value of this <see cref="CorsairColor"/>.
/// </summary>
public byte A { get; set; }
/// <summary>
/// Gets or sets the red component value of this <see cref="CorsairColor"/>.
/// </summary>
public byte R { get; set; }
/// <summary>
/// Gets or sets the green component value of this <see cref="CorsairColor"/>.
/// </summary>
public byte G { get; set; }
/// <summary>
/// Gets or sets the blue component value of this <see cref="CorsairColor"/>.
/// </summary>
public byte B { get; set; }
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="CorsairColor"/> class.
/// The class created by this constructor equals <see cref="Transparent"/>.
/// </summary>
public CorsairColor()
{ }
public CorsairColor(byte r, byte g, byte b) : this(255, r, g, b)
/// <summary>
/// Initializes a new instance of the <see cref="CorsairColor"/> class using only RGB-Values.
/// Alpha defaults to 255.
/// </summary>
/// <param name="r">The red component value of this <see cref="CorsairColor"/>.</param>
/// <param name="g">The green component value of this <see cref="CorsairColor"/>.</param>
/// <param name="b">The blue component value of this <see cref="CorsairColor"/>.</param>
public CorsairColor(byte r, byte g, byte b)
: this(255, r, g, b)
{ }
/// <summary>
/// Initializes a new instance of the <see cref="CorsairColor"/> class using ARGB-values.
/// </summary>
/// <param name="a">The alpha component value of this <see cref="CorsairColor"/>.</param>
/// <param name="r">The red component value of this <see cref="CorsairColor"/>.</param>
/// <param name="g">The green component value of this <see cref="CorsairColor"/>.</param>
/// <param name="b">The blue component value of this <see cref="CorsairColor"/>.</param>
public CorsairColor(byte a, byte r, byte g, byte b)
{
this.A = a;
@@ -39,6 +81,10 @@ namespace CUE.NET.Devices.Generic
this.B = b;
}
/// <summary>
/// Initializes a new instance of the <see cref="CorsairColor"/> class by cloning a existing <see cref="CorsairColor"/>.
/// </summary>
/// <param name="color">The <see cref="CorsairColor"/> the values are copied from.</param>
public CorsairColor(CorsairColor color)
: this(color.A, color.R, color.G, color.B)
{ }
@@ -47,11 +93,19 @@ namespace CUE.NET.Devices.Generic
#region Operators
/// <summary>
/// Converts the individual byte-values of this <see cref="CorsairColor"/> to a human-readable string.
/// </summary>
/// <returns>A string that contains the individual byte-values of this <see cref="CorsairColor"/>. For example "[A: 255, R: 255, G: 0, B: 0]".</returns>
public override string ToString()
{
return $"[A: {A}, R: {R}, G: {G}, B: {B}]";
}
/// <summary>
/// Tests whether the specified object is a <see cref="CorsairColor" /> and is equivalent to this <see cref="CorsairColor" />.
/// </summary>
/// <param name="obj">The object to test.</param>
/// <returns>true if <paramref name="obj" /> is a <see cref="CorsairColor" /> equivalent to this <see cref="CorsairColor" /> ; otherwise, false.</returns>
public override bool Equals(object obj)
{
CorsairColor compareColor = obj as CorsairColor;
@@ -67,6 +121,10 @@ namespace CUE.NET.Devices.Generic
return (compareColor.A == A) && (compareColor.R == R) && (compareColor.G == G) && (compareColor.B == B);
}
/// <summary>
/// Returns a hash code for this <see cref="CorsairColor" />.
/// </summary>
/// <returns>An integer value that specifies the hash code for this <see cref="CorsairColor" />.</returns>
public override int GetHashCode()
{
unchecked
@@ -79,20 +137,41 @@ namespace CUE.NET.Devices.Generic
}
}
/// <summary>
/// Returns a value that indicates whether two specified <see cref="CorsairColor" /> are equal.
/// </summary>
/// <param name="color1">The first <see cref="CorsairColor" /> color to compare.</param>
/// <param name="color2">The second <see cref="CorsairColor" /> color to compare.</param>
/// <returns>true if <paramref name="color1" /> and <paramref name="color2" /> are equal; otherwise, false.</returns>
public static bool operator ==(CorsairColor color1, CorsairColor color2)
{
return ReferenceEquals(color1, null) ? ReferenceEquals(color2, null) : color1.Equals(color2);
}
/// <summary>
/// Returns a value that indicates whether two specified <see cref="CorsairColor" /> are equal.
/// </summary>
/// <param name="color1">The first <see cref="CorsairColor" /> color to compare.</param>
/// <param name="color2">The second <see cref="CorsairColor" /> color to compare.</param>
/// <returns>true if <paramref name="color1" /> and <paramref name="color2" /> are not equal; otherwise, false.</returns>
public static bool operator !=(CorsairColor color1, CorsairColor color2)
{
return !(color1 == color2);
}
/// <summary>
/// Converts a <see cref="Color" /> to a <see cref="CorsairColor" />.
/// </summary>
/// <param name="color">The <see cref="Color"/> to convert.</param>
public static implicit operator CorsairColor(Color color)
{
return new CorsairColor(color.A, color.R, color.G, color.B);
}
/// <summary>
/// Converts a <see cref="CorsairColor" /> to a <see cref="Color" />.
/// </summary>
/// <param name="color">The <see cref="CorsairColor"/> to convert.</param>
public static implicit operator Color(CorsairColor color)
{
return Color.FromArgb(color.A, color.R, color.G, color.B);
+35 -2
View File
@@ -2,6 +2,7 @@
// ReSharper disable UnusedAutoPropertyAccessor.Global
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
using System.Diagnostics;
using System.Drawing;
using CUE.NET.Devices.Generic.Enums;
using CUE.NET.Helper;
@@ -11,10 +12,11 @@ namespace CUE.NET.Devices.Generic
/// <summary>
/// Represents a single LED of a CUE-device.
/// </summary>
[DebuggerDisplay("{Id} {Color}")]
public class CorsairLed
{
#region Properties & Fields
/// <summary>
/// Gets the key-ID of the Led.
/// </summary>
@@ -52,7 +54,7 @@ namespace CUE.NET.Devices.Generic
/// <summary>
/// Gets or sets if the color of this LED can be changed.
/// </summary>
public bool IsLocked { get; set; } = false;
public bool IsLocked { get; set; }
#endregion
@@ -73,6 +75,15 @@ namespace CUE.NET.Devices.Generic
#region Methods
/// <summary>
/// Converts the Id and the <see cref="Color"/> of this <see cref="CorsairLed"/> to a human-readable string.
/// </summary>
/// <returns>A string that contains the Id and the <see cref="Color"/> of this <see cref="CorsairLed"/>. For example "Enter [A: 255, R: 255, G: 0, B: 0]".</returns>
public override string ToString()
{
return $"{Id} {Color}";
}
/// <summary>
/// Updates the LED to the requested color.
/// </summary>
@@ -92,5 +103,27 @@ namespace CUE.NET.Devices.Generic
}
#endregion
#region Operators
/// <summary>
/// Converts a <see cref="CorsairLed" /> to a <see cref="CorsairLedId" />.
/// </summary>
/// <param name="led">The <see cref="CorsairLed"/> to convert.</param>
public static implicit operator CorsairLedId(CorsairLed led)
{
return led?.Id ?? CorsairLedId.Invalid;
}
/// <summary>
/// Converts a <see cref="CorsairLed" /> to a <see cref="CorsairColor" />.
/// </summary>
/// <param name="led">The <see cref="CorsairLed"/> to convert.</param>
public static implicit operator CorsairColor(CorsairLed led)
{
return led?.Color;
}
#endregion
}
}
@@ -1,6 +1,8 @@
// ReSharper disable InconsistentNaming
// ReSharper disable UnusedMember.Global
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
namespace CUE.NET.Devices.Generic.Enums
{
/// <summary>
@@ -1,6 +1,8 @@
// ReSharper disable InconsistentNaming
// ReSharper disable UnusedMember.Global
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
namespace CUE.NET.Devices.Generic.Enums
{
/// <summary>
@@ -8,6 +10,7 @@ namespace CUE.NET.Devices.Generic.Enums
/// </summary>
public enum CorsairDeviceType
{
Unknown = 0,
Mouse = 1,
Keyboard = 2,
+2
View File
@@ -1,5 +1,7 @@
// ReSharper disable InconsistentNaming
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
namespace CUE.NET.Devices.Generic.Enums
{
/// <summary>
@@ -6,7 +6,7 @@ using System;
namespace CUE.NET.Devices.Generic.EventArgs
{
/// <summary>
/// Represents the information supplied with an Exception-event.
/// Represents the information supplied with an <see cref="ICueDevice.Exception"/>-event.
/// </summary>
public class ExceptionEventArgs : System.EventArgs
{
@@ -5,16 +5,26 @@ using System.Collections.Generic;
namespace CUE.NET.Devices.Generic.EventArgs
{
/// <summary>
/// Represents the information supplied with an <see cref="ICueDevice.LedsUpdated"/>-event.
/// </summary>
public class LedsUpdatedEventArgs : System.EventArgs
{
#region Properties & Fields
/// <summary>
/// Gets a list of <see cref="LedUpateRequest"/> from the updated leds.
/// </summary>
public IEnumerable<LedUpateRequest> UpdatedLeds { get; }
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="LedsUpdatedEventArgs"/> class.
/// </summary>
/// <param name="updatedLeds">The updated leds.</param>
public LedsUpdatedEventArgs(IEnumerable<LedUpateRequest> updatedLeds)
{
this.UpdatedLeds = updatedLeds;
@@ -5,16 +5,26 @@ using System.Collections.Generic;
namespace CUE.NET.Devices.Generic.EventArgs
{
/// <summary>
/// Represents the information supplied with an <see cref="ICueDevice.LedsUpdating"/>-event.
/// </summary>
public class LedsUpdatingEventArgs : System.EventArgs
{
#region Properties & Fields
/// <summary>
/// Gets a list of <see cref="LedUpateRequest"/> from the updating leds.
/// </summary>
public ICollection<LedUpateRequest> UpdatingLeds { get; }
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="LedsUpdatingEventArgs"/> class.
/// </summary>
/// <param name="updatingLeds">The updating leds.</param>
public LedsUpdatingEventArgs(ICollection<LedUpateRequest> updatingLeds)
{
this.UpdatingLeds = updatingLeds;
@@ -1,5 +1,8 @@
namespace CUE.NET.Devices.Generic.EventArgs
{
/// <summary>
/// Represents the information supplied with an <see cref="ICueDevice.Updated"/>-event.
/// </summary>
public class UpdatedEventArgs : System.EventArgs
{ }
}
@@ -3,16 +3,26 @@
namespace CUE.NET.Devices.Generic.EventArgs
{
/// <summary>
/// Represents the information supplied with an <see cref="ICueDevice.Updating"/>-event.
/// </summary>
public class UpdatingEventArgs : System.EventArgs
{
#region Properties & Fields
/// <summary>
/// Gets the elapsed time (in seconds) sonce the last update.
/// </summary>
public float DeltaTime { get; }
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="UpdatingEventArgs"/> class.
/// </summary>
/// <param name="deltaTime">The elapsed time (in seconds) sonce the last update.</param>
public UpdatingEventArgs(float deltaTime)
{
this.DeltaTime = deltaTime;
@@ -1,6 +1,8 @@
// ReSharper disable UnusedMember.Global
// ReSharper disable InconsistentNaming
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
using CUE.NET.Devices.Generic.Enums;
namespace CUE.NET.Devices.Headset.Enums
@@ -1,6 +1,8 @@
// ReSharper disable UnusedMember.Global
// ReSharper disable InconsistentNaming
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
using CUE.NET.Devices.Generic.Enums;
namespace CUE.NET.Devices.Keyboard.Enums
@@ -1,6 +1,8 @@
// ReSharper disable InconsistentNaming
// ReSharper disable UnusedMember.Global
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
namespace CUE.NET.Devices.Keyboard.Enums
{
/// <summary>
+2
View File
@@ -1,6 +1,8 @@
// ReSharper disable UnusedMember.Global
// ReSharper disable InconsistentNaming
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
using CUE.NET.Devices.Generic.Enums;
namespace CUE.NET.Devices.Mouse.Enums
@@ -1,6 +1,8 @@
// ReSharper disable UnusedMember.Global
// ReSharper disable InconsistentNaming
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
using CUE.NET.Devices.Generic.Enums;
namespace CUE.NET.Devices.Mousemat.Enums