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 368ae8d..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.
@@ -155,8 +163,8 @@ namespace RGB.NET.Core
/// The color created from the values.
public static Color Create(float alpha, float h, float c, float l)
{
- (float r, float g, float _b) = CalculateRGBFromHcl(h, c, l);
- return new Color(alpha, r, g, _b);
+ (float r, float g, float b) = CalculateRGBFromHcl(h, c, l);
+ return new Color(alpha, r, g, b);
}
#endregion
@@ -167,6 +175,7 @@ namespace RGB.NET.Core
{
const float RADIANS_DEGREES_CONVERSION = 180.0f / MathF.PI;
+ // ReSharper disable once InconsistentNaming - b is used above
(float l, float a, float _b) = LabColor.CalculateLabFromRGB(r, g, b);
float h, c;
diff --git a/RGB.NET.Core/Color/LabColor.cs b/RGB.NET.Core/Color/LabColor.cs
index 5583a79..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.
@@ -155,6 +163,7 @@ namespace RGB.NET.Core
/// The color created from the values.
public static Color Create(float alpha, float l, float a, float b)
{
+ // ReSharper disable once InconsistentNaming - b is used above
(float r, float g, float _b) = CalculateRGBFromLab(l, a, b);
return new Color(alpha, r, g, _b);
}
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/IDecoratable.cs b/RGB.NET.Core/Decorators/IDecoratable.cs
index 781d9f1..2892638 100644
--- a/RGB.NET.Core/Decorators/IDecoratable.cs
+++ b/RGB.NET.Core/Decorators/IDecoratable.cs
@@ -13,7 +13,7 @@ namespace RGB.NET.Core
///
/// Represents a basic decoratable for a specific type of
///
- ///
+ /// The type of decorators this decoratable can be decorated with.
public interface IDecoratable : IDecoratable
where T : IDecorator
{
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..5f9e9bf 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;
}
+ ///
+ /// Gets the custom data associated with the specified LED.
+ ///
+ /// The id of the led.
+ /// The custom data for the specified 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..b058971 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,18 +40,18 @@ 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.
- ///
+ /// A enumerable of leds inside the specified rectangle.
IEnumerable this[Rectangle referenceRect, double minOverlayPercentage = 0.5] { get; }
#endregion
@@ -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 5233ce9..d2a8d1d 100644
--- a/RGB.NET.Core/Devices/IRGBDeviceProvider.cs
+++ b/RGB.NET.Core/Devices/IRGBDeviceProvider.cs
@@ -1,4 +1,6 @@
-using System;
+// ReSharper disable EventNeverSubscribedTo.Global
+
+using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -17,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
@@ -28,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;
@@ -36,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 cdc04f7..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.
@@ -33,7 +36,7 @@ namespace RGB.NET.Core
x = (x * cos) - (y * sin);
y = (x * sin) + (y * cos);
- return new Point(x + origin.X, y + origin.Y); ;
+ return new Point(x + origin.X, y + origin.Y);
}
#endregion
diff --git a/RGB.NET.Core/Extensions/RectangleExtensions.cs b/RGB.NET.Core/Extensions/RectangleExtensions.cs
index ce5745e..ea0dde7 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,7 +74,8 @@ namespace RGB.NET.Core
///
/// Calculates the representing the intersection of this and the one provided as parameter.
///
- /// The intersecting
+ /// 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..514a680 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.
+ ///
+ /// A enumerable containing all leds of 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 b6be55b..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,43 +60,42 @@ 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)
{
lock (GroupLeds)
foreach (Led led in leds)
- if ((led != null) && !ContainsLed(led))
+ if (!ContainsLed(led))
GroupLeds.Add(led);
}
///
- /// 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)
{
lock (GroupLeds)
foreach (Led led in leds)
- if (led != null)
- GroupLeds.Remove(led);
+ GroupLeds.Remove(led);
}
///
- /// 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.
@@ -107,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/MVVM/AbstractBindable.cs b/RGB.NET.Core/MVVM/AbstractBindable.cs
index 5d41f1c..92a3cd8 100644
--- a/RGB.NET.Core/MVVM/AbstractBindable.cs
+++ b/RGB.NET.Core/MVVM/AbstractBindable.cs
@@ -21,12 +21,12 @@ namespace RGB.NET.Core
#region Methods
///
- /// Checks if the property already matches the desirec value or needs to be updated.
+ /// Checks if the property already matches the desired value or needs to be updated.
///
/// Type of the property.
/// Reference to the backing-filed.
/// Value to apply.
- ///
+ /// true if the value needs to be updated; otherweise false.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected virtual bool RequiresUpdate(ref T storage, T value) => !Equals(storage, value);
diff --git a/RGB.NET.Core/Positioning/IPlaceable.cs b/RGB.NET.Core/Positioning/IPlaceable.cs
index dd6d79c..dcc3a17 100644
--- a/RGB.NET.Core/Positioning/IPlaceable.cs
+++ b/RGB.NET.Core/Positioning/IPlaceable.cs
@@ -1,7 +1,12 @@
-using System;
+// ReSharper disable EventNeverSubscribedTo.Global
+
+using System;
namespace RGB.NET.Core
{
+ ///
+ /// Represents a generic placeable element.
+ ///
public interface IPlaceable
{
#region Properties & Fields
@@ -48,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/Point.cs b/RGB.NET.Core/Positioning/Point.cs
index 5f04a76..588d889 100644
--- a/RGB.NET.Core/Positioning/Point.cs
+++ b/RGB.NET.Core/Positioning/Point.cs
@@ -1,6 +1,7 @@
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedMember.Global
+using System;
using System.Diagnostics;
namespace RGB.NET.Core
@@ -65,9 +66,8 @@ namespace RGB.NET.Core
/// true if is a equivalent to this ; otherwise, false.
public override bool Equals(object? obj)
{
- if (!(obj is Point)) return false;
+ if (obj is not Point comparePoint) return false;
- Point comparePoint = (Point)obj;
return ((float.IsNaN(X) && float.IsNaN(comparePoint.X)) || X.EqualsInTolerance(comparePoint.X))
&& ((float.IsNaN(Y) && float.IsNaN(comparePoint.Y)) || Y.EqualsInTolerance(comparePoint.Y));
}
@@ -76,15 +76,7 @@ namespace RGB.NET.Core
/// Returns a hash code for this .
///
/// An integer value that specifies the hash code for this .
- public override int GetHashCode()
- {
- unchecked
- {
- int hashCode = X.GetHashCode();
- hashCode = (hashCode * 397) ^ Y.GetHashCode();
- return hashCode;
- }
- }
+ public override int GetHashCode() => HashCode.Combine(X, Y);
#endregion
diff --git a/RGB.NET.Core/Positioning/Rectangle.cs b/RGB.NET.Core/Positioning/Rectangle.cs
index 3c545e6..36715a1 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,19 +75,19 @@ 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
+ /// The array of used to calculate the and .
public Rectangle(params Rectangle[] rectangles)
: this(rectangles.AsEnumerable())
{ }
///
- /// 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
+ /// The list of used to calculate the and .
public Rectangle(IEnumerable rectangles)
{
bool hasPoint = false;
@@ -113,20 +113,20 @@ 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
+ /// The array of used to calculate the and .
public Rectangle(params Point[] points)
: this(points.AsEnumerable())
{ }
///
///
- /// 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
+ /// The list of used to calculate the and .
public Rectangle(IEnumerable points)
: this()
{
@@ -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/RGB.NET.Core.csproj b/RGB.NET.Core/RGB.NET.Core.csproj
index 67fe585..c111d9c 100644
--- a/RGB.NET.Core/RGB.NET.Core.csproj
+++ b/RGB.NET.Core/RGB.NET.Core.csproj
@@ -15,11 +15,10 @@
RGB.NET.Core
Core-Module of RGB.NET
Core-Module of RGB.NET, a C# (.NET) library for accessing various RGB-peripherals
- Copyright © Darth Affe 2020
- Copyright © Darth Affe 2020
- http://lib.arge.be/icon.png
+ Copyright © Darth Affe 2021
+ icon.png
https://github.com/DarthAffe/RGB.NET
- https://raw.githubusercontent.com/DarthAffe/RGB.NET/master/LICENSE
+ LGPL-2.1-only
Github
https://github.com/DarthAffe/RGB.NET
True
@@ -34,19 +33,24 @@
true
True
True
+ pdbonly
+ snupkg
$(DefineConstants);TRACE;DEBUG
true
- full
false
- pdbonly
true
$(NoWarn);CS1591;CS1572;CS1573
$(DefineConstants);RELEASE
+
+
+
+
+
\ No newline at end of file
diff --git a/RGB.NET.Core/RGB.NET.Core.csproj.DotSettings b/RGB.NET.Core/RGB.NET.Core.csproj.DotSettings
index 9d38d8a..bf7655f 100644
--- a/RGB.NET.Core/RGB.NET.Core.csproj.DotSettings
+++ b/RGB.NET.Core/RGB.NET.Core.csproj.DotSettings
@@ -24,4 +24,5 @@
True
True
True
- True
\ No newline at end of file
+ True
+
\ No newline at end of file
diff --git a/RGB.NET.Core/RGBSurface.cs b/RGB.NET.Core/RGBSurface.cs
index 033d33e..6b9d726 100644
--- a/RGB.NET.Core/RGBSurface.cs
+++ b/RGB.NET.Core/RGBSurface.cs
@@ -18,11 +18,11 @@ namespace RGB.NET.Core
{
#region Properties & Fields
- private Stopwatch _deltaTimeCounter;
+ private readonly Stopwatch _deltaTimeCounter;
private readonly IList _devices = new List();
private readonly IList _updateTriggers = new List();
- private readonly List _ledGroups = new List();
+ private readonly List _ledGroups = new();
///
/// Gets a readonly list containing all loaded .
@@ -83,7 +83,7 @@ namespace RGB.NET.Core
///
/// Represents the event-handler of the -event.
///
- ///
+ /// The arguments provided by the event.
public delegate void SurfaceLayoutChangedEventHandler(SurfaceLayoutChangedEventArgs args);
#endregion
@@ -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 48a5f6f..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);
}
@@ -74,11 +97,11 @@ namespace RGB.NET.Core
{
T[] rent = ArrayPool.Shared.Rent(bufferSize);
- Span buffer = new Span(rent).Slice(0, bufferSize);
+ Span buffer = new Span(rent)[..bufferSize];
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/AbstractUpdateTrigger.cs b/RGB.NET.Core/Update/AbstractUpdateTrigger.cs
index 127b215..10ccd52 100644
--- a/RGB.NET.Core/Update/AbstractUpdateTrigger.cs
+++ b/RGB.NET.Core/Update/AbstractUpdateTrigger.cs
@@ -9,6 +9,7 @@ namespace RGB.NET.Core
{
#region Properties & Fields
+ ///
public abstract double LastUpdateTime { get; protected set; }
#endregion
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