From 59e11e5b822cc0a8a95eec2bf15dd0618f8dd339 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sat, 31 Jul 2021 16:59:51 +0200 Subject: [PATCH] Fixed code issues --- .../Color/Behaviors/DefaultColorBehavior.cs | 26 +++--- .../Color/Behaviors/IColorBehavior.cs | 23 ++++++ RGB.NET.Core/Color/HSVColor.cs | 34 +++++--- RGB.NET.Core/Color/HclColor.cs | 38 +++++---- RGB.NET.Core/Color/LabColor.cs | 34 +++++--- RGB.NET.Core/Color/RGBColor.cs | 80 ++++++++++++------- RGB.NET.Core/Color/XYZColor.cs | 38 +++++---- .../ColorCorrection/IColorCorrection.cs | 2 +- .../AbstractUpdateAwareDecorator.cs | 4 + RGB.NET.Core/Decorators/IDecorator.cs | 4 +- RGB.NET.Core/Devices/AbstractRGBDevice.cs | 46 +++++++++-- .../Devices/AbstractRGBDeviceProvider.cs | 75 ++++++++++++++++- RGB.NET.Core/Devices/IRGBDevice.cs | 27 ++++++- RGB.NET.Core/Devices/IRGBDeviceInfo.cs | 3 + RGB.NET.Core/Devices/IRGBDeviceProvider.cs | 18 ++++- RGB.NET.Core/Devices/KeyboardLayoutType.cs | 5 ++ .../Devices/TypeInterfaces/IKeyboard.cs | 11 ++- RGB.NET.Core/Events/ExceptionEventArgs.cs | 8 ++ RGB.NET.Core/Events/ResolvePathEventArgs.cs | 62 -------------- .../Events/SurfaceLayoutChangedEventArgs.cs | 3 +- .../Exceptions/DeviceProviderException.cs | 14 +++- RGB.NET.Core/Extensions/ColorExtensions.cs | 7 +- RGB.NET.Core/Extensions/MathExtensions.cs | 16 +++- RGB.NET.Core/Extensions/PointExtensions.cs | 7 +- .../Extensions/RectangleExtensions.cs | 38 +++++---- RGB.NET.Core/Extensions/SurfaceExtensions.cs | 22 ++++- RGB.NET.Core/Groups/AbstractLedGroup.cs | 6 ++ RGB.NET.Core/Groups/ILedGroup.cs | 6 ++ RGB.NET.Core/Groups/LedGroupExtension.cs | 9 ++- RGB.NET.Core/Groups/ListLedGroup.cs | 18 ++--- RGB.NET.Core/Helper/DeviceHelper.cs | 12 +++ RGB.NET.Core/Ids/IdGenerator.cs | 12 +++ RGB.NET.Core/Leds/Led.cs | 4 + RGB.NET.Core/Leds/LedMapping.cs | 68 ++++++++++++++++ RGB.NET.Core/Positioning/IPlaceable.cs | 30 +++++++ RGB.NET.Core/Positioning/Placeable.cs | 63 +++++++++++++++ RGB.NET.Core/Positioning/Rectangle.cs | 18 +++-- RGB.NET.Core/Positioning/Rotation.cs | 8 +- RGB.NET.Core/Positioning/Size.cs | 6 +- RGB.NET.Core/RGBSurface.cs | 17 +++- .../Rendering/Brushes/AbstractBrush.cs | 8 +- .../Rendering/Brushes/SolidColorBrush.cs | 3 +- .../Rendering/Brushes/TextureBrush.cs | 12 +++ RGB.NET.Core/Rendering/Textures/ITexture.cs | 22 ++++- .../Rendering/Textures/PixelTexture.cs | 76 +++++++++++++++++- .../Textures/Sampler/AverageColorSampler.cs | 9 ++- .../Rendering/Textures/Sampler/ISampler.cs | 11 ++- .../Rendering/Textures/Sampler/SamplerInfo.cs | 21 +++++ RGB.NET.Core/Update/CustomUpdateData.cs | 2 +- .../Update/Devices/DeviceUpdateTrigger.cs | 22 +++++ RGB.NET.Core/Update/Devices/IUpdateQueue.cs | 8 ++ RGB.NET.Core/Update/IUpdateTrigger.cs | 6 ++ RGB.NET.Core/Update/ManualUpdateTrigger.cs | 6 +- RGB.NET.Core/Update/TimerUpdateTrigger.cs | 13 ++- RGB.NET.Devices.Asus/AsusDeviceProvider.cs | 4 + RGB.NET.Devices.Asus/Enum/AsusLedId.cs | 1 + .../Keyboard/AsusKeyboardLedMapping.cs | 7 +- .../Keyboard/AsusKeyboardRGBDevice.cs | 13 ++- .../Generic/CoolerMasterRGBDeviceInfo.cs | 1 + .../Mouse/CoolerMasterMouseRGBDevice.cs | 3 +- .../Native/_CoolerMasterSDK.cs | 2 +- .../Custom/CorsairCustomRGBDevice.cs | 1 + .../Custom/CorsairCustomRGBDeviceInfo.cs | 43 ++++------ .../Enum/CorsairAccessMode.cs | 2 +- .../Enum/CorsairChannelDeviceType.cs | 2 +- .../Enum/CorsairDeviceCaps.cs | 2 +- .../Enum/CorsairDeviceType.cs | 2 +- RGB.NET.Devices.Corsair/Enum/CorsairLedId.cs | 4 +- .../Enum/CorsairLogicalKeyboardLayout.cs | 3 +- .../Enum/CorsairPhysicalKeyboardLayout.cs | 2 +- .../Enum/CorsairPhysicalMouseLayout.cs | 2 +- .../Generic/LedMappings.cs | 31 +++++++ .../CorsairGraphicsCardRGBDevice.cs | 1 + .../Headset/CorsairHeadsetRGBDevice.cs | 1 + .../CorsairHeadsetStandRGBDevice.cs | 1 + .../Keyboard/CorsairKeyboardRGBDevice.cs | 1 + .../Mainboard/CorsairMainboardRGBDevice.cs | 1 + .../Memory/CorsairMemoryRGBDevice.cs | 1 + .../Mouse/CorsairMouseRGBDevice.cs | 1 + .../Mousepad/CorsairMousepadRGBDevice.cs | 1 + RGB.NET.Devices.Corsair/Native/_CUESDK.cs | 2 +- RGB.NET.Devices.DMX/DMXDeviceProvider.cs | 2 +- .../Enum/LogitechDeviceType.cs | 3 + .../Enum/LogitechLedId.cs | 1 + .../Generic/LedMappings.cs | 24 ++++++ .../Native/_LogitechGSDK.cs | 2 +- RGB.NET.Devices.Msi/Native/_MsiSDK.cs | 2 +- .../Generic/MidiUpdateQueue.cs | 2 +- .../Generic/NovationRGBDevice.cs | 1 + RGB.NET.Devices.PicoPi/PicoPi/LedMappings.cs | 6 ++ RGB.NET.Devices.PicoPi/PicoPi/PicoPiSDK.cs | 9 +++ RGB.NET.Devices.Razer/Generic/LedMappings.cs | 24 ++++++ .../Generic/RazerRGBDevice.cs | 1 + RGB.NET.Devices.Razer/Native/_RazerSDK.cs | 2 +- .../Enum/SteelSeriesLedId.cs | 4 + .../Generic/LedMappings.cs | 30 +++++++ .../WS281XDeviceProvider.cs | 5 +- .../Enum/WootingDeviceType.cs | 3 + RGB.NET.HID/HIDLoader.cs | 41 ++++++++++ RGB.NET.Layout/DeviceLayout.cs | 19 ++++- RGB.NET.Layout/IDeviceLayout.cs | 6 ++ RGB.NET.Layout/ILedLayout.cs | 6 ++ RGB.NET.Layout/LayoutExtension.cs | 10 +++ RGB.NET.Layout/LedLayout.cs | 19 +++++ RGB.NET.Presets/Decorators/FlashDecorator.cs | 5 ++ .../Decorators/MoveGradientDecorator.cs | 1 + RGB.NET.Presets/Groups/RectangleLedGroup.cs | 6 +- RGB.NET.Presets/Helper/GradientHelper.cs | 2 +- .../Textures/AbstractGradientTexture.cs | 17 +++- RGB.NET.Presets/Textures/BytePixelTexture.cs | 37 +++++++-- .../Textures/ConicalGradientTexture.cs | 12 ++- RGB.NET.Presets/Textures/Enums/ColorFormat.cs | 7 +- RGB.NET.Presets/Textures/FloatPixelTexture.cs | 37 +++++++-- .../Textures/Gradients/LinearGradient.cs | 4 +- .../Textures/Gradients/RainbowGradient.cs | 2 +- .../Textures/LinearGradientTexture.cs | 7 +- .../Textures/RadialGradientTexture.cs | 7 +- .../Textures/Sampler/AverageByteSampler.cs | 6 +- .../Textures/Sampler/AverageFloatSampler.cs | 6 +- Tests/RGB.NET.Core.Tests/Color/ColorTest.cs | 36 ++++++--- 120 files changed, 1348 insertions(+), 342 deletions(-) delete mode 100644 RGB.NET.Core/Events/ResolvePathEventArgs.cs diff --git a/RGB.NET.Core/Color/Behaviors/DefaultColorBehavior.cs b/RGB.NET.Core/Color/Behaviors/DefaultColorBehavior.cs index 48ef24f..6e7e4c1 100644 --- a/RGB.NET.Core/Color/Behaviors/DefaultColorBehavior.cs +++ b/RGB.NET.Core/Color/Behaviors/DefaultColorBehavior.cs @@ -1,5 +1,11 @@ -namespace RGB.NET.Core +using System; + +namespace RGB.NET.Core { + /// + /// + /// Represents the default-behavior for the work with colors. + /// public class DefaultColorBehavior : IColorBehavior { #region Methods @@ -13,11 +19,12 @@ /// /// Tests whether the specified object is a and is equivalent to this . /// + /// The color to test. /// The object to test. /// true if is a equivalent to this ; otherwise, false. public virtual bool Equals(in Color color, object? obj) { - if (!(obj is Color color2)) return false; + if (obj is not Color color2) return false; (float a, float r, float g, float b) = color2.GetRGB(); return color.A.EqualsInTolerance(a) && color.R.EqualsInTolerance(r) && color.G.EqualsInTolerance(g) && color.B.EqualsInTolerance(b); @@ -27,22 +34,13 @@ /// Returns a hash code for this . /// /// An integer value that specifies the hash code for this . - public virtual int GetHashCode(in Color color) - { - unchecked - { - int hashCode = color.A.GetHashCode(); - hashCode = (hashCode * 397) ^ color.R.GetHashCode(); - hashCode = (hashCode * 397) ^ color.G.GetHashCode(); - hashCode = (hashCode * 397) ^ color.B.GetHashCode(); - return hashCode; - } - } + public virtual int GetHashCode(in Color color) => HashCode.Combine(color.A, color.R, color.G, color.B); /// /// Blends a over this color. /// - /// The to blend. + /// The to to blend over. + /// The to blend. public virtual Color Blend(in Color baseColor, in Color blendColor) { if (blendColor.A.EqualsInTolerance(0)) return baseColor; diff --git a/RGB.NET.Core/Color/Behaviors/IColorBehavior.cs b/RGB.NET.Core/Color/Behaviors/IColorBehavior.cs index 0e4a23f..cbc117f 100644 --- a/RGB.NET.Core/Color/Behaviors/IColorBehavior.cs +++ b/RGB.NET.Core/Color/Behaviors/IColorBehavior.cs @@ -1,13 +1,36 @@ namespace RGB.NET.Core { + /// + /// Represents a behavior of a color for base operations. + /// public interface IColorBehavior { + /// + /// Converts the specified to a string representation. + /// + /// The color to convert. + /// The string representation of the specified color. string ToString(in Color color); + /// + /// Tests whether the specified object is a and is equivalent to this . + /// + /// The color to test. + /// The object to test. + /// true if is a equivalent to this ; otherwise, false. bool Equals(in Color color, object? obj); + /// + /// Returns a hash code for this . + /// + /// An integer value that specifies the hash code for this . int GetHashCode(in Color color); + /// + /// Blends a over this color. + /// + /// The to to blend over. + /// The to blend. Color Blend(in Color baseColor, in Color blendColor); } } diff --git a/RGB.NET.Core/Color/HSVColor.cs b/RGB.NET.Core/Color/HSVColor.cs index 492742f..5bc4cba 100644 --- a/RGB.NET.Core/Color/HSVColor.cs +++ b/RGB.NET.Core/Color/HSVColor.cs @@ -4,6 +4,9 @@ using System; namespace RGB.NET.Core { + /// + /// Contains helper-methods and extension for the -type to work in the HSV color space. + /// public static class HSVColor { #region Getter @@ -11,22 +14,22 @@ namespace RGB.NET.Core /// /// Gets the hue component value (HSV-color space) of this as degree in the range [0..360]. /// - /// - /// + /// The color to get the value from. + /// The hue component value of the color. public static float GetHue(this in Color color) => color.GetHSV().hue; /// /// Gets the saturation component value (HSV-color space) of this in the range [0..1]. /// - /// - /// + /// The color to get the value from. + /// The saturation component value of the color. public static float GetSaturation(this in Color color) => color.GetHSV().saturation; /// /// Gets the value component value (HSV-color space) of this in the range [0..1]. /// - /// - /// + /// The color to get the value from. + /// The value component value of the color. public static float GetValue(this in Color color) => color.GetHSV().value; /// @@ -35,8 +38,8 @@ namespace RGB.NET.Core /// Saturation in the range [0..1]. /// Value in the range [0..1]. /// - /// - /// + /// The color to get the value from. + /// A tuple containing the hue, saturation and value component value of the color. public static (float hue, float saturation, float value) GetHSV(this in Color color) => CaclulateHSVFromRGB(color.R, color.G, color.B); @@ -45,8 +48,9 @@ namespace RGB.NET.Core #region Manipulation /// - /// Adds the given HSV values to this color. + /// Adds the specified HSV values to this color. /// + /// The color to modify. /// The hue value to add. /// The saturation value to add. /// The value value to add. @@ -58,8 +62,9 @@ namespace RGB.NET.Core } /// - /// Subtracts the given HSV values to this color. + /// Subtracts the specified HSV values to this color. /// + /// The color to modify. /// The hue value to subtract. /// The saturation value to subtract. /// The value value to subtract. @@ -71,8 +76,9 @@ namespace RGB.NET.Core } /// - /// Multiplies the given HSV values to this color. + /// Multiplies the specified HSV values to this color. /// + /// The color to modify. /// The hue value to multiply. /// The saturation value to multiply. /// The value value to multiply. @@ -84,8 +90,9 @@ namespace RGB.NET.Core } /// - /// Divides the given HSV values to this color. + /// Divides the specified HSV values to this color. /// + /// The color to modify. /// The hue value to divide. /// The saturation value to divide. /// The value value to divide. @@ -97,8 +104,9 @@ namespace RGB.NET.Core } /// - /// Sets the given hue value of this color. + /// Sets the specified hue value of this color. /// + /// The color to modify. /// The hue value to set. /// The saturation value to set. /// The value value to set. diff --git a/RGB.NET.Core/Color/HclColor.cs b/RGB.NET.Core/Color/HclColor.cs index 3adc41b..e4554d6 100644 --- a/RGB.NET.Core/Color/HclColor.cs +++ b/RGB.NET.Core/Color/HclColor.cs @@ -4,6 +4,9 @@ using System; namespace RGB.NET.Core { + /// + /// Contains helper-methods and extension for the -type to work in the Hcl color space. + /// public static class HclColor { #region Getter @@ -11,23 +14,23 @@ namespace RGB.NET.Core /// /// Gets the H component value (Hcl-color space) of this in the range [0..360]. /// - /// - /// - public static float GetHclH(this in Color color) => color.GetHcl().l; + /// The color to get the value from. + /// The H component value of the color. + public static float GetHclH(this in Color color) => color.GetHcl().h; /// /// Gets the c component value (Hcl-color space) of this in the range [0..1]. /// - /// - /// + /// The color to get the value from. + /// The c component value of the color. public static float GetHclC(this in Color color) => color.GetHcl().c; /// /// Gets the l component value (Hcl-color space) of this in the range [0..1]. /// - /// - /// - public static float GetHclL(this in Color color) => color.GetHcl().h; + /// The color to get the value from. + /// The l component value of the color. + public static float GetHclL(this in Color color) => color.GetHcl().l; /// /// Gets the H, c and l component values (Hcl-color space) of this . @@ -35,8 +38,8 @@ namespace RGB.NET.Core /// c in the range [0..1]. /// l in the range [0..1]. /// - /// - /// + /// The color to get the value from. + /// A tuple containing the H, c and l component value of the color. public static (float h, float c, float l) GetHcl(this in Color color) => CalculateHclFromRGB(color.R, color.G, color.B); @@ -45,8 +48,9 @@ namespace RGB.NET.Core #region Manipulation /// - /// Adds the given Hcl values to this color. + /// Adds the specified Hcl values to this color. /// + /// The color to modify. /// The H value to add. /// The c value to add. /// The l value to add. @@ -58,8 +62,9 @@ namespace RGB.NET.Core } /// - /// Subtracts the given Hcl values to this color. + /// Subtracts the specified Hcl values to this color. /// + /// The color to modify. /// The H value to subtract. /// The c value to subtract. /// The l value to subtract. @@ -71,8 +76,9 @@ namespace RGB.NET.Core } /// - /// Multiplies the given Hcl values to this color. + /// Multiplies the specified Hcl values to this color. /// + /// The color to modify. /// The H value to multiply. /// The c value to multiply. /// The l value to multiply. @@ -84,8 +90,9 @@ namespace RGB.NET.Core } /// - /// Divides the given Hcl values to this color. + /// Divides the specified Hcl values to this color. /// + /// The color to modify. /// The H value to divide. /// The c value to divide. /// The l value to divide. @@ -97,8 +104,9 @@ namespace RGB.NET.Core } /// - /// Sets the given X value of this color. + /// Sets the specified X value of this color. /// + /// The color to modify. /// The H value to set. /// The c value to set. /// The l value to set. diff --git a/RGB.NET.Core/Color/LabColor.cs b/RGB.NET.Core/Color/LabColor.cs index 3da5f2c..af212cb 100644 --- a/RGB.NET.Core/Color/LabColor.cs +++ b/RGB.NET.Core/Color/LabColor.cs @@ -4,6 +4,9 @@ using System; namespace RGB.NET.Core { + /// + /// Contains helper-methods and extension for the -type to work in the Lab color space. + /// public static class LabColor { #region Getter @@ -11,22 +14,22 @@ namespace RGB.NET.Core /// /// Gets the L component value (Lab-color space) of this in the range [0..100]. /// - /// - /// + /// The color to get the value from. + /// The L component value of the color. public static float GetLabL(this in Color color) => color.GetLab().l; /// /// Gets the a component value (Lab-color space) of this in the range [0..1]. /// - /// - /// + /// The color to get the value from. + /// The a component value of the color. public static float GetLabA(this in Color color) => color.GetLab().a; /// /// Gets the b component value (Lab-color space) of this in the range [0..1]. /// - /// - /// + /// The color to get the value from. + /// The b component value of the color. public static float GetLabB(this in Color color) => color.GetLab().b; /// @@ -35,8 +38,8 @@ namespace RGB.NET.Core /// a in the range [0..1]. /// b in the range [0..1]. /// - /// - /// + /// The color to get the value from. + /// A tuple containing the L, a and b component value of the color. public static (float l, float a, float b) GetLab(this in Color color) => CalculateLabFromRGB(color.R, color.G, color.B); @@ -45,8 +48,9 @@ namespace RGB.NET.Core #region Manipulation /// - /// Adds the given Lab values to this color. + /// Adds the specified Lab values to this color. /// + /// The color to modify. /// The L value to add. /// The a value to add. /// The b value to add. @@ -58,8 +62,9 @@ namespace RGB.NET.Core } /// - /// Subtracts the given Lab values to this color. + /// Subtracts the specified Lab values to this color. /// + /// The color to modify. /// The L value to subtract. /// The a value to subtract. /// The b value to subtract. @@ -71,8 +76,9 @@ namespace RGB.NET.Core } /// - /// Multiplies the given Lab values to this color. + /// Multiplies the specified Lab values to this color. /// + /// The color to modify. /// The L value to multiply. /// The a value to multiply. /// The b value to multiply. @@ -84,8 +90,9 @@ namespace RGB.NET.Core } /// - /// Divides the given Lab values to this color. + /// Divides the specified Lab values to this color. /// + /// The color to modify. /// The L value to divide. /// The a value to divide. /// The b value to divide. @@ -97,8 +104,9 @@ namespace RGB.NET.Core } /// - /// Sets the given X valueof this color. + /// Sets the specified X valueof this color. /// + /// The color to modify. /// The L value to set. /// The a value to set. /// The b value to set. diff --git a/RGB.NET.Core/Color/RGBColor.cs b/RGB.NET.Core/Color/RGBColor.cs index 9f4c2cb..2f78733 100644 --- a/RGB.NET.Core/Color/RGBColor.cs +++ b/RGB.NET.Core/Color/RGBColor.cs @@ -4,6 +4,9 @@ using System; namespace RGB.NET.Core { + /// + /// Contains helper-methods and extension for the -type to work in the RGB color space. + /// public static class RGBColor { #region Getter @@ -11,44 +14,44 @@ namespace RGB.NET.Core /// /// Gets the A component value of this as byte in the range [0..255]. /// - /// - /// + /// The color to get the value from. + /// The A component value of the color. public static byte GetA(this in Color color) => color.A.GetByteValueFromPercentage(); /// /// Gets the R component value of this as byte in the range [0..255]. /// - /// - /// + /// The color to get the value from. + /// The R component value of the color. public static byte GetR(this in Color color) => color.R.GetByteValueFromPercentage(); /// /// Gets the G component value of this as byte in the range [0..255]. /// - /// - /// + /// The color to get the value from. + /// The G component value of the color. public static byte GetG(this in Color color) => color.G.GetByteValueFromPercentage(); /// /// Gets the B component value of this as byte in the range [0..255]. /// - /// - /// + /// The color to get the value from. + /// The B component value of the color. public static byte GetB(this in Color color) => color.B.GetByteValueFromPercentage(); /// /// Gets the A, R, G and B component value of this as byte in the range [0..255]. /// - /// - /// + /// The color to get the value from. + /// A tuple containing the A, R, G and B component value of the color. public static (byte a, byte r, byte g, byte b) GetRGBBytes(this in Color color) => (color.GetA(), color.GetR(), color.GetG(), color.GetB()); /// /// Gets the A, R, G and B component value of this as percentage in the range [0..1]. /// - /// - /// + /// The color to get the value from. + /// A tuple containing the A, R, G and B component value of the color. public static (float a, float r, float g, float b) GetRGB(this in Color color) => (color.A, color.R, color.G, color.B); @@ -59,8 +62,9 @@ namespace RGB.NET.Core #region Add /// - /// Adds the given RGB values to this color. + /// Adds the specified RGB values to this color. /// + /// The color to modify. /// The red value to add. /// The green value to add. /// The blue value to add. @@ -69,8 +73,9 @@ namespace RGB.NET.Core => new(color.A, color.GetR() + r, color.GetG() + g, color.GetB() + b); /// - /// Adds the given RGB-percent values to this color. + /// Adds the specified RGB-percent values to this color. /// + /// The color to modify. /// The red value to add. /// The green value to add. /// The blue value to add. @@ -79,16 +84,18 @@ namespace RGB.NET.Core => new(color.A, color.R + r, color.G + g, color.B + b); /// - /// Adds the given alpha value to this color. + /// Adds the specified alpha value to this color. /// + /// The color to modify. /// The alpha value to add. /// The new color after the modification. public static Color AddA(this in Color color, int a) => new(color.GetA() + a, color.R, color.G, color.B); /// - /// Adds the given alpha-percent value to this color. + /// Adds the specified alpha-percent value to this color. /// + /// The color to modify. /// The alpha value to add. /// The new color after the modification. public static Color AddA(this in Color color, float a) @@ -99,8 +106,9 @@ namespace RGB.NET.Core #region Subtract /// - /// Subtracts the given RGB values to this color. + /// Subtracts the specified RGB values to this color. /// + /// The color to modify. /// The red value to subtract. /// The green value to subtract. /// The blue value to subtract. @@ -109,8 +117,9 @@ namespace RGB.NET.Core => new(color.A, color.GetR() - r, color.GetG() - g, color.GetB() - b); /// - /// Subtracts the given RGB values to this color. + /// Subtracts the specified RGB values to this color. /// + /// The color to modify. /// The red value to subtract. /// The green value to subtract. /// The blue value to subtract. @@ -119,17 +128,19 @@ namespace RGB.NET.Core => new(color.A, color.R - r, color.G - g, color.B - b); /// - /// Subtracts the given alpha value to this color. + /// Subtracts the specified alpha value to this color. /// + /// The color to modify. /// The alpha value to subtract. /// The new color after the modification. public static Color SubtractA(this in Color color, int a) => new(color.GetA() - a, color.R, color.G, color.B); /// - /// Subtracts the given alpha-percent value to this color. + /// Subtracts the specified alpha-percent value to this color. /// - /// The alpha value to subtract. + /// The color to modify. + /// The alpha value to subtract. /// The new color after the modification. public static Color SubtractA(this in Color color, float aPercent) => new(color.A - aPercent, color.R, color.G, color.B); @@ -139,8 +150,9 @@ namespace RGB.NET.Core #region Multiply /// - /// Multiplies the given RGB values to this color. + /// Multiplies the specified RGB values to this color. /// + /// The color to modify. /// The red value to multiply. /// The green value to multiply. /// The blue value to multiply. @@ -149,8 +161,9 @@ namespace RGB.NET.Core => new(color.A, color.R * r, color.G * g, color.B * b); /// - /// Multiplies the given alpha value to this color. + /// Multiplies the specified alpha value to this color. /// + /// The color to modify. /// The alpha value to multiply. /// The new color after the modification. public static Color MultiplyA(this in Color color, float a) @@ -161,8 +174,9 @@ namespace RGB.NET.Core #region Divide /// - /// Divides the given RGB values to this color. + /// Divides the specified RGB values to this color. /// + /// The color to modify. /// The red value to divide. /// The green value to divide. /// The blue value to divide. @@ -171,8 +185,9 @@ namespace RGB.NET.Core => new(color.A, color.R / r, color.G / g, color.B / b); /// - /// Divides the given alpha value to this color. + /// Divides the specified alpha value to this color. /// + /// The color to modify. /// The alpha value to divide. /// The new color after the modification. public static Color DivideA(this in Color color, float a) @@ -183,8 +198,9 @@ namespace RGB.NET.Core #region Set /// - /// Sets the given RGB value of this color. + /// Sets the specified RGB value of this color. /// + /// The color to modify. /// The red value to set. /// The green value to set. /// The blue value to set. @@ -193,8 +209,9 @@ namespace RGB.NET.Core => new(color.A, r ?? color.GetR(), g ?? color.GetG(), b ?? color.GetB()); /// - /// Sets the given RGB value of this color. + /// Sets the specified RGB value of this color. /// + /// The color to modify. /// The red value to set. /// The green value to set. /// The blue value to set. @@ -203,8 +220,9 @@ namespace RGB.NET.Core => new(color.A, r ?? color.GetR(), g ?? color.GetG(), b ?? color.GetB()); /// - /// Sets the given RGB value of this color. + /// Sets the specified RGB value of this color. /// + /// The color to modify. /// The red value to set. /// The green value to set. /// The blue value to set. @@ -213,15 +231,17 @@ namespace RGB.NET.Core => new(color.A, r ?? color.R, g ?? color.G, b ?? color.B); /// - /// Sets the given alpha value of this color. + /// Sets the specified alpha value of this color. /// + /// The color to modify. /// The alpha value to set. /// The new color after the modification. public static Color SetA(this in Color color, int a) => new(a, color.R, color.G, color.B); /// - /// Sets the given alpha value of this color. + /// Sets the specified alpha value of this color. /// + /// The color to modify. /// The alpha value to set. /// The new color after the modification. public static Color SetA(this in Color color, float a) => new(a, color.R, color.G, color.B); diff --git a/RGB.NET.Core/Color/XYZColor.cs b/RGB.NET.Core/Color/XYZColor.cs index d02329e..97363a8 100644 --- a/RGB.NET.Core/Color/XYZColor.cs +++ b/RGB.NET.Core/Color/XYZColor.cs @@ -4,6 +4,9 @@ using System; namespace RGB.NET.Core { + /// + /// Contains helper-methods and extension for the -type to work in the XYZ color space. + /// public static class XYZColor { #region Getter @@ -11,22 +14,22 @@ namespace RGB.NET.Core /// /// Gets the X component value (XYZ-color space) of this in the range [0..95.047]. /// - /// - /// + /// The color to get the value from. + /// The X component value of the color. public static float GetX(this in Color color) => color.GetXYZ().x; /// /// Gets the Y component value (XYZ-color space) of this in the range [0..100]. /// - /// - /// + /// The color to get the value from. + /// The Y component value of the color. public static float GetY(this in Color color) => color.GetXYZ().y; /// /// Gets the Z component value (XYZ-color space) of this in the range [0..108.883]. /// - /// - /// + /// The color to get the value from. + /// The Z component value of the color. public static float GetZ(this in Color color) => color.GetXYZ().z; /// @@ -35,8 +38,8 @@ namespace RGB.NET.Core /// Y in the range [0..100]. /// Z in the range [0..108.883]. /// - /// - /// + /// The color to get the value from. + /// A tuple containing the X, Y and Z component value of the color. public static (float x, float y, float z) GetXYZ(this in Color color) => CaclulateXYZFromRGB(color.R, color.G, color.B); @@ -45,8 +48,9 @@ namespace RGB.NET.Core #region Manipulation /// - /// Adds the given XYZ values to this color. + /// Adds the specified XYZ values to this color. /// + /// The color to modify. /// The X value to add. /// The Y value to add. /// The Z value to add. @@ -58,8 +62,9 @@ namespace RGB.NET.Core } /// - /// Subtracts the given XYZ values to this color. + /// Subtracts the specified XYZ values to this color. /// + /// The color to modify. /// The X value to subtract. /// The Y value to subtract. /// The Z value to subtract. @@ -71,8 +76,9 @@ namespace RGB.NET.Core } /// - /// Multiplies the given XYZ values to this color. + /// Multiplies the specified XYZ values to this color. /// + /// The color to modify. /// The X value to multiply. /// The Y value to multiply. /// The Z value to multiply. @@ -84,8 +90,9 @@ namespace RGB.NET.Core } /// - /// Divides the given XYZ values to this color. + /// Divides the specified XYZ values to this color. /// + /// The color to modify. /// The X value to divide. /// The Y value to divide. /// The Z value to divide. @@ -97,16 +104,17 @@ namespace RGB.NET.Core } /// - /// Sets the given X valueof this color. + /// Sets the specified X valueof this color. /// + /// The color to modify. /// The X value to set. /// The Y value to set. /// The Z value to set. /// The new color after the modification. - public static Color SetXYZ(this in Color color, float? x = null, float? y = null, float? value = null) + public static Color SetXYZ(this in Color color, float? x = null, float? y = null, float? z = null) { (float cX, float cY, float cZ) = color.GetXYZ(); - return Create(color.A, x ?? cX, y ?? cY, value ?? cZ); + return Create(color.A, x ?? cX, y ?? cY, z ?? cZ); } #endregion diff --git a/RGB.NET.Core/ColorCorrection/IColorCorrection.cs b/RGB.NET.Core/ColorCorrection/IColorCorrection.cs index f738f5a..c61cc7f 100644 --- a/RGB.NET.Core/ColorCorrection/IColorCorrection.cs +++ b/RGB.NET.Core/ColorCorrection/IColorCorrection.cs @@ -8,7 +8,7 @@ namespace RGB.NET.Core public interface IColorCorrection { /// - /// Applies the to the given . + /// Applies the to the specified . /// /// The to correct. void ApplyTo(ref Color color); diff --git a/RGB.NET.Core/Decorators/AbstractUpdateAwareDecorator.cs b/RGB.NET.Core/Decorators/AbstractUpdateAwareDecorator.cs index 7217d25..6552510 100644 --- a/RGB.NET.Core/Decorators/AbstractUpdateAwareDecorator.cs +++ b/RGB.NET.Core/Decorators/AbstractUpdateAwareDecorator.cs @@ -8,6 +8,9 @@ { #region Properties & Fields + /// + /// Gets the surface this decorator is attached to. + /// protected RGBSurface Surface { get; } /// @@ -22,6 +25,7 @@ /// /// Initializes a new instance of the class. /// + /// The surface this decorator is attached to. /// Bool indicating if the should call even if the Decorator is disabled. protected AbstractUpdateAwareDecorator(RGBSurface surface, bool updateIfDisabled = false) { diff --git a/RGB.NET.Core/Decorators/IDecorator.cs b/RGB.NET.Core/Decorators/IDecorator.cs index 1e9acdd..e955d3f 100644 --- a/RGB.NET.Core/Decorators/IDecorator.cs +++ b/RGB.NET.Core/Decorators/IDecorator.cs @@ -23,13 +23,13 @@ #region Methods /// - /// Attaches this to the given target. + /// Attaches this to the specified target. /// /// The object this should be attached to. void OnAttached(IDecoratable decoratable); /// - /// Detaches this from the given target. + /// Detaches this from the specified target. /// /// The object this should be detached from. void OnDetached(IDecoratable decoratable); diff --git a/RGB.NET.Core/Devices/AbstractRGBDevice.cs b/RGB.NET.Core/Devices/AbstractRGBDevice.cs index 4505c42..f851f41 100644 --- a/RGB.NET.Core/Devices/AbstractRGBDevice.cs +++ b/RGB.NET.Core/Devices/AbstractRGBDevice.cs @@ -52,6 +52,9 @@ namespace RGB.NET.Core /// protected Dictionary LedMapping { get; } = new(); + /// + /// Gets the update queue used to update this device. + /// protected IUpdateQueue UpdateQueue { get; } #region Indexer @@ -72,6 +75,11 @@ namespace RGB.NET.Core #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The device info of this device. + /// The queue used to update this device. protected AbstractRGBDevice(TDeviceInfo deviceInfo, IUpdateQueue updateQueue) { this.DeviceInfo = deviceInfo; @@ -97,7 +105,22 @@ namespace RGB.NET.Core UpdateLeds(ledsToUpdate); } + /// + /// Gets an enumerable of LEDs that are changed and requires an update. + /// + /// Forces all LEDs to be treated as dirty. + /// The collection LEDs to update. protected virtual IEnumerable GetLedsToUpdate(bool flushLeds) => ((RequiresFlush || flushLeds) ? LedMapping.Values : LedMapping.Values.Where(x => x.IsDirty)).Where(led => led.RequestedColor?.A > 0); + + /// + /// Gets an enumerable of a custom data and color tuple for the specified leds. + /// + /// + /// Applies all . + /// if no ist specified the is used. + /// + /// The enumerable of leds to convert. + /// The enumerable of custom data and color tuples for the specified leds. protected virtual IEnumerable<(object key, Color color)> GetUpdateData(IEnumerable leds) { if (ColorCorrections.Count > 0) @@ -145,13 +168,7 @@ namespace RGB.NET.Core protected virtual void DeviceUpdate() { } - /// - /// Initializes the with the specified id. - /// - /// The to initialize. - /// The location of the to initialize. - /// The size of the to initialize. - /// The initialized led. + /// public virtual Led? AddLed(LedId ledId, in Point location, in Size size, object? customData = null) { if ((ledId == LedId.Invalid) || LedMapping.ContainsKey(ledId)) return null; @@ -161,6 +178,7 @@ namespace RGB.NET.Core return led; } + /// public virtual Led? RemoveLed(LedId ledId) { if (ledId == LedId.Invalid) return null; @@ -170,8 +188,19 @@ namespace RGB.NET.Core return led; } + /// + /// + /// + /// + /// protected virtual object? GetLedCustomData(LedId ledId) => null; + /// + /// Called when the device is attached to a surface. + /// + /// + /// When overriden base should be called to validate boundries. + /// protected virtual void OnAttached() { if (Location == Point.Invalid) Location = new Point(0, 0); @@ -182,6 +211,9 @@ namespace RGB.NET.Core } } + /// + /// Called when the device is detached from a surface. + /// protected virtual void OnDetached() { } #region Enumerator diff --git a/RGB.NET.Core/Devices/AbstractRGBDeviceProvider.cs b/RGB.NET.Core/Devices/AbstractRGBDeviceProvider.cs index e81f72c..81ac6f2 100644 --- a/RGB.NET.Core/Devices/AbstractRGBDeviceProvider.cs +++ b/RGB.NET.Core/Devices/AbstractRGBDeviceProvider.cs @@ -5,31 +5,48 @@ using System.Linq; namespace RGB.NET.Core { + /// + /// Represents the abstract base implementation for a . + /// public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider { #region Properties & Fields private readonly double _defaultUpdateRateHardLimit; + /// public bool IsInitialized { get; protected set; } + + /// public bool ThrowsExceptions { get; protected set; } + /// public virtual IEnumerable Devices { get; protected set; } = Enumerable.Empty(); + /// + /// Gets the dictionary containing the registered update triggers. + /// Normally should be used to access them. + /// protected Dictionary UpdateTriggerMapping { get; } = new(); + /// public ReadOnlyCollection<(int id, IDeviceUpdateTrigger trigger)> UpdateTriggers => new(UpdateTriggerMapping.Select(x => (x.Key, x.Value)).ToList()); #endregion #region Events + /// public event EventHandler? Exception; #endregion #region Constructors - + + /// + /// Initializes a new instance of the class. + /// + /// The update rate hard limit all update triggers for this device provider are initialized with. protected AbstractRGBDeviceProvider(double defaultUpdateRateHardLimit = 0) { this._defaultUpdateRateHardLimit = defaultUpdateRateHardLimit; @@ -39,6 +56,7 @@ namespace RGB.NET.Core #region Methods + /// public bool Initialize(RGBDeviceType loadFilter = RGBDeviceType.All, bool throwExceptions = false) { ThrowsExceptions = throwExceptions; @@ -71,6 +89,14 @@ namespace RGB.NET.Core return true; } + /// + /// Loads devices and returns a filtered list of them. + /// + /// + /// The underlying loading of the devices happens in . + /// + /// -flags to filter the device with. + /// The filtered collection of loaded devices. protected virtual IEnumerable GetLoadedDevices(RGBDeviceType loadFilter) { List devices = new(); @@ -92,10 +118,29 @@ namespace RGB.NET.Core return devices; } + /// + /// Initializes the underlying SDK. + /// protected abstract void InitializeSDK(); + /// + /// Loads all devices this device provider is capable of loading. + /// + /// + /// Filtering happens in . + /// + /// A collection of loaded devices. protected abstract IEnumerable LoadDevices(); + /// + /// Gets the mapped to the specified id or a new one if the id wasn't requested before. + /// + /// + /// The creation of the update trigger happens in . + /// + /// The id of the update trigger. + /// The update rate hard limit to be set in the update trigger. + /// The update trigger mapped to the specified id. protected virtual IDeviceUpdateTrigger GetUpdateTrigger(int id = -1, double? updateRateHardLimit = null) { if (!UpdateTriggerMapping.TryGetValue(id, out IDeviceUpdateTrigger? updaeTrigger)) @@ -104,8 +149,18 @@ namespace RGB.NET.Core return updaeTrigger; } + /// + /// Creates a update trigger with the specified id and the specified update rate hard limit. + /// + /// The id of the update trigger. + /// The update rate hard limit tobe set in the update trigger. + /// The newly created update trigger. protected virtual IDeviceUpdateTrigger CreateUpdateTrigger(int id, double updateRateHardLimit) => new DeviceUpdateTrigger(updateRateHardLimit); + + /// + /// Resets the device provider and disposes all devices and update triggers. + /// protected virtual void Reset() { foreach (IDeviceUpdateTrigger updateTrigger in UpdateTriggerMapping.Values) @@ -115,9 +170,15 @@ namespace RGB.NET.Core device.Dispose(); Devices = Enumerable.Empty(); + UpdateTriggerMapping.Clear(); IsInitialized = false; } + /// + /// Triggers the -event and throws the specified exception if is true and it is not overriden in the event. + /// + /// The exception to throw. + /// Indicates if the exception is critical for device provider to work correctly. protected virtual void Throw(Exception ex, bool isCritical = false) { ExceptionEventArgs args = new(ex, isCritical, ThrowsExceptions); @@ -127,9 +188,19 @@ namespace RGB.NET.Core throw new DeviceProviderException(ex, isCritical); } + /// + /// Throws the event. + /// + /// The parameters passed to the event. protected virtual void OnException(ExceptionEventArgs args) => Exception?.Invoke(this, args); - public virtual void Dispose() => Reset(); + /// + public virtual void Dispose() + { + Reset(); + + GC.SuppressFinalize(this); + } #endregion } diff --git a/RGB.NET.Core/Devices/IRGBDevice.cs b/RGB.NET.Core/Devices/IRGBDevice.cs index 983d54d..28c2dde 100644 --- a/RGB.NET.Core/Devices/IRGBDevice.cs +++ b/RGB.NET.Core/Devices/IRGBDevice.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; namespace RGB.NET.Core { - /// + /// /// /// /// @@ -13,6 +13,9 @@ namespace RGB.NET.Core { #region Properties + /// + /// Gets the surface this device is attached to. + /// RGBSurface? Surface { get; internal set; } /// @@ -20,6 +23,9 @@ namespace RGB.NET.Core /// IRGBDeviceInfo DeviceInfo { get; } + /// + /// Gets a list of color corrections applied to this device. + /// IList ColorCorrections { get; } #endregion @@ -34,14 +40,14 @@ namespace RGB.NET.Core Led? this[LedId ledId] { get; } /// - /// Gets the at the given physical location. + /// Gets the at the specified physical location. /// /// The to get the location from. - /// The at the given or null if no location is found. + /// The at the specified or null if no location is found. Led? this[Point location] { get; } /// - /// Gets a list of inside the given . + /// Gets a list of inside the specified . /// /// The to check. /// The minimal percentage overlay a must have with the to be taken into the list. @@ -58,8 +64,21 @@ namespace RGB.NET.Core /// Specifies whether all (including clean ones) should be updated. void Update(bool flushLeds = false); + /// + /// Adds a led to the device. + /// + /// The id of the led. + /// The location of the led on the device. + /// The size of the led. + /// Custom data saved on the led. + /// The newly added led or null if a led with this id is already added. Led? AddLed(LedId ledId, in Point location, in Size size, object? customData = null); + /// + /// Removes the led with the specified id from the device. + /// + /// The id of the led to remove. + /// The removed led or null if there was no led with the specified id. Led? RemoveLed(LedId ledId); #endregion diff --git a/RGB.NET.Core/Devices/IRGBDeviceInfo.cs b/RGB.NET.Core/Devices/IRGBDeviceInfo.cs index 3bb29c2..10de56e 100644 --- a/RGB.NET.Core/Devices/IRGBDeviceInfo.cs +++ b/RGB.NET.Core/Devices/IRGBDeviceInfo.cs @@ -27,6 +27,9 @@ /// string Model { get; } + /// + /// Gets custom metadata added to the layout. + /// object? LayoutMetadata { get; set; } #endregion diff --git a/RGB.NET.Core/Devices/IRGBDeviceProvider.cs b/RGB.NET.Core/Devices/IRGBDeviceProvider.cs index cad53ce..d2a8d1d 100644 --- a/RGB.NET.Core/Devices/IRGBDeviceProvider.cs +++ b/RGB.NET.Core/Devices/IRGBDeviceProvider.cs @@ -19,10 +19,18 @@ namespace RGB.NET.Core bool IsInitialized { get; } /// - /// Gets a list of loaded by this . + /// Indicates if exceptions in the device provider are thrown or silently ignored. + /// + bool ThrowsExceptions { get; } + + /// + /// Gets a collection of loaded by this . /// IEnumerable Devices { get; } + /// + /// Gets a collection registered to this device provider. + /// ReadOnlyCollection<(int id, IDeviceUpdateTrigger trigger)> UpdateTriggers { get; } #endregion @@ -30,7 +38,7 @@ namespace RGB.NET.Core #region Events /// - /// Occurs when an exception is thrown in the device provider + /// Occurs when an exception is thrown in the device provider. /// event EventHandler? Exception; @@ -38,6 +46,12 @@ namespace RGB.NET.Core #region Methods + /// + /// Initializes the device provider and loads available devices. + /// + /// -flags to filter the devices to load. + /// Specifies if exceptions should be thrown or silently be ignored. + /// true if the initialization was successful; false otherwise. bool Initialize(RGBDeviceType loadFilter = RGBDeviceType.All, bool throwExceptions = false); #endregion diff --git a/RGB.NET.Core/Devices/KeyboardLayoutType.cs b/RGB.NET.Core/Devices/KeyboardLayoutType.cs index b763057..fec594c 100644 --- a/RGB.NET.Core/Devices/KeyboardLayoutType.cs +++ b/RGB.NET.Core/Devices/KeyboardLayoutType.cs @@ -1,6 +1,11 @@ // ReSharper disable InconsistentNaming +#pragma warning disable 1591 + namespace RGB.NET.Core { + /// + /// Contains a list of available keyboard layout types. + /// public enum KeyboardLayoutType { Unknown = 0, diff --git a/RGB.NET.Core/Devices/TypeInterfaces/IKeyboard.cs b/RGB.NET.Core/Devices/TypeInterfaces/IKeyboard.cs index dd28694..aec72f3 100644 --- a/RGB.NET.Core/Devices/TypeInterfaces/IKeyboard.cs +++ b/RGB.NET.Core/Devices/TypeInterfaces/IKeyboard.cs @@ -1,15 +1,24 @@ namespace RGB.NET.Core { /// - /// Represents a keyboard-device + /// Represents a generic keyboard-device. /// public interface IKeyboard : IRGBDevice { + /// + /// Gets the device information assiciated with this device. + /// new IKeyboardDeviceInfo DeviceInfo { get; } } + /// + /// Represents a generic keyboard device information. + /// public interface IKeyboardDeviceInfo : IRGBDeviceInfo { + /// + /// Gets the of the keyboard. + /// KeyboardLayoutType Layout { get; } } } diff --git a/RGB.NET.Core/Events/ExceptionEventArgs.cs b/RGB.NET.Core/Events/ExceptionEventArgs.cs index c5ae6bc..14ed9b0 100644 --- a/RGB.NET.Core/Events/ExceptionEventArgs.cs +++ b/RGB.NET.Core/Events/ExceptionEventArgs.cs @@ -18,8 +18,14 @@ namespace RGB.NET.Core /// public Exception Exception { get; } + /// + /// Gets a bool indicating if the exception is critical for the thrower. + /// public bool IsCritical { get; } + /// + /// Gets or sets if the exception should be thrown after the event is handled. + /// public bool Throw { get; set; } #endregion @@ -31,6 +37,8 @@ namespace RGB.NET.Core /// Initializes a new instance of the class. /// /// The which is responsible for the event-call. + /// Indicates if the exception is critical for the thrower. + /// Indicates if the exception should be thrown after the event is handled. public ExceptionEventArgs(Exception exception, bool isCritical = false, bool @throw = false) { this.Exception = exception; diff --git a/RGB.NET.Core/Events/ResolvePathEventArgs.cs b/RGB.NET.Core/Events/ResolvePathEventArgs.cs deleted file mode 100644 index 7257bf2..0000000 --- a/RGB.NET.Core/Events/ResolvePathEventArgs.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; - -namespace RGB.NET.Core -{ - public class ResolvePathEventArgs : EventArgs - { - #region Properties & Fields - - /// - /// Gets the filename used to resolve the path. - /// Also check before use. - /// - public string? RelativePart { get; } - - /// - /// Gets the filename used to resolve the path. - /// Also check before use. - /// - public string? FileName { get; } - - /// - /// Gets the relative path used to resolve the path. - /// If this is set and are unused. - /// - public string? RelativePath { get; } - - /// - /// Gets or sets the resolved path. - /// - public string FinalPath { get; set; } - - #endregion - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The filename used to resolve the path. - /// The filename used to resolve the path. - /// The relative part used to resolve the path. - public ResolvePathEventArgs(string relativePart, string fileName, string finalPath) - { - this.RelativePart = relativePart; - this.FileName = fileName; - this.FinalPath = finalPath; - } - - /// - /// Initializes a new instance of the class. - /// - /// The relative path used to resolve the path. - /// The relative part used to resolve the path. - public ResolvePathEventArgs(string relativePath, string finalPath) - { - this.RelativePath = relativePath; - this.FinalPath = finalPath; - } - - #endregion - } -} diff --git a/RGB.NET.Core/Events/SurfaceLayoutChangedEventArgs.cs b/RGB.NET.Core/Events/SurfaceLayoutChangedEventArgs.cs index e591385..8bbc6a2 100644 --- a/RGB.NET.Core/Events/SurfaceLayoutChangedEventArgs.cs +++ b/RGB.NET.Core/Events/SurfaceLayoutChangedEventArgs.cs @@ -43,7 +43,8 @@ namespace RGB.NET.Core /// /// The that caused the change. /// A value indicating if the event is caused by the addition of a new to the . - /// A value indicating if the event is caused by a changed location of one of the devices on the . + /// A value indicating if the event is caused by the removal of a from the . + /// A value indicating if the event is caused by a change to a on the . private SurfaceLayoutChangedEventArgs(IRGBDevice? devices, bool deviceAdded, bool deviceRemoved, bool deviceChanged) { this.Devices = devices; diff --git a/RGB.NET.Core/Exceptions/DeviceProviderException.cs b/RGB.NET.Core/Exceptions/DeviceProviderException.cs index f17afdb..6384f67 100644 --- a/RGB.NET.Core/Exceptions/DeviceProviderException.cs +++ b/RGB.NET.Core/Exceptions/DeviceProviderException.cs @@ -2,16 +2,28 @@ namespace RGB.NET.Core { + /// + /// + /// Represents an exception thrown by a . + /// public class DeviceProviderException : ApplicationException { #region Properties & Fields - private bool IsCritical { get; } + /// + /// Gets a bool indicating if the exception is critical and shouldn't be ingored. + /// + public bool IsCritical { get; } #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The exception that is the casue of the current exception or null if this exception was thrown on purpose. + /// A value indicating if the exception is critical and shouldn't be ignored. public DeviceProviderException(Exception? innerException, bool isCritical) : base(innerException?.Message, innerException) { diff --git a/RGB.NET.Core/Extensions/ColorExtensions.cs b/RGB.NET.Core/Extensions/ColorExtensions.cs index b905baf..bdca800 100644 --- a/RGB.NET.Core/Extensions/ColorExtensions.cs +++ b/RGB.NET.Core/Extensions/ColorExtensions.cs @@ -2,17 +2,20 @@ namespace RGB.NET.Core { + /// + /// Offers some extensions and helper-methods for related things. + /// public static class ColorExtensions { #region Methods /// - /// Calculates the distance between the two given colors using the redmean algorithm. + /// Calculates the distance between the two specified colors using the redmean algorithm. /// For more infos check https://www.compuphase.com/cmetric.htm /// /// The start color of the distance calculation. /// The end color fot the distance calculation. - /// + /// The redmean distance between the two specified colors. public static double DistanceTo(this in Color color1, in Color color2) { (_, byte r1, byte g1, byte b1) = color1.GetRGBBytes(); diff --git a/RGB.NET.Core/Extensions/MathExtensions.cs b/RGB.NET.Core/Extensions/MathExtensions.cs index ad098bf..a656e70 100644 --- a/RGB.NET.Core/Extensions/MathExtensions.cs +++ b/RGB.NET.Core/Extensions/MathExtensions.cs @@ -4,7 +4,7 @@ using System.Runtime.CompilerServices; namespace RGB.NET.Core { /// - /// Offers some extensions and helper-methods for the work with floats + /// Offers some extensions and helper-methods for the work with floats. /// public static class FloatExtensions { @@ -83,18 +83,28 @@ namespace RGB.NET.Core return value; } + /// + /// Converts a normalized float value in the range [0..1] to a byte [0..255]. + /// + /// The normalized float value to convert. + /// The byte value. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte GetByteValueFromPercentage(this float percentage) { if (float.IsNaN(percentage)) return 0; percentage = percentage.Clamp(0, 1.0f); - return (byte)(percentage >= 1.0 ? 255 : percentage * 256.0); + return (byte)(percentage >= 1.0f ? 255 : percentage * 256.0f); } + /// + /// Converts a byte value [0..255] to a normalized float value in the range [0..1]. + /// + /// The byte value to convert. + /// The normalized float value. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float GetPercentageFromByteValue(this byte value) - => ((float)value) / byte.MaxValue; + => value == 255 ? 1.0f : (value / 256.0f); #endregion } diff --git a/RGB.NET.Core/Extensions/PointExtensions.cs b/RGB.NET.Core/Extensions/PointExtensions.cs index 3fdf7a7..73e52e9 100644 --- a/RGB.NET.Core/Extensions/PointExtensions.cs +++ b/RGB.NET.Core/Extensions/PointExtensions.cs @@ -2,12 +2,15 @@ namespace RGB.NET.Core { + /// + /// Offers some extensions and helper-methods for related things. + /// public static class PointExtensions { #region Methods /// - /// Moves the specified by the given amount. + /// Moves the specified by the specified amount. /// /// The to move. /// The x-ammount to move. @@ -16,7 +19,7 @@ namespace RGB.NET.Core public static Point Translate(this in Point point, float x = 0, float y = 0) => new(point.X + x, point.Y + y); /// - /// Rotates the specified by the given amuont around the given origin. + /// Rotates the specified by the specified amuont around the specified origin. /// /// The to rotate. /// The rotation. diff --git a/RGB.NET.Core/Extensions/RectangleExtensions.cs b/RGB.NET.Core/Extensions/RectangleExtensions.cs index ce5745e..4b7104a 100644 --- a/RGB.NET.Core/Extensions/RectangleExtensions.cs +++ b/RGB.NET.Core/Extensions/RectangleExtensions.cs @@ -2,12 +2,15 @@ namespace RGB.NET.Core { + /// + /// Offers some extensions and helper-methods for the work with rectangles. + /// public static class RectangleExtensions { #region Methods /// - /// Sets the of the given rectangle. + /// Sets the of the specified rectangle. /// /// The rectangle to modify. /// The new location of the rectangle. @@ -15,7 +18,7 @@ namespace RGB.NET.Core public static Rectangle SetLocation(this in Rectangle rect, in Point location) => new(location, rect.Size); /// - /// Sets the of the of the given rectangle. + /// Sets the of the of the specified rectangle. /// /// The rectangle to modify. /// The new x-location of the rectangle. @@ -23,7 +26,7 @@ namespace RGB.NET.Core public static Rectangle SetX(this in Rectangle rect, float x) => new(new Point(x, rect.Location.Y), rect.Size); /// - /// Sets the of the of the given rectangle. + /// Sets the of the of the specified rectangle. /// /// The rectangle to modify. /// The new y-location of the rectangle. @@ -31,7 +34,7 @@ namespace RGB.NET.Core public static Rectangle SetY(this in Rectangle rect, float y) => new(new Point(rect.Location.X, y), rect.Size); /// - /// Sets the of the given rectangle. + /// Sets the of the specified rectangle. /// /// The rectangle to modify. /// The new size of the rectangle. @@ -39,7 +42,7 @@ namespace RGB.NET.Core public static Rectangle SetSize(this in Rectangle rect, in Size size) => new(rect.Location, size); /// - /// Sets the of the of the given rectangle. + /// Sets the of the of the specified rectangle. /// /// The rectangle to modify. /// The new width of the rectangle. @@ -47,7 +50,7 @@ namespace RGB.NET.Core public static Rectangle SetWidth(this in Rectangle rect, float width) => new(rect.Location, new Size(width, rect.Size.Height)); /// - /// Sets the of the of the given rectangle. + /// Sets the of the of the specified rectangle. /// /// The rectangle to modify. /// The new height of the rectangle. @@ -57,6 +60,7 @@ namespace RGB.NET.Core /// /// Calculates the percentage of intersection of a rectangle. /// + /// The rectangle to calculate the intersection for. /// The intersecting rectangle. /// The percentage of intersection. public static float CalculateIntersectPercentage(this in Rectangle rect, in Rectangle intersectingRect) @@ -70,6 +74,7 @@ namespace RGB.NET.Core /// /// Calculates the representing the intersection of this and the one provided as parameter. /// + /// The rectangle to calculate the intersection for. /// The intersecting /// A new representing the intersection this and the one provided as parameter. public static Rectangle CalculateIntersection(this in Rectangle rect, in Rectangle intersectingRectangle) @@ -89,29 +94,32 @@ namespace RGB.NET.Core /// /// Determines if the specified is contained within this . /// + /// The containing rectangle. /// The to test. - /// true if the rectangle contains the given point; otherwise false. + /// true if the rectangle contains the specified point; otherwise false. public static bool Contains(this in Rectangle rect, in Point point) => rect.Contains(point.X, point.Y); /// /// Determines if the specified location is contained within this . /// + /// The containing rectangle. /// The X-location to test. /// The Y-location to test. - /// true if the rectangle contains the given coordinates; otherwise false. + /// true if the rectangle contains the specified coordinates; otherwise false. public static bool Contains(this in Rectangle rect, float x, float y) => (rect.Location.X <= x) && (x < (rect.Location.X + rect.Size.Width)) - && (rect.Location.Y <= y) && (y < (rect.Location.Y + rect.Size.Height)); + && (rect.Location.Y <= y) && (y < (rect.Location.Y + rect.Size.Height)); /// /// Determines if the specified is contained within this . /// - /// The to test. - /// true if the rectangle contains the given rect; otherwise false. + /// The containing rectangle. + /// The to test. + /// true if the rectangle contains the specified rect; otherwise false. public static bool Contains(this in Rectangle rect, in Rectangle rect2) => (rect.Location.X <= rect2.Location.X) && ((rect2.Location.X + rect2.Size.Width) <= (rect.Location.X + rect.Size.Width)) - && (rect.Location.Y <= rect2.Location.Y) && ((rect2.Location.Y + rect2.Size.Height) <= (rect.Location.Y + rect.Size.Height)); + && (rect.Location.Y <= rect2.Location.Y) && ((rect2.Location.Y + rect2.Size.Height) <= (rect.Location.Y + rect.Size.Height)); /// - /// Moves the specified by the given amount. + /// Moves the specified by the specified amount. /// /// The to move. /// The amount to move. @@ -119,7 +127,7 @@ namespace RGB.NET.Core public static Rectangle Translate(this in Rectangle rect, in Point point) => rect.Translate(point.X, point.Y); /// - /// Moves the specified by the given amount. + /// Moves the specified by the specified amount. /// /// The to move. /// The x-ammount to move. @@ -128,7 +136,7 @@ namespace RGB.NET.Core public static Rectangle Translate(this in Rectangle rect, float x = 0, float y = 0) => new(rect.Location.Translate(x, y), rect.Size); /// - /// Rotates the specified by the given amuont around the given origin. + /// Rotates the specified by the specified amuont around the specified origin. /// /// /// The returned array of is filled with the new locations of the rectangle clockwise starting from the top left: diff --git a/RGB.NET.Core/Extensions/SurfaceExtensions.cs b/RGB.NET.Core/Extensions/SurfaceExtensions.cs index fb53fc0..8b789e8 100644 --- a/RGB.NET.Core/Extensions/SurfaceExtensions.cs +++ b/RGB.NET.Core/Extensions/SurfaceExtensions.cs @@ -5,10 +5,20 @@ using System.Linq; namespace RGB.NET.Core { + /// + /// Offers some extensions and helper-methods for the work with the surface. + /// public static class SurfaceExtensions { #region Methods + /// + /// Initializes the specifiec device provider and attaches all devices. + /// + /// The surface to attach the devices to. + /// The device provider to load. + /// -flags to filter the devices to load. + /// Specifies if exceptions should be thrown or silently be ignored. public static void Load(this RGBSurface surface, IRGBDeviceProvider deviceProvider, RGBDeviceType loadFilter = RGBDeviceType.All, bool throwExceptions = false) { if (!deviceProvider.IsInitialized) @@ -17,13 +27,22 @@ namespace RGB.NET.Core surface.Attach(deviceProvider.Devices); } - + /// + /// Attaches the specified devices to the surface. + /// + /// The surface the devices are attached to. + /// The devices to attach. public static void Attach(this RGBSurface surface, IEnumerable devices) { foreach (IRGBDevice device in devices) surface.Attach(device); } + /// + /// Detaches the specified devices from the surface. + /// + /// The surface the devices are detached from. + /// The devices to detach. public static void Detach(this RGBSurface surface, IEnumerable devices) { foreach (IRGBDevice device in devices) @@ -42,6 +61,7 @@ namespace RGB.NET.Core /// /// Gets all devices of the specified . /// + /// The surface to get the devices from. /// The of the devices to get. /// A collection of devices matching the specified . public static IEnumerable GetDevices(this RGBSurface surface, RGBDeviceType deviceType) diff --git a/RGB.NET.Core/Groups/AbstractLedGroup.cs b/RGB.NET.Core/Groups/AbstractLedGroup.cs index c035937..c42de03 100644 --- a/RGB.NET.Core/Groups/AbstractLedGroup.cs +++ b/RGB.NET.Core/Groups/AbstractLedGroup.cs @@ -13,6 +13,8 @@ namespace RGB.NET.Core #region Properties & Fields RGBSurface? ILedGroup.Surface { get; set; } + + /// public RGBSurface? Surface => ((ILedGroup)this).Surface; /// @@ -37,6 +39,10 @@ namespace RGB.NET.Core #region Methods + /// + /// Gets a enumerable containing all leds in this group. + /// + /// protected abstract IEnumerable GetLeds(); /// diff --git a/RGB.NET.Core/Groups/ILedGroup.cs b/RGB.NET.Core/Groups/ILedGroup.cs index adcf9b7..94d4a95 100644 --- a/RGB.NET.Core/Groups/ILedGroup.cs +++ b/RGB.NET.Core/Groups/ILedGroup.cs @@ -10,8 +10,14 @@ namespace RGB.NET.Core /// public interface ILedGroup : IDecoratable, IEnumerable { + /// + /// Gets the surface this group is attached to or null if it is not attached to any surface. + /// RGBSurface? Surface { get; internal set; } + /// + /// Gets a bool indicating if the group is attached to a surface. + /// bool IsAttached => Surface != null; /// diff --git a/RGB.NET.Core/Groups/LedGroupExtension.cs b/RGB.NET.Core/Groups/LedGroupExtension.cs index 3d29d4c..5565d59 100644 --- a/RGB.NET.Core/Groups/LedGroupExtension.cs +++ b/RGB.NET.Core/Groups/LedGroupExtension.cs @@ -9,7 +9,7 @@ namespace RGB.NET.Core public static class LedGroupExtension { /// - /// Converts the given to a . + /// Converts the specified to a . /// /// The to convert. /// The converted . @@ -26,7 +26,7 @@ namespace RGB.NET.Core } /// - /// Returns a new which contains all from the given excluding the specified ones. + /// Returns a new which contains all from the specified excluding the specified ones. /// /// The base . /// The to exclude. @@ -41,14 +41,15 @@ namespace RGB.NET.Core // ReSharper disable once UnusedMethodReturnValue.Global /// - /// Attaches the given to the . + /// Attaches the specified to the . /// /// The to attach. + /// The to attach this group to. /// true if the could be attached; otherwise, false. public static bool Attach(this ILedGroup ledGroup, RGBSurface surface) => surface.Attach(ledGroup); /// - /// Detaches the given from the . + /// Detaches the specified from the . /// /// The to attach. /// true if the could be detached; otherwise, false. diff --git a/RGB.NET.Core/Groups/ListLedGroup.cs b/RGB.NET.Core/Groups/ListLedGroup.cs index 06e28ae..872c492 100644 --- a/RGB.NET.Core/Groups/ListLedGroup.cs +++ b/RGB.NET.Core/Groups/ListLedGroup.cs @@ -26,7 +26,7 @@ namespace RGB.NET.Core /// /// Initializes a new instance of the class. /// - /// Specifies whether this should be automatically attached or not. + /// Specifies the surface to attach this group to or null if the group should not be attached on creation. public ListLedGroup(RGBSurface? surface) : base(surface) { } @@ -35,7 +35,7 @@ namespace RGB.NET.Core /// /// Initializes a new instance of the class. /// - /// Specifies whether this should be automatically attached or not. + /// Specifies the surface to attach this group to or null if the group should not be attached on creation. /// The initial of this . public ListLedGroup(RGBSurface? surface, IEnumerable leds) : base(surface) @@ -47,7 +47,7 @@ namespace RGB.NET.Core /// /// Initializes a new instance of the class. /// - /// Specifies whether this should be automatically attached or not. + /// Specifies the surface to attach this group to or null if the group should not be attached on creation. /// The initial of this . public ListLedGroup(RGBSurface? surface, params Led[] leds) : base(surface) @@ -60,13 +60,13 @@ namespace RGB.NET.Core #region Methods /// - /// Adds the given LED(s) to this . + /// Adds the specified LED(s) to this . /// /// The LED(s) to add. public void AddLed(params Led[] leds) => AddLeds(leds); /// - /// Adds the given to this . + /// Adds the specified to this . /// /// The to add. public void AddLeds(IEnumerable leds) @@ -78,13 +78,13 @@ namespace RGB.NET.Core } /// - /// Removes the given LED(s) from this . + /// Removes the specified LED(s) from this . /// /// The LED(s) to remove. public void RemoveLed(params Led[] leds) => RemoveLeds(leds); /// - /// Removes the given from this . + /// Removes the specified from this . /// /// The to remove. public void RemoveLeds(IEnumerable leds) @@ -95,7 +95,7 @@ namespace RGB.NET.Core } /// - /// Checks if a given LED is contained by this ledgroup. + /// Checks if a specified LED is contained by this ledgroup. /// /// The LED which should be checked. /// true if the LED is contained by this ledgroup; otherwise, false. @@ -106,7 +106,7 @@ namespace RGB.NET.Core } /// - /// Merges the from the given ledgroup in this ledgroup. + /// Merges the from the specified ledgroup in this ledgroup. /// /// The ledgroup to merge. public void MergeLeds(ILedGroup groupToMerge) diff --git a/RGB.NET.Core/Helper/DeviceHelper.cs b/RGB.NET.Core/Helper/DeviceHelper.cs index cb2f358..99dbb96 100644 --- a/RGB.NET.Core/Helper/DeviceHelper.cs +++ b/RGB.NET.Core/Helper/DeviceHelper.cs @@ -3,10 +3,22 @@ using System.Runtime.CompilerServices; namespace RGB.NET.Core { + /// + /// Offsers some helper methods for device creation. + /// public static class DeviceHelper { #region Methods + /// + /// Creates a unique device name from a manufacturer and model name. + /// + /// + /// The id is made unique based on the assembly calling this method. + /// + /// The manufacturer of the device. + /// The model of the device. + /// The unique identifier for this device. [MethodImpl(MethodImplOptions.NoInlining)] public static string CreateDeviceName(string manufacturer, string model) => IdGenerator.MakeUnique(Assembly.GetCallingAssembly(), $"{manufacturer} {model}"); diff --git a/RGB.NET.Core/Ids/IdGenerator.cs b/RGB.NET.Core/Ids/IdGenerator.cs index cb68c41..27f21c4 100644 --- a/RGB.NET.Core/Ids/IdGenerator.cs +++ b/RGB.NET.Core/Ids/IdGenerator.cs @@ -4,6 +4,9 @@ using System.Runtime.CompilerServices; namespace RGB.NET.Core { + /// + /// Offers some methods to create and handle unique identifiers. + /// public static class IdGenerator { #region Properties & Fields @@ -18,6 +21,11 @@ namespace RGB.NET.Core #region Methods + /// + /// Makes the specified id unique based on the calling assembly by adding a counter if needed. + /// + /// The id to make unique. + /// The unique id. [MethodImpl(MethodImplOptions.NoInlining)] public static string MakeUnique(string id) => MakeUnique(Assembly.GetCallingAssembly(), id); @@ -49,6 +57,10 @@ namespace RGB.NET.Core return counter <= 1 ? mappedId : $"{mappedId} ({counter})"; } + /// + /// Resets the counter used to create unique ids. + /// All previous generated ids are not garantueed to stay unique if this is called! + /// [MethodImpl(MethodImplOptions.NoInlining)] public static void ResetCounter() => ResetCounter(Assembly.GetCallingAssembly()); diff --git a/RGB.NET.Core/Leds/Led.cs b/RGB.NET.Core/Leds/Led.cs index 33ea3da..4717724 100644 --- a/RGB.NET.Core/Leds/Led.cs +++ b/RGB.NET.Core/Leds/Led.cs @@ -96,6 +96,9 @@ namespace RGB.NET.Core /// public object? CustomData { get; } + /// + /// Gets or sets some custom metadata of this led. + /// public object? LayoutMetadata { get; set; } #endregion @@ -124,6 +127,7 @@ namespace RGB.NET.Core #region Methods + /// protected override void UpdateActualPlaceableData() { base.UpdateActualPlaceableData(); diff --git a/RGB.NET.Core/Leds/LedMapping.cs b/RGB.NET.Core/Leds/LedMapping.cs index 0c980d1..d75802a 100644 --- a/RGB.NET.Core/Leds/LedMapping.cs +++ b/RGB.NET.Core/Leds/LedMapping.cs @@ -4,6 +4,10 @@ using System.Linq; namespace RGB.NET.Core { + /// + /// Represents a mapping from to a custom identifier. + /// + /// The identifier the is mapped to. public class LedMapping : IEnumerable<(LedId ledId, T mapping)> where T : notnull { @@ -12,15 +16,30 @@ namespace RGB.NET.Core private readonly Dictionary _mapping = new(); private readonly Dictionary _reverseMapping = new(); + /// + /// Gets the number of entries in this mapping. + /// public int Count => _mapping.Count; + /// + /// Gets a collection of all mapped ledids. + /// public ICollection LedIds => _mapping.Keys; + + /// + /// Gets a collection of all mapped custom identifiers. + /// public ICollection Mappings => _reverseMapping.Keys; #endregion #region Indexer + /// + /// Gets the custom identifier mapped to the specified . + /// + /// The led id to get the mapped identifier. + /// The mapped ifentifier. public T this[LedId ledId] { get => _mapping[ledId]; @@ -31,6 +50,11 @@ namespace RGB.NET.Core } } + /// + /// Gets the mapped to the specified custom identifier. + /// + /// The custom identifier to get the mapped led id. + /// The led id. public LedId this[T mapping] { get => _reverseMapping[mapping]; @@ -41,18 +65,52 @@ namespace RGB.NET.Core #region Methods + /// + /// Adds a new entry to the mapping. + /// + /// The to map. + /// The custom identifier to map. public void Add(LedId ledId, T mapping) { _mapping.Add(ledId, mapping); _reverseMapping.Add(mapping, ledId); } + /// + /// Checks if the specified is mapped. + /// + /// The led id to check. + /// true if the led id is mapped; otherwise false. public bool Contains(LedId ledId) => _mapping.ContainsKey(ledId); + + /// + /// Checks if the specified custom identifier is mapped. + /// + /// The custom identifier to check. + /// true if the led id is mapped; otherwise false. public bool Contains(T mapping) => _reverseMapping.ContainsKey(mapping); + /// + /// Gets the custom identifier mapped to the specified led id. + /// + /// The led id to get the custom identifier for. + /// Contains the mapped custom identifier or null if there is no mapping for the specified led id. + /// true if there was a custom identifier for the specified led id; otherwise false. public bool TryGetValue(LedId ledId, out T? mapping) => _mapping.TryGetValue(ledId, out mapping); + + /// + /// Gets the led id mapped to the specified custom identifier. + /// + /// The custom identifier to get the led id for. + /// Contains the mapped led id or null if there is no mapping for the specified led id. + /// true if there was a led id for the specified custom identifier; otherwise false. public bool TryGetValue(T mapping, out LedId ledId) => _reverseMapping.TryGetValue(mapping, out ledId); + /// + /// Removes the specified led id and the mapped custom identifier. + /// + /// The led id to remove. + /// true if there was a mapping for the led id to remove; otherwise false. public bool Remove(LedId ledId) { if (_mapping.TryGetValue(ledId, out T? mapping)) @@ -60,6 +118,11 @@ namespace RGB.NET.Core return _mapping.Remove(ledId); } + /// + /// Removes the specified custom identifier and the mapped led id. + /// + /// The custom identifier to remove. + /// true if there was a mapping for the custom identifier to remove; otherwise false. public bool Remove(T mapping) { if (_reverseMapping.TryGetValue(mapping, out LedId ledId)) @@ -67,6 +130,9 @@ namespace RGB.NET.Core return _reverseMapping.Remove(mapping); } + /// + /// Removes all registered mappings. + /// public void Clear() { _mapping.Clear(); @@ -74,6 +140,8 @@ namespace RGB.NET.Core } IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + + /// public IEnumerator<(LedId ledId, T mapping)> GetEnumerator() => _mapping.Select(x => (x.Key, x.Value)).GetEnumerator(); #endregion diff --git a/RGB.NET.Core/Positioning/IPlaceable.cs b/RGB.NET.Core/Positioning/IPlaceable.cs index d7e116f..dcc3a17 100644 --- a/RGB.NET.Core/Positioning/IPlaceable.cs +++ b/RGB.NET.Core/Positioning/IPlaceable.cs @@ -4,6 +4,9 @@ using System; namespace RGB.NET.Core { + /// + /// Represents a generic placeable element. + /// public interface IPlaceable { #region Properties & Fields @@ -50,12 +53,39 @@ namespace RGB.NET.Core #region Events + /// + /// Occurs when the property was changed. + /// event EventHandler LocationChanged; + + /// + /// Occurs when the property was changed. + /// event EventHandler SizeChanged; + + /// + /// Occurs when the property was changed. + /// event EventHandler ScaleChanged; + + /// + /// Occurs when the property was changed. + /// event EventHandler RotationChanged; + + /// + /// Occurs when the property was changed. + /// event EventHandler ActualLocationChanged; + + /// + /// Occurs when the property was changed. + /// event EventHandler ActualSizeChanged; + + /// + /// Occurs when the property was changed. + /// event EventHandler BoundaryChanged; #endregion diff --git a/RGB.NET.Core/Positioning/Placeable.cs b/RGB.NET.Core/Positioning/Placeable.cs index f415f48..3aa5431 100644 --- a/RGB.NET.Core/Positioning/Placeable.cs +++ b/RGB.NET.Core/Positioning/Placeable.cs @@ -2,10 +2,16 @@ namespace RGB.NET.Core { + /// + /// Represents a placeable element. + /// public class Placeable : AbstractBindable, IPlaceable { #region Properties & Fields + /// + /// Gets the parent this placeable is placed in. + /// protected IPlaceable? Parent { get; } private Point _location = Point.Invalid; @@ -96,20 +102,40 @@ namespace RGB.NET.Core #region Events + /// public event EventHandler? LocationChanged; + + /// public event EventHandler? SizeChanged; + + /// public event EventHandler? ScaleChanged; + + /// public event EventHandler? RotationChanged; + + /// public event EventHandler? ActualLocationChanged; + + /// public event EventHandler? ActualSizeChanged; + + /// public event EventHandler? BoundaryChanged; #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// public Placeable() { } + /// + /// Initializes a new instance of the class. + /// + /// The parent this placeable is placed in. public Placeable(IPlaceable parent) { this.Parent = parent; @@ -117,12 +143,23 @@ namespace RGB.NET.Core Parent.BoundaryChanged += (_, _) => UpdateActualPlaceableData(); } + /// + /// Initializes a new instance of the class. + /// + /// The location of this placeable. + /// The size of this placeable. public Placeable(Point location, Size size) { this.Location = location; this.Size = size; } + /// + /// Initializes a new instance of the class. + /// + /// The parent placeable this placeable is placed in. + /// The location of this placeable. + /// The size of this placeable. public Placeable(IPlaceable parent, Point location, Size size) { this.Parent = parent; @@ -136,6 +173,9 @@ namespace RGB.NET.Core #region Methods + /// + /// Updates the , and based on the , and . + /// protected virtual void UpdateActualPlaceableData() { if (Parent != null) @@ -166,32 +206,55 @@ namespace RGB.NET.Core } } + /// + /// Called when the property was changed. + /// protected virtual void OnLocationChanged() { LocationChanged?.Invoke(this, new EventArgs()); UpdateActualPlaceableData(); } + /// + /// Called when the property was changed. + /// protected virtual void OnSizeChanged() { SizeChanged?.Invoke(this, new EventArgs()); UpdateActualPlaceableData(); } + /// + /// Called when the property was changed. + /// protected virtual void OnScaleChanged() { ScaleChanged?.Invoke(this, new EventArgs()); UpdateActualPlaceableData(); } + /// + /// Called when the property was changed. + /// protected virtual void OnRotationChanged() { RotationChanged?.Invoke(this, new EventArgs()); UpdateActualPlaceableData(); } + /// + /// Called when the property was changed. + /// protected virtual void OnActualLocationChanged() => ActualLocationChanged?.Invoke(this, new EventArgs()); + + /// + /// Called when the property was changed. + /// protected virtual void OnActualSizeChanged() => ActualSizeChanged?.Invoke(this, new EventArgs()); + + /// + /// Called when the property was changed. + /// protected virtual void OnBoundaryChanged() => BoundaryChanged?.Invoke(this, new EventArgs()); #endregion diff --git a/RGB.NET.Core/Positioning/Rectangle.cs b/RGB.NET.Core/Positioning/Rectangle.cs index 3c545e6..466c312 100644 --- a/RGB.NET.Core/Positioning/Rectangle.cs +++ b/RGB.NET.Core/Positioning/Rectangle.cs @@ -54,14 +54,14 @@ namespace RGB.NET.Core { } /// - /// Initializes a new instance of the class using the (0,0) and the given . + /// Initializes a new instance of the class using the (0,0) and the specified . /// /// The size of of this . public Rectangle(Size size) : this(new Point(), size) { } /// - /// Initializes a new instance of the class using the given and . + /// Initializes a new instance of the class using the specified and . /// /// The location of this of this . /// The size of of this . @@ -75,7 +75,7 @@ namespace RGB.NET.Core /// /// - /// Initializes a new instance of the class using the given array of . + /// Initializes a new instance of the class using the specified array of . /// The and is calculated to completely contain all rectangles provided as parameters. /// /// The array of used to calculate the and @@ -84,7 +84,7 @@ namespace RGB.NET.Core { } /// - /// Initializes a new instance of the class using the given list of . + /// Initializes a new instance of the class using the specified list of . /// The and is calculated to completely contain all rectangles provided as parameters. /// /// The list of used to calculate the and @@ -113,7 +113,7 @@ namespace RGB.NET.Core /// /// - /// Initializes a new instance of the class using the given array of . + /// Initializes a new instance of the class using the specified array of . /// The and is calculated to contain all points provided as parameters. /// /// The array of used to calculate the and @@ -123,7 +123,7 @@ namespace RGB.NET.Core /// /// - /// Initializes a new instance of the class using the given list of . + /// Initializes a new instance of the class using the specified list of . /// The and is calculated to contain all points provided as parameters. /// /// The list of used to calculate the and @@ -223,6 +223,12 @@ namespace RGB.NET.Core public static bool operator !=(in Rectangle rectangle1, in Rectangle rectangle2) => !(rectangle1 == rectangle2); // DarthAffe 20.02.2021: Used for normalization + /// + /// Returns a normalized to the specified reference. + /// + /// The rectangle to nromalize. + /// The reference used for normalization. + /// A normalized rectangle. public static Rectangle operator /(in Rectangle rectangle1, in Rectangle rectangle2) { float x = rectangle1.Location.X / (rectangle2.Size.Width - rectangle2.Location.X); diff --git a/RGB.NET.Core/Positioning/Rotation.cs b/RGB.NET.Core/Positioning/Rotation.cs index 39a5315..8b024ae 100644 --- a/RGB.NET.Core/Positioning/Rotation.cs +++ b/RGB.NET.Core/Positioning/Rotation.cs @@ -44,7 +44,7 @@ namespace RGB.NET.Core /// /// Initializes a new instance of the class using the provided values. /// - /// The rotation in degrees. + /// The rotation in degrees. public Rotation(float degrees) : this(degrees, degrees * DEGREES_RADIANS_CONVERSION) { } @@ -60,16 +60,16 @@ namespace RGB.NET.Core #region Methods /// - /// Creates a new Rotation out of the given degree-angle. + /// Creates a new Rotation out of the specified degree-angle. /// /// The angle in degrees. /// The new rotation. public static Rotation FromDegrees(float degrees) => new(degrees); /// - /// Creates a new Rotation out of the given radian-angle. + /// Creates a new Rotation out of the specified radian-angle. /// - /// The angle in radians. + /// The angle in radians. /// The new rotation. public static Rotation FromRadians(float radians) => new(radians * RADIANS_DEGREES_CONVERSION, radians); diff --git a/RGB.NET.Core/Positioning/Size.cs b/RGB.NET.Core/Positioning/Size.cs index 3a8c279..b4a77ac 100644 --- a/RGB.NET.Core/Positioning/Size.cs +++ b/RGB.NET.Core/Positioning/Size.cs @@ -74,7 +74,7 @@ namespace RGB.NET.Core /// true if is a equivalent to this ; otherwise, false. public override bool Equals(object? obj) { - if (!(obj is Size size)) return false; + if (obj is not Size size) return false; (float width, float height) = size; return ((float.IsNaN(Width) && float.IsNaN(width)) || Width.EqualsInTolerance(width)) @@ -185,11 +185,11 @@ namespace RGB.NET.Core public static Size operator /(in Size size, float factor) => factor.EqualsInTolerance(0) ? Invalid : new Size(size.Width / factor, size.Height / factor); /// - /// Returns a new representing the multiplication of the and the given . + /// Returns a new representing the multiplication of the and the specified . /// /// The to scale. /// The scaling factor. - /// A new representing the multiplication of the and the given . + /// A new representing the multiplication of the and the specified . public static Size operator *(in Size size, in Scale scale) => new(size.Width * scale.Horizontal, size.Height * scale.Vertical); #endregion diff --git a/RGB.NET.Core/RGBSurface.cs b/RGB.NET.Core/RGBSurface.cs index 34eabd3..669c044 100644 --- a/RGB.NET.Core/RGBSurface.cs +++ b/RGB.NET.Core/RGBSurface.cs @@ -225,7 +225,7 @@ namespace RGB.NET.Core } /// - /// Attaches the given . + /// Attaches the specified . /// /// The to attach. /// true if the could be attached; otherwise, false. @@ -245,10 +245,10 @@ namespace RGB.NET.Core } /// - /// Detaches the given . + /// Detaches the specified . /// - /// The to detached. - /// true if the could be detached; otherwise, false. + /// The to detache. + /// true if the could be detached; false otherwise. public bool Detach(ILedGroup ledGroup) { lock (_ledGroups) @@ -261,6 +261,10 @@ namespace RGB.NET.Core } } + /// + /// Attaches the specified . + /// + /// The to attach. public void Attach(IRGBDevice device) { lock (_devices) @@ -276,6 +280,11 @@ namespace RGB.NET.Core } } + /// + /// Detaches the specified . + /// + /// The to detache. + /// true if the could be detached; false otherwise. public void Detach(IRGBDevice device) { lock (_devices) diff --git a/RGB.NET.Core/Rendering/Brushes/AbstractBrush.cs b/RGB.NET.Core/Rendering/Brushes/AbstractBrush.cs index e4d7274..1e988e6 100644 --- a/RGB.NET.Core/Rendering/Brushes/AbstractBrush.cs +++ b/RGB.NET.Core/Rendering/Brushes/AbstractBrush.cs @@ -46,6 +46,12 @@ namespace RGB.NET.Core #region Methods + /// + /// Renders the brush to the specified list of . + /// + /// The bounding box the brush is rendered in. + /// The targets to render to. + /// A enumerable containing the rendered for each . public virtual IEnumerable<(RenderTarget renderTarget, Color color)> Render(Rectangle rectangle, IEnumerable renderTargets) { foreach (RenderTarget renderTarget in renderTargets) @@ -74,7 +80,7 @@ namespace RGB.NET.Core } /// - /// Gets the color at an specific point assuming the brush is drawn into the given rectangle. + /// Gets the color at an specific point assuming the brush is drawn into the specified rectangle. /// /// The rectangle in which the brush should be drawn. /// The target (key/point) from which the color should be taken. diff --git a/RGB.NET.Core/Rendering/Brushes/SolidColorBrush.cs b/RGB.NET.Core/Rendering/Brushes/SolidColorBrush.cs index aaf9409..444c90c 100644 --- a/RGB.NET.Core/Rendering/Brushes/SolidColorBrush.cs +++ b/RGB.NET.Core/Rendering/Brushes/SolidColorBrush.cs @@ -24,8 +24,7 @@ namespace RGB.NET.Core #endregion #region Constructors - - /// + /// /// Initializes a new instance of the class. /// diff --git a/RGB.NET.Core/Rendering/Brushes/TextureBrush.cs b/RGB.NET.Core/Rendering/Brushes/TextureBrush.cs index 2ec8f05..f67b090 100644 --- a/RGB.NET.Core/Rendering/Brushes/TextureBrush.cs +++ b/RGB.NET.Core/Rendering/Brushes/TextureBrush.cs @@ -1,10 +1,17 @@ namespace RGB.NET.Core { + /// + /// + /// Represents a brush drawing a texture. + /// public class TextureBrush : AbstractBrush { #region Properties & Fields private ITexture _texture = ITexture.Empty; + /// + /// Gets or sets the texture drawn by this brush. + /// public ITexture Texture { get => _texture; @@ -15,6 +22,10 @@ #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The texture drawn by this brush. public TextureBrush(ITexture texture) { this.Texture = texture; @@ -24,6 +35,7 @@ #region Methods + /// protected override Color GetColorAtPoint(in Rectangle rectangle, in RenderTarget renderTarget) { Rectangle normalizedRect = renderTarget.Rectangle / rectangle; diff --git a/RGB.NET.Core/Rendering/Textures/ITexture.cs b/RGB.NET.Core/Rendering/Textures/ITexture.cs index 7d297e1..4ef1114 100644 --- a/RGB.NET.Core/Rendering/Textures/ITexture.cs +++ b/RGB.NET.Core/Rendering/Textures/ITexture.cs @@ -1,12 +1,32 @@ namespace RGB.NET.Core { + /// + /// Represents a generic texture. + /// public interface ITexture { + /// + /// Gets a empty texture. + /// static ITexture Empty => new EmptyTexture(); - + + /// + /// Gets the size of the texture + /// Size Size { get; } + /// + /// Gets the color at the specified location. + /// + /// The location to get the color from. + /// The color at the specified location. Color this[in Point point] { get; } + + /// + /// Gets the sampled color inside the specified rectangle. + /// + /// The rectangle to get the color from. + /// The sampled color. Color this[in Rectangle rectangle] { get; } } } diff --git a/RGB.NET.Core/Rendering/Textures/PixelTexture.cs b/RGB.NET.Core/Rendering/Textures/PixelTexture.cs index f5f1719..4164a5e 100644 --- a/RGB.NET.Core/Rendering/Textures/PixelTexture.cs +++ b/RGB.NET.Core/Rendering/Textures/PixelTexture.cs @@ -4,6 +4,11 @@ using System.Runtime.CompilerServices; namespace RGB.NET.Core { + /// + /// + /// Represents a texture made of pixels (like a common image). + /// + /// The type of the pixels. public abstract class PixelTexture : ITexture where T : unmanaged { @@ -18,11 +23,20 @@ namespace RGB.NET.Core private readonly int _dataPerPixel; private readonly int _stride; + /// + /// Gets or sets the sampler used to get the color of a region. + /// public ISampler Sampler { get; set; } + + /// public Size Size { get; } + /// + /// Gets the underlying pixel data. + /// protected abstract ReadOnlySpan Data { get; } + /// public virtual Color this[in Point point] { get @@ -35,6 +49,7 @@ namespace RGB.NET.Core } } + /// public virtual Color this[in Rectangle rectangle] { get @@ -50,6 +65,14 @@ namespace RGB.NET.Core } } + /// + /// Gets the sampled color inside the specified region. + /// + /// The x-location of the region. + /// The y-location of the region. + /// The with of the region. + /// The height of the region. + /// The sampled color. public virtual Color this[int x, int y, int width, int height] { get @@ -66,7 +89,7 @@ namespace RGB.NET.Core GetRegionData(x, y, width, height, buffer); Span pixelData = stackalloc T[_dataPerPixel]; - Sampler.SampleColor(new SamplerInfo(width, height, buffer), pixelData); + Sampler.Sample(new SamplerInfo(width, height, buffer), pixelData); return GetColor(pixelData); } @@ -78,7 +101,7 @@ namespace RGB.NET.Core GetRegionData(x, y, width, height, buffer); Span pixelData = stackalloc T[_dataPerPixel]; - Sampler.SampleColor(new SamplerInfo(width, height, buffer), pixelData); + Sampler.Sample(new SamplerInfo(width, height, buffer), pixelData); ArrayPool.Shared.Return(rent); @@ -91,6 +114,14 @@ namespace RGB.NET.Core #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The width of the texture. + /// The height of the texture. + /// The amount of data-entries per pixel. + /// The sampler used to get the color of a region. + /// The stride of the data or -1 if the width should be used. public PixelTexture(int with, int height, int dataPerPixel, ISampler sampler, int stride = -1) { this._stride = stride == -1 ? with : stride; @@ -104,11 +135,30 @@ namespace RGB.NET.Core #region Methods + /// + /// Converts the pixel-data to a color. + /// + /// The pixel-data to convert. + /// The color represented by the specified pixel-data. protected abstract Color GetColor(in ReadOnlySpan pixel); + /// + /// Gets the pixel-data at the specified location. + /// + /// The x-location. + /// The y-location. + /// The pixel-data on the specified location. [MethodImpl(MethodImplOptions.AggressiveInlining)] protected virtual ReadOnlySpan GetPixelData(int x, int y) => Data.Slice((y * _stride) + x, _dataPerPixel); + /// + /// Writes the pixel-data of the specified region to the passed buffer. + /// + /// The x-location of the region to get the data for. + /// The y-location of the region to get the data for. + /// The width of the region to get the data for. + /// The height of the region to get the data for. + /// The buffer to write the data to. protected virtual void GetRegionData(int x, int y, int width, int height, in Span buffer) { int dataWidth = width * _dataPerPixel; @@ -124,34 +174,54 @@ namespace RGB.NET.Core #endregion } + /// + /// + /// Represents a texture made of color-pixels. + /// public sealed class PixelTexture : PixelTexture { #region Properties & Fields private readonly Color[] _data; + /// protected override ReadOnlySpan Data => _data; #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// A is used. + /// + /// The width of the texture. + /// The height of the texture. + /// The pixel-data of the texture. public PixelTexture(int with, int height, Color[] data) : this(with, height, data, new AverageColorSampler()) { } + /// + /// Initializes a new instance of the class. + /// + /// The width of the texture. + /// The height of the texture. + /// The pixel-data of the texture. + /// The sampler used to get the color of a region. public PixelTexture(int with, int height, Color[] data, ISampler sampler) : base(with, height, 1, sampler) { this._data = data; - if (Data.Length != (with * height)) throw new ArgumentException($"Data-Length {Data.Length} differs from the given size {with}x{height} ({with * height})."); + if (Data.Length != (with * height)) throw new ArgumentException($"Data-Length {Data.Length} differs from the specified size {with}x{height} ({with * height})."); } #endregion #region Methods + /// protected override Color GetColor(in ReadOnlySpan pixel) => pixel[0]; #endregion diff --git a/RGB.NET.Core/Rendering/Textures/Sampler/AverageColorSampler.cs b/RGB.NET.Core/Rendering/Textures/Sampler/AverageColorSampler.cs index 4910dbc..c1e8ed2 100644 --- a/RGB.NET.Core/Rendering/Textures/Sampler/AverageColorSampler.cs +++ b/RGB.NET.Core/Rendering/Textures/Sampler/AverageColorSampler.cs @@ -2,11 +2,18 @@ namespace RGB.NET.Core { + /// + /// Represents a sampled that averages multiple color to a single color. + /// + /// + /// Averages all components (A, R, G, B) of the colors separately which isn't ideal in cases where multiple different colors are combined. + /// public class AverageColorSampler : ISampler { #region Methods - public void SampleColor(in SamplerInfo info, in Span pixelData) + /// + public void Sample(in SamplerInfo info, in Span pixelData) { int count = info.Width * info.Height; if (count == 0) return; diff --git a/RGB.NET.Core/Rendering/Textures/Sampler/ISampler.cs b/RGB.NET.Core/Rendering/Textures/Sampler/ISampler.cs index ce507bd..aa89a14 100644 --- a/RGB.NET.Core/Rendering/Textures/Sampler/ISampler.cs +++ b/RGB.NET.Core/Rendering/Textures/Sampler/ISampler.cs @@ -2,8 +2,17 @@ namespace RGB.NET.Core { + /// + /// Represents a generic sampler to combine multipel data entries to a single one. + /// + /// The type of the data to sample. public interface ISampler { - void SampleColor(in SamplerInfo info, in Span pixelData); + /// + /// Samples the specified data to a single pixel-buffer. + /// + /// The information containing the data to sample. + /// The buffer used to write the resulting pixel to. + void Sample(in SamplerInfo info, in Span pixelData); } } diff --git a/RGB.NET.Core/Rendering/Textures/Sampler/SamplerInfo.cs b/RGB.NET.Core/Rendering/Textures/Sampler/SamplerInfo.cs index a544381..9eff14b 100644 --- a/RGB.NET.Core/Rendering/Textures/Sampler/SamplerInfo.cs +++ b/RGB.NET.Core/Rendering/Textures/Sampler/SamplerInfo.cs @@ -2,18 +2,39 @@ namespace RGB.NET.Core { + /// + /// Represents the information used to sample data. + /// + /// The type of the data to sample. public readonly ref struct SamplerInfo { #region Properties & Fields + /// + /// Gets the width of the region the data comes from. + /// public int Width { get; } + + /// + /// Gets the height of region the data comes from. + /// public int Height { get; } + + /// + /// Gets the data to sample. + /// public ReadOnlySpan Data { get; } #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The width of the region the data comes from. + /// The height of region the data comes from. + /// The data to sample. public SamplerInfo(int width, int height, ReadOnlySpan data) { this.Width = width; diff --git a/RGB.NET.Core/Update/CustomUpdateData.cs b/RGB.NET.Core/Update/CustomUpdateData.cs index 0c14e77..c5b5c1c 100644 --- a/RGB.NET.Core/Update/CustomUpdateData.cs +++ b/RGB.NET.Core/Update/CustomUpdateData.cs @@ -19,7 +19,7 @@ namespace RGB.NET.Core /// Gets or sets the value for a specific key. /// /// The key of the value. - /// The value represented by the given key. + /// The value represented by the specified key. public object? this[string key] { get => _data.TryGetValue(key.ToUpperInvariant(), out object? data) ? data : default; diff --git a/RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs b/RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs index 4ae41cd..d70cb63 100644 --- a/RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs +++ b/RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs @@ -53,13 +53,32 @@ namespace RGB.NET.Core } } + /// public override double LastUpdateTime { get; protected set; } + /// + /// Gets or sets the event to trigger when new data is available (). + /// protected AutoResetEvent HasDataEvent { get; set; } = new(false); + /// + /// Gets or sets a bool indicating if the trigger is currently updating. + /// protected bool IsRunning { get; set; } + + /// + /// Gets or sets the update loop of this trigger. + /// protected Task? UpdateTask { get; set; } + + /// + /// Gets or sets the cancellation token source used to create the cancellation token checked by the . + /// protected CancellationTokenSource? UpdateTokenSource { get; set; } + + /// + /// Gets or sets the cancellation token checked by the . + /// protected CancellationToken UpdateToken { get; set; } #endregion @@ -116,6 +135,9 @@ namespace RGB.NET.Core UpdateTask = null; } + /// + /// The update loop called by the . + /// protected virtual void UpdateLoop() { OnStartup(); diff --git a/RGB.NET.Core/Update/Devices/IUpdateQueue.cs b/RGB.NET.Core/Update/Devices/IUpdateQueue.cs index 0fbcd7a..16ddef4 100644 --- a/RGB.NET.Core/Update/Devices/IUpdateQueue.cs +++ b/RGB.NET.Core/Update/Devices/IUpdateQueue.cs @@ -3,6 +3,11 @@ using System.Collections.Generic; namespace RGB.NET.Core { + /// + /// Represents a generic update queue. + /// + /// The identifier used to identify the data processed by this queue. + /// The type of the data processed by this queue. public interface IUpdateQueue : IDisposable where TIdentifier : notnull { @@ -19,6 +24,9 @@ namespace RGB.NET.Core void Reset(); } + /// + /// Represents a generic update queue processing -data using -identifiers. + /// public interface IUpdateQueue : IUpdateQueue { } } diff --git a/RGB.NET.Core/Update/IUpdateTrigger.cs b/RGB.NET.Core/Update/IUpdateTrigger.cs index 0af6d33..d0c52dc 100644 --- a/RGB.NET.Core/Update/IUpdateTrigger.cs +++ b/RGB.NET.Core/Update/IUpdateTrigger.cs @@ -7,6 +7,9 @@ namespace RGB.NET.Core /// public interface IUpdateTrigger : IDisposable { + /// + /// Gets the time spent for the last update. + /// double LastUpdateTime { get; } /// @@ -19,6 +22,9 @@ namespace RGB.NET.Core /// event EventHandler? Update; + /// + /// Starts the update trigger. + /// void Start(); } } diff --git a/RGB.NET.Core/Update/ManualUpdateTrigger.cs b/RGB.NET.Core/Update/ManualUpdateTrigger.cs index 96877cb..eaece84 100644 --- a/RGB.NET.Core/Update/ManualUpdateTrigger.cs +++ b/RGB.NET.Core/Update/ManualUpdateTrigger.cs @@ -8,7 +8,7 @@ namespace RGB.NET.Core { /// /// - /// Represents an + /// Represents an update trigger that is manully triggered by calling . /// public sealed class ManualUpdateTrigger : AbstractUpdateTrigger { @@ -31,7 +31,6 @@ namespace RGB.NET.Core /// /// Initializes a new instance of the class. /// - /// A value indicating if the trigger should automatically right after construction. public ManualUpdateTrigger() { Start(); @@ -69,6 +68,9 @@ namespace RGB.NET.Core } } + /// + /// Triggers an update. + /// public void TriggerUpdate() => _mutex.Set(); private void UpdateLoop() diff --git a/RGB.NET.Core/Update/TimerUpdateTrigger.cs b/RGB.NET.Core/Update/TimerUpdateTrigger.cs index 5a7b7e3..98a7237 100644 --- a/RGB.NET.Core/Update/TimerUpdateTrigger.cs +++ b/RGB.NET.Core/Update/TimerUpdateTrigger.cs @@ -9,7 +9,7 @@ namespace RGB.NET.Core { /// /// - /// Represents an + /// Represents an update trigger that triggers in a set interval. /// public class TimerUpdateTrigger : AbstractUpdateTrigger { @@ -17,8 +17,19 @@ namespace RGB.NET.Core private readonly object _lock = new(); + /// + /// Gets or sets the update loop of this trigger. + /// protected Task? UpdateTask { get; set; } + + /// + /// Gets or sets the cancellation token source used to create the cancellation token checked by the . + /// protected CancellationTokenSource? UpdateTokenSource { get; set; } + + /// + /// Gets or sets the cancellation token checked by the . + /// protected CancellationToken UpdateToken { get; set; } private double _updateFrequency = 1.0 / 30.0; diff --git a/RGB.NET.Devices.Asus/AsusDeviceProvider.cs b/RGB.NET.Devices.Asus/AsusDeviceProvider.cs index 68c545f..66e1ece 100644 --- a/RGB.NET.Devices.Asus/AsusDeviceProvider.cs +++ b/RGB.NET.Devices.Asus/AsusDeviceProvider.cs @@ -43,6 +43,7 @@ namespace RGB.NET.Devices.Asus #region Methods + /// protected override void InitializeSDK() { // ReSharper disable once SuspiciousTypeConversion.Global @@ -50,6 +51,7 @@ namespace RGB.NET.Devices.Asus _sdk.SwitchMode(); } + /// protected override IEnumerable LoadDevices() { if (_sdk == null) yield break; @@ -84,6 +86,8 @@ namespace RGB.NET.Devices.Asus _devices = null; _sdk = null; + + GC.SuppressFinalize(this); } #endregion diff --git a/RGB.NET.Devices.Asus/Enum/AsusLedId.cs b/RGB.NET.Devices.Asus/Enum/AsusLedId.cs index 5a9a118..d3fbf5d 100644 --- a/RGB.NET.Devices.Asus/Enum/AsusLedId.cs +++ b/RGB.NET.Devices.Asus/Enum/AsusLedId.cs @@ -1,4 +1,5 @@ // ReSharper disable InconsistentNaming +#pragma warning disable 1591 namespace RGB.NET.Devices.Asus { diff --git a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardLedMapping.cs b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardLedMapping.cs index 24f427f..4b7ab36 100644 --- a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardLedMapping.cs +++ b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardLedMapping.cs @@ -2,6 +2,9 @@ namespace RGB.NET.Devices.Asus { + /// + /// Contains mappings for to . + /// public static class LedMappings { /// @@ -163,12 +166,14 @@ namespace RGB.NET.Devices.Asus /// /// A LED mapping containing extra lights for the ROG Zephyrus Duo 15 + /// + /// /// /// ASUS notebooks have extra lights under wide keys like space and backspace, these do not appear as keys on the device. /// Instead they only appear in the Lights enumerable, this mapping maps LED IDs to the index of these lights. /// /// You may add more of these by further populating . - /// + /// public static LedMapping ROGZephyrusDuo15 { get; } = new() { { LedId.Keyboard_Custom50, 39 }, // Mapping starts at Custom50 to avoid possible conflicts with KeyboardMapping above diff --git a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs index f2a02c9..9ac6f69 100644 --- a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs @@ -25,8 +25,8 @@ namespace RGB.NET.Devices.Asus #region Properties & Fields private readonly LedMapping? _ledMapping; - private Dictionary _ledAsusLed = new(); - private Dictionary _ledAsusLights = new(); + private readonly Dictionary _ledAsusLed = new(); + private readonly Dictionary _ledAsusLights = new(); IKeyboardDeviceInfo IKeyboard.DeviceInfo => DeviceInfo; @@ -34,11 +34,10 @@ namespace RGB.NET.Devices.Asus /// Gets or sets a list of extra LED mappings to apply to modes that match the provided regex /// Note: These LED mappings should be based on light indexes /// - public static List ExtraLedMappings = - new() - { - new AsusKeyboardExtraMapping(new Regex("(ROG Zephyrus Duo 15).*?"), LedMappings.ROGZephyrusDuo15) - }; + public static readonly List ExtraLedMappings = new() + { + new AsusKeyboardExtraMapping(new Regex("(ROG Zephyrus Duo 15).*?"), LedMappings.ROGZephyrusDuo15) + }; #endregion diff --git a/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDeviceInfo.cs b/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDeviceInfo.cs index 3efe8eb..b695a69 100644 --- a/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDeviceInfo.cs +++ b/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDeviceInfo.cs @@ -23,6 +23,7 @@ namespace RGB.NET.Devices.CoolerMaster /// public string Model { get; } + /// public object? LayoutMetadata { get; set; } /// diff --git a/RGB.NET.Devices.CoolerMaster/Mouse/CoolerMasterMouseRGBDevice.cs b/RGB.NET.Devices.CoolerMaster/Mouse/CoolerMasterMouseRGBDevice.cs index f67d587..f40ee2f 100644 --- a/RGB.NET.Devices.CoolerMaster/Mouse/CoolerMasterMouseRGBDevice.cs +++ b/RGB.NET.Devices.CoolerMaster/Mouse/CoolerMasterMouseRGBDevice.cs @@ -10,12 +10,13 @@ namespace RGB.NET.Devices.CoolerMaster public class CoolerMasterMouseRGBDevice : CoolerMasterRGBDevice, IMouse { #region Constructors - + /// /// /// Initializes a new instance of the class. /// /// The specific information provided by CoolerMaster for the mouse + /// The update trigger used to update this device. internal CoolerMasterMouseRGBDevice(CoolerMasterMouseRGBDeviceInfo info, IDeviceUpdateTrigger updateTrigger) : base(info, updateTrigger) { diff --git a/RGB.NET.Devices.CoolerMaster/Native/_CoolerMasterSDK.cs b/RGB.NET.Devices.CoolerMaster/Native/_CoolerMasterSDK.cs index bb05b71..e0d367e 100644 --- a/RGB.NET.Devices.CoolerMaster/Native/_CoolerMasterSDK.cs +++ b/RGB.NET.Devices.CoolerMaster/Native/_CoolerMasterSDK.cs @@ -57,7 +57,7 @@ namespace RGB.NET.Devices.CoolerMaster.Native [DllImport("kernel32.dll", CharSet = CharSet.Unicode)] private static extern IntPtr LoadLibrary(string dllToLoad); - [DllImport("kernel32.dll", CharSet = CharSet.Unicode)] + [DllImport("kernel32.dll", CharSet = CharSet.Ansi)] private static extern IntPtr GetProcAddress(IntPtr dllHandle, string name); #endregion diff --git a/RGB.NET.Devices.Corsair/Custom/CorsairCustomRGBDevice.cs b/RGB.NET.Devices.Corsair/Custom/CorsairCustomRGBDevice.cs index 5deab5c..588fa9d 100644 --- a/RGB.NET.Devices.Corsair/Custom/CorsairCustomRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Custom/CorsairCustomRGBDevice.cs @@ -21,6 +21,7 @@ namespace RGB.NET.Devices.Corsair /// Initializes a new instance of the class. /// /// The specific information provided by CUE for the custom-device. + /// The queue used to update this device. internal CorsairCustomRGBDevice(CorsairCustomRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) : base(info, new LedMapping(), updateQueue) { } diff --git a/RGB.NET.Devices.Corsair/Custom/CorsairCustomRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Custom/CorsairCustomRGBDeviceInfo.cs index d6e222d..c89423c 100644 --- a/RGB.NET.Devices.Corsair/Custom/CorsairCustomRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/Custom/CorsairCustomRGBDeviceInfo.cs @@ -49,32 +49,21 @@ namespace RGB.NET.Devices.Corsair #region Methods private static RGBDeviceType GetDeviceType(CorsairChannelDeviceType deviceType) - { - switch (deviceType) + => deviceType switch { - case CorsairChannelDeviceType.Invalid: - return RGBDeviceType.Unknown; - - case CorsairChannelDeviceType.FanHD: - case CorsairChannelDeviceType.FanSP: - case CorsairChannelDeviceType.FanLL: - case CorsairChannelDeviceType.FanML: - case CorsairChannelDeviceType.DAP: - case CorsairChannelDeviceType.FanQL: - case CorsairChannelDeviceType.FanSPPRO: - return RGBDeviceType.Fan; - - case CorsairChannelDeviceType.Strip: - return RGBDeviceType.LedStripe; - - case CorsairChannelDeviceType.Pump: - case CorsairChannelDeviceType.WaterBlock: - return RGBDeviceType.Cooler; - - default: - throw new ArgumentOutOfRangeException(nameof(deviceType), deviceType, null); - } - } + CorsairChannelDeviceType.Invalid => RGBDeviceType.Unknown, + CorsairChannelDeviceType.FanHD => RGBDeviceType.Fan, + CorsairChannelDeviceType.FanSP => RGBDeviceType.Fan, + CorsairChannelDeviceType.FanLL => RGBDeviceType.Fan, + CorsairChannelDeviceType.FanML => RGBDeviceType.Fan, + CorsairChannelDeviceType.DAP => RGBDeviceType.Fan, + CorsairChannelDeviceType.FanQL => RGBDeviceType.Fan, + CorsairChannelDeviceType.FanSPPRO => RGBDeviceType.Fan, + CorsairChannelDeviceType.Strip => RGBDeviceType.LedStripe, + CorsairChannelDeviceType.Pump => RGBDeviceType.Cooler, + CorsairChannelDeviceType.WaterBlock => RGBDeviceType.Cooler, + _ => throw new ArgumentOutOfRangeException(nameof(deviceType), deviceType, null) + }; private static string GetModelName(string model, _CorsairChannelDeviceInfo channelDeviceInfo) { @@ -126,7 +115,9 @@ namespace RGB.NET.Devices.Corsair return "Pump"; default: - throw new ArgumentOutOfRangeException(nameof(channelDeviceInfo.type), channelDeviceInfo.type, null); +#pragma warning disable CA2208 // Instantiate argument exceptions correctly + throw new ArgumentOutOfRangeException($"{nameof(channelDeviceInfo)}.{nameof(channelDeviceInfo.type)}", channelDeviceInfo.type, null); +#pragma warning restore CA2208 // Instantiate argument exceptions correctly } } diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairAccessMode.cs b/RGB.NET.Devices.Corsair/Enum/CorsairAccessMode.cs index af8a87c..bf0adf7 100644 --- a/RGB.NET.Devices.Corsair/Enum/CorsairAccessMode.cs +++ b/RGB.NET.Devices.Corsair/Enum/CorsairAccessMode.cs @@ -6,7 +6,7 @@ namespace RGB.NET.Devices.Corsair { /// - /// Contains list of available SDK access modes. + /// Represents an SDK access mode. /// public enum CorsairAccessMode { diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairChannelDeviceType.cs b/RGB.NET.Devices.Corsair/Enum/CorsairChannelDeviceType.cs index 9b26176..5ac79a0 100644 --- a/RGB.NET.Devices.Corsair/Enum/CorsairChannelDeviceType.cs +++ b/RGB.NET.Devices.Corsair/Enum/CorsairChannelDeviceType.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Devices.Corsair { /// - /// Contains list of available corsair channel device types. + /// Contains a list of available corsair channel device types. /// public enum CorsairChannelDeviceType { diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairDeviceCaps.cs b/RGB.NET.Devices.Corsair/Enum/CorsairDeviceCaps.cs index 4d49626..75b94f3 100644 --- a/RGB.NET.Devices.Corsair/Enum/CorsairDeviceCaps.cs +++ b/RGB.NET.Devices.Corsair/Enum/CorsairDeviceCaps.cs @@ -6,7 +6,7 @@ using System; namespace RGB.NET.Devices.Corsair { /// - /// Contains list of corsair device capabilities. + /// Contains a list of corsair device capabilities. /// [Flags] public enum CorsairDeviceCaps diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairDeviceType.cs b/RGB.NET.Devices.Corsair/Enum/CorsairDeviceType.cs index 52bb851..096fffc 100644 --- a/RGB.NET.Devices.Corsair/Enum/CorsairDeviceType.cs +++ b/RGB.NET.Devices.Corsair/Enum/CorsairDeviceType.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Devices.Corsair { /// - /// Contains list of available corsair device types. + /// Contains a list of available corsair device types. /// public enum CorsairDeviceType { diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairLedId.cs b/RGB.NET.Devices.Corsair/Enum/CorsairLedId.cs index da23132..ea8040b 100644 --- a/RGB.NET.Devices.Corsair/Enum/CorsairLedId.cs +++ b/RGB.NET.Devices.Corsair/Enum/CorsairLedId.cs @@ -1,9 +1,11 @@ // ReSharper disable InconsistentNaming +// ReSharper disable UnusedMember.Global +#pragma warning disable 1591 namespace RGB.NET.Devices.Corsair { /// - /// Contains list of all LEDs available for all corsair devices. + /// Contains a list of all LEDs available for all corsair devices. /// public enum CorsairLedId { diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairLogicalKeyboardLayout.cs b/RGB.NET.Devices.Corsair/Enum/CorsairLogicalKeyboardLayout.cs index ce8ea57..5e5091b 100644 --- a/RGB.NET.Devices.Corsair/Enum/CorsairLogicalKeyboardLayout.cs +++ b/RGB.NET.Devices.Corsair/Enum/CorsairLogicalKeyboardLayout.cs @@ -1,10 +1,11 @@ // ReSharper disable InconsistentNaming // ReSharper disable UnusedMember.Global +#pragma warning disable 1591 namespace RGB.NET.Devices.Corsair { /// - /// Contains list of available logical layouts for corsair keyboards. + /// Contains a list of available logical layouts for corsair keyboards. /// public enum CorsairLogicalKeyboardLayout { diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairPhysicalKeyboardLayout.cs b/RGB.NET.Devices.Corsair/Enum/CorsairPhysicalKeyboardLayout.cs index 0905b96..dc7d1b7 100644 --- a/RGB.NET.Devices.Corsair/Enum/CorsairPhysicalKeyboardLayout.cs +++ b/RGB.NET.Devices.Corsair/Enum/CorsairPhysicalKeyboardLayout.cs @@ -4,7 +4,7 @@ namespace RGB.NET.Devices.Corsair { /// - /// Contains list of available physical layouts for corsair keyboards. + /// Contains a list of available physical layouts for corsair keyboards. /// public enum CorsairPhysicalKeyboardLayout { diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairPhysicalMouseLayout.cs b/RGB.NET.Devices.Corsair/Enum/CorsairPhysicalMouseLayout.cs index e1fe9fb..cd45f6f 100644 --- a/RGB.NET.Devices.Corsair/Enum/CorsairPhysicalMouseLayout.cs +++ b/RGB.NET.Devices.Corsair/Enum/CorsairPhysicalMouseLayout.cs @@ -1,7 +1,7 @@ namespace RGB.NET.Devices.Corsair { /// - /// Contains list of available physical layouts for mice. + /// Contains a list of available physical layouts for mice. /// public enum CorsairPhysicalMouseLayout { diff --git a/RGB.NET.Devices.Corsair/Generic/LedMappings.cs b/RGB.NET.Devices.Corsair/Generic/LedMappings.cs index 4547e12..b144bf8 100644 --- a/RGB.NET.Devices.Corsair/Generic/LedMappings.cs +++ b/RGB.NET.Devices.Corsair/Generic/LedMappings.cs @@ -2,6 +2,9 @@ namespace RGB.NET.Devices.Corsair { + /// + /// Contains mappings for to . + /// public static class LedMappings { static LedMappings() @@ -28,18 +31,43 @@ namespace RGB.NET.Devices.Corsair Keyboard.Add(LedId.Custom101 + i, CorsairLedId.OemLed101 + i); } + /// + /// Gets the mapping for graphics cards. + /// public static LedMapping GraphicsCard { get; } = new(); + + /// + /// Gets the mapping for headsets. + /// public static LedMapping HeadsetStand { get; } = new(); + + /// + /// Gets the mapping for mainboards. + /// public static LedMapping Mainboard { get; } = new(); + + /// + /// Gets the mapping for memory. + /// public static LedMapping Memory { get; } = new(); + + /// + /// Gets the mapping for mousepads. + /// public static LedMapping Mousepad { get; } = new(); + /// + /// Gets the mapping for headsets. + /// public static LedMapping Headset { get; } = new() { { LedId.Headset1, CorsairLedId.LeftLogo }, { LedId.Headset2, CorsairLedId.RightLogo }, }; + /// + /// Gets the mapping for mice. + /// public static LedMapping Mouse { get; } = new() { { LedId.Mouse1, CorsairLedId.B1 }, @@ -64,6 +92,9 @@ namespace RGB.NET.Devices.Corsair { LedId.Mouse20, CorsairLedId.B20 }, }; + /// + /// Gets the mapping for keyboards. + /// public static LedMapping Keyboard { get; } = new() { { LedId.Invalid, CorsairLedId.Invalid }, diff --git a/RGB.NET.Devices.Corsair/GraphicsCard/CorsairGraphicsCardRGBDevice.cs b/RGB.NET.Devices.Corsair/GraphicsCard/CorsairGraphicsCardRGBDevice.cs index e2f7205..76bd4e7 100644 --- a/RGB.NET.Devices.Corsair/GraphicsCard/CorsairGraphicsCardRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/GraphicsCard/CorsairGraphicsCardRGBDevice.cs @@ -18,6 +18,7 @@ namespace RGB.NET.Devices.Corsair /// Initializes a new instance of the class. /// /// The specific information provided by CUE for the graphics card. + /// The queue used to update this device. internal CorsairGraphicsCardRGBDevice(CorsairGraphicsCardRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) : base(info, LedMappings.GraphicsCard, updateQueue) { } diff --git a/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs b/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs index b1e1228..50c0a43 100644 --- a/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs @@ -18,6 +18,7 @@ namespace RGB.NET.Devices.Corsair /// Initializes a new instance of the class. /// /// The specific information provided by CUE for the headset + /// The queue used to update this device. internal CorsairHeadsetRGBDevice(CorsairHeadsetRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) : base(info, LedMappings.Headset, updateQueue) { } diff --git a/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDevice.cs b/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDevice.cs index e55ab93..4587da3 100644 --- a/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDevice.cs @@ -18,6 +18,7 @@ namespace RGB.NET.Devices.Corsair /// Initializes a new instance of the class. /// /// The specific information provided by CUE for the headset stand + /// The queue used to update this device. internal CorsairHeadsetStandRGBDevice(CorsairHeadsetStandRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) : base(info, LedMappings.HeadsetStand, updateQueue) { } diff --git a/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs b/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs index 68eb450..b5f3144 100644 --- a/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs @@ -24,6 +24,7 @@ namespace RGB.NET.Devices.Corsair /// Initializes a new instance of the class. /// /// The specific information provided by CUE for the keyboard + /// The queue used to update this device. internal CorsairKeyboardRGBDevice(CorsairKeyboardRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) : base(info, LedMappings.Keyboard, updateQueue) { } diff --git a/RGB.NET.Devices.Corsair/Mainboard/CorsairMainboardRGBDevice.cs b/RGB.NET.Devices.Corsair/Mainboard/CorsairMainboardRGBDevice.cs index 9652bf0..14bedfc 100644 --- a/RGB.NET.Devices.Corsair/Mainboard/CorsairMainboardRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Mainboard/CorsairMainboardRGBDevice.cs @@ -18,6 +18,7 @@ namespace RGB.NET.Devices.Corsair /// Initializes a new instance of the class. /// /// The specific information provided by CUE for the memory. + /// The queue used to update this device. internal CorsairMainboardRGBDevice(CorsairMainboardRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) : base(info, LedMappings.Mainboard, updateQueue) { } diff --git a/RGB.NET.Devices.Corsair/Memory/CorsairMemoryRGBDevice.cs b/RGB.NET.Devices.Corsair/Memory/CorsairMemoryRGBDevice.cs index 1f37d1c..3532312 100644 --- a/RGB.NET.Devices.Corsair/Memory/CorsairMemoryRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Memory/CorsairMemoryRGBDevice.cs @@ -18,6 +18,7 @@ namespace RGB.NET.Devices.Corsair /// Initializes a new instance of the class. /// /// The specific information provided by CUE for the memory. + /// The queue used to update this device. internal CorsairMemoryRGBDevice(CorsairMemoryRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) : base(info, LedMappings.Memory, updateQueue) { } diff --git a/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs b/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs index e69e22e..82c455f 100644 --- a/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs @@ -18,6 +18,7 @@ namespace RGB.NET.Devices.Corsair /// Initializes a new instance of the class. /// /// The specific information provided by CUE for the mouse + /// The queue used to update this device. internal CorsairMouseRGBDevice(CorsairMouseRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) : base(info, LedMappings.Mouse, updateQueue) { } diff --git a/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDevice.cs b/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDevice.cs index d475a6f..7278271 100644 --- a/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDevice.cs @@ -18,6 +18,7 @@ namespace RGB.NET.Devices.Corsair /// Initializes a new instance of the class. /// /// The specific information provided by CUE for the mousepad + /// The queue used to update this device. internal CorsairMousepadRGBDevice(CorsairMousepadRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) : base(info, LedMappings.Mousepad, updateQueue) { } diff --git a/RGB.NET.Devices.Corsair/Native/_CUESDK.cs b/RGB.NET.Devices.Corsair/Native/_CUESDK.cs index 05483a5..b1dd6c8 100644 --- a/RGB.NET.Devices.Corsair/Native/_CUESDK.cs +++ b/RGB.NET.Devices.Corsair/Native/_CUESDK.cs @@ -68,7 +68,7 @@ namespace RGB.NET.Devices.Corsair.Native [DllImport("kernel32.dll")] private static extern bool FreeLibrary(IntPtr dllHandle); - [DllImport("kernel32.dll", CharSet = CharSet.Unicode)] + [DllImport("kernel32.dll", CharSet = CharSet.Ansi)] private static extern IntPtr GetProcAddress(IntPtr dllHandle, string name); #endregion diff --git a/RGB.NET.Devices.DMX/DMXDeviceProvider.cs b/RGB.NET.Devices.DMX/DMXDeviceProvider.cs index 0d23fd5..cda8583 100644 --- a/RGB.NET.Devices.DMX/DMXDeviceProvider.cs +++ b/RGB.NET.Devices.DMX/DMXDeviceProvider.cs @@ -46,7 +46,7 @@ namespace RGB.NET.Devices.DMX #region Methods /// - /// Adds the given to this device-provider. + /// Adds the specified to this device-provider. /// /// The to add. public void AddDeviceDefinition(IDMXDeviceDefinition deviceDefinition) => DeviceDefinitions.Add(deviceDefinition); diff --git a/RGB.NET.Devices.Logitech/Enum/LogitechDeviceType.cs b/RGB.NET.Devices.Logitech/Enum/LogitechDeviceType.cs index 6697b2d..181e5a9 100644 --- a/RGB.NET.Devices.Logitech/Enum/LogitechDeviceType.cs +++ b/RGB.NET.Devices.Logitech/Enum/LogitechDeviceType.cs @@ -1,5 +1,8 @@ namespace RGB.NET.Devices.Logitech { + /// + /// Contains list of available logitech device types. + /// public enum LogitechDeviceType { Keyboard = 0x0, diff --git a/RGB.NET.Devices.Logitech/Enum/LogitechLedId.cs b/RGB.NET.Devices.Logitech/Enum/LogitechLedId.cs index 799ab70..3101371 100644 --- a/RGB.NET.Devices.Logitech/Enum/LogitechLedId.cs +++ b/RGB.NET.Devices.Logitech/Enum/LogitechLedId.cs @@ -1,4 +1,5 @@ // ReSharper disable InconsistentNaming +#pragma warning disable 1591 namespace RGB.NET.Devices.Logitech { diff --git a/RGB.NET.Devices.Logitech/Generic/LedMappings.cs b/RGB.NET.Devices.Logitech/Generic/LedMappings.cs index 679a4e3..dcc31f4 100644 --- a/RGB.NET.Devices.Logitech/Generic/LedMappings.cs +++ b/RGB.NET.Devices.Logitech/Generic/LedMappings.cs @@ -2,8 +2,14 @@ namespace RGB.NET.Devices.Logitech { + /// + /// Contains mappings for to . + /// public static class LedMappings { + /// + /// Gets the mapping for per key devices. + /// public static LedMapping PerKey { get; } = new() { { LedId.Keyboard_Escape, LogitechLedId.ESC }, @@ -131,11 +137,17 @@ namespace RGB.NET.Devices.Logitech { LedId.Keyboard_Custom1, LogitechLedId.G_BADGE }, }; + /// + /// Gets the mapping for per device devices. + /// public static LedMapping Device { get; } = new() { { LedId.Custom1, 0 } }; + /// + /// Gets the mapping for per zone keyboards. + /// public static LedMapping ZoneKeyboard { get; } = new() { { LedId.Keyboard_Programmable1, 0 }, @@ -172,6 +184,9 @@ namespace RGB.NET.Devices.Logitech { LedId.Keyboard_Programmable32, 31 }, }; + /// + /// Gets the mapping for per zone mice. + /// public static LedMapping ZoneMouse { get; } = new() { { LedId.Mouse1, 0 }, @@ -208,6 +223,9 @@ namespace RGB.NET.Devices.Logitech { LedId.Mouse32, 31 }, }; + /// + /// Gets the mapping for per zone headsets. + /// public static LedMapping ZoneHeadset { get; } = new() { { LedId.Headset1, 0 }, @@ -244,6 +262,9 @@ namespace RGB.NET.Devices.Logitech { LedId.Headset32, 31 }, }; + /// + /// Gets the mapping for per zone mousepads. + /// public static LedMapping ZoneMousepad { get; } = new() { { LedId.Mousepad1, 0 }, @@ -280,6 +301,9 @@ namespace RGB.NET.Devices.Logitech { LedId.Mousepad32, 31 }, }; + /// + /// Gets the mapping for per zone speakers. + /// public static LedMapping ZoneSpeaker { get; } = new() { { LedId.Speaker1, 0 }, diff --git a/RGB.NET.Devices.Logitech/Native/_LogitechGSDK.cs b/RGB.NET.Devices.Logitech/Native/_LogitechGSDK.cs index 1f34dab..f47efaf 100644 --- a/RGB.NET.Devices.Logitech/Native/_LogitechGSDK.cs +++ b/RGB.NET.Devices.Logitech/Native/_LogitechGSDK.cs @@ -69,7 +69,7 @@ namespace RGB.NET.Devices.Logitech.Native [DllImport("kernel32.dll")] private static extern bool FreeLibrary(IntPtr dllHandle); - [DllImport("kernel32.dll", CharSet = CharSet.Unicode)] + [DllImport("kernel32.dll", CharSet = CharSet.Ansi)] private static extern IntPtr GetProcAddress(IntPtr dllHandle, string name); #endregion diff --git a/RGB.NET.Devices.Msi/Native/_MsiSDK.cs b/RGB.NET.Devices.Msi/Native/_MsiSDK.cs index faa9dfe..fcc9fc3 100644 --- a/RGB.NET.Devices.Msi/Native/_MsiSDK.cs +++ b/RGB.NET.Devices.Msi/Native/_MsiSDK.cs @@ -75,7 +75,7 @@ namespace RGB.NET.Devices.Msi.Native [DllImport("kernel32.dll")] private static extern bool FreeLibrary(IntPtr dllHandle); - [DllImport("kernel32.dll", CharSet = CharSet.Unicode)] + [DllImport("kernel32.dll", CharSet = CharSet.Ansi)] private static extern IntPtr GetProcAddress(IntPtr dllHandle, string name); #endregion diff --git a/RGB.NET.Devices.Novation/Generic/MidiUpdateQueue.cs b/RGB.NET.Devices.Novation/Generic/MidiUpdateQueue.cs index 9c39612..aa040be 100644 --- a/RGB.NET.Devices.Novation/Generic/MidiUpdateQueue.cs +++ b/RGB.NET.Devices.Novation/Generic/MidiUpdateQueue.cs @@ -53,7 +53,7 @@ namespace RGB.NET.Devices.Novation /// - /// Creates a update-message out of a given data set. + /// Creates a update-message out of a specified data set. /// /// The data set to create the message from. /// The message created out of the data set. diff --git a/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs b/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs index ffa5d9c..94a267e 100644 --- a/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs +++ b/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs @@ -17,6 +17,7 @@ namespace RGB.NET.Devices.Novation /// Initializes a new instance of the class. /// /// The generic information provided by Novation for the device. + /// The update trigger used to update this device. protected NovationRGBDevice(TDeviceInfo info, IDeviceUpdateTrigger updateTrigger) : base(info, GetUpdateQueue(updateTrigger, info)) { } diff --git a/RGB.NET.Devices.PicoPi/PicoPi/LedMappings.cs b/RGB.NET.Devices.PicoPi/PicoPi/LedMappings.cs index dd37db9..4ed85f6 100644 --- a/RGB.NET.Devices.PicoPi/PicoPi/LedMappings.cs +++ b/RGB.NET.Devices.PicoPi/PicoPi/LedMappings.cs @@ -2,10 +2,16 @@ namespace RGB.NET.Devices.PicoPi { + /// + /// Contains mappings for to the buffer-offset. + /// public static class LedMappings { #region Properties & Fields + /// + /// Gets the defautlt offset-mapping. + /// public static LedMapping StripeMapping = new(); #endregion diff --git a/RGB.NET.Devices.PicoPi/PicoPi/PicoPiSDK.cs b/RGB.NET.Devices.PicoPi/PicoPi/PicoPiSDK.cs index f3a8248..c2ad416 100644 --- a/RGB.NET.Devices.PicoPi/PicoPi/PicoPiSDK.cs +++ b/RGB.NET.Devices.PicoPi/PicoPi/PicoPiSDK.cs @@ -13,7 +13,16 @@ namespace RGB.NET.Devices.PicoPi { #region Constants + /// + /// The vendor id used by the pico-pi firmware. + /// Registered at https://pid.codes/1209/2812/ + /// public const int VENDOR_ID = 0x1209; + + /// + /// The product id used by the pico-pi firmware. + /// Registered at https://pid.codes/1209/2812/ + /// public const int HID_BULK_CONTROLLER_PID = 0x2812; private const byte COMMAND_CHANNEL_COUNT = 0x01; diff --git a/RGB.NET.Devices.Razer/Generic/LedMappings.cs b/RGB.NET.Devices.Razer/Generic/LedMappings.cs index d136b54..cd9cbff 100644 --- a/RGB.NET.Devices.Razer/Generic/LedMappings.cs +++ b/RGB.NET.Devices.Razer/Generic/LedMappings.cs @@ -3,8 +3,14 @@ using RGB.NET.Devices.Razer.Native; namespace RGB.NET.Devices.Razer { + /// + /// Contains mappings for to the matrix location. + /// public static class LedMappings { + /// + /// Gets the mapping for keyboards. + /// public static LedMapping Keyboard { get; } = new() { //Row 0 is empty @@ -154,6 +160,9 @@ namespace RGB.NET.Devices.Razer //Row 7 is also empty }; + /// + /// Gets the mapping for laptop keyboards. + /// public static LedMapping LaptopKeyboard { get; } = new() { //Row 0 is empty @@ -272,6 +281,9 @@ namespace RGB.NET.Devices.Razer //Row 7 is also empty }; + /// + /// Gets the mapping for mice. + /// public static LedMapping Mouse { get; } = new() { //row 0 empty @@ -316,12 +328,24 @@ namespace RGB.NET.Devices.Razer }; //TODO DarthAffe 27.04.2021: Are mappings for these possible? + /// + /// Gets the mapping for mousepads. + /// public static LedMapping Mousepad { get; } = new(); + /// + /// Gets the mapping for headsets. + /// public static LedMapping Headset { get; } = new(); + /// + /// Gets the mapping for keypads. + /// public static LedMapping Keypad { get; } = new(); + /// + /// Gets the mapping for chroma link devices. + /// public static LedMapping ChromaLink { get; } = new(); } } diff --git a/RGB.NET.Devices.Razer/Generic/RazerRGBDevice.cs b/RGB.NET.Devices.Razer/Generic/RazerRGBDevice.cs index 6a7208c..97ef2ea 100644 --- a/RGB.NET.Devices.Razer/Generic/RazerRGBDevice.cs +++ b/RGB.NET.Devices.Razer/Generic/RazerRGBDevice.cs @@ -17,6 +17,7 @@ namespace RGB.NET.Devices.Razer /// Initializes a new instance of the class. /// /// The generic information provided by razer for the device. + /// The queue used to update this device. protected RazerRGBDevice(RazerRGBDeviceInfo info, IUpdateQueue updateQueue) : base(info, updateQueue) { diff --git a/RGB.NET.Devices.Razer/Native/_RazerSDK.cs b/RGB.NET.Devices.Razer/Native/_RazerSDK.cs index cd377e1..65c29d3 100644 --- a/RGB.NET.Devices.Razer/Native/_RazerSDK.cs +++ b/RGB.NET.Devices.Razer/Native/_RazerSDK.cs @@ -68,7 +68,7 @@ namespace RGB.NET.Devices.Razer.Native [DllImport("kernel32.dll")] private static extern bool FreeLibrary(IntPtr dllHandle); - [DllImport("kernel32.dll", CharSet = CharSet.Unicode)] + [DllImport("kernel32.dll", CharSet = CharSet.Ansi)] private static extern IntPtr GetProcAddress(IntPtr dllHandle, string name); #endregion diff --git a/RGB.NET.Devices.SteelSeries/Enum/SteelSeriesLedId.cs b/RGB.NET.Devices.SteelSeries/Enum/SteelSeriesLedId.cs index 29a4035..9adcfdc 100644 --- a/RGB.NET.Devices.SteelSeries/Enum/SteelSeriesLedId.cs +++ b/RGB.NET.Devices.SteelSeries/Enum/SteelSeriesLedId.cs @@ -1,7 +1,11 @@ // ReSharper disable InconsistentNaming +#pragma warning disable 1591 namespace RGB.NET.Devices.SteelSeries { + /// + /// Contains a list of Steel Series LED IDs + /// public enum SteelSeriesLedId { [APIName("one")] diff --git a/RGB.NET.Devices.SteelSeries/Generic/LedMappings.cs b/RGB.NET.Devices.SteelSeries/Generic/LedMappings.cs index ec8d699..a1def31 100644 --- a/RGB.NET.Devices.SteelSeries/Generic/LedMappings.cs +++ b/RGB.NET.Devices.SteelSeries/Generic/LedMappings.cs @@ -2,8 +2,14 @@ namespace RGB.NET.Devices.SteelSeries { + /// + /// Contains mappings for to . + /// public static class LedMappings { + /// + /// Gets the uk-mapping for keyboards. + /// public static LedMapping KeyboardMappingUk { get; } = new() { { LedId.Logo, SteelSeriesLedId.Logo }, @@ -114,6 +120,9 @@ namespace RGB.NET.Devices.SteelSeries { LedId.Keyboard_NumPeriodAndDelete, SteelSeriesLedId.KeypadPeriod } }; + /// + /// Gets the uk-tkl-mapping for keyboards. + /// public static LedMapping KeyboardTklMappingUk { get; } = new() { { LedId.Logo, SteelSeriesLedId.Logo }, @@ -207,17 +216,26 @@ namespace RGB.NET.Devices.SteelSeries { LedId.Keyboard_ArrowRight, SteelSeriesLedId.RightArrow } }; + /// + /// Gets the mapping for one-zone mice. + /// public static LedMapping MouseOneZone { get; } = new() { { LedId.Mouse1, SteelSeriesLedId.ZoneOne } }; + /// + /// Gets the mapping for two-zone mice. + /// public static LedMapping MouseTwoZone { get; } = new() { { LedId.Mouse1, SteelSeriesLedId.ZoneOne }, { LedId.Mouse2, SteelSeriesLedId.ZoneTwo } }; + /// + /// Gets the mapping for three-zone mice. + /// public static LedMapping MouseThreeZone { get; } = new() { { LedId.Mouse1, SteelSeriesLedId.ZoneOne }, @@ -225,6 +243,9 @@ namespace RGB.NET.Devices.SteelSeries { LedId.Mouse3, SteelSeriesLedId.ZoneThree } }; + /// + /// Gets the mapping for eight-zone mice. + /// public static LedMapping MouseEightZone { get; } = new() { { LedId.Mouse1, SteelSeriesLedId.ZoneOne }, @@ -237,12 +258,18 @@ namespace RGB.NET.Devices.SteelSeries { LedId.Mouse8, SteelSeriesLedId.ZoneEight } }; + /// + /// Gets the mapping for two-zone headsets. + /// public static LedMapping HeadsetTwoZone { get; } = new() { { LedId.Headset1, SteelSeriesLedId.ZoneOne }, { LedId.Headset2, SteelSeriesLedId.ZoneTwo } }; + /// + /// Gets the mapping for twelve-zone mousepads + /// public static LedMapping MousepadTwelveZone { get; } = new() { { LedId.Mousepad1, SteelSeriesLedId.ZoneOne }, @@ -259,6 +286,9 @@ namespace RGB.NET.Devices.SteelSeries { LedId.Mousepad12, SteelSeriesLedId.ZoneTwelve }, }; + /// + /// Gets the mapping for 103-zone led strip devices (monitor). + /// public static LedMapping MonitorOnehundredandthreeZone { get; } = new() { { LedId.LedStripe1, SteelSeriesLedId.ZoneOne }, diff --git a/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs b/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs index deac3ae..a4d8c67 100644 --- a/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs +++ b/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs @@ -11,6 +11,7 @@ namespace RGB.NET.Devices.WS281X /// Represents a device provider responsible for WS2812B- and WS2811-Led-devices. /// // ReSharper disable once InconsistentNaming + // ReSharper disable once UnusedType.Global public class WS281XDeviceProvider : AbstractRGBDeviceProvider { #region Properties & Fields @@ -47,14 +48,16 @@ namespace RGB.NET.Devices.WS281X #region Methods /// - /// Adds the given to this device-provider. + /// Adds the specified to this device-provider. /// /// The to add. // ReSharper disable once UnusedMember.Global public void AddDeviceDefinition(IWS281XDeviceDefinition deviceDefinition) => DeviceDefinitions.Add(deviceDefinition); + /// protected override void InitializeSDK() { } + /// protected override IEnumerable LoadDevices() { int i = 0; diff --git a/RGB.NET.Devices.Wooting/Enum/WootingDeviceType.cs b/RGB.NET.Devices.Wooting/Enum/WootingDeviceType.cs index 473ff2e..6b25a54 100644 --- a/RGB.NET.Devices.Wooting/Enum/WootingDeviceType.cs +++ b/RGB.NET.Devices.Wooting/Enum/WootingDeviceType.cs @@ -2,6 +2,9 @@ namespace RGB.NET.Devices.Wooting.Enum { + /// + /// Represents the type of a wooting device + /// public enum WootingDeviceType { /// 10 Keyless Keyboard. E.g. Wooting One diff --git a/RGB.NET.HID/HIDLoader.cs b/RGB.NET.HID/HIDLoader.cs index f4a7389..a8cee36 100644 --- a/RGB.NET.HID/HIDLoader.cs +++ b/RGB.NET.HID/HIDLoader.cs @@ -7,8 +7,18 @@ using RGB.NET.Core; namespace RGB.NET.HID { + /// + /// Represents the data used to define a HID-device. + /// + /// The type of the identifier leds are mapped to. + /// The type of the custom data added to the HID-device. public record HIDDeviceDefinition(int ProductId, RGBDeviceType DeviceType, string Name, LedMapping LedMapping, TData CustomData) where TLed : notnull; + /// + /// Represents a loaded for HID-devices based on the specified definitions. + /// + /// The type of the identifier leds are mapped to. + /// The type of the custom data added to the HID-device. public class HIDLoader : IEnumerable> where TLed : notnull { @@ -16,14 +26,24 @@ namespace RGB.NET.HID private readonly Dictionary> _deviceDefinitions = new(); + /// + /// Gets the vendor id used for this loader. + /// public int VendorId { get; } + /// + /// Gets or sets the filter used to determine which devices should be loaded. + /// public RGBDeviceType LoadFilter { get; set; } = RGBDeviceType.All; #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The vendor id used for this loader. public HIDLoader(int vendorId) { this.VendorId = vendorId; @@ -33,9 +53,21 @@ namespace RGB.NET.HID #region Methods + /// + /// Adds a new to this loader. + /// + /// The product id of the HID-device. + /// The type of the device. + /// The name of the device. + /// The mapping of the leds of the device. + /// Some custom data to attach to the device. public void Add(int productId, RGBDeviceType deviceType, string name, LedMapping ledMapping, TData customData) => _deviceDefinitions.Add(productId, new HIDDeviceDefinition(productId, deviceType, name, ledMapping, customData)); + /// + /// Gets a enumerable containing all devices from the definition-list that are connected and match the . + /// + /// The enumerable containing the connected devices. public IEnumerable<(HIDDeviceDefinition definition, HidDevice device)> GetConnectedDevices() { IEnumerable devices = DeviceList.Local.GetHidDevices(VendorId); @@ -47,11 +79,20 @@ namespace RGB.NET.HID } } + /// + /// Gets a enumerable containing all the first device of each group of devices from the definition-list that are connected and match the . + /// The grouping is done by the specified function. + /// + /// The type of the key used to group the devices. + /// The function grouping the devices. + /// The enumerable containing the selected devices. public IEnumerable<(HIDDeviceDefinition definition, HidDevice device)> GetConnectedDevices(Func, TKey> groupBy) => GetConnectedDevices().GroupBy(x => groupBy(x.definition)) .Select(group => group.First()); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + + /// public IEnumerator> GetEnumerator() => _deviceDefinitions.Values.GetEnumerator(); #endregion diff --git a/RGB.NET.Layout/DeviceLayout.cs b/RGB.NET.Layout/DeviceLayout.cs index 77049e9..6aaccee 100644 --- a/RGB.NET.Layout/DeviceLayout.cs +++ b/RGB.NET.Layout/DeviceLayout.cs @@ -87,6 +87,10 @@ namespace RGB.NET.Layout [DefaultValue(19.0)] public float LedUnitHeight { get; set; } = 19.0f; + /// + /// Gets or sets the internal list of led layouts. + /// Normally you should use to access this data. + /// [XmlArray("Leds")] public List InternalLeds { get; set; } = new(); @@ -96,9 +100,14 @@ namespace RGB.NET.Layout [XmlIgnore] public IEnumerable Leds => InternalLeds; + /// + /// Gets or sets the internal custom data of this layout. + /// Normally you should use to access or set this data. + /// [XmlElement("CustomData")] public object? InternalCustomData { get; set; } + /// [XmlIgnore] public object? CustomData { get; set; } @@ -107,9 +116,11 @@ namespace RGB.NET.Layout #region Methods /// - /// Creates a new from the given xml. + /// Creates a new from the specified xml. /// /// The path to the xml file. + /// The type of the custom data. + /// The type of the custom data of the leds. /// The deserialized . public static DeviceLayout? Load(string path, Type? customDeviceDataType = null, Type? customLedDataType = null) { @@ -144,6 +155,12 @@ namespace RGB.NET.Layout } } + /// + /// Gets the deserialized custom data. + /// + /// The internal custom data node. + /// The type of the custom data. + /// The deserialized custom data object. protected virtual object? GetCustomData(object? customData, Type? type) { XmlNode? node = (customData as XmlNode) ?? (customData as IEnumerable)?.FirstOrDefault()?.ParentNode; //HACK DarthAffe 16.01.2021: This gives us the CustomData-Node diff --git a/RGB.NET.Layout/IDeviceLayout.cs b/RGB.NET.Layout/IDeviceLayout.cs index 2879200..aa05b7c 100644 --- a/RGB.NET.Layout/IDeviceLayout.cs +++ b/RGB.NET.Layout/IDeviceLayout.cs @@ -3,6 +3,9 @@ using RGB.NET.Core; namespace RGB.NET.Layout { + /// + /// Represents a generic layout of a device. + /// public interface IDeviceLayout { /// @@ -55,6 +58,9 @@ namespace RGB.NET.Layout /// IEnumerable Leds { get; } + /// + /// Gets the the custom data associated with the device. + /// object? CustomData { get; } } } diff --git a/RGB.NET.Layout/ILedLayout.cs b/RGB.NET.Layout/ILedLayout.cs index 5569692..9725166 100644 --- a/RGB.NET.Layout/ILedLayout.cs +++ b/RGB.NET.Layout/ILedLayout.cs @@ -2,6 +2,9 @@ namespace RGB.NET.Layout { + /// + /// Represents a generic layour of a LED. + /// public interface ILedLayout { /// @@ -39,6 +42,9 @@ namespace RGB.NET.Layout /// float Height { get; } + /// + /// Gets the the custom data associated with the LED. + /// object? CustomData { get; } } } diff --git a/RGB.NET.Layout/LayoutExtension.cs b/RGB.NET.Layout/LayoutExtension.cs index ec88f27..e917c42 100644 --- a/RGB.NET.Layout/LayoutExtension.cs +++ b/RGB.NET.Layout/LayoutExtension.cs @@ -5,8 +5,18 @@ using RGB.NET.Core; namespace RGB.NET.Layout { + /// + /// Offers some extensions and helper-methods for layout related things. + /// public static class LayoutExtension { + /// + /// Applies the specified layout to the specified device. + /// + /// The layout to apply. + /// The device to apply the layout to. + /// Indicates if LEDs that are in the layout but not on the device should be created. + /// Indicates if LEDS that are on the device but not in the layout should be removed. public static void ApplyTo(this IDeviceLayout layout, IRGBDevice device, bool createMissingLeds = false, bool removeExcessiveLeds = false) { device.Size = new Size(layout.Width, layout.Height); diff --git a/RGB.NET.Layout/LedLayout.cs b/RGB.NET.Layout/LedLayout.cs index 39af645..75d5fad 100644 --- a/RGB.NET.Layout/LedLayout.cs +++ b/RGB.NET.Layout/LedLayout.cs @@ -61,9 +61,14 @@ namespace RGB.NET.Layout [DefaultValue("1.0")] public string DescriptiveHeight { get; set; } = "1.0"; + /// + /// Gets or sets the internal custom data of this layout. + /// Normally you should use to access or set this data. + /// [XmlElement("CustomData")] public object? InternalCustomData { get; set; } + /// [XmlIgnore] public object? CustomData { get; set; } @@ -128,6 +133,14 @@ namespace RGB.NET.Layout Y = GetLocationValue(DescriptiveY, lastLed?.Y ?? 0, Height, lastLed?.Height ?? 0); } + /// + /// Gets the calculated location-value from the internal representation. + /// + /// The value provided by the layout. + /// The location of the last calculated LED. + /// The size of the current LED. + /// The size of the last loaded LED. + /// The location-value of the LED. protected virtual float GetLocationValue(string value, float lastValue, float currentSize, float lastSize) { try @@ -165,6 +178,12 @@ namespace RGB.NET.Layout } } + /// + /// Gets the calculated size-value from the internal representation. + /// + /// The value provided by the layout. + /// The absolute size of one 'unit'. + /// The size-value of the LED. protected virtual float GetSizeValue(string value, float unitSize) { try diff --git a/RGB.NET.Presets/Decorators/FlashDecorator.cs b/RGB.NET.Presets/Decorators/FlashDecorator.cs index 696782a..fd46c23 100644 --- a/RGB.NET.Presets/Decorators/FlashDecorator.cs +++ b/RGB.NET.Presets/Decorators/FlashDecorator.cs @@ -76,6 +76,11 @@ namespace RGB.NET.Presets.Decorators #region Constructors + /// + /// Creates a new from the specified xml. + /// + /// The surface this decorator belongs to. + /// A value indicating if the decorator should be updated if it is disabled. public FlashDecorator(RGBSurface surface, bool updateIfDisabled = false) : base(surface, updateIfDisabled) { } diff --git a/RGB.NET.Presets/Decorators/MoveGradientDecorator.cs b/RGB.NET.Presets/Decorators/MoveGradientDecorator.cs index 5f2280f..7233ec4 100644 --- a/RGB.NET.Presets/Decorators/MoveGradientDecorator.cs +++ b/RGB.NET.Presets/Decorators/MoveGradientDecorator.cs @@ -38,6 +38,7 @@ namespace RGB.NET.Presets.Decorators /// /// Initializes a new instance of the class. /// + /// The surface this decorator belongs to. /// The speed of the movement in units per second. /// The meaning of units differs for the different but 360 units will always be one complete cycle: /// : 360 unit = 1 offset. diff --git a/RGB.NET.Presets/Groups/RectangleLedGroup.cs b/RGB.NET.Presets/Groups/RectangleLedGroup.cs index a17ff98..c650322 100644 --- a/RGB.NET.Presets/Groups/RectangleLedGroup.cs +++ b/RGB.NET.Presets/Groups/RectangleLedGroup.cs @@ -54,10 +54,10 @@ namespace RGB.NET.Presets.Groups /// /// Initializes a new instance of the class. /// + /// Specifies the surface to attach this group to or null if the group should not be attached on creation. /// They first to calculate the of this from. /// They second to calculate the of this from. /// (optional) The minimal percentage overlay a must have with the to be taken into the . (default: 0.5) - /// (optional) Specifies whether this should be automatically attached or not. (default: true) public RectangleLedGroup(RGBSurface? surface, Led fromLed, Led toLed, double minOverlayPercentage = 0.5) : this(surface, new Rectangle(fromLed.Boundary, toLed.Boundary), minOverlayPercentage) { } @@ -66,10 +66,10 @@ namespace RGB.NET.Presets.Groups /// /// Initializes a new instance of the class. /// + /// Specifies the surface to attach this group to or null if the group should not be attached on creation. /// They first point to calculate the of this from. /// They second point to calculate the of this from. /// (optional) The minimal percentage overlay a must have with the to be taken into the . (default: 0.5) - /// (optional) Specifies whether this should be automatically attached or not. (default: true) public RectangleLedGroup(RGBSurface? surface, Point fromPoint, Point toPoint, double minOverlayPercentage = 0.5) : this(surface, new Rectangle(fromPoint, toPoint), minOverlayPercentage) { } @@ -78,9 +78,9 @@ namespace RGB.NET.Presets.Groups /// /// Initializes a new instance of the class. /// + /// Specifies the surface to attach this group to or null if the group should not be attached on creation. /// The of this . /// (optional) The minimal percentage overlay a must have with the to be taken into the . (default: 0.5) - /// (optional) Specifies whether this should be automatically attached or not. (default: true) public RectangleLedGroup(RGBSurface? surface, Rectangle rectangle, double minOverlayPercentage = 0.5) : base(surface) { diff --git a/RGB.NET.Presets/Helper/GradientHelper.cs b/RGB.NET.Presets/Helper/GradientHelper.cs index 6254fe5..88bba71 100644 --- a/RGB.NET.Presets/Helper/GradientHelper.cs +++ b/RGB.NET.Presets/Helper/GradientHelper.cs @@ -14,7 +14,7 @@ namespace RGB.NET.Presets.Helper // Based on https://web.archive.org/web/20170125201230/https://dotupdate.wordpress.com/2008/01/28/find-the-color-of-a-point-in-a-lineargradientbrush/ /// - /// Calculates the offset of an given on an gradient. + /// Calculates the offset of an specified on an gradient. /// /// The start of the gradient. /// The end of the gradient. diff --git a/RGB.NET.Presets/Textures/AbstractGradientTexture.cs b/RGB.NET.Presets/Textures/AbstractGradientTexture.cs index a724871..44fb53e 100644 --- a/RGB.NET.Presets/Textures/AbstractGradientTexture.cs +++ b/RGB.NET.Presets/Textures/AbstractGradientTexture.cs @@ -3,12 +3,17 @@ using RGB.NET.Presets.Textures.Gradients; namespace RGB.NET.Presets.Textures { + /// + /// + /// + /// Represents a abstract texture containing a color-gradient. + /// public abstract class AbstractGradientTexture : AbstractBindable, ITexture { #region Properties & Fields /// - /// Gets the gradient drawn by the brush. + /// Gets the gradient used to generate this texture. /// public IGradient Gradient { get; } @@ -25,6 +30,11 @@ namespace RGB.NET.Presets.Textures #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The size of the texture. + /// The gradient used to generate this texture. protected AbstractGradientTexture(Size size, IGradient gradient) { this.Size = size; @@ -35,6 +45,11 @@ namespace RGB.NET.Presets.Textures #region Methods + /// + /// Gets the color at the specified location of the texture. + /// + /// The location to get the color from. + /// The color at the specified location. protected abstract Color GetColor(in Point point); #endregion diff --git a/RGB.NET.Presets/Textures/BytePixelTexture.cs b/RGB.NET.Presets/Textures/BytePixelTexture.cs index ab008b7..9f1fd85 100644 --- a/RGB.NET.Presets/Textures/BytePixelTexture.cs +++ b/RGB.NET.Presets/Textures/BytePixelTexture.cs @@ -4,42 +4,69 @@ using RGB.NET.Presets.Textures.Sampler; namespace RGB.NET.Presets.Textures { + /// + /// + /// Represents a texture of byte-data pixels. + /// public sealed class BytePixelTexture : PixelTexture { #region Properties & Fields private readonly byte[] _data; + /// protected override ReadOnlySpan Data => _data; + /// + /// Gets the color format the data is in. + /// public ColorFormat ColorFormat { get; } #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// A is used. + /// + /// The width of the texture. + /// The height of the texture. + /// The pixel-data of the texture. + /// The color format the data is in. (default: RGB) public BytePixelTexture(int with, int height, byte[] data, ColorFormat colorFormat = ColorFormat.RGB) : this(with, height, data, new AverageByteSampler(), colorFormat) { } + /// + /// Initializes a new instance of the class. + /// + /// The width of the texture. + /// The height of the texture. + /// The pixel-data of the texture. + /// The sampler used to get the color of a region. + /// The color format the data is in. (default: RGB) public BytePixelTexture(int with, int height, byte[] data, ISampler sampler, ColorFormat colorFormat = ColorFormat.RGB) : base(with, height, 3, sampler) { this._data = data; this.ColorFormat = colorFormat; - if (Data.Length != ((with * height) * 3)) throw new ArgumentException($"Data-Length {Data.Length} differs from the given size {with}x{height} * 3 bytes ({with * height * 3})."); + if (Data.Length != ((with * height) * 3)) throw new ArgumentException($"Data-Length {Data.Length} differs from the specified size {with}x{height} * 3 bytes ({with * height * 3})."); } #endregion #region Methods + /// protected override Color GetColor(in ReadOnlySpan pixel) { - if (ColorFormat == ColorFormat.BGR) - return new Color(pixel[2], pixel[1], pixel[0]); - - return new Color(pixel[0], pixel[1], pixel[2]); + return ColorFormat switch + { + ColorFormat.RGB => new Color(pixel[0], pixel[1], pixel[2]), + ColorFormat.BGR => new Color(pixel[2], pixel[1], pixel[0]), + _ => throw new ArgumentOutOfRangeException() + }; } #endregion diff --git a/RGB.NET.Presets/Textures/ConicalGradientTexture.cs b/RGB.NET.Presets/Textures/ConicalGradientTexture.cs index cf53ae4..60066fc 100644 --- a/RGB.NET.Presets/Textures/ConicalGradientTexture.cs +++ b/RGB.NET.Presets/Textures/ConicalGradientTexture.cs @@ -12,7 +12,7 @@ namespace RGB.NET.Presets.Textures { /// /// - /// Represents a brush drawing a conical gradient. + /// Represents a texture drawing a conical gradient. /// public sealed class ConicalGradientTexture : AbstractGradientTexture { @@ -51,6 +51,7 @@ namespace RGB.NET.Presets.Textures /// /// Initializes a new instance of the class. /// + /// The size of the texture. /// The drawn by this . public ConicalGradientTexture(Size size, IGradient gradient) : base(size, gradient) @@ -59,8 +60,9 @@ namespace RGB.NET.Presets.Textures /// /// Initializes a new instance of the class. /// - /// The center (as percentage in the range [0..1]). + /// The size of the texture. /// The drawn by this . + /// The center (as percentage in the range [0..1]). public ConicalGradientTexture(Size size, IGradient gradient, Point center) : base(size, gradient) { @@ -70,9 +72,10 @@ namespace RGB.NET.Presets.Textures /// /// Initializes a new instance of the class. /// - /// The center (as percentage in the range [0..1]). - /// The origin (radian-angle) the is drawn to. + /// The size of the texture. /// The drawn by this . + /// The center (as percentage in the range [0..1]). + /// The origin (radian-angle) the gradient is drawn to. public ConicalGradientTexture(Size size, IGradient gradient, Point center, float origin) : base(size, gradient) { @@ -84,6 +87,7 @@ namespace RGB.NET.Presets.Textures #region Methods + /// protected override Color GetColor(in Point point) { float angle = MathF.Atan2(point.Y - Center.Y, point.X - Center.X) - Origin; diff --git a/RGB.NET.Presets/Textures/Enums/ColorFormat.cs b/RGB.NET.Presets/Textures/Enums/ColorFormat.cs index a098ff5..d190501 100644 --- a/RGB.NET.Presets/Textures/Enums/ColorFormat.cs +++ b/RGB.NET.Presets/Textures/Enums/ColorFormat.cs @@ -1,5 +1,10 @@ -namespace RGB.NET.Presets.Textures +#pragma warning disable 1591 + +namespace RGB.NET.Presets.Textures { + /// + /// Contains a list of possible color formats. + /// public enum ColorFormat { RGB, diff --git a/RGB.NET.Presets/Textures/FloatPixelTexture.cs b/RGB.NET.Presets/Textures/FloatPixelTexture.cs index 686f05c..1eb3e08 100644 --- a/RGB.NET.Presets/Textures/FloatPixelTexture.cs +++ b/RGB.NET.Presets/Textures/FloatPixelTexture.cs @@ -4,42 +4,69 @@ using RGB.NET.Presets.Textures.Sampler; namespace RGB.NET.Presets.Textures { + /// + /// + /// Represents a texture of float-data pixels. + /// public sealed class FloatPixelTexture : PixelTexture { #region Properties & Fields private readonly float[] _data; + /// protected override ReadOnlySpan Data => _data; + /// + /// Gets the color format the data is in. + /// public ColorFormat ColorFormat { get; } #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// A is used. + /// + /// The width of the texture. + /// The height of the texture. + /// The pixel-data of the texture. + /// The color format the data is in. (default: RGB) public FloatPixelTexture(int with, int height, float[] data, ColorFormat colorFormat = ColorFormat.RGB) : this(with, height, data, new AverageFloatSampler(), colorFormat) { } + /// + /// Initializes a new instance of the class. + /// + /// The width of the texture. + /// The height of the texture. + /// The pixel-data of the texture. + /// The sampler used to get the color of a region. + /// The color format the data is in. (default: RGB) public FloatPixelTexture(int with, int height, float[] data, ISampler sampler, ColorFormat colorFormat = ColorFormat.RGB) : base(with, height, 3, sampler) { this._data = data; this.ColorFormat = colorFormat; - if (Data.Length != ((with * height) * 3)) throw new ArgumentException($"Data-Length {Data.Length} differs from the given size {with}x{height} * 3 bytes ({with * height * 3})."); + if (Data.Length != ((with * height) * 3)) throw new ArgumentException($"Data-Length {Data.Length} differs from the specified size {with}x{height} * 3 bytes ({with * height * 3})."); } #endregion #region Methods + /// protected override Color GetColor(in ReadOnlySpan pixel) { - if (ColorFormat == ColorFormat.BGR) - return new Color(pixel[2], pixel[1], pixel[0]); - - return new Color(pixel[0], pixel[1], pixel[2]); + return ColorFormat switch + { + ColorFormat.RGB => new Color(pixel[0], pixel[1], pixel[2]), + ColorFormat.BGR => new Color(pixel[2], pixel[1], pixel[0]), + _ => throw new ArgumentOutOfRangeException() + }; } #endregion diff --git a/RGB.NET.Presets/Textures/Gradients/LinearGradient.cs b/RGB.NET.Presets/Textures/Gradients/LinearGradient.cs index 2aa898e..9c27d08 100644 --- a/RGB.NET.Presets/Textures/Gradients/LinearGradient.cs +++ b/RGB.NET.Presets/Textures/Gradients/LinearGradient.cs @@ -79,7 +79,7 @@ namespace RGB.NET.Presets.Textures.Gradients /// /// - /// Gets the linear interpolated at the given offset. + /// Gets the linear interpolated at the specified offset. /// /// The percentage offset to take the color from. /// The at the specific offset. @@ -106,7 +106,7 @@ namespace RGB.NET.Presets.Textures.Gradients } /// - /// Get the two s encapsulating the given offset. + /// Get the two s encapsulating the specified offset. /// /// The reference offset. /// The ordered list of to choose from. diff --git a/RGB.NET.Presets/Textures/Gradients/RainbowGradient.cs b/RGB.NET.Presets/Textures/Gradients/RainbowGradient.cs index 1ec32e2..470c877 100644 --- a/RGB.NET.Presets/Textures/Gradients/RainbowGradient.cs +++ b/RGB.NET.Presets/Textures/Gradients/RainbowGradient.cs @@ -67,7 +67,7 @@ namespace RGB.NET.Presets.Textures.Gradients /// /// - /// Gets the color on the rainbow at the given offset. + /// Gets the color on the rainbow at the specified offset. /// /// The percentage offset to take the color from. /// The color at the specific offset. diff --git a/RGB.NET.Presets/Textures/LinearGradientTexture.cs b/RGB.NET.Presets/Textures/LinearGradientTexture.cs index d37bf6a..f3173d3 100644 --- a/RGB.NET.Presets/Textures/LinearGradientTexture.cs +++ b/RGB.NET.Presets/Textures/LinearGradientTexture.cs @@ -13,7 +13,7 @@ namespace RGB.NET.Presets.Textures { /// /// - /// Represents a brush drawing a linear gradient. + /// Represents a texture drawing a linear gradient. /// public sealed class LinearGradientTexture : AbstractGradientTexture { @@ -46,6 +46,7 @@ namespace RGB.NET.Presets.Textures /// /// Initializes a new instance of the class. /// + /// The size of the texture. /// The drawn by this . public LinearGradientTexture(Size size, IGradient gradient) : base(size, gradient) @@ -54,9 +55,10 @@ namespace RGB.NET.Presets.Textures /// /// Initializes a new instance of the class. /// + /// The size of the texture. + /// The drawn by this . /// The start (as percentage in the range [0..1]). /// The end (as percentage in the range [0..1]). - /// The drawn by this . public LinearGradientTexture(Size size, IGradient gradient, Point startPoint, Point endPoint) : base(size, gradient) { @@ -68,6 +70,7 @@ namespace RGB.NET.Presets.Textures #region Methods + /// protected override Color GetColor(in Point point) { float offset = GradientHelper.CalculateLinearGradientOffset(StartPoint, EndPoint, point); diff --git a/RGB.NET.Presets/Textures/RadialGradientTexture.cs b/RGB.NET.Presets/Textures/RadialGradientTexture.cs index b5ff848..4f6f4ca 100644 --- a/RGB.NET.Presets/Textures/RadialGradientTexture.cs +++ b/RGB.NET.Presets/Textures/RadialGradientTexture.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Presets.Textures { /// /// - /// Represents a brush drawing a radial gradient around a center point. + /// Represents a texture drawing a radial gradient around a center point. /// public sealed class RadialGradientTexture : AbstractGradientTexture { @@ -39,6 +39,7 @@ namespace RGB.NET.Presets.Textures /// /// Initializes a new instance of the class. /// + /// The size of the texture. /// The gradient drawn by the brush. public RadialGradientTexture(Size size, IGradient gradient) : base(size, gradient) @@ -47,8 +48,9 @@ namespace RGB.NET.Presets.Textures /// /// Initializes a new instance of the class. /// - /// The center point (as percentage in the range [0..1]). + /// The size of the texture. /// The gradient drawn by the brush. + /// The center point (as percentage in the range [0..1]). public RadialGradientTexture(Size size, IGradient gradient, Point center) : base(size, gradient) { @@ -66,6 +68,7 @@ namespace RGB.NET.Presets.Textures _referenceDistance = GradientHelper.CalculateDistance(new Point(referenceX, referenceY), Center); } + /// protected override Color GetColor(in Point point) { float distance = GradientHelper.CalculateDistance(point, Center); diff --git a/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs b/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs index b2f3770..dc94e5c 100644 --- a/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs +++ b/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs @@ -3,11 +3,15 @@ using RGB.NET.Core; namespace RGB.NET.Presets.Textures.Sampler { + /// + /// Represents a sampled that averages multiple byte-data entries. + /// public class AverageByteSampler : ISampler { #region Methods - public void SampleColor(in SamplerInfo info, in Span pixelData) + /// + public void Sample(in SamplerInfo info, in Span pixelData) { int count = info.Width * info.Height; if (count == 0) return; diff --git a/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs b/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs index 12b0368..902971f 100644 --- a/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs +++ b/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs @@ -3,11 +3,15 @@ using RGB.NET.Core; namespace RGB.NET.Presets.Textures.Sampler { + /// + /// Represents a sampled that averages multiple float-data entries. + /// public class AverageFloatSampler : ISampler { #region Methods - public void SampleColor(in SamplerInfo info, in Span pixelData) + /// + public void Sample(in SamplerInfo info, in Span pixelData) { int count = info.Width * info.Height; if (count == 0) return; diff --git a/Tests/RGB.NET.Core.Tests/Color/ColorTest.cs b/Tests/RGB.NET.Core.Tests/Color/ColorTest.cs index 4b22146..ed2e5d0 100644 --- a/Tests/RGB.NET.Core.Tests/Color/ColorTest.cs +++ b/Tests/RGB.NET.Core.Tests/Color/ColorTest.cs @@ -324,13 +324,16 @@ namespace RGB.NET.Core.Tests.Color Assert.AreEqual(1, color2.A); Core.Color color3 = new(128, 0, 0, 0); - Assert.AreEqual(128 / 255.0f, color3.A); + Assert.AreEqual(128 / 256.0f, color3.A); Core.Color color4 = new(30, 0, 0, 0); - Assert.AreEqual(30 / 255.0f, color4.A); + Assert.AreEqual(30 / 256.0f, color4.A); Core.Color color5 = new(201, 0, 0, 0); - Assert.AreEqual(201 / 255.0f, color5.A); + Assert.AreEqual(201 / 256.0f, color5.A); + + Core.Color color6 = new(255, 0, 0, 0); + Assert.AreEqual(1f, color6.A); } [TestMethod] @@ -343,13 +346,16 @@ namespace RGB.NET.Core.Tests.Color Assert.AreEqual(1, color2.R); Core.Color color3 = new(0, 128, 0, 0); - Assert.AreEqual(128 / 255.0f, color3.R); + Assert.AreEqual(128 / 256.0f, color3.R); Core.Color color4 = new(0, 30, 0, 0); - Assert.AreEqual(30 / 255.0f, color4.R); + Assert.AreEqual(30 / 256.0f, color4.R); Core.Color color5 = new(0, 201, 0, 0); - Assert.AreEqual(201 / 255.0f, color5.R); + Assert.AreEqual(201 / 256.0f, color5.R); + + Core.Color color6 = new(0, 255, 0, 0); + Assert.AreEqual(1f, color6.R); } [TestMethod] @@ -362,13 +368,16 @@ namespace RGB.NET.Core.Tests.Color Assert.AreEqual(1, color2.G); Core.Color color3 = new(0, 0, 128, 0); - Assert.AreEqual(128 / 255.0f, color3.G); + Assert.AreEqual(128 / 256.0f, color3.G); Core.Color color4 = new(0, 0, 30, 0); - Assert.AreEqual(30 / 255.0f, color4.G); + Assert.AreEqual(30 / 256.0f, color4.G); Core.Color color5 = new(0, 0, 201, 0); - Assert.AreEqual(201 / 255.0f, color5.G); + Assert.AreEqual(201 / 256.0f, color5.G); + + Core.Color color6 = new(0, 0, 255, 0); + Assert.AreEqual(1f, color6.G); } [TestMethod] @@ -381,13 +390,16 @@ namespace RGB.NET.Core.Tests.Color Assert.AreEqual(1, color2.B); Core.Color color3 = new(0, 0, 0, 128); - Assert.AreEqual(128 / 255.0f, color3.B); + Assert.AreEqual(128 / 256.0f, color3.B); Core.Color color4 = new(0, 0, 0, 30); - Assert.AreEqual(30 / 255.0f, color4.B); + Assert.AreEqual(30 / 256.0f, color4.B); Core.Color color5 = new(0, 0, 0, 201); - Assert.AreEqual(201 / 255.0f, color5.B); + Assert.AreEqual(201 / 256.0f, color5.B); + + Core.Color color6 = new(0, 0, 0, 255); + Assert.AreEqual(1f, color6.B); } #endregion