diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5dd87e20..3d230929 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,26 +24,19 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: | + 9.0.x 8.0.x - 7.0.x - 6.0.x - name: Restore dependencies run: dotnet restore - name: Build run: dotnet build --no-restore --configuration Release /p:Version=${{ github.event.inputs.version }}-prerelease.${{ github.event.inputs.increment }} - name: Test run: dotnet test --no-build --verbosity normal --configuration Release - - name: Upload a Build Artifact NET6 + - name: Upload a Build Artifact NET9 uses: actions/upload-artifact@v4.3.1 with: - name: RGB.NET-NET6 - path: bin/net6.0/RGB.NET.*.dll - if-no-files-found: error - - name: Upload a Build Artifact NET7 - uses: actions/upload-artifact@v4.3.1 - with: - name: RGB.NET-NET7 - path: bin/net7.0/RGB.NET.*.dll + name: RGB.NET-NET9 + path: bin/net9.0/RGB.NET.*.dll if-no-files-found: error - name: Upload a Build Artifact NET8 uses: actions/upload-artifact@v4.3.1 diff --git a/.github/workflows/pr_verify.yml b/.github/workflows/pr_verify.yml index 539b7285..e4cc59ec 100644 --- a/.github/workflows/pr_verify.yml +++ b/.github/workflows/pr_verify.yml @@ -15,9 +15,8 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: | + 9.0.x 8.0.x - 7.0.x - 6.0.x - name: Restore dependencies run: dotnet restore - name: Build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 25047824..943dea60 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,26 +20,19 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: | + 9.0.x 8.0.x - 7.0.x - 6.0.x - name: Restore dependencies run: dotnet restore - name: Build run: dotnet build --no-restore --configuration Release /p:Version=${{ github.event.inputs.version }} - name: Test run: dotnet test --no-build --verbosity normal --configuration Release - - name: Upload a Build Artifact NET6 + - name: Upload a Build Artifact NET9 uses: actions/upload-artifact@v4.3.1 with: - name: RGB.NET-NET6 - path: bin/net6.0/RGB.NET.*.dll - if-no-files-found: error - - name: Upload a Build Artifact NET7 - uses: actions/upload-artifact@v4.3.1 - with: - name: RGB.NET-NET7 - path: bin/net7.0/RGB.NET.*.dll + name: RGB.NET-NET9 + path: bin/net9.0/RGB.NET.*.dll if-no-files-found: error - name: Upload a Build Artifact NET8 uses: actions/upload-artifact@v4.3.1 @@ -58,6 +51,6 @@ jobs: with: tag_name: v${{ github.event.inputs.version }} generate_release_notes: true - files: bin/net8.0/RGB.NET.*.dll + files: bin/net9.0/RGB.NET.*.dll - name: Nuget Push run: dotnet nuget push **\*.nupkg --skip-duplicate --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json diff --git a/RGB.NET.Core/Color/Behaviors/DefaultColorBehavior.cs b/RGB.NET.Core/Color/Behaviors/DefaultColorBehavior.cs index c1859c2f..36f41c8c 100644 --- a/RGB.NET.Core/Color/Behaviors/DefaultColorBehavior.cs +++ b/RGB.NET.Core/Color/Behaviors/DefaultColorBehavior.cs @@ -14,7 +14,7 @@ public sealed class DefaultColorBehavior : IColorBehavior /// Converts the individual byte values of this to a human-readable string. /// /// A string that contains the individual byte values of this . For example "[A: 255, R: 255, G: 0, B: 0]". - public string ToString(in Color color) => $"[A: {color.GetA()}, R: {color.GetR()}, G: {color.GetG()}, B: {color.GetB()}]"; + public string ToString(Color color) => $"[A: {color.GetA()}, R: {color.GetR()}, G: {color.GetG()}, B: {color.GetB()}]"; /// /// Tests whether the specified object is a and is equivalent to this . @@ -22,7 +22,7 @@ public sealed class DefaultColorBehavior : IColorBehavior /// The color to test. /// The object to test. /// true if is a equivalent to this ; otherwise, false. - public bool Equals(in Color color, object? obj) => obj is Color color2 && Equals(color, color2); + public bool Equals(Color color, object? obj) => obj is Color color2 && Equals(color, color2); /// /// Tests whether the specified object is a and is equivalent to this . @@ -30,7 +30,7 @@ public sealed class DefaultColorBehavior : IColorBehavior /// The first color to test. /// The second color to test. /// true if equivalent to this ; otherwise, false. - public bool Equals(in Color color, in Color color2) => color.A.EqualsInTolerance(color2.A) + public bool Equals(Color color, Color color2) => color.A.EqualsInTolerance(color2.A) && color.R.EqualsInTolerance(color2.R) && color.G.EqualsInTolerance(color2.G) && color.B.EqualsInTolerance(color2.B); @@ -39,14 +39,14 @@ public bool Equals(in Color color, in Color color2) => color.A.EqualsInTolerance /// Returns a hash code for this . /// /// An integer value that specifies the hash code for this . - public int GetHashCode(in Color color) => HashCode.Combine(color.A, color.R, color.G, color.B); + public int GetHashCode(Color color) => HashCode.Combine(color.A, color.R, color.G, color.B); /// /// Blends a over this color. /// /// The to to blend over. /// The to blend. - public Color Blend(in Color baseColor, in Color blendColor) + public Color Blend(Color baseColor, 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 f365f37e..432bb4f0 100644 --- a/RGB.NET.Core/Color/Behaviors/IColorBehavior.cs +++ b/RGB.NET.Core/Color/Behaviors/IColorBehavior.cs @@ -10,7 +10,7 @@ public interface IColorBehavior /// /// The color to convert. /// The string representation of the specified color. - string ToString(in Color color); + string ToString(Color color); /// /// Tests whether the specified object is a and is equivalent to this . @@ -18,7 +18,7 @@ public interface IColorBehavior /// The color to test. /// The object to test. /// true if is a equivalent to this ; otherwise, false. - bool Equals(in Color color, object? obj); + bool Equals(Color color, object? obj); /// /// Tests whether the specified object is a and is equivalent to this . @@ -26,18 +26,18 @@ public interface IColorBehavior /// The first color to test. /// The second color to test. /// true if equivalent to this ; otherwise, false. - bool Equals(in Color color, in Color color2); + bool Equals(Color color, Color color2); /// /// Returns a hash code for this . /// /// An integer value that specifies the hash code for this . - int GetHashCode(in Color color); + int GetHashCode(Color color); /// /// Blends a over this color. /// /// The to to blend over. /// The to blend. - Color Blend(in Color baseColor, in Color blendColor); + Color Blend(Color baseColor, Color blendColor); } \ No newline at end of file diff --git a/RGB.NET.Core/Color/Color.cs b/RGB.NET.Core/Color/Color.cs index c7865026..3ef16fb9 100644 --- a/RGB.NET.Core/Color/Color.cs +++ b/RGB.NET.Core/Color/Color.cs @@ -175,7 +175,7 @@ public Color(float a, float r, float g, float b) /// Initializes a new instance of the struct by cloning a existing . /// /// The the values are copied from. - public Color(in Color color) + public Color(Color color) : this(color.A, color.R, color.G, color.B) { } @@ -214,7 +214,7 @@ public Color(in Color color) /// Blends a over this color, as defined by the current . /// /// The to blend. - public Color Blend(in Color color) => Behavior.Blend(this, color); + public Color Blend(Color color) => Behavior.Blend(this, color); #endregion @@ -226,7 +226,7 @@ public Color(in Color color) /// The base color. /// The color to blend. /// The blended color. - public static Color operator +(in Color color1, in Color color2) => color1.Blend(color2); + public static Color operator +(Color color1, Color color2) => color1.Blend(color2); /// /// Returns a value that indicates whether two specified are equal. @@ -234,7 +234,7 @@ public Color(in Color color) /// The first to compare. /// The second to compare. /// true if and are equal; otherwise, false. - public static bool operator ==(in Color color1, in Color color2) => color1.Equals(color2); + public static bool operator ==(Color color1, Color color2) => color1.Equals(color2); /// /// Returns a value that indicates whether two specified are equal. @@ -242,7 +242,7 @@ public Color(in Color color) /// The first to compare. /// The second to compare. /// true if and are not equal; otherwise, false. - public static bool operator !=(in Color color1, in Color color2) => !(color1 == color2); + public static bool operator !=(Color color1, Color color2) => !(color1 == color2); /// /// Converts a of ARGB-components to a . diff --git a/RGB.NET.Core/Color/HSVColor.cs b/RGB.NET.Core/Color/HSVColor.cs index 35af63fe..c4177db6 100644 --- a/RGB.NET.Core/Color/HSVColor.cs +++ b/RGB.NET.Core/Color/HSVColor.cs @@ -16,21 +16,21 @@ public static class HSVColor /// /// 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; + public static float GetHue(this 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; + public static float GetSaturation(this 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; + public static float GetValue(this Color color) => color.GetHSV().value; /// /// Gets the hue, saturation and value component values (HSV-color space) of this . @@ -40,7 +40,7 @@ public static class HSVColor /// /// 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) + public static (float hue, float saturation, float value) GetHSV(this Color color) => CaclulateHSVFromRGB(color.R, color.G, color.B); #endregion @@ -55,7 +55,7 @@ public static (float hue, float saturation, float value) GetHSV(this in Color co /// The saturation value to add. /// The value value to add. /// The new color after the modification. - public static Color AddHSV(this in Color color, float hue = 0, float saturation = 0, float value = 0) + public static Color AddHSV(this Color color, float hue = 0, float saturation = 0, float value = 0) { (float cHue, float cSaturation, float cValue) = color.GetHSV(); return Create(color.A, cHue + hue, cSaturation + saturation, cValue + value); @@ -69,7 +69,7 @@ public static Color AddHSV(this in Color color, float hue = 0, float saturation /// The saturation value to subtract. /// The value value to subtract. /// The new color after the modification. - public static Color SubtractHSV(this in Color color, float hue = 0, float saturation = 0, float value = 0) + public static Color SubtractHSV(this Color color, float hue = 0, float saturation = 0, float value = 0) { (float cHue, float cSaturation, float cValue) = color.GetHSV(); return Create(color.A, cHue - hue, cSaturation - saturation, cValue - value); @@ -83,7 +83,7 @@ public static Color SubtractHSV(this in Color color, float hue = 0, float satura /// The saturation value to multiply. /// The value value to multiply. /// The new color after the modification. - public static Color MultiplyHSV(this in Color color, float hue = 1, float saturation = 1, float value = 1) + public static Color MultiplyHSV(this Color color, float hue = 1, float saturation = 1, float value = 1) { (float cHue, float cSaturation, float cValue) = color.GetHSV(); return Create(color.A, cHue * hue, cSaturation * saturation, cValue * value); @@ -97,7 +97,7 @@ public static Color MultiplyHSV(this in Color color, float hue = 1, float satura /// The saturation value to divide. /// The value value to divide. /// The new color after the modification. - public static Color DivideHSV(this in Color color, float hue = 1, float saturation = 1, float value = 1) + public static Color DivideHSV(this Color color, float hue = 1, float saturation = 1, float value = 1) { (float cHue, float cSaturation, float cValue) = color.GetHSV(); return Create(color.A, cHue / hue, cSaturation / saturation, cValue / value); @@ -111,7 +111,7 @@ public static Color DivideHSV(this in Color color, float hue = 1, float saturati /// The saturation value to set. /// The value value to set. /// The new color after the modification. - public static Color SetHSV(this in Color color, float? hue = null, float? saturation = null, float? value = null) + public static Color SetHSV(this Color color, float? hue = null, float? saturation = null, float? value = null) { (float cHue, float cSaturation, float cValue) = color.GetHSV(); return Create(color.A, hue ?? cHue, saturation ?? cSaturation, value ?? cValue); diff --git a/RGB.NET.Core/Color/HclColor.cs b/RGB.NET.Core/Color/HclColor.cs index 4133c582..7a6e5be7 100644 --- a/RGB.NET.Core/Color/HclColor.cs +++ b/RGB.NET.Core/Color/HclColor.cs @@ -16,21 +16,21 @@ public static class HclColor /// /// 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; + public static float GetHclH(this 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; + public static float GetHclC(this Color color) => color.GetHcl().c; /// /// Gets the l component value (Hcl-color space) of this in the range [0..1]. /// /// 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; + public static float GetHclL(this Color color) => color.GetHcl().l; /// /// Gets the H, c and l component values (Hcl-color space) of this . @@ -40,7 +40,7 @@ public static class HclColor /// /// 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) + public static (float h, float c, float l) GetHcl(this Color color) => CalculateHclFromRGB(color.R, color.G, color.B); #endregion @@ -55,7 +55,7 @@ public static (float h, float c, float l) GetHcl(this in Color color) /// The c value to add. /// The l value to add. /// The new color after the modification. - public static Color AddHcl(this in Color color, float h = 0, float c = 0, float l = 0) + public static Color AddHcl(this Color color, float h = 0, float c = 0, float l = 0) { (float cH, float cC, float cL) = color.GetHcl(); return Create(color.A, cH + h, cC + c, cL + l); @@ -69,7 +69,7 @@ public static Color AddHcl(this in Color color, float h = 0, float c = 0, float /// The c value to subtract. /// The l value to subtract. /// The new color after the modification. - public static Color SubtractHcl(this in Color color, float h = 0, float c = 0, float l = 0) + public static Color SubtractHcl(this Color color, float h = 0, float c = 0, float l = 0) { (float cH, float cC, float cL) = color.GetHcl(); return Create(color.A, cH - h, cC - c, cL - l); @@ -83,7 +83,7 @@ public static Color SubtractHcl(this in Color color, float h = 0, float c = 0, f /// The c value to multiply. /// The l value to multiply. /// The new color after the modification. - public static Color MultiplyHcl(this in Color color, float h = 1, float c = 1, float l = 1) + public static Color MultiplyHcl(this Color color, float h = 1, float c = 1, float l = 1) { (float cH, float cC, float cL) = color.GetHcl(); return Create(color.A, cH * h, cC * c, cL * l); @@ -97,7 +97,7 @@ public static Color MultiplyHcl(this in Color color, float h = 1, float c = 1, f /// The c value to divide. /// The l value to divide. /// The new color after the modification. - public static Color DivideHcl(this in Color color, float h = 1, float c = 1, float l = 1) + public static Color DivideHcl(this Color color, float h = 1, float c = 1, float l = 1) { (float cH, float cC, float cL) = color.GetHcl(); return Create(color.A, cH / h, cC / c, cL / l); @@ -111,7 +111,7 @@ public static Color DivideHcl(this in Color color, float h = 1, float c = 1, flo /// The c value to set. /// The l value to set. /// The new color after the modification. - public static Color SetHcl(this in Color color, float? h = null, float? c = null, float? l = null) + public static Color SetHcl(this Color color, float? h = null, float? c = null, float? l = null) { (float cH, float cC, float cL) = color.GetHcl(); return Create(color.A, h ?? cH, c ?? cC, l ?? cL); diff --git a/RGB.NET.Core/Color/LabColor.cs b/RGB.NET.Core/Color/LabColor.cs index 7be06502..438f0692 100644 --- a/RGB.NET.Core/Color/LabColor.cs +++ b/RGB.NET.Core/Color/LabColor.cs @@ -16,21 +16,21 @@ public static class LabColor /// /// 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; + public static float GetLabL(this 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; + public static float GetLabA(this 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; + public static float GetLabB(this Color color) => color.GetLab().b; /// /// Gets the L, a and b component values (Lab-color space) of this . @@ -40,7 +40,7 @@ public static class LabColor /// /// 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) + public static (float l, float a, float b) GetLab(this Color color) => CalculateLabFromRGB(color.R, color.G, color.B); #endregion @@ -55,7 +55,7 @@ public static (float l, float a, float b) GetLab(this in Color color) /// The a value to add. /// The b value to add. /// The new color after the modification. - public static Color AddLab(this in Color color, float l = 0, float a = 0, float b = 0) + public static Color AddLab(this Color color, float l = 0, float a = 0, float b = 0) { (float cL, float cA, float cB) = color.GetLab(); return Create(color.A, cL + l, cA + a, cB + b); @@ -69,7 +69,7 @@ public static Color AddLab(this in Color color, float l = 0, float a = 0, float /// The a value to subtract. /// The b value to subtract. /// The new color after the modification. - public static Color SubtractLab(this in Color color, float l = 0, float a = 0, float b = 0) + public static Color SubtractLab(this Color color, float l = 0, float a = 0, float b = 0) { (float cL, float cA, float cB) = color.GetLab(); return Create(color.A, cL - l, cA - a, cB - b); @@ -83,7 +83,7 @@ public static Color SubtractLab(this in Color color, float l = 0, float a = 0, f /// The a value to multiply. /// The b value to multiply. /// The new color after the modification. - public static Color MultiplyLab(this in Color color, float l = 1, float a = 1, float b = 1) + public static Color MultiplyLab(this Color color, float l = 1, float a = 1, float b = 1) { (float cL, float cA, float cB) = color.GetLab(); return Create(color.A, cL * l, cA * a, cB * b); @@ -97,7 +97,7 @@ public static Color MultiplyLab(this in Color color, float l = 1, float a = 1, f /// The a value to divide. /// The b value to divide. /// The new color after the modification. - public static Color DivideLab(this in Color color, float l = 1, float a = 1, float b = 1) + public static Color DivideLab(this Color color, float l = 1, float a = 1, float b = 1) { (float cL, float cA, float cB) = color.GetLab(); return Create(color.A, cL / l, cA / a, cB / b); @@ -111,7 +111,7 @@ public static Color DivideLab(this in Color color, float l = 1, float a = 1, flo /// The a value to set. /// The b value to set. /// The new color after the modification. - public static Color SetLab(this in Color color, float? l = null, float? a = null, float? b = null) + public static Color SetLab(this Color color, float? l = null, float? a = null, float? b = null) { (float cL, float cA, float cB) = color.GetLab(); return Create(color.A, l ?? cL, a ?? cA, b ?? cB); diff --git a/RGB.NET.Core/Color/RGBColor.cs b/RGB.NET.Core/Color/RGBColor.cs index 9ffa528d..4b61189e 100644 --- a/RGB.NET.Core/Color/RGBColor.cs +++ b/RGB.NET.Core/Color/RGBColor.cs @@ -16,35 +16,35 @@ public static class RGBColor /// /// 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(); + public static byte GetA(this 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(); + public static byte GetR(this 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(); + public static byte GetG(this 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(); + public static byte GetB(this 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) + public static (byte a, byte r, byte g, byte b) GetRGBBytes(this Color color) => (color.GetA(), color.GetR(), color.GetG(), color.GetB()); /// @@ -52,7 +52,7 @@ public static (byte a, byte r, byte g, byte b) GetRGBBytes(this in Color color) /// /// 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) + public static (float a, float r, float g, float b) GetRGB(this Color color) => (color.A, color.R, color.G, color.B); #endregion @@ -69,7 +69,7 @@ public static (float a, float r, float g, float b) GetRGB(this in Color color) /// The green value to add. /// The blue value to add. /// The new color after the modification. - public static Color AddRGB(this in Color color, int r = 0, int g = 0, int b = 0) + public static Color AddRGB(this Color color, int r = 0, int g = 0, int b = 0) => new(color.A, color.GetR() + r, color.GetG() + g, color.GetB() + b); /// @@ -80,7 +80,7 @@ public static Color AddRGB(this in Color color, int r = 0, int g = 0, int b = 0) /// The green value to add. /// The blue value to add. /// The new color after the modification. - public static Color AddRGB(this in Color color, float r = 0, float g = 0, float b = 0) + public static Color AddRGB(this Color color, float r = 0, float g = 0, float b = 0) => new(color.A, color.R + r, color.G + g, color.B + b); /// @@ -89,7 +89,7 @@ public static Color AddRGB(this in Color color, float r = 0, float g = 0, float /// 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) + public static Color AddA(this Color color, int a) => new(color.GetA() + a, color.R, color.G, color.B); /// @@ -98,7 +98,7 @@ public static Color AddA(this in Color color, int a) /// 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) + public static Color AddA(this Color color, float a) => new(color.A + a, color.R, color.G, color.B); #endregion @@ -113,7 +113,7 @@ public static Color AddA(this in Color color, float a) /// The green value to subtract. /// The blue value to subtract. /// The new color after the modification. - public static Color SubtractRGB(this in Color color, int r = 0, int g = 0, int b = 0) + public static Color SubtractRGB(this Color color, int r = 0, int g = 0, int b = 0) => new(color.A, color.GetR() - r, color.GetG() - g, color.GetB() - b); /// @@ -124,7 +124,7 @@ public static Color SubtractRGB(this in Color color, int r = 0, int g = 0, int b /// The green value to subtract. /// The blue value to subtract. /// The new color after the modification. - public static Color SubtractRGB(this in Color color, float r = 0, float g = 0, float b = 0) + public static Color SubtractRGB(this Color color, float r = 0, float g = 0, float b = 0) => new(color.A, color.R - r, color.G - g, color.B - b); /// @@ -133,7 +133,7 @@ public static Color SubtractRGB(this in Color color, float r = 0, float g = 0, f /// 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) + public static Color SubtractA(this Color color, int a) => new(color.GetA() - a, color.R, color.G, color.B); /// @@ -142,7 +142,7 @@ public static Color SubtractA(this in Color color, int a) /// 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) + public static Color SubtractA(this Color color, float aPercent) => new(color.A - aPercent, color.R, color.G, color.B); #endregion @@ -157,7 +157,7 @@ public static Color SubtractA(this in Color color, float aPercent) /// The green value to multiply. /// The blue value to multiply. /// The new color after the modification. - public static Color MultiplyRGB(this in Color color, float r = 1, float g = 1, float b = 1) + public static Color MultiplyRGB(this Color color, float r = 1, float g = 1, float b = 1) => new(color.A, color.R * r, color.G * g, color.B * b); /// @@ -166,7 +166,7 @@ public static Color MultiplyRGB(this in Color color, float r = 1, float g = 1, f /// 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) + public static Color MultiplyA(this Color color, float a) => new(color.A * a, color.R, color.G, color.B); #endregion @@ -181,7 +181,7 @@ public static Color MultiplyA(this in Color color, float a) /// The green value to divide. /// The blue value to divide. /// The new color after the modification. - public static Color DivideRGB(this in Color color, float r = 1, float g = 1, float b = 1) + public static Color DivideRGB(this Color color, float r = 1, float g = 1, float b = 1) => new(color.A, color.R / r, color.G / g, color.B / b); /// @@ -190,7 +190,7 @@ public static Color DivideRGB(this in Color color, float r = 1, float g = 1, flo /// 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) + public static Color DivideA(this Color color, float a) => new(color.A / a, color.R, color.G, color.B); #endregion @@ -205,7 +205,7 @@ public static Color DivideA(this in Color color, float a) /// The green value to set. /// The blue value to set. /// The new color after the modification. - public static Color SetRGB(this in Color color, byte? r = null, byte? g = null, byte? b = null) + public static Color SetRGB(this Color color, byte? r = null, byte? g = null, byte? b = null) => new(color.A, r ?? color.GetR(), g ?? color.GetG(), b ?? color.GetB()); /// @@ -216,7 +216,7 @@ public static Color SetRGB(this in Color color, byte? r = null, byte? g = null, /// The green value to set. /// The blue value to set. /// The new color after the modification. - public static Color SetRGB(this in Color color, int? r = null, int? g = null, int? b = null) + public static Color SetRGB(this Color color, int? r = null, int? g = null, int? b = null) => new(color.A, r ?? color.GetR(), g ?? color.GetG(), b ?? color.GetB()); /// @@ -227,7 +227,7 @@ public static Color SetRGB(this in Color color, int? r = null, int? g = null, in /// The green value to set. /// The blue value to set. /// The new color after the modification. - public static Color SetRGB(this in Color color, float? r = null, float? g = null, float? b = null) + public static Color SetRGB(this Color color, float? r = null, float? g = null, float? b = null) => new(color.A, r ?? color.R, g ?? color.G, b ?? color.B); /// @@ -236,7 +236,7 @@ public static Color SetRGB(this in Color color, float? r = null, float? g = null /// 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); + public static Color SetA(this Color color, int a) => new(a, color.R, color.G, color.B); /// /// Sets the specified alpha value of this color. @@ -244,7 +244,7 @@ public static Color SetRGB(this in Color color, float? r = null, float? g = null /// 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); + public static Color SetA(this Color color, float a) => new(a, color.R, color.G, color.B); #endregion @@ -256,13 +256,13 @@ public static Color SetRGB(this in Color color, float? r = null, float? g = null /// Gets the current color as a RGB-HEX-string. /// /// The RGB-HEX-string. - public static string AsRGBHexString(this in Color color, bool leadingHash = true) => (leadingHash ? "#" : "") + ConversionHelper.ToHex(color.GetR(), color.GetG(), color.GetB()); + public static string AsRGBHexString(this Color color, bool leadingHash = true) => (leadingHash ? "#" : "") + ConversionHelper.ToHex(color.GetR(), color.GetG(), color.GetB()); /// /// Gets the current color as a ARGB-HEX-string. /// /// The ARGB-HEX-string. - public static string AsARGBHexString(this in Color color, bool leadingHash = true) => (leadingHash ? "#" : "") + ConversionHelper.ToHex(color.GetA(), color.GetR(), color.GetG(), color.GetB()); + public static string AsARGBHexString(this Color color, bool leadingHash = true) => (leadingHash ? "#" : "") + ConversionHelper.ToHex(color.GetA(), color.GetR(), color.GetG(), color.GetB()); #endregion diff --git a/RGB.NET.Core/Color/XYZColor.cs b/RGB.NET.Core/Color/XYZColor.cs index 168d4f73..a20f5ace 100644 --- a/RGB.NET.Core/Color/XYZColor.cs +++ b/RGB.NET.Core/Color/XYZColor.cs @@ -16,21 +16,21 @@ public static class XYZColor /// /// 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; + public static float GetX(this 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; + public static float GetY(this 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; + public static float GetZ(this Color color) => color.GetXYZ().z; /// /// Gets the X, Y and Z component values (XYZ-color space) of this . @@ -40,7 +40,7 @@ public static class XYZColor /// /// 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) + public static (float x, float y, float z) GetXYZ(this Color color) => CaclulateXYZFromRGB(color.R, color.G, color.B); #endregion @@ -55,7 +55,7 @@ public static (float x, float y, float z) GetXYZ(this in Color color) /// The Y value to add. /// The Z value to add. /// The new color after the modification. - public static Color AddXYZ(this in Color color, float x = 0, float y = 0, float z = 0) + public static Color AddXYZ(this Color color, float x = 0, float y = 0, float z = 0) { (float cX, float cY, float cZ) = color.GetXYZ(); return Create(color.A, cX + x, cY + y, cZ + z); @@ -69,7 +69,7 @@ public static Color AddXYZ(this in Color color, float x = 0, float y = 0, float /// The Y value to subtract. /// The Z value to subtract. /// The new color after the modification. - public static Color SubtractXYZ(this in Color color, float x = 0, float y = 0, float z = 0) + public static Color SubtractXYZ(this Color color, float x = 0, float y = 0, float z = 0) { (float cX, float cY, float cZ) = color.GetXYZ(); return Create(color.A, cX - x, cY - y, cZ - z); @@ -83,7 +83,7 @@ public static Color SubtractXYZ(this in Color color, float x = 0, float y = 0, f /// The Y value to multiply. /// The Z value to multiply. /// The new color after the modification. - public static Color MultiplyXYZ(this in Color color, float x = 1, float y = 1, float z = 1) + public static Color MultiplyXYZ(this Color color, float x = 1, float y = 1, float z = 1) { (float cX, float cY, float cZ) = color.GetXYZ(); return Create(color.A, cX * x, cY * y, cZ * z); @@ -97,7 +97,7 @@ public static Color MultiplyXYZ(this in Color color, float x = 1, float y = 1, f /// The Y value to divide. /// The Z value to divide. /// The new color after the modification. - public static Color DivideXYZ(this in Color color, float x = 1, float y = 1, float z = 1) + public static Color DivideXYZ(this Color color, float x = 1, float y = 1, float z = 1) { (float cX, float cY, float cZ) = color.GetXYZ(); return Create(color.A, cX / x, cY / y, cZ / z); @@ -111,7 +111,7 @@ public static Color DivideXYZ(this in Color color, float x = 1, float y = 1, flo /// 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? z = null) + public static Color SetXYZ(this 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, z ?? cZ); diff --git a/RGB.NET.Core/Compatibility/Lock.cs b/RGB.NET.Core/Compatibility/Lock.cs new file mode 100644 index 00000000..0a28501a --- /dev/null +++ b/RGB.NET.Core/Compatibility/Lock.cs @@ -0,0 +1,8 @@ +#if NET8_0 + +// ReSharper disable once CheckNamespace +namespace RGB.NET.Core.Compatibility.Net8; + +public sealed class Lock; + +#endif \ No newline at end of file diff --git a/RGB.NET.Core/Decorators/IBrushDecorator.cs b/RGB.NET.Core/Decorators/IBrushDecorator.cs index ec1c4325..89594b7c 100644 --- a/RGB.NET.Core/Decorators/IBrushDecorator.cs +++ b/RGB.NET.Core/Decorators/IBrushDecorator.cs @@ -12,5 +12,5 @@ public interface IBrushDecorator : IDecorator /// The rectangle in which the should be drawn. /// The target (key/point) from which the should be taken. /// The to be modified. - void ManipulateColor(in Rectangle rectangle, in RenderTarget renderTarget, ref Color color); + void ManipulateColor(Rectangle rectangle, RenderTarget renderTarget, ref Color color); } \ No newline at end of file diff --git a/RGB.NET.Core/Devices/AbstractRGBDevice.cs b/RGB.NET.Core/Devices/AbstractRGBDevice.cs index 9e3572b3..311c4685 100644 --- a/RGB.NET.Core/Devices/AbstractRGBDevice.cs +++ b/RGB.NET.Core/Devices/AbstractRGBDevice.cs @@ -43,7 +43,7 @@ public abstract class AbstractRGBDevice : Placeable, IRGBDevice DeviceInfo; /// - public IList ColorCorrections { get; } = new List(); + public IList ColorCorrections { get; } = []; /// /// Gets or sets if the device needs to be flushed on every update. @@ -63,7 +63,7 @@ public abstract class AbstractRGBDevice : Placeable, IRGBDevice - Led? IRGBDevice.this[LedId ledId] => LedMapping.TryGetValue(ledId, out Led? led) ? led : null; + Led? IRGBDevice.this[LedId ledId] => LedMapping.GetValueOrDefault(ledId); /// Led? IRGBDevice.this[Point location] => LedMapping.Values.FirstOrDefault(x => x.Boundary.Contains(location)); @@ -119,7 +119,7 @@ public virtual void Update(bool flushLeds = false) /// Applies all . /// if no ist specified the is used. /// - /// The enumerable of leds to convert. + /// The of led to convert. /// The enumerable of custom data and color tuples for the specified leds. [MethodImpl(MethodImplOptions.AggressiveInlining)] protected (object key, Color color) GetUpdateData(Led led) @@ -179,7 +179,7 @@ protected virtual void DeviceUpdate() { } /// - public virtual Led? AddLed(LedId ledId, in Point location, in Size size, object? customData = null) + public virtual Led? AddLed(LedId ledId, Point location, Size size, object? customData = null) { if ((ledId == LedId.Invalid) || LedMapping.ContainsKey(ledId)) return null; diff --git a/RGB.NET.Core/Devices/IRGBDevice.cs b/RGB.NET.Core/Devices/IRGBDevice.cs index 6e79fb3f..ce9dbd23 100644 --- a/RGB.NET.Core/Devices/IRGBDevice.cs +++ b/RGB.NET.Core/Devices/IRGBDevice.cs @@ -72,7 +72,7 @@ public interface IRGBDevice : IEnumerable, IPlaceable, IBindable, IDisposab /// 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); + Led? AddLed(LedId ledId, Point location, Size size, object? customData = null); /// /// Removes the led with the specified id from the device. diff --git a/RGB.NET.Core/Extensions/ColorExtensions.cs b/RGB.NET.Core/Extensions/ColorExtensions.cs index c2afc234..de3756ad 100644 --- a/RGB.NET.Core/Extensions/ColorExtensions.cs +++ b/RGB.NET.Core/Extensions/ColorExtensions.cs @@ -16,7 +16,7 @@ public static class ColorExtensions /// 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) + public static double DistanceTo(this Color color1, Color color2) { (_, byte r1, byte g1, byte b1) = color1.GetRGBBytes(); (_, byte r2, byte g2, byte b2) = color2.GetRGBBytes(); diff --git a/RGB.NET.Core/Extensions/MathExtensions.cs b/RGB.NET.Core/Extensions/MathExtensions.cs index c3176b1a..93107b64 100644 --- a/RGB.NET.Core/Extensions/MathExtensions.cs +++ b/RGB.NET.Core/Extensions/MathExtensions.cs @@ -91,10 +91,11 @@ public static float Wrap(this float value, float min, float max) [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte GetByteValueFromPercentage(this float percentage) { - if (float.IsNaN(percentage)) return 0; + // ReSharper disable once ConvertIfStatementToSwitchStatement - This results in a bit more instructions + if (float.IsNaN(percentage) || (percentage <= 0)) return 0; + if (percentage >= 1.0f) return byte.MaxValue; - percentage = percentage.Clamp(0, 1.0f); - return (byte)(percentage >= 1.0f ? 255 : percentage * 256.0f); + return (byte)(percentage * 256.0f); } /// diff --git a/RGB.NET.Core/Extensions/PointExtensions.cs b/RGB.NET.Core/Extensions/PointExtensions.cs index 1acab3a7..747098cb 100644 --- a/RGB.NET.Core/Extensions/PointExtensions.cs +++ b/RGB.NET.Core/Extensions/PointExtensions.cs @@ -16,7 +16,7 @@ public static class PointExtensions /// The x-ammount to move. /// The y-ammount to move. /// The new location of the point. - public static Point Translate(this in Point point, float x = 0, float y = 0) => new(point.X + x, point.Y + y); + public static Point Translate(this Point point, float x = 0, float y = 0) => new(point.X + x, point.Y + y); /// /// Rotates the specified by the specified amuont around the specified origin. @@ -25,7 +25,7 @@ public static class PointExtensions /// The rotation. /// The origin to rotate around. [0,0] if not set. /// The new location of the point. - public static Point Rotate(this in Point point, in Rotation rotation, in Point origin = new()) + public static Point Rotate(this Point point, Rotation rotation, Point origin = new()) { float sin = MathF.Sin(rotation.Radians); float cos = MathF.Cos(rotation.Radians); diff --git a/RGB.NET.Core/Extensions/RectangleExtensions.cs b/RGB.NET.Core/Extensions/RectangleExtensions.cs index c97256fd..077c193d 100644 --- a/RGB.NET.Core/Extensions/RectangleExtensions.cs +++ b/RGB.NET.Core/Extensions/RectangleExtensions.cs @@ -15,7 +15,7 @@ public static class RectangleExtensions /// The rectangle to modify. /// The new location of the rectangle. /// The modified . - public static Rectangle SetLocation(this in Rectangle rect, in Point location) => new(location, rect.Size); + public static Rectangle SetLocation(this Rectangle rect, Point location) => new(location, rect.Size); /// /// Sets the of the of the specified rectangle. @@ -23,7 +23,7 @@ public static class RectangleExtensions /// The rectangle to modify. /// The new x-location of the rectangle. /// The modified . - public static Rectangle SetX(this in Rectangle rect, float x) => new(new Point(x, rect.Location.Y), rect.Size); + public static Rectangle SetX(this Rectangle rect, float x) => new(new Point(x, rect.Location.Y), rect.Size); /// /// Sets the of the of the specified rectangle. @@ -31,7 +31,7 @@ public static class RectangleExtensions /// The rectangle to modify. /// The new y-location of the rectangle. /// The modified . - public static Rectangle SetY(this in Rectangle rect, float y) => new(new Point(rect.Location.X, y), rect.Size); + public static Rectangle SetY(this Rectangle rect, float y) => new(new Point(rect.Location.X, y), rect.Size); /// /// Sets the of the specified rectangle. @@ -39,7 +39,7 @@ public static class RectangleExtensions /// The rectangle to modify. /// The new size of the rectangle. /// The modified . - public static Rectangle SetSize(this in Rectangle rect, in Size size) => new(rect.Location, size); + public static Rectangle SetSize(this Rectangle rect, Size size) => new(rect.Location, size); /// /// Sets the of the of the specified rectangle. @@ -47,7 +47,7 @@ public static class RectangleExtensions /// The rectangle to modify. /// The new width of the rectangle. /// The modified . - public static Rectangle SetWidth(this in Rectangle rect, float width) => new(rect.Location, new Size(width, rect.Size.Height)); + public static Rectangle SetWidth(this Rectangle rect, float width) => new(rect.Location, new Size(width, rect.Size.Height)); /// /// Sets the of the of the specified rectangle. @@ -55,7 +55,7 @@ public static class RectangleExtensions /// The rectangle to modify. /// The new height of the rectangle. /// The modified . - public static Rectangle SetHeight(this in Rectangle rect, float height) => new(rect.Location, new Size(rect.Size.Width, height)); + public static Rectangle SetHeight(this Rectangle rect, float height) => new(rect.Location, new Size(rect.Size.Width, height)); /// /// Calculates the percentage of intersection of a rectangle. @@ -63,7 +63,7 @@ public static class RectangleExtensions /// 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) + public static float CalculateIntersectPercentage(this Rectangle rect, Rectangle intersectingRect) { if (rect.IsEmpty || intersectingRect.IsEmpty) return 0; @@ -77,7 +77,7 @@ public static float CalculateIntersectPercentage(this in Rectangle rect, in Rect /// 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) + public static Rectangle CalculateIntersection(this Rectangle rect, Rectangle intersectingRectangle) { float x1 = Math.Max(rect.Location.X, intersectingRectangle.Location.X); float x2 = Math.Min(rect.Location.X + rect.Size.Width, intersectingRectangle.Location.X + intersectingRectangle.Size.Width); @@ -97,7 +97,7 @@ public static Rectangle CalculateIntersection(this in Rectangle rect, in Rectang /// The containing rectangle. /// The to test. /// 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); + public static bool Contains(this Rectangle rect, Point point) => rect.Contains(point.X, point.Y); /// /// Determines if the specified location is contained within this . @@ -106,7 +106,7 @@ public static Rectangle CalculateIntersection(this in Rectangle rect, in Rectang /// The X-location to test. /// The Y-location to test. /// 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)) + public static bool Contains(this 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)); /// @@ -115,7 +115,7 @@ public static bool Contains(this in Rectangle rect, float x, float y) => (rect.L /// 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)) + public static bool Contains(this Rectangle rect, 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)); /// @@ -124,7 +124,7 @@ public static bool Contains(this in Rectangle rect, in Rectangle rect2) => (rect /// The to move. /// The amount to move. /// The moved rectangle. - public static Rectangle Translate(this in Rectangle rect, in Point point) => rect.Translate(point.X, point.Y); + public static Rectangle Translate(this Rectangle rect, Point point) => rect.Translate(point.X, point.Y); /// /// Moves the specified by the specified amount. @@ -133,7 +133,7 @@ public static bool Contains(this in Rectangle rect, in Rectangle rect2) => (rect /// The x-ammount to move. /// The y-ammount to move. /// The moved rectangle. - public static Rectangle Translate(this in Rectangle rect, float x = 0, float y = 0) => new(rect.Location.Translate(x, y), rect.Size); + public static Rectangle Translate(this Rectangle rect, float x = 0, float y = 0) => new(rect.Location.Translate(x, y), rect.Size); /// /// Rotates the specified by the specified amuont around the specified origin. @@ -149,14 +149,14 @@ public static bool Contains(this in Rectangle rect, in Rectangle rect2) => (rect /// The rotation. /// The origin to rotate around. [0,0] if not set. /// A array of containing the new locations of the corners of the original rectangle. - public static Point[] Rotate(this in Rectangle rect, in Rotation rotation, in Point origin = new()) + public static Point[] Rotate(this Rectangle rect, Rotation rotation, Point origin = new()) { Point[] points = [ rect.Location, // top left - new Point(rect.Location.X + rect.Size.Width, rect.Location.Y), // top right - new Point(rect.Location.X + rect.Size.Width, rect.Location.Y + rect.Size.Height), // bottom right - new Point(rect.Location.X, rect.Location.Y + rect.Size.Height), // bottom right + new(rect.Location.X + rect.Size.Width, rect.Location.Y), // top right + new(rect.Location.X + rect.Size.Width, rect.Location.Y + rect.Size.Height), // bottom right + new(rect.Location.X, rect.Location.Y + rect.Size.Height), // bottom right ]; float sin = MathF.Sin(rotation.Radians); diff --git a/RGB.NET.Core/Groups/ListLedGroup.cs b/RGB.NET.Core/Groups/ListLedGroup.cs index 4bca2fbd..511cdad9 100644 --- a/RGB.NET.Core/Groups/ListLedGroup.cs +++ b/RGB.NET.Core/Groups/ListLedGroup.cs @@ -20,7 +20,7 @@ public sealed class ListLedGroup : AbstractLedGroup /// /// Gets the list containing the of this . /// - private readonly IList _groupLeds = new List(); + private readonly IList _groupLeds = []; #endregion @@ -142,7 +142,7 @@ public void MergeLeds(ILedGroup groupToMerge) public override IList ToList() { lock (_groupLeds) - return new List(_groupLeds); + return [.._groupLeds]; } protected override IDisposable ToListUnsafe(out IList leds) diff --git a/RGB.NET.Core/Helper/ConversionHelper.cs b/RGB.NET.Core/Helper/ConversionHelper.cs index 0be3dfbc..d05b94bc 100644 --- a/RGB.NET.Core/Helper/ConversionHelper.cs +++ b/RGB.NET.Core/Helper/ConversionHelper.cs @@ -40,7 +40,7 @@ public static string ToHex(params byte[] bytes) public static byte[] HexToBytes(ReadOnlySpan hexString) { if ((hexString.Length == 0) || ((hexString.Length % 2) != 0)) - return Array.Empty(); + return []; byte[] buffer = new byte[hexString.Length / 2]; for (int bx = 0, sx = 0; bx < buffer.Length; ++bx, ++sx) diff --git a/RGB.NET.Core/Helper/TimerHelper.cs b/RGB.NET.Core/Helper/TimerHelper.cs index e2742ab4..1da32e68 100644 --- a/RGB.NET.Core/Helper/TimerHelper.cs +++ b/RGB.NET.Core/Helper/TimerHelper.cs @@ -24,7 +24,7 @@ public static class TimerHelper #region Properties & Fields - private static readonly object HIGH_RESOLUTION_TIMER_LOCK = new(); + private static readonly Lock HIGH_RESOLUTION_TIMER_LOCK = new(); private static bool _areHighResolutionTimersEnabled = false; diff --git a/RGB.NET.Core/Positioning/Point.cs b/RGB.NET.Core/Positioning/Point.cs index e92c65f3..b8f15e72 100644 --- a/RGB.NET.Core/Positioning/Point.cs +++ b/RGB.NET.Core/Positioning/Point.cs @@ -90,7 +90,7 @@ public bool Equals(Point other) => ((float.IsNaN(X) && float.IsNaN(other.X)) || /// The first to compare. /// The second to compare. /// true if and are equal; otherwise, false. - public static bool operator ==(in Point point1, in Point point2) => point1.Equals(point2); + public static bool operator ==(Point point1, Point point2) => point1.Equals(point2); /// /// Returns a value that indicates whether two specified are equal. @@ -98,7 +98,7 @@ public bool Equals(Point other) => ((float.IsNaN(X) && float.IsNaN(other.X)) || /// The first to compare. /// The second to compare. /// true if and are not equal; otherwise, false. - public static bool operator !=(in Point point1, in Point point2) => !(point1 == point2); + public static bool operator !=(Point point1, Point point2) => !(point1 == point2); /// /// Returns a new representing the addition of the two provided . @@ -106,7 +106,7 @@ public bool Equals(Point other) => ((float.IsNaN(X) && float.IsNaN(other.X)) || /// The first . /// The second . /// A new representing the addition of the two provided . - public static Point operator +(in Point point1, in Point point2) => new(point1.X + point2.X, point1.Y + point2.Y); + public static Point operator +(Point point1, Point point2) => new(point1.X + point2.X, point1.Y + point2.Y); /// /// Returns a new created from the provided and . @@ -114,7 +114,7 @@ public bool Equals(Point other) => ((float.IsNaN(X) && float.IsNaN(other.X)) || /// The of the rectangle. /// The of the rectangle. /// The rectangle created from the provided and . - public static Rectangle operator +(in Point point, in Size size) => new(point, size); + public static Rectangle operator +(Point point, Size size) => new(point, size); /// /// Returns a new representing the subtraction of the two provided . @@ -122,7 +122,7 @@ public bool Equals(Point other) => ((float.IsNaN(X) && float.IsNaN(other.X)) || /// The first . /// The second . /// A new representing the subtraction of the two provided . - public static Point operator -(in Point point1, in Point point2) => new(point1.X - point2.X, point1.Y - point2.Y); + public static Point operator -(Point point1, Point point2) => new(point1.X - point2.X, point1.Y - point2.Y); /// /// Returns a new representing the multiplication of the two provided . @@ -130,7 +130,7 @@ public bool Equals(Point other) => ((float.IsNaN(X) && float.IsNaN(other.X)) || /// The first . /// The second . /// A new representing the multiplication of the two provided . - public static Point operator *(in Point point1, in Point point2) => new(point1.X * point2.X, point1.Y * point2.Y); + public static Point operator *(Point point1, Point point2) => new(point1.X * point2.X, point1.Y * point2.Y); /// /// Returns a new representing the division of the two provided . @@ -138,7 +138,7 @@ public bool Equals(Point other) => ((float.IsNaN(X) && float.IsNaN(other.X)) || /// The first . /// The second . /// A new representing the division of the two provided . - public static Point operator /(in Point point1, in Point point2) + public static Point operator /(Point point1, Point point2) { if (point2.X.EqualsInTolerance(0) || point2.Y.EqualsInTolerance(0)) return Invalid; return new Point(point1.X / point2.X, point1.Y / point2.Y); @@ -150,7 +150,7 @@ public bool Equals(Point other) => ((float.IsNaN(X) && float.IsNaN(other.X)) || /// The . /// The . /// A new representing the multiplication of the and the provided . - public static Point operator *(in Point point, in Scale scale) => new(point.X * scale.Horizontal, point.Y * scale.Vertical); + public static Point operator *(Point point, Scale scale) => new(point.X * scale.Horizontal, point.Y * scale.Vertical); #endregion } \ No newline at end of file diff --git a/RGB.NET.Core/Positioning/Rectangle.cs b/RGB.NET.Core/Positioning/Rectangle.cs index 095a210e..a1cf4de6 100644 --- a/RGB.NET.Core/Positioning/Rectangle.cs +++ b/RGB.NET.Core/Positioning/Rectangle.cs @@ -179,7 +179,7 @@ internal Rectangle(IList leds) #region Methods - private static (Point location, Size size) InitializeFromPoints(in Point point1, in Point point2) + private static (Point location, Size size) InitializeFromPoints(Point point1, Point point2) { float posX = Math.Min(point1.X, point2.X); float posY = Math.Min(point1.Y, point2.Y); @@ -225,7 +225,7 @@ private static (Point location, Size size) InitializeFromPoints(in Point point1, /// The first to compare. /// The second to compare. /// true if and are equal; otherwise, false. - public static bool operator ==(in Rectangle rectangle1, in Rectangle rectangle2) => rectangle1.Equals(rectangle2); + public static bool operator ==(Rectangle rectangle1, Rectangle rectangle2) => rectangle1.Equals(rectangle2); /// /// Returns a value that indicates whether two specified are equal. @@ -233,7 +233,7 @@ private static (Point location, Size size) InitializeFromPoints(in Point point1, /// The first to compare. /// The second to compare. /// true if and are not equal; otherwise, false. - public static bool operator !=(in Rectangle rectangle1, in Rectangle rectangle2) => !(rectangle1 == rectangle2); + public static bool operator !=(Rectangle rectangle1, Rectangle rectangle2) => !(rectangle1 == rectangle2); // DarthAffe 20.02.2021: Used for normalization /// @@ -242,7 +242,7 @@ private static (Point location, Size size) InitializeFromPoints(in Point point1, /// The rectangle to nromalize. /// The reference used for normalization. /// A normalized rectangle. - public static Rectangle operator /(in Rectangle rectangle1, in Rectangle rectangle2) + public static Rectangle operator /(Rectangle rectangle1, Rectangle rectangle2) { float x = rectangle1.Location.X / (rectangle2.Size.Width - rectangle2.Location.X); float y = rectangle1.Location.Y / (rectangle2.Size.Height - rectangle2.Location.Y); diff --git a/RGB.NET.Core/Positioning/Rotation.cs b/RGB.NET.Core/Positioning/Rotation.cs index e204b757..4b6732b6 100644 --- a/RGB.NET.Core/Positioning/Rotation.cs +++ b/RGB.NET.Core/Positioning/Rotation.cs @@ -103,7 +103,7 @@ private Rotation(float degrees, float radians) /// The first to compare. /// The second to compare. /// true if and are equal; otherwise, false. - public static bool operator ==(in Rotation rotation1, in Rotation rotation2) => rotation1.Equals(rotation2); + public static bool operator ==(Rotation rotation1, Rotation rotation2) => rotation1.Equals(rotation2); /// /// Returns a value that indicates whether two specified are equal. @@ -111,7 +111,7 @@ private Rotation(float degrees, float radians) /// The first to compare. /// The second to compare. /// true if and are not equal; otherwise, false. - public static bool operator !=(in Rotation rotation1, in Rotation rotation2) => !(rotation1 == rotation2); + public static bool operator !=(Rotation rotation1, Rotation rotation2) => !(rotation1 == rotation2); /// /// Returns a new representing the addition of the and the provided value. @@ -119,7 +119,7 @@ private Rotation(float degrees, float radians) /// The . /// The value to add. /// A new representing the addition of the and the provided value. - public static Rotation operator +(in Rotation rotation, float value) => new(rotation.Degrees + value); + public static Rotation operator +(Rotation rotation, float value) => new(rotation.Degrees + value); /// /// Returns a new representing the subtraction of the and the provided value. @@ -127,7 +127,7 @@ private Rotation(float degrees, float radians) /// The . /// The value to substract. /// A new representing the subtraction of the and the provided value. - public static Rotation operator -(in Rotation rotation, float value) => new(rotation.Degrees - value); + public static Rotation operator -(Rotation rotation, float value) => new(rotation.Degrees - value); /// /// Returns a new representing the multiplication of the and the provided value. @@ -135,7 +135,7 @@ private Rotation(float degrees, float radians) /// The . /// The value to multiply with. /// A new representing the multiplication of the and the provided value. - public static Rotation operator *(in Rotation rotation, float value) => new(rotation.Degrees * value); + public static Rotation operator *(Rotation rotation, float value) => new(rotation.Degrees * value); /// /// Returns a new representing the division of the and the provided value. @@ -143,7 +143,7 @@ private Rotation(float degrees, float radians) /// The . /// The value to device with. /// A new representing the division of the and the provided value. - public static Rotation operator /(in Rotation rotation, float value) => value.EqualsInTolerance(0) ? new Rotation(0) : new Rotation(rotation.Degrees / value); + public static Rotation operator /(Rotation rotation, float value) => value.EqualsInTolerance(0) ? new Rotation(0) : new Rotation(rotation.Degrees / value); /// /// Converts a float to a . @@ -155,7 +155,7 @@ private Rotation(float degrees, float radians) /// Converts to a float representing the rotation in degrees. /// /// The rotatio to convert. - public static implicit operator float(in Rotation rotation) => rotation.Degrees; + public static implicit operator float(Rotation rotation) => rotation.Degrees; #endregion } \ No newline at end of file diff --git a/RGB.NET.Core/Positioning/Size.cs b/RGB.NET.Core/Positioning/Size.cs index 1a9a6d63..22704494 100644 --- a/RGB.NET.Core/Positioning/Size.cs +++ b/RGB.NET.Core/Positioning/Size.cs @@ -110,7 +110,7 @@ public void Deconstruct(out float width, out float height) /// The first to compare. /// The second to compare. /// true if and are equal; otherwise, false. - public static bool operator ==(in Size size1, in Size size2) => size1.Equals(size2); + public static bool operator ==(Size size1, Size size2) => size1.Equals(size2); /// /// Returns a value that indicates whether two specified are equal. @@ -118,7 +118,7 @@ public void Deconstruct(out float width, out float height) /// The first to compare. /// The second to compare. /// true if and are not equal; otherwise, false. - public static bool operator !=(in Size size1, in Size size2) => !(size1 == size2); + public static bool operator !=(Size size1, Size size2) => !(size1 == size2); /// /// Returns a new representing the addition of the two provided . @@ -126,7 +126,7 @@ public void Deconstruct(out float width, out float height) /// The first . /// The second . /// A new representing the addition of the two provided . - public static Size operator +(in Size size1, in Size size2) => new(size1.Width + size2.Width, size1.Height + size2.Height); + public static Size operator +(Size size1, Size size2) => new(size1.Width + size2.Width, size1.Height + size2.Height); /// /// Returns a new created from the provided and . @@ -134,7 +134,7 @@ public void Deconstruct(out float width, out float height) /// The of the rectangle. /// The of the rectangle. /// The rectangle created from the provided and . - public static Rectangle operator +(in Size size, in Point point) => new(point, size); + public static Rectangle operator +(Size size, Point point) => new(point, size); /// /// Returns a new representing the subtraction of the two provided . @@ -142,7 +142,7 @@ public void Deconstruct(out float width, out float height) /// The first . /// The second . /// A new representing the subtraction of the two provided . - public static Size operator -(in Size size1, in Size size2) => new(size1.Width - size2.Width, size1.Height - size2.Height); + public static Size operator -(Size size1, Size size2) => new(size1.Width - size2.Width, size1.Height - size2.Height); /// /// Returns a new representing the multiplication of the two provided . @@ -150,7 +150,7 @@ public void Deconstruct(out float width, out float height) /// The first . /// The second . /// A new representing the multiplication of the two provided . - public static Size operator *(in Size size1, in Size size2) => new(size1.Width * size2.Width, size1.Height * size2.Height); + public static Size operator *(Size size1, Size size2) => new(size1.Width * size2.Width, size1.Height * size2.Height); /// /// Returns a new representing the multiplication of the and the provided factor. @@ -158,7 +158,7 @@ public void Deconstruct(out float width, out float height) /// The . /// The factor by which the should be multiplied. /// A new representing the multiplication of the and the provided factor. - public static Size operator *(in Size size, float factor) => new(size.Width * factor, size.Height * factor); + public static Size operator *(Size size, float factor) => new(size.Width * factor, size.Height * factor); /// /// Returns a new representing the division of the two provided . @@ -166,7 +166,7 @@ public void Deconstruct(out float width, out float height) /// The first . /// The second . /// A new representing the division of the two provided . - public static Size operator /(in Size size1, in Size size2) + public static Size operator /(Size size1, Size size2) => size2.Width.EqualsInTolerance(0) || size2.Height.EqualsInTolerance(0) ? Invalid : new Size(size1.Width / size2.Width, size1.Height / size2.Height); @@ -176,7 +176,7 @@ public void Deconstruct(out float width, out float height) /// The . /// The factor by which the should be divided. /// A new representing the division of the and the provided factor. - public static Size operator /(in Size size, float factor) => factor.EqualsInTolerance(0) ? Invalid : new Size(size.Width / factor, size.Height / factor); + public static Size operator /(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 specified . @@ -184,7 +184,7 @@ public void Deconstruct(out float width, out float height) /// The to scale. /// The scaling factor. /// 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); + public static Size operator *(Size size, Scale scale) => new(size.Width * scale.Horizontal, size.Height * scale.Vertical); #endregion } \ No newline at end of file diff --git a/RGB.NET.Core/RGB.NET.Core.csproj b/RGB.NET.Core/RGB.NET.Core.csproj index 1022bf04..a945aa43 100644 --- a/RGB.NET.Core/RGB.NET.Core.csproj +++ b/RGB.NET.Core/RGB.NET.Core.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net9.0;net8.0 latest enable @@ -52,6 +52,10 @@ RELEASE + + + + diff --git a/RGB.NET.Core/RGBSurface.cs b/RGB.NET.Core/RGBSurface.cs index 5c3387fc..2de9c13e 100644 --- a/RGB.NET.Core/RGBSurface.cs +++ b/RGB.NET.Core/RGBSurface.cs @@ -20,8 +20,8 @@ public sealed class RGBSurface : AbstractBindable, IDisposable private readonly Stopwatch _deltaTimeCounter; - private readonly IList _devices = new List(); - private readonly IList _updateTriggers = new List(); + private readonly IList _devices = []; + private readonly IList _updateTriggers = []; private readonly List _ledGroups = []; /// diff --git a/RGB.NET.Core/Rendering/Brushes/AbstractBrush.cs b/RGB.NET.Core/Rendering/Brushes/AbstractBrush.cs index bc39b5d3..dc69fb21 100644 --- a/RGB.NET.Core/Rendering/Brushes/AbstractBrush.cs +++ b/RGB.NET.Core/Rendering/Brushes/AbstractBrush.cs @@ -69,7 +69,7 @@ protected AbstractBrush(float brightness = 1, float opacity = 1) /// The rectangle in which the brush should be drawn. /// The target (key/point) from which the color should be taken. /// The to be modified. - protected virtual void ApplyDecorators(in Rectangle rectangle, in RenderTarget renderTarget, ref Color color) + protected virtual void ApplyDecorators(Rectangle rectangle, RenderTarget renderTarget, ref Color color) { if (Decorators.Count == 0) return; @@ -89,7 +89,7 @@ protected virtual void ApplyDecorators(in Rectangle rectangle, in RenderTarget r /// The rectangle in which the brush should be drawn. /// The target (key/point) from which the color should be taken. /// The color at the specified point. - protected abstract Color GetColorAtPoint(in Rectangle rectangle, in RenderTarget renderTarget); + protected abstract Color GetColorAtPoint(Rectangle rectangle, RenderTarget renderTarget); /// /// Finalizes the color by appliing the overall brightness and opacity.
diff --git a/RGB.NET.Core/Rendering/Brushes/SolidColorBrush.cs b/RGB.NET.Core/Rendering/Brushes/SolidColorBrush.cs index 02f8e2db..33464b68 100644 --- a/RGB.NET.Core/Rendering/Brushes/SolidColorBrush.cs +++ b/RGB.NET.Core/Rendering/Brushes/SolidColorBrush.cs @@ -41,7 +41,7 @@ public SolidColorBrush(Color color) #region Methods /// - protected override Color GetColorAtPoint(in Rectangle rectangle, in RenderTarget renderTarget) => Color; + protected override Color GetColorAtPoint(Rectangle rectangle, RenderTarget renderTarget) => Color; #endregion diff --git a/RGB.NET.Core/Rendering/Brushes/TextureBrush.cs b/RGB.NET.Core/Rendering/Brushes/TextureBrush.cs index 41280cd2..3881545f 100644 --- a/RGB.NET.Core/Rendering/Brushes/TextureBrush.cs +++ b/RGB.NET.Core/Rendering/Brushes/TextureBrush.cs @@ -36,7 +36,7 @@ public TextureBrush(ITexture texture) #region Methods /// - protected override Color GetColorAtPoint(in Rectangle rectangle, in RenderTarget renderTarget) + protected override Color GetColorAtPoint(Rectangle rectangle, RenderTarget renderTarget) { Rectangle normalizedRect = renderTarget.Rectangle / rectangle; return Texture[normalizedRect]; diff --git a/RGB.NET.Core/Rendering/Textures/EmptyTexture.cs b/RGB.NET.Core/Rendering/Textures/EmptyTexture.cs index 7aca9b7a..28152f42 100644 --- a/RGB.NET.Core/Rendering/Textures/EmptyTexture.cs +++ b/RGB.NET.Core/Rendering/Textures/EmptyTexture.cs @@ -5,8 +5,8 @@ internal sealed class EmptyTexture : ITexture #region Properties & Fields public Size Size { get; } = new(0, 0); - public Color this[in Point point] => Color.Transparent; - public Color this[in Rectangle rectangle] => Color.Transparent; + public Color this[Point point] => Color.Transparent; + public Color this[Rectangle rectangle] => Color.Transparent; #endregion } \ No newline at end of file diff --git a/RGB.NET.Core/Rendering/Textures/ITexture.cs b/RGB.NET.Core/Rendering/Textures/ITexture.cs index 8fdd2ae7..93773bba 100644 --- a/RGB.NET.Core/Rendering/Textures/ITexture.cs +++ b/RGB.NET.Core/Rendering/Textures/ITexture.cs @@ -20,12 +20,12 @@ public interface ITexture ///
/// The location to get the color from. /// The color at the specified location. - Color this[in Point point] { get; } + Color this[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; } + Color this[Rectangle rectangle] { get; } } \ No newline at end of file diff --git a/RGB.NET.Core/Rendering/Textures/PixelTexture.cs b/RGB.NET.Core/Rendering/Textures/PixelTexture.cs index 170d2d55..40478408 100644 --- a/RGB.NET.Core/Rendering/Textures/PixelTexture.cs +++ b/RGB.NET.Core/Rendering/Textures/PixelTexture.cs @@ -39,7 +39,7 @@ public abstract class PixelTexture : ITexture public Size Size { get; } /// - public virtual Color this[in Point point] + public virtual Color this[Point point] { get { @@ -52,7 +52,7 @@ public virtual Color this[in Point point] } /// - public virtual Color this[in Rectangle rectangle] + public virtual Color this[Rectangle rectangle] { get { @@ -126,7 +126,7 @@ public PixelTexture(int with, int height, int dataPerPixel, ISampler sampler, ///
/// The pixel-data to convert. /// The color represented by the specified pixel-data. - protected abstract Color GetColor(in ReadOnlySpan pixel); + protected abstract Color GetColor(ReadOnlySpan pixel); /// /// Gets the pixel-data at the specified location. @@ -189,7 +189,7 @@ public PixelTexture(int with, int height, Color[] data, ISampler sampler) /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - protected override Color GetColor(in ReadOnlySpan pixel) => pixel[0]; + protected override Color GetColor(ReadOnlySpan pixel) => pixel[0]; #endregion } \ No newline at end of file diff --git a/RGB.NET.Core/Rendering/Textures/Sampler/AverageColorSampler.cs b/RGB.NET.Core/Rendering/Textures/Sampler/AverageColorSampler.cs index 9ba2cb02..24f4dfb3 100644 --- a/RGB.NET.Core/Rendering/Textures/Sampler/AverageColorSampler.cs +++ b/RGB.NET.Core/Rendering/Textures/Sampler/AverageColorSampler.cs @@ -22,7 +22,7 @@ public sealed class AverageColorSampler : ISampler #region Methods /// - public unsafe void Sample(in SamplerInfo info, in Span pixelData) + public unsafe void Sample(SamplerInfo info, 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 9a2c4f10..7461afd9 100644 --- a/RGB.NET.Core/Rendering/Textures/Sampler/ISampler.cs +++ b/RGB.NET.Core/Rendering/Textures/Sampler/ISampler.cs @@ -13,5 +13,5 @@ public interface ISampler /// /// The information containing the data to sample. /// The buffer used to write the resulting pixel to. - void Sample(in SamplerInfo info, in Span pixelData); + void Sample(SamplerInfo info, Span pixelData); } \ No newline at end of file diff --git a/RGB.NET.Core/Rendering/Textures/Sampler/SamplerInfo.cs b/RGB.NET.Core/Rendering/Textures/Sampler/SamplerInfo.cs index bf59c937..19ae76ce 100644 --- a/RGB.NET.Core/Rendering/Textures/Sampler/SamplerInfo.cs +++ b/RGB.NET.Core/Rendering/Textures/Sampler/SamplerInfo.cs @@ -44,7 +44,7 @@ public readonly ref struct SamplerInfo /// The width of the region the data comes from. /// The height of region the data comes from. /// The data to sample. - public SamplerInfo(int x, int y, int width, int height, int stride, int dataPerPixel, in ReadOnlySpan data) + public SamplerInfo(int x, int y, int width, int height, int stride, int dataPerPixel, ReadOnlySpan data) { this._x = x; this._y = y; diff --git a/RGB.NET.Core/Update/AbstractUpdateTrigger.cs b/RGB.NET.Core/Update/AbstractUpdateTrigger.cs index 974e0b08..22dcca7d 100644 --- a/RGB.NET.Core/Update/AbstractUpdateTrigger.cs +++ b/RGB.NET.Core/Update/AbstractUpdateTrigger.cs @@ -29,13 +29,13 @@ public abstract class AbstractUpdateTrigger : AbstractBindable, IUpdateTrigger /// Invokes the -event. ///
/// Optional custom-data passed to the subscribers of the .event. - protected virtual void OnStartup(CustomUpdateData? updateData = null) => Starting?.Invoke(this, updateData ?? new CustomUpdateData()); + protected virtual void OnStartup(CustomUpdateData? updateData = null) => Starting?.Invoke(this, updateData ?? CustomUpdateData.Empty); /// /// Invokes the -event. /// /// Optional custom-data passed to the subscribers of the .event. - protected virtual void OnUpdate(CustomUpdateData? updateData = null) => Update?.Invoke(this, updateData ?? new CustomUpdateData()); + protected virtual void OnUpdate(CustomUpdateData? updateData = null) => Update?.Invoke(this, updateData ?? CustomUpdateData.Empty); /// public abstract void Start(); diff --git a/RGB.NET.Core/Update/CustomUpdateData.cs b/RGB.NET.Core/Update/CustomUpdateData.cs index 736723a8..bce97f3b 100644 --- a/RGB.NET.Core/Update/CustomUpdateData.cs +++ b/RGB.NET.Core/Update/CustomUpdateData.cs @@ -52,6 +52,9 @@ public sealed class CustomUpdateData : ICustomUpdateData { #region Properties & Fields + // ReSharper disable once InconsistentNaming + public static readonly CustomUpdateData Empty = new(); + private readonly Dictionary _data = []; #endregion @@ -65,7 +68,7 @@ public sealed class CustomUpdateData : ICustomUpdateData /// The value represented by the specified key. public object? this[string key] { - get => _data.TryGetValue(key, out object? data) ? data : default; + get => _data.GetValueOrDefault(key); set => _data[key] = value; } diff --git a/RGB.NET.Core/Update/Devices/UpdateQueue.cs b/RGB.NET.Core/Update/Devices/UpdateQueue.cs index 22ef7f9e..ba9e3bb6 100644 --- a/RGB.NET.Core/Update/Devices/UpdateQueue.cs +++ b/RGB.NET.Core/Update/Devices/UpdateQueue.cs @@ -1,6 +1,7 @@ using System; using System.Buffers; using System.Collections.Generic; +using System.Threading; namespace RGB.NET.Core; @@ -14,7 +15,7 @@ public abstract class UpdateQueue : AbstractReferenceCountin { #region Properties & Fields - private readonly object _dataLock = new(); + private readonly Lock _dataLock = new(); private readonly IDeviceUpdateTrigger _updateTrigger; private readonly Dictionary _currentDataSet = []; @@ -80,7 +81,7 @@ protected virtual void OnStartup(object? sender, CustomUpdateData customData) { /// Performs the update this queue is responsible for. ///
/// The set of data that needs to be updated. - protected abstract bool Update(in ReadOnlySpan<(TIdentifier key, TData color)> dataSet); + protected abstract bool Update(ReadOnlySpan<(TIdentifier key, TData color)> dataSet); /// /// Sets or merges the provided data set in the current dataset and notifies the trigger that there is new data available. diff --git a/RGB.NET.Core/Update/TimerUpdateTrigger.cs b/RGB.NET.Core/Update/TimerUpdateTrigger.cs index 6b94b3f4..303b5177 100644 --- a/RGB.NET.Core/Update/TimerUpdateTrigger.cs +++ b/RGB.NET.Core/Update/TimerUpdateTrigger.cs @@ -14,7 +14,7 @@ public sealed class TimerUpdateTrigger : AbstractUpdateTrigger { #region Properties & Fields - private readonly object _lock = new(); + private readonly Lock _lock = new(); private readonly CustomUpdateData? _customUpdateData; diff --git a/RGB.NET.Devices.Asus/AsusDeviceProvider.cs b/RGB.NET.Devices.Asus/AsusDeviceProvider.cs index 805db68e..f6ea3126 100644 --- a/RGB.NET.Devices.Asus/AsusDeviceProvider.cs +++ b/RGB.NET.Devices.Asus/AsusDeviceProvider.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Threading; using AuraServiceLib; using RGB.NET.Core; @@ -17,7 +18,7 @@ public sealed class AsusDeviceProvider : AbstractRGBDeviceProvider #region Properties & Fields // ReSharper disable once InconsistentNaming - private static readonly object _lock = new(); + private static readonly Lock _lock = new(); private static AsusDeviceProvider? _instance; /// @@ -76,7 +77,7 @@ protected override IEnumerable LoadDevices() yield return (AsusDeviceType)device.Type switch { - AsusDeviceType.MB_RGB => new AsusMainboardRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Mainboard, device, WMIHelper.GetMainboardInfo()?.model ?? device.Name), GetUpdateTrigger()), + AsusDeviceType.MB_RGB => new AsusMainboardRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Mainboard, device, "Asus Motherboard"), GetUpdateTrigger()), AsusDeviceType.MB_ADDRESABLE => new AsusUnspecifiedRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.LedStripe, device), LedId.LedStripe1, GetUpdateTrigger()), AsusDeviceType.VGA_RGB => new AsusGraphicsCardRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.GraphicsCard, device), GetUpdateTrigger()), AsusDeviceType.HEADSET_RGB => new AsusHeadsetRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Headset, device), GetUpdateTrigger()), diff --git a/RGB.NET.Devices.Asus/Generic/AsusUpdateQueue.cs b/RGB.NET.Devices.Asus/Generic/AsusUpdateQueue.cs index 2f40ec68..e6077a68 100644 --- a/RGB.NET.Devices.Asus/Generic/AsusUpdateQueue.cs +++ b/RGB.NET.Devices.Asus/Generic/AsusUpdateQueue.cs @@ -43,7 +43,7 @@ public AsusUpdateQueue(IDeviceUpdateTrigger updateTrigger, IAuraSyncDevice devic #region Methods /// - protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet) { try { diff --git a/RGB.NET.Devices.Asus/Helper/WMIHelper.cs b/RGB.NET.Devices.Asus/Helper/WMIHelper.cs deleted file mode 100644 index 482f3a3c..00000000 --- a/RGB.NET.Devices.Asus/Helper/WMIHelper.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System; -using System.Management; - -namespace RGB.NET.Devices.Asus; - -// ReSharper disable once InconsistentNaming -internal static class WMIHelper -{ - #region Properties & Fields - - // ReSharper disable InconsistentNaming - private static readonly ManagementObjectSearcher? _systemModelSearcher; - private static readonly ManagementObjectSearcher? _mainboardSearcher; - private static readonly ManagementObjectSearcher? _graphicsCardSearcher; - // ReSharper restore InconsistentNaming - - private static string? _systemModelInfo; - private static (string manufacturer, string model)? _mainboardInfo; - private static string? _graphicsCardInfo; - - #endregion - - #region Constructors - - static WMIHelper() - { - if (OperatingSystem.IsWindows()) - { - _systemModelSearcher = new ManagementObjectSearcher(@"root\CIMV2", "SELECT Model FROM Win32_ComputerSystem"); - _mainboardSearcher = new ManagementObjectSearcher(@"root\CIMV2", "SELECT Manufacturer,Product FROM Win32_BaseBoard"); - _graphicsCardSearcher = new ManagementObjectSearcher(@"root\CIMV2", "SELECT Name FROM Win32_VideoController"); - } - } - - #endregion - - #region Methods - - internal static string? GetSystemModelInfo() - { - if (!OperatingSystem.IsWindows()) return null; - - if ((_systemModelInfo == null) && (_systemModelSearcher != null)) - foreach (ManagementBaseObject managementBaseObject in _systemModelSearcher.Get()) - { - _systemModelInfo = managementBaseObject["Model"].ToString(); - break; - } - - return _systemModelInfo; - } - - internal static (string manufacturer, string model)? GetMainboardInfo() - { - if (!OperatingSystem.IsWindows()) return null; - - if (!_mainboardInfo.HasValue && (_mainboardSearcher != null)) - foreach (ManagementBaseObject managementBaseObject in _mainboardSearcher.Get()) - { - _mainboardInfo = (managementBaseObject["Manufacturer"].ToString() ?? string.Empty, managementBaseObject["Product"].ToString() ?? string.Empty); - break; - } - - return _mainboardInfo; - } - - internal static string? GetGraphicsCardsInfo() - { - if (!OperatingSystem.IsWindows()) return null; - - if ((_graphicsCardInfo == null) && (_graphicsCardSearcher != null)) - foreach (ManagementBaseObject managementBaseObject in _graphicsCardSearcher.Get()) - { - _graphicsCardInfo = managementBaseObject["Name"].ToString(); - break; - } - - return _graphicsCardInfo; - } - - #endregion -} \ No newline at end of file diff --git a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs index 12004290..50a0878d 100644 --- a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs @@ -37,8 +37,8 @@ public sealed class AsusKeyboardRGBDevice : AsusRGBDevice ExtraLedMappings = [ - new AsusKeyboardExtraMapping(new Regex("(ROG Zephyrus Duo 15).*?"), LedMappings.ROGZephyrusDuo15), - new AsusKeyboardExtraMapping(new Regex("(ROG Strix G513QM).*?"), LedMappings.ROGStrixG15) + new(new Regex("(ROG Zephyrus Duo 15).*?"), LedMappings.ROGZephyrusDuo15), + new(new Regex("(ROG Strix G513QM).*?"), LedMappings.ROGStrixG15) ]; #endregion diff --git a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDeviceInfo.cs b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDeviceInfo.cs index 3afb50cd..3baf7282 100644 --- a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDeviceInfo.cs @@ -13,7 +13,6 @@ public sealed class AsusKeyboardRGBDeviceInfo : AsusRGBDeviceInfo, IKeyboardDevi /// /// The ASUS SDK returns useless names for notebook keyboards, possibly for others as well. - /// Keep a list of those and rely on to get the real model /// private static readonly List GENERIC_DEVICE_NAMES = ["NotebookKeyboard"]; @@ -37,7 +36,7 @@ internal AsusKeyboardRGBDeviceInfo(IAuraSyncDevice device) #region Methods - private static string? GetKeyboardModel(string deviceName) => GENERIC_DEVICE_NAMES.Contains(deviceName) ? WMIHelper.GetSystemModelInfo() : deviceName; + private static string GetKeyboardModel(string deviceName) => GENERIC_DEVICE_NAMES.Contains(deviceName) ? "Asus Keyboard" : deviceName; #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj b/RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj index ecf4ea78..b04586c7 100644 --- a/RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj +++ b/RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net9.0;net8.0 latest enable @@ -51,13 +51,13 @@ RELEASE - - - + + - + + diff --git a/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs b/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs index cecc41d1..d6813849 100644 --- a/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs +++ b/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Threading; using RGB.NET.Core; using RGB.NET.Devices.CoolerMaster.Helper; using RGB.NET.Devices.CoolerMaster.Native; @@ -18,7 +19,7 @@ public sealed class CoolerMasterDeviceProvider : AbstractRGBDeviceProvider #region Properties & Fields // ReSharper disable once InconsistentNaming - private static readonly object _lock = new(); + private static readonly Lock _lock = new(); private static CoolerMasterDeviceProvider? _instance; /// diff --git a/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterUpdateQueue.cs b/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterUpdateQueue.cs index 99e14281..f7506cec 100644 --- a/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterUpdateQueue.cs +++ b/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterUpdateQueue.cs @@ -37,7 +37,7 @@ public CoolerMasterUpdateQueue(IDeviceUpdateTrigger updateTrigger, CoolerMasterD #region Methods /// - protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet) { try { diff --git a/RGB.NET.Devices.CoolerMaster/RGB.NET.Devices.CoolerMaster.csproj b/RGB.NET.Devices.CoolerMaster/RGB.NET.Devices.CoolerMaster.csproj index 73017c6b..c54ced29 100644 --- a/RGB.NET.Devices.CoolerMaster/RGB.NET.Devices.CoolerMaster.csproj +++ b/RGB.NET.Devices.CoolerMaster/RGB.NET.Devices.CoolerMaster.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net9.0;net8.0 latest enable @@ -51,6 +51,10 @@ RELEASE + + + + diff --git a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs index 4dba9ea8..1d0e7d62 100644 --- a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs +++ b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs @@ -18,7 +18,7 @@ public sealed class CorsairDeviceProvider : AbstractRGBDeviceProvider #region Properties & Fields // ReSharper disable once InconsistentNaming - private static readonly object _lock = new(); + private static readonly Lock _lock = new(); private static CorsairDeviceProvider? _instance; /// diff --git a/RGB.NET.Devices.Corsair/Generic/CorsairDeviceUpdateQueue.cs b/RGB.NET.Devices.Corsair/Generic/CorsairDeviceUpdateQueue.cs index be3a3bf7..bd707a2a 100644 --- a/RGB.NET.Devices.Corsair/Generic/CorsairDeviceUpdateQueue.cs +++ b/RGB.NET.Devices.Corsair/Generic/CorsairDeviceUpdateQueue.cs @@ -40,7 +40,7 @@ internal CorsairDeviceUpdateQueue(IDeviceUpdateTrigger updateTrigger, _CorsairDe #region Methods /// - protected override unsafe bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override unsafe bool Update(ReadOnlySpan<(object key, Color color)> dataSet) { try { diff --git a/RGB.NET.Devices.Corsair/Native/_CUESDK.cs b/RGB.NET.Devices.Corsair/Native/_CUESDK.cs index 38324e35..6c48745f 100644 --- a/RGB.NET.Devices.Corsair/Native/_CUESDK.cs +++ b/RGB.NET.Devices.Corsair/Native/_CUESDK.cs @@ -133,7 +133,7 @@ private static IEnumerable GetPossibleLibraryPaths() if (OperatingSystem.IsWindows()) possibleLibraryPaths = Environment.Is64BitProcess ? CorsairDeviceProvider.PossibleX64NativePaths : CorsairDeviceProvider.PossibleX86NativePaths; else - possibleLibraryPaths = Enumerable.Empty(); + possibleLibraryPaths = []; return possibleLibraryPaths.Select(Environment.ExpandEnvironmentVariables); } diff --git a/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj b/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj index ee6cfcaf..ff0914d7 100644 --- a/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj +++ b/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net9.0;net8.0 latest enable @@ -52,6 +52,10 @@ RELEASE + + + + diff --git a/RGB.NET.Devices.Corsair_Legacy/CorsairLegacyDeviceProvider.cs b/RGB.NET.Devices.Corsair_Legacy/CorsairLegacyDeviceProvider.cs index 9f770e8e..d893dfd1 100644 --- a/RGB.NET.Devices.Corsair_Legacy/CorsairLegacyDeviceProvider.cs +++ b/RGB.NET.Devices.Corsair_Legacy/CorsairLegacyDeviceProvider.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; +using System.Threading; using RGB.NET.Core; using RGB.NET.Devices.CorsairLegacy.Native; @@ -19,7 +20,7 @@ public sealed class CorsairLegacyDeviceProvider : AbstractRGBDeviceProvider #region Properties & Fields // ReSharper disable once InconsistentNaming - private static readonly object _lock = new(); + private static readonly Lock _lock = new(); private static CorsairLegacyDeviceProvider? _instance; /// diff --git a/RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDeviceInfo.cs index 783089e9..967bd5de 100644 --- a/RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDeviceInfo.cs @@ -124,16 +124,19 @@ private static string GetModelName(string model, _CorsairChannelDeviceInfo chann // LS100 Led Strips are reported as one big strip if configured in monitor mode in iCUE, 138 LEDs for dual monitor, 84 for single if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 138)) return "LS100 LED Strip (dual monitor)"; - else if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 84)) + + if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 84)) return "LS100 LED Strip (single monitor)"; + // Any other value means an "External LED Strip" in iCUE, these are reported per-strip, 15 for short strips, 27 for long - else if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 15)) + if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 15)) return "LS100 LED Strip (short)"; - else if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 27)) + + if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 27)) return "LS100 LED Strip (long)"; + // Device model is "Commander Pro" for regular LED strips - else - return "LED Strip"; + return "LED Strip"; case CorsairChannelDeviceType.DAP: return "DAP Fan"; diff --git a/RGB.NET.Devices.Corsair_Legacy/Generic/CorsairDeviceUpdateQueue.cs b/RGB.NET.Devices.Corsair_Legacy/Generic/CorsairDeviceUpdateQueue.cs index a7669117..52373532 100644 --- a/RGB.NET.Devices.Corsair_Legacy/Generic/CorsairDeviceUpdateQueue.cs +++ b/RGB.NET.Devices.Corsair_Legacy/Generic/CorsairDeviceUpdateQueue.cs @@ -35,7 +35,7 @@ public CorsairDeviceUpdateQueue(IDeviceUpdateTrigger updateTrigger, int deviceIn #region Methods /// - protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet) { try { diff --git a/RGB.NET.Devices.Corsair_Legacy/Native/_CUESDK.cs b/RGB.NET.Devices.Corsair_Legacy/Native/_CUESDK.cs index 3ace4359..dda97dd3 100644 --- a/RGB.NET.Devices.Corsair_Legacy/Native/_CUESDK.cs +++ b/RGB.NET.Devices.Corsair_Legacy/Native/_CUESDK.cs @@ -64,7 +64,7 @@ private static IEnumerable GetPossibleLibraryPaths() if (OperatingSystem.IsWindows()) possibleLibraryPaths = Environment.Is64BitProcess ? CorsairLegacyDeviceProvider.PossibleX64NativePaths : CorsairLegacyDeviceProvider.PossibleX86NativePaths; else - possibleLibraryPaths = Enumerable.Empty(); + possibleLibraryPaths = []; return possibleLibraryPaths.Select(Environment.ExpandEnvironmentVariables); } diff --git a/RGB.NET.Devices.Corsair_Legacy/RGB.NET.Devices.Corsair_Legacy.csproj b/RGB.NET.Devices.Corsair_Legacy/RGB.NET.Devices.Corsair_Legacy.csproj index c80995d1..e9c4509a 100644 --- a/RGB.NET.Devices.Corsair_Legacy/RGB.NET.Devices.Corsair_Legacy.csproj +++ b/RGB.NET.Devices.Corsair_Legacy/RGB.NET.Devices.Corsair_Legacy.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net9.0;net8.0 latest enable @@ -52,6 +52,10 @@ RELEASE + + + + diff --git a/RGB.NET.Devices.DMX/DMXDeviceProvider.cs b/RGB.NET.Devices.DMX/DMXDeviceProvider.cs index b5d725c3..5e654593 100644 --- a/RGB.NET.Devices.DMX/DMXDeviceProvider.cs +++ b/RGB.NET.Devices.DMX/DMXDeviceProvider.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Threading; using RGB.NET.Core; using RGB.NET.Devices.DMX.E131; @@ -17,7 +18,7 @@ public sealed class DMXDeviceProvider : AbstractRGBDeviceProvider #region Properties & Fields // ReSharper disable once InconsistentNaming - private static readonly object _lock = new(); + private static readonly Lock _lock = new(); private static DMXDeviceProvider? _instance; /// diff --git a/RGB.NET.Devices.DMX/E131/E131UpdateQueue.cs b/RGB.NET.Devices.DMX/E131/E131UpdateQueue.cs index 2e513ec4..4fb1f433 100644 --- a/RGB.NET.Devices.DMX/E131/E131UpdateQueue.cs +++ b/RGB.NET.Devices.DMX/E131/E131UpdateQueue.cs @@ -59,7 +59,7 @@ protected override void OnUpdate(object? sender, CustomUpdateData customData) } /// - protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet) { try { diff --git a/RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj b/RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj index df8e5475..679d94d4 100644 --- a/RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj +++ b/RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net9.0;net8.0 latest enable @@ -51,6 +51,10 @@ RELEASE + + + + diff --git a/RGB.NET.Devices.Debug/DebugDeviceProvider.cs b/RGB.NET.Devices.Debug/DebugDeviceProvider.cs index 636e57f9..cbd97a2e 100644 --- a/RGB.NET.Devices.Debug/DebugDeviceProvider.cs +++ b/RGB.NET.Devices.Debug/DebugDeviceProvider.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Threading; using RGB.NET.Core; using RGB.NET.Layout; @@ -17,7 +18,7 @@ public sealed class DebugDeviceProvider : AbstractRGBDeviceProvider #region Properties & Fields // ReSharper disable once InconsistentNaming - private static readonly object _lock = new(); + private static readonly Lock _lock = new(); private static DebugDeviceProvider? _instance; /// diff --git a/RGB.NET.Devices.Debug/DebugDeviceUpdateQueue.cs b/RGB.NET.Devices.Debug/DebugDeviceUpdateQueue.cs index df86acca..e228ea5d 100644 --- a/RGB.NET.Devices.Debug/DebugDeviceUpdateQueue.cs +++ b/RGB.NET.Devices.Debug/DebugDeviceUpdateQueue.cs @@ -7,7 +7,7 @@ internal sealed class DebugDeviceUpdateQueue() : UpdateQueue(new DeviceUpdateTri { #region Methods - protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) => true; + protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet) => true; #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Debug/RGB.NET.Devices.Debug.csproj b/RGB.NET.Devices.Debug/RGB.NET.Devices.Debug.csproj index 1f177287..14db0ca5 100644 --- a/RGB.NET.Devices.Debug/RGB.NET.Devices.Debug.csproj +++ b/RGB.NET.Devices.Debug/RGB.NET.Devices.Debug.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net9.0;net8.0 latest enable @@ -51,6 +51,10 @@ RELEASE + + + + diff --git a/RGB.NET.Devices.Logitech/HID/LightspeedHidLoader.cs b/RGB.NET.Devices.Logitech/HID/LightspeedHidLoader.cs index de498815..e1dc2429 100644 --- a/RGB.NET.Devices.Logitech/HID/LightspeedHidLoader.cs +++ b/RGB.NET.Devices.Logitech/HID/LightspeedHidLoader.cs @@ -104,7 +104,9 @@ private IEnumerable Detect(int pid) Dictionary deviceUsages = DeviceList.Local .GetHidDevices(VendorId, pid) .Where(d => d.DevicePath.Contains("mi_02")) - .ToDictionary(x => (byte)x.GetUsage(), x => x); + .Select(x => ((byte)x.GetUsage(), x)) + .DistinctBy(x => x.Item1) + .ToDictionary(x => x.Item1, x => x.x); foreach ((int wirelessPid, byte _) in GetWirelessDevices(deviceUsages)) yield return wirelessPid; @@ -137,7 +139,7 @@ private Dictionary GetWirelessDevices(IReadOnlyDictionary GetWirelessDevices(IReadOnlyDictionary GetWirelessDevices(IReadOnlyDictionary GetWirelessDevices(IReadOnlyDictionary @@ -70,6 +71,8 @@ public static LogitechDeviceProvider Instance { 0xC342, RGBDeviceType.Keyboard, "G512", LedMappings.PerKey, 0 }, { 0xC343, RGBDeviceType.Keyboard, "G915 TKL", LedMappings.PerKey, 0 }, { 0xC541, RGBDeviceType.Keyboard, "G915", LedMappings.PerKey, 0 }, + { 0xC359, RGBDeviceType.Keyboard, "G915 X", LedMappings.PerKey, 0 }, + { 0xC547, RGBDeviceType.Keyboard, "G915 X TKL", LedMappings.PerKey, 0 }, //non-rgb { 0xC333, RGBDeviceType.Keyboard, "G610", LedMappings.PerKey, 0 }, diff --git a/RGB.NET.Devices.Logitech/Native/_LogitechGSDK.cs b/RGB.NET.Devices.Logitech/Native/_LogitechGSDK.cs index 42ebb6cc..f7ca06e6 100644 --- a/RGB.NET.Devices.Logitech/Native/_LogitechGSDK.cs +++ b/RGB.NET.Devices.Logitech/Native/_LogitechGSDK.cs @@ -63,7 +63,7 @@ private static IEnumerable GetPossibleLibraryPaths() if (OperatingSystem.IsWindows()) possibleLibraryPaths = Environment.Is64BitProcess ? LogitechDeviceProvider.PossibleX64NativePaths : LogitechDeviceProvider.PossibleX86NativePaths; else - possibleLibraryPaths = Enumerable.Empty(); + possibleLibraryPaths = []; return possibleLibraryPaths.Select(Environment.ExpandEnvironmentVariables); } diff --git a/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceUpdateQueue.cs b/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceUpdateQueue.cs index b780a283..655c9a71 100644 --- a/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceUpdateQueue.cs +++ b/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceUpdateQueue.cs @@ -25,7 +25,7 @@ public LogitechPerDeviceUpdateQueue(IDeviceUpdateTrigger updateTrigger) #region Methods /// - protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet) { try { diff --git a/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyUpdateQueue.cs b/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyUpdateQueue.cs index 7f1917f2..7159b66e 100644 --- a/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyUpdateQueue.cs +++ b/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyUpdateQueue.cs @@ -24,7 +24,7 @@ public LogitechPerKeyUpdateQueue(IDeviceUpdateTrigger updateTrigger) #region Methods /// - protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet) { try { diff --git a/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj b/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj index 6ae10dd6..4c27d963 100644 --- a/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj +++ b/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net9.0;net8.0 latest enable @@ -52,6 +52,10 @@ RELEASE + + + + diff --git a/RGB.NET.Devices.Logitech/Zone/LogitechZoneUpdateQueue.cs b/RGB.NET.Devices.Logitech/Zone/LogitechZoneUpdateQueue.cs index c9a83a56..baf22535 100644 --- a/RGB.NET.Devices.Logitech/Zone/LogitechZoneUpdateQueue.cs +++ b/RGB.NET.Devices.Logitech/Zone/LogitechZoneUpdateQueue.cs @@ -33,7 +33,7 @@ public LogitechZoneUpdateQueue(IDeviceUpdateTrigger updateTrigger, LogitechDevic #region Methods /// - protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet) { try { diff --git a/RGB.NET.Devices.Msi/Generic/MsiDeviceUpdateQueue.cs b/RGB.NET.Devices.Msi/Generic/MsiDeviceUpdateQueue.cs index 0367029b..0a648569 100644 --- a/RGB.NET.Devices.Msi/Generic/MsiDeviceUpdateQueue.cs +++ b/RGB.NET.Devices.Msi/Generic/MsiDeviceUpdateQueue.cs @@ -34,7 +34,7 @@ public MsiDeviceUpdateQueue(IDeviceUpdateTrigger updateTrigger, string deviceTyp #region Methods /// - protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet) { try { diff --git a/RGB.NET.Devices.Msi/MsiDeviceProvider.cs b/RGB.NET.Devices.Msi/MsiDeviceProvider.cs index 54be621b..d7022a32 100644 --- a/RGB.NET.Devices.Msi/MsiDeviceProvider.cs +++ b/RGB.NET.Devices.Msi/MsiDeviceProvider.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Threading; using RGB.NET.Core; using RGB.NET.Devices.Msi.Exceptions; using RGB.NET.Devices.Msi.Native; @@ -18,7 +19,7 @@ public class MsiDeviceProvider : AbstractRGBDeviceProvider #region Properties & Fields // ReSharper disable once InconsistentNaming - private static readonly object _lock = new(); + private static readonly Lock _lock = new(); private static MsiDeviceProvider? _instance; /// diff --git a/RGB.NET.Devices.Msi/Native/_MsiSDK.cs b/RGB.NET.Devices.Msi/Native/_MsiSDK.cs index 1bc63fd6..91fbd922 100644 --- a/RGB.NET.Devices.Msi/Native/_MsiSDK.cs +++ b/RGB.NET.Devices.Msi/Native/_MsiSDK.cs @@ -68,7 +68,7 @@ private static IEnumerable GetPossibleLibraryPaths() if (OperatingSystem.IsWindows()) possibleLibraryPaths = Environment.Is64BitProcess ? MsiDeviceProvider.PossibleX64NativePaths : MsiDeviceProvider.PossibleX86NativePaths; else - possibleLibraryPaths = Enumerable.Empty(); + possibleLibraryPaths = []; return possibleLibraryPaths.Select(Environment.ExpandEnvironmentVariables); } diff --git a/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj b/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj index 12f416f4..4409e880 100644 --- a/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj +++ b/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net9.0;net8.0 latest enable @@ -51,6 +51,10 @@ RELEASE + + + + diff --git a/RGB.NET.Devices.Novation/Generic/LimitedColorUpdateQueue.cs b/RGB.NET.Devices.Novation/Generic/LimitedColorUpdateQueue.cs index 987b691e..1eb0548d 100644 --- a/RGB.NET.Devices.Novation/Generic/LimitedColorUpdateQueue.cs +++ b/RGB.NET.Devices.Novation/Generic/LimitedColorUpdateQueue.cs @@ -25,7 +25,7 @@ public LimitedColorUpdateQueue(IDeviceUpdateTrigger updateTrigger, int deviceId) #region Methods /// - protected override ShortMessage CreateMessage(object key, in Color color) + protected override ShortMessage CreateMessage(object key, Color color) { (byte mode, byte id) = ((byte, byte))key; return new ShortMessage(mode, id, Convert.ToByte(ConvertColor(color))); @@ -37,7 +37,7 @@ protected override ShortMessage CreateMessage(object key, in Color color) /// /// The to convert. /// The novation-representation of the . - private static int ConvertColor(in Color color) + private static int ConvertColor(Color color) { (double hue, double _, double value) = color.GetHSV(); diff --git a/RGB.NET.Devices.Novation/Generic/MidiUpdateQueue.cs b/RGB.NET.Devices.Novation/Generic/MidiUpdateQueue.cs index 945c4ff5..8b451762 100644 --- a/RGB.NET.Devices.Novation/Generic/MidiUpdateQueue.cs +++ b/RGB.NET.Devices.Novation/Generic/MidiUpdateQueue.cs @@ -35,7 +35,7 @@ protected MidiUpdateQueue(IDeviceUpdateTrigger updateTrigger, int deviceId) #region Methods /// - protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet) { try { @@ -68,7 +68,7 @@ protected virtual void SendMessage(ShortMessage? message) /// The key used to identify the LED to update. /// The color to send. /// The message created out of the data set. - protected abstract ShortMessage? CreateMessage(object key, in Color color); + protected abstract ShortMessage? CreateMessage(object key, Color color); /// public override void Dispose() diff --git a/RGB.NET.Devices.Novation/Generic/RGBColorUpdateQueue.cs b/RGB.NET.Devices.Novation/Generic/RGBColorUpdateQueue.cs index aa3f53d5..0584d45f 100644 --- a/RGB.NET.Devices.Novation/Generic/RGBColorUpdateQueue.cs +++ b/RGB.NET.Devices.Novation/Generic/RGBColorUpdateQueue.cs @@ -151,7 +151,7 @@ public RGBColorUpdateQueue(IDeviceUpdateTrigger updateTrigger, int deviceId) #region Methods /// - protected override ShortMessage? CreateMessage(object key, in Color color) + protected override ShortMessage? CreateMessage(object key, Color color) { (byte mode, byte id) = ((byte, byte))key; if (mode == 0x00) return null; @@ -165,7 +165,7 @@ public RGBColorUpdateQueue(IDeviceUpdateTrigger updateTrigger, int deviceId) /// /// The to convert. /// The novation-representation of the . - private static int ConvertColor(in Color color) + private static int ConvertColor(Color color) { int bestVelocity = 0; double bestMatchDistance = double.MaxValue; diff --git a/RGB.NET.Devices.Novation/NovationDeviceProvider.cs b/RGB.NET.Devices.Novation/NovationDeviceProvider.cs index e3c9b777..c2e2435a 100644 --- a/RGB.NET.Devices.Novation/NovationDeviceProvider.cs +++ b/RGB.NET.Devices.Novation/NovationDeviceProvider.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; using RGB.NET.Core; using Sanford.Multimedia.Midi; @@ -18,7 +19,7 @@ public sealed class NovationDeviceProvider : AbstractRGBDeviceProvider #region Properties & Fields // ReSharper disable once InconsistentNaming - private static readonly object _lock = new(); + private static readonly Lock _lock = new(); private static NovationDeviceProvider? _instance; /// diff --git a/RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj b/RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj index c249fc27..a526cfba 100644 --- a/RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj +++ b/RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net9.0;net8.0 latest enable @@ -51,6 +51,10 @@ RELEASE + + + + diff --git a/RGB.NET.Devices.OpenRGB/Generic/OpenRGBUpdateQueue.cs b/RGB.NET.Devices.OpenRGB/Generic/OpenRGBUpdateQueue.cs index 0537d11b..43ddc0ba 100644 --- a/RGB.NET.Devices.OpenRGB/Generic/OpenRGBUpdateQueue.cs +++ b/RGB.NET.Devices.OpenRGB/Generic/OpenRGBUpdateQueue.cs @@ -48,7 +48,7 @@ public OpenRGBUpdateQueue(IDeviceUpdateTrigger updateTrigger, int deviceId, Open #region Methods /// - protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet) { try { diff --git a/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs b/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs index 26b3a2a9..33ac3342 100644 --- a/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs +++ b/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; namespace RGB.NET.Devices.OpenRGB; @@ -15,7 +16,7 @@ public sealed class OpenRGBDeviceProvider : AbstractRGBDeviceProvider #region Properties & Fields // ReSharper disable once InconsistentNaming - private static readonly object _lock = new(); + private static readonly Lock _lock = new(); private readonly List _clients = []; diff --git a/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj b/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj index 6b325210..5f7a0143 100644 --- a/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj +++ b/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj @@ -1,6 +1,6 @@ - net8.0;net7.0;net6.0 + net9.0;net8.0 latest enable @@ -51,13 +51,17 @@ RELEASE + + + + - + diff --git a/RGB.NET.Devices.PicoPi/PicoPi/PicoPiBulkUpdateQueue.cs b/RGB.NET.Devices.PicoPi/PicoPi/PicoPiBulkUpdateQueue.cs index edd290be..3b211ae0 100644 --- a/RGB.NET.Devices.PicoPi/PicoPi/PicoPiBulkUpdateQueue.cs +++ b/RGB.NET.Devices.PicoPi/PicoPi/PicoPiBulkUpdateQueue.cs @@ -44,7 +44,7 @@ public PicoPiBulkUpdateQueue(IDeviceUpdateTrigger updateTrigger, PicoPiSDK sdk, #region Methods /// - protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet) { try { diff --git a/RGB.NET.Devices.PicoPi/PicoPi/PicoPiHIDUpdateQueue.cs b/RGB.NET.Devices.PicoPi/PicoPi/PicoPiHIDUpdateQueue.cs index 652ba807..cae4080b 100644 --- a/RGB.NET.Devices.PicoPi/PicoPi/PicoPiHIDUpdateQueue.cs +++ b/RGB.NET.Devices.PicoPi/PicoPi/PicoPiHIDUpdateQueue.cs @@ -41,7 +41,7 @@ public PicoPiHIDUpdateQueue(IDeviceUpdateTrigger updateTrigger, PicoPiSDK sdk, i #region Methods /// - protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet) { try { diff --git a/RGB.NET.Devices.PicoPi/PicoPi/PicoPiSDK.cs b/RGB.NET.Devices.PicoPi/PicoPi/PicoPiSDK.cs index 2dcd6de4..1e5c3ce2 100644 --- a/RGB.NET.Devices.PicoPi/PicoPi/PicoPiSDK.cs +++ b/RGB.NET.Devices.PicoPi/PicoPi/PicoPiSDK.cs @@ -212,7 +212,7 @@ private int GetVersion() /// /// The data to send. /// The channel to update. - public void SendHidUpdate(in Span buffer, int channel) + public void SendHidUpdate(Span buffer, int channel) { int chunks = buffer.Length / HID_OFFSET_MULTIPLIER; if ((chunks * HID_OFFSET_MULTIPLIER) < buffer.Length) chunks++; @@ -232,7 +232,7 @@ public void SendHidUpdate(in Span buffer, int channel) /// The channel to update. /// The chunk id of the packet. (Required if packets are fragmented.) /// A value indicating if the device should update directly after receiving this packet. (If packets are fragmented this should only be true for the last chunk.) - public void SendHidUpdate(in Span data, int channel, int chunk, bool update) + public void SendHidUpdate(Span data, int channel, int chunk, bool update) { if (data.Length == 0) return; @@ -253,7 +253,7 @@ public void SendHidUpdate(in Span data, int channel, int chunk, bool updat /// /// The data packet to send. /// The channel to update. - public void SendBulkUpdate(in Span data, int channel) + public void SendBulkUpdate(Span data, int channel) { if ((data.Length == 0) || !IsBulkSupported) return; diff --git a/RGB.NET.Devices.PicoPi/PicoPiDeviceProvider.cs b/RGB.NET.Devices.PicoPi/PicoPiDeviceProvider.cs index ebcdff51..f5b879d2 100644 --- a/RGB.NET.Devices.PicoPi/PicoPiDeviceProvider.cs +++ b/RGB.NET.Devices.PicoPi/PicoPiDeviceProvider.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; using HidSharp; using RGB.NET.Core; using RGB.NET.Devices.PicoPi.Enum; @@ -26,7 +27,7 @@ public sealed class PicoPiDeviceProvider : AbstractRGBDeviceProvider #region Properties & Fields // ReSharper disable once InconsistentNaming - private static readonly object _lock = new(); + private static readonly Lock _lock = new(); private static PicoPiDeviceProvider? _instance; /// diff --git a/RGB.NET.Devices.PicoPi/RGB.NET.Devices.PicoPi.csproj b/RGB.NET.Devices.PicoPi/RGB.NET.Devices.PicoPi.csproj index a2b134f7..b42f3613 100644 --- a/RGB.NET.Devices.PicoPi/RGB.NET.Devices.PicoPi.csproj +++ b/RGB.NET.Devices.PicoPi/RGB.NET.Devices.PicoPi.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net9.0;net8.0 latest enable @@ -51,6 +51,10 @@ RELEASE + + + + diff --git a/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkUpdateQueue.cs b/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkUpdateQueue.cs index 17b7add5..1b12a93a 100644 --- a/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkUpdateQueue.cs @@ -25,7 +25,7 @@ public RazerChromaLinkUpdateQueue(IDeviceUpdateTrigger updateTrigger) #region Methods /// - protected override nint CreateEffectParams(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override nint CreateEffectParams(ReadOnlySpan<(object key, Color color)> dataSet) { _Color[] colors = new _Color[_Defines.CHROMALINK_MAX_LEDS]; diff --git a/RGB.NET.Devices.Razer/Generic/LedMappings.cs b/RGB.NET.Devices.Razer/Generic/LedMappings.cs index d1a3dabb..3b24f78e 100644 --- a/RGB.NET.Devices.Razer/Generic/LedMappings.cs +++ b/RGB.NET.Devices.Razer/Generic/LedMappings.cs @@ -13,10 +13,17 @@ public static class LedMappings /// public static LedMapping Keyboard { get; } = new() { - //Row 0 is empty + #region Row 0 + + [LedId.LedStripe1] = (_Defines.KEYBOARD_MAX_COLUMN * 0) + 0, + [LedId.LedStripe16] = (_Defines.KEYBOARD_MAX_COLUMN * 0) + 23, + + #endregion #region Row 1 + [LedId.LedStripe2] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 0, + [LedId.Custom1] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 1, [LedId.Keyboard_Escape] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 2, [LedId.Keyboard_F1] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 4, [LedId.Keyboard_F2] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 5, @@ -33,12 +40,17 @@ public static class LedMappings [LedId.Keyboard_PrintScreen] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 16, [LedId.Keyboard_ScrollLock] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 17, [LedId.Keyboard_PauseBreak] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 18, - [LedId.Logo] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 21, + [LedId.Keyboard_MediaPreviousTrack] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 19, + [LedId.Keyboard_MediaPlay] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 20, + [LedId.Keyboard_MediaNextTrack] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 21, + [LedId.Keyboard_MediaMute] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 22, + [LedId.LedStripe15] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 23, #endregion #region Row 2 + [LedId.LedStripe3] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 0, [LedId.Keyboard_Programmable1] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 1, [LedId.Keyboard_GraveAccentAndTilde] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 2, [LedId.Keyboard_1] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 3, @@ -61,11 +73,13 @@ public static class LedMappings [LedId.Keyboard_NumSlash] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 20, [LedId.Keyboard_NumAsterisk] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 21, [LedId.Keyboard_NumMinus] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 22, + [LedId.LedStripe14] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 23, #endregion #region Row 3 + [LedId.LedStripe4] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 0, [LedId.Keyboard_Programmable2] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 1, [LedId.Keyboard_Tab] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 2, [LedId.Keyboard_Q] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 3, @@ -88,11 +102,13 @@ public static class LedMappings [LedId.Keyboard_Num8] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 20, [LedId.Keyboard_Num9] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 21, [LedId.Keyboard_NumPlus] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 22, + [LedId.LedStripe13] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 23, #endregion #region Row 4 + [LedId.LedStripe5] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 0, [LedId.Keyboard_Programmable3] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 1, [LedId.Keyboard_CapsLock] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 2, [LedId.Keyboard_A] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 3, @@ -111,11 +127,13 @@ public static class LedMappings [LedId.Keyboard_Num4] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 19, [LedId.Keyboard_Num5] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 20, [LedId.Keyboard_Num6] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 21, + [LedId.LedStripe12] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 23, #endregion #region Row 5 + [LedId.LedStripe6] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 0, [LedId.Keyboard_Programmable4] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 1, [LedId.Keyboard_LeftShift] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 2, [LedId.Keyboard_NonUsBackslash] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 3, @@ -135,11 +153,13 @@ public static class LedMappings [LedId.Keyboard_Num2] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 20, [LedId.Keyboard_Num3] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 21, [LedId.Keyboard_NumEnter] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 22, + [LedId.LedStripe11] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 23, #endregion #region Row 6 + [LedId.LedStripe7] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 0, [LedId.Keyboard_Programmable5] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 1, [LedId.Keyboard_LeftCtrl] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 2, [LedId.Keyboard_LeftGui] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 3, @@ -152,12 +172,18 @@ public static class LedMappings [LedId.Keyboard_ArrowLeft] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 16, [LedId.Keyboard_ArrowDown] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 17, [LedId.Keyboard_ArrowRight] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 18, + [LedId.LedStripe9] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 19, [LedId.Keyboard_Num0] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 20, [LedId.Keyboard_NumPeriodAndDelete] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 21, + [LedId.LedStripe10] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 23, #endregion - //Row 7 is also empty + #region Row 6 + + [LedId.LedStripe8] = (_Defines.KEYBOARD_MAX_COLUMN * 7) + 0, + + #endregion }; diff --git a/RGB.NET.Devices.Razer/Generic/RazerUpdateQueue.cs b/RGB.NET.Devices.Razer/Generic/RazerUpdateQueue.cs index 615e48b1..f8fa4170 100644 --- a/RGB.NET.Devices.Razer/Generic/RazerUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/Generic/RazerUpdateQueue.cs @@ -30,7 +30,7 @@ protected RazerUpdateQueue(IDeviceUpdateTrigger updateTrigger) #region Methods /// - protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet) { try { @@ -77,7 +77,7 @@ public override void Reset() /// /// The data to be updated. /// An pointing to the effect parameter struct. - protected abstract nint CreateEffectParams(in ReadOnlySpan<(object key, Color color)> dataSet); + protected abstract nint CreateEffectParams(ReadOnlySpan<(object key, Color color)> dataSet); #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Razer/Headset/RazerHeadsetUpdateQueue.cs b/RGB.NET.Devices.Razer/Headset/RazerHeadsetUpdateQueue.cs index 8ddbce31..e29f435f 100644 --- a/RGB.NET.Devices.Razer/Headset/RazerHeadsetUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/Headset/RazerHeadsetUpdateQueue.cs @@ -25,7 +25,7 @@ public RazerHeadsetUpdateQueue(IDeviceUpdateTrigger updateTrigger) #region Methods /// - protected override nint CreateEffectParams(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override nint CreateEffectParams(ReadOnlySpan<(object key, Color color)> dataSet) { _Color[] colors = new _Color[_Defines.HEADSET_MAX_LEDS]; diff --git a/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardUpdateQueue.cs b/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardUpdateQueue.cs index 68e0f5f7..4a709aa5 100644 --- a/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardUpdateQueue.cs @@ -25,7 +25,7 @@ public RazerKeyboardUpdateQueue(IDeviceUpdateTrigger updateTrigger) #region Methods /// - protected override nint CreateEffectParams(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override nint CreateEffectParams(ReadOnlySpan<(object key, Color color)> dataSet) { _Color[] colors = new _Color[_Defines.KEYBOARD_MAX_LEDS]; diff --git a/RGB.NET.Devices.Razer/Keypad/RazerKeypadUpdateQueue.cs b/RGB.NET.Devices.Razer/Keypad/RazerKeypadUpdateQueue.cs index 7e2470e1..e33487aa 100644 --- a/RGB.NET.Devices.Razer/Keypad/RazerKeypadUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/Keypad/RazerKeypadUpdateQueue.cs @@ -25,7 +25,7 @@ public RazerKeypadUpdateQueue(IDeviceUpdateTrigger updateTrigger) #region Methods /// - protected override nint CreateEffectParams(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override nint CreateEffectParams(ReadOnlySpan<(object key, Color color)> dataSet) { _Color[] colors = new _Color[_Defines.KEYPAD_MAX_LEDS]; diff --git a/RGB.NET.Devices.Razer/Mouse/RazerMouseUpdateQueue.cs b/RGB.NET.Devices.Razer/Mouse/RazerMouseUpdateQueue.cs index cbdde12b..8e056c61 100644 --- a/RGB.NET.Devices.Razer/Mouse/RazerMouseUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/Mouse/RazerMouseUpdateQueue.cs @@ -25,7 +25,7 @@ public RazerMouseUpdateQueue(IDeviceUpdateTrigger updateTrigger) #region Methods /// - protected override nint CreateEffectParams(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override nint CreateEffectParams(ReadOnlySpan<(object key, Color color)> dataSet) { _Color[] colors = new _Color[_Defines.MOUSE_MAX_LEDS]; diff --git a/RGB.NET.Devices.Razer/Mousepad/RazerMousepadUpdateQueue.cs b/RGB.NET.Devices.Razer/Mousepad/RazerMousepadUpdateQueue.cs index 8f510e43..3b694878 100644 --- a/RGB.NET.Devices.Razer/Mousepad/RazerMousepadUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/Mousepad/RazerMousepadUpdateQueue.cs @@ -25,7 +25,7 @@ public RazerMousepadUpdateQueue(IDeviceUpdateTrigger updateTrigger) #region Methods /// - protected override nint CreateEffectParams(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override nint CreateEffectParams(ReadOnlySpan<(object key, Color color)> dataSet) { _Color[] colors = new _Color[_Defines.MOUSEPAD_MAX_LEDS]; diff --git a/RGB.NET.Devices.Razer/Native/_RazerSDK.cs b/RGB.NET.Devices.Razer/Native/_RazerSDK.cs index 4b99cc66..e7f71964 100644 --- a/RGB.NET.Devices.Razer/Native/_RazerSDK.cs +++ b/RGB.NET.Devices.Razer/Native/_RazerSDK.cs @@ -64,7 +64,7 @@ private static IEnumerable GetPossibleLibraryPaths() if (OperatingSystem.IsWindows()) possibleLibraryPaths = Environment.Is64BitProcess ? RazerDeviceProvider.PossibleX64NativePaths : RazerDeviceProvider.PossibleX86NativePaths; else - possibleLibraryPaths = Enumerable.Empty(); + possibleLibraryPaths = []; return possibleLibraryPaths.Select(Environment.ExpandEnvironmentVariables); } diff --git a/RGB.NET.Devices.Razer/RGB.NET.Devices.Razer.csproj b/RGB.NET.Devices.Razer/RGB.NET.Devices.Razer.csproj index 36323999..bf464624 100644 --- a/RGB.NET.Devices.Razer/RGB.NET.Devices.Razer.csproj +++ b/RGB.NET.Devices.Razer/RGB.NET.Devices.Razer.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net9.0;net8.0 latest enable @@ -52,6 +52,10 @@ RELEASE + + + + diff --git a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs index 047705d7..e7e3d87b 100644 --- a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs +++ b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; using RGB.NET.Core; using RGB.NET.Devices.Razer.Native; using RGB.NET.HID; @@ -20,7 +21,7 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider #region Properties & Fields // ReSharper disable once InconsistentNaming - private static readonly object _lock = new(); + private static readonly Lock _lock = new(); private static RazerDeviceProvider? _instance; /// @@ -139,9 +140,10 @@ public static RazerDeviceProvider Instance { 0x028B, RGBDeviceType.Keyboard, "Blade 17 (2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x028C, RGBDeviceType.Keyboard, "Blade 14 (2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x029F, RGBDeviceType.Keyboard, "Blade 16 (2023)", LedMappings.Blade, RazerEndpointType.Keyboard }, - { 0x028D, RGBDeviceType.Keyboard, "BlackWidow V4", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x028D, RGBDeviceType.Keyboard, "BlackWidow V4 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x0290, RGBDeviceType.Keyboard, "DeathStalker V2 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wireless { 0x0292, RGBDeviceType.Keyboard, "DeathStalker V2 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wired + { 0x0293, RGBDeviceType.Keyboard, "BlackWidow V4 X", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x0294, RGBDeviceType.Keyboard, "Ornata V3 X", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x0295, RGBDeviceType.Keyboard, "DeathStalker V2", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x0296, RGBDeviceType.Keyboard, "DeathStalker V2 Pro TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wireless @@ -149,7 +151,9 @@ public static RazerDeviceProvider Instance { 0x02A0, RGBDeviceType.Keyboard, "Blade 18", LedMappings.Blade, RazerEndpointType.Keyboard }, { 0x02A1, RGBDeviceType.Keyboard, "Ornata V3", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x02A5, RGBDeviceType.Keyboard, "BlackWidow V4 75%", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x02A7, RGBDeviceType.Keyboard, "Huntsman V3 Pro TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x0A24, RGBDeviceType.Keyboard, "BlackWidow V3 TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x02BA, RGBDeviceType.Keyboard, "BlackWidow V4 Mini HyperSpeed", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Mice { 0x0013, RGBDeviceType.Mouse, "Orochi 2011", LedMappings.Mouse, RazerEndpointType.Mouse }, @@ -223,6 +227,7 @@ public static RazerDeviceProvider Instance { 0x009A, RGBDeviceType.Mouse, "Pro Click Mini (Wireless)", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x009C, RGBDeviceType.Mouse, "DeathAdder V2 X Hyperspeed", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x00A1, RGBDeviceType.Mouse, "DeathAdder V2 Lite", LedMappings.Mouse, RazerEndpointType.Mouse }, + { 0x00A3, RGBDeviceType.Mouse, "Cobra", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x00A5, RGBDeviceType.Mouse, "Viper V2 Pro (Wired)", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x00A6, RGBDeviceType.Mouse, "Viper V2 Pro (Wireless)", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x00A7, RGBDeviceType.Mouse, "Naga V2 Pro", LedMappings.Mouse, RazerEndpointType.Mouse }, @@ -238,6 +243,7 @@ public static RazerDeviceProvider Instance { 0x0C01, RGBDeviceType.Mousepad, "Goliathus", LedMappings.Mousepad, RazerEndpointType.ChromaLink }, { 0x0C02, RGBDeviceType.Mousepad, "Goliathus Extended", LedMappings.Mousepad, RazerEndpointType.ChromaLink }, { 0x0C04, RGBDeviceType.Mousepad, "Firefly v2", LedMappings.Mousepad, RazerEndpointType.Mousepad }, + { 0x0C08, RGBDeviceType.Mousepad, "Firefly v2 Pro", LedMappings.Mousepad, RazerEndpointType.Mousepad }, // Headsets { 0x0501, RGBDeviceType.Headset, "Kraken 7.1", LedMappings.Headset, RazerEndpointType.Headset }, @@ -267,12 +273,13 @@ public static RazerDeviceProvider Instance { 0x00A4, RGBDeviceType.LedStripe, "Mouse Dock Pro", LedMappings.Mousepad, RazerEndpointType.Mousepad }, // DarthAffe 22.09.2023: Most likely also a mousepad? { 0x0517, RGBDeviceType.Speaker, "Nommo Chroma", LedMappings.ChromaLink, RazerEndpointType.ChromaLink }, { 0x0518, RGBDeviceType.Speaker, "Nommo Pro", LedMappings.ChromaLink, RazerEndpointType.ChromaLink }, + { 0x054A, RGBDeviceType.Speaker, "Leviathan V2 X", LedMappings.ChromaLink, RazerEndpointType.ChromaLink }, { 0x0F07, RGBDeviceType.Unknown, "Chroma Mug Holder", LedMappings.ChromaLink, RazerEndpointType.ChromaLink }, { 0x0F09, RGBDeviceType.LedController, "Chroma Hardware Development Kit (HDK)", LedMappings.ChromaLink, RazerEndpointType.ChromaLink }, { 0x0F13, RGBDeviceType.Unknown, "Lian Li O11", LedMappings.ChromaLink, RazerEndpointType.ChromaLink }, { 0x0F1D, RGBDeviceType.Unknown, "Mouse Bungee V3 Chroma", LedMappings.ChromaLink, RazerEndpointType.ChromaLink }, { 0x0F1F, RGBDeviceType.LedController, "Addressable RGB Controller", LedMappings.ChromaLink, RazerEndpointType.ChromaLink }, - + { 0x0F2C, RGBDeviceType.LedController, "Chroma Wireless ARGB Controller", LedMappings.ChromaLink, RazerEndpointType.ChromaLink }, }; #endregion diff --git a/RGB.NET.Devices.SteelSeries/Generic/LedMappings.cs b/RGB.NET.Devices.SteelSeries/Generic/LedMappings.cs index 59310bda..5f637fa2 100644 --- a/RGB.NET.Devices.SteelSeries/Generic/LedMappings.cs +++ b/RGB.NET.Devices.SteelSeries/Generic/LedMappings.cs @@ -480,7 +480,7 @@ public static class LedMappings { LedId.Mouse9, SteelSeriesLedId.ZoneNine }, { LedId.Mouse10, SteelSeriesLedId.ZoneTen } }; - + /// /// Gets the mapping for two-zone headsets. /// @@ -627,4 +627,32 @@ public static class LedMappings { LedId.LedStripe102, SteelSeriesLedId.ZoneOneHundredTwo }, { LedId.LedStripe103, SteelSeriesLedId.ZoneOneHundredThree } }; + + /// + /// Gets the mapping for 10-zone kayboard. + /// + public static LedMapping KeyboardTenZone { get; } = new() + { + { LedId.Keyboard_Custom1, SteelSeriesLedId.ZoneOne }, + { LedId.Keyboard_Custom2, SteelSeriesLedId.ZoneTwo }, + { LedId.Keyboard_Custom3, SteelSeriesLedId.ZoneThree }, + { LedId.Keyboard_Custom4, SteelSeriesLedId.ZoneFour }, + { LedId.Keyboard_Custom5, SteelSeriesLedId.ZoneFive }, + { LedId.Keyboard_Custom6, SteelSeriesLedId.ZoneSix }, + { LedId.Keyboard_Custom7, SteelSeriesLedId.ZoneSeven }, + { LedId.Keyboard_Custom8, SteelSeriesLedId.ZoneEight }, + { LedId.Keyboard_Custom9, SteelSeriesLedId.ZoneNine }, + { LedId.Keyboard_Custom10, SteelSeriesLedId.ZoneTen } + }; + + /// + /// Gets the mapping for 4-zone speakers. + /// + public static LedMapping SpeakerFourZone { get; } = new() + { + { LedId.Speaker1, SteelSeriesLedId.ZoneOne }, + { LedId.Speaker2, SteelSeriesLedId.ZoneTwo }, + { LedId.Speaker3, SteelSeriesLedId.ZoneThree }, + { LedId.Speaker4, SteelSeriesLedId.ZoneFour }, + }; } \ No newline at end of file diff --git a/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesDeviceUpdateQueue.cs b/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesDeviceUpdateQueue.cs index c85f3946..815e223d 100644 --- a/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesDeviceUpdateQueue.cs +++ b/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesDeviceUpdateQueue.cs @@ -51,7 +51,7 @@ protected override void OnUpdate(object? sender, CustomUpdateData customData) } /// - protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet) { try { diff --git a/RGB.NET.Devices.SteelSeries/RGB.NET.Devices.SteelSeries.csproj b/RGB.NET.Devices.SteelSeries/RGB.NET.Devices.SteelSeries.csproj index 76525ce4..fd5b2811 100644 --- a/RGB.NET.Devices.SteelSeries/RGB.NET.Devices.SteelSeries.csproj +++ b/RGB.NET.Devices.SteelSeries/RGB.NET.Devices.SteelSeries.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net9.0;net8.0 latest enable @@ -51,6 +51,10 @@ RELEASE + + + + diff --git a/RGB.NET.Devices.SteelSeries/SteelSeriesDeviceProvider.cs b/RGB.NET.Devices.SteelSeries/SteelSeriesDeviceProvider.cs index 4f5a399c..57485114 100644 --- a/RGB.NET.Devices.SteelSeries/SteelSeriesDeviceProvider.cs +++ b/RGB.NET.Devices.SteelSeries/SteelSeriesDeviceProvider.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading; using RGB.NET.Core; using RGB.NET.Devices.SteelSeries.API; using RGB.NET.HID; @@ -21,7 +22,7 @@ public sealed class SteelSeriesDeviceProvider : AbstractRGBDeviceProvider #region Properties & Fields // ReSharper disable once InconsistentNaming - private static readonly object _lock = new(); + private static readonly Lock _lock = new(); private static SteelSeriesDeviceProvider? _instance; /// @@ -46,6 +47,7 @@ public static SteelSeriesDeviceProvider Instance //Mice { 0x1836, RGBDeviceType.Mouse, "Aerox 3", LedMappings.MouseThreeZone, SteelSeriesDeviceType.ThreeZone }, { 0x183A, RGBDeviceType.Mouse, "Aerox 3 Wireless", LedMappings.MouseThreeZone, SteelSeriesDeviceType.ThreeZone }, + { 0x1858, RGBDeviceType.Mouse, "Aerox 9 Wireless", LedMappings.MouseThreeZone, SteelSeriesDeviceType.ThreeZone }, { 0x1702, RGBDeviceType.Mouse, "Rival 100", LedMappings.MouseOneZone, SteelSeriesDeviceType.OneZone }, { 0x1814, RGBDeviceType.Mouse, "Rival 105", LedMappings.MouseOneZone, SteelSeriesDeviceType.OneZone }, { 0x1816, RGBDeviceType.Mouse, "Rival 106", LedMappings.MouseOneZone, SteelSeriesDeviceType.OneZone }, @@ -69,6 +71,7 @@ public static SteelSeriesDeviceProvider Instance { 0x1852, RGBDeviceType.Mouse, "Aerox 5 Wireless", LedMappings.MouseThreeZone, SteelSeriesDeviceType.ThreeZone }, //Keyboards + { 0x161A, RGBDeviceType.Keyboard, "Apex 3", LedMappings.KeyboardTenZone, SteelSeriesDeviceType.TenZone }, { 0x161C, RGBDeviceType.Keyboard, "Apex 5", LedMappings.KeyboardMappingUk, SteelSeriesDeviceType.PerKey }, { 0x1612, RGBDeviceType.Keyboard, "Apex 7", LedMappings.KeyboardMappingUk, SteelSeriesDeviceType.PerKey }, { 0x1618, RGBDeviceType.Keyboard, "Apex 7 TKL", LedMappings.KeyboardTklMappingUk, SteelSeriesDeviceType.PerKey }, @@ -76,9 +79,12 @@ public static SteelSeriesDeviceProvider Instance { 0x1600, RGBDeviceType.Keyboard, "Apex M800", LedMappings.KeyboardMappingUk, SteelSeriesDeviceType.PerKey }, { 0x1610, RGBDeviceType.Keyboard, "Apex Pro", LedMappings.KeyboardMappingUk, SteelSeriesDeviceType.PerKey }, { 0x1614, RGBDeviceType.Keyboard, "Apex Pro TKL", LedMappings.KeyboardTklMappingUk, SteelSeriesDeviceType.PerKey }, + { 0x1644, RGBDeviceType.Keyboard, "Apex Pro TKL Wireless Gen3", LedMappings.KeyboardTklMappingUk, SteelSeriesDeviceType.PerKey }, + { 0x1630, RGBDeviceType.Keyboard, "Apex Pro TKL", LedMappings.KeyboardTklMappingUk, SteelSeriesDeviceType.PerKey }, // DarthAffe 27.05.2024: This could be a generic wireless connector + { 0x1640, RGBDeviceType.Keyboard, "Apex Pro 3", LedMappings.KeyboardMappingUk, SteelSeriesDeviceType.PerKey }, { 0x2036, RGBDeviceType.Keyboard, "MSI Notebook", LedMappings.KeyboardNotebookMappingUk, SteelSeriesDeviceType.PerKey }, { 0x113A, RGBDeviceType.Keyboard, "MSI GE78HX", LedMappings.KeyboardMSIGE78Mapping, SteelSeriesDeviceType.PerKey }, - { 0x1122, RGBDeviceType.Keyboard, "MSI Notebook", LedMappings.KeyboardNotebookMappingUk, SteelSeriesDeviceType.PerKey }, + { 0x1122, RGBDeviceType.Keyboard, "MSI Notebook", LedMappings.KeyboardNotebookMappingUk, SteelSeriesDeviceType.PerKey }, //Headsets { 0x12AA, RGBDeviceType.Headset, "Arctis 5", LedMappings.HeadsetTwoZone, SteelSeriesDeviceType.TwoZone }, @@ -93,6 +99,9 @@ public static SteelSeriesDeviceProvider Instance //Monitors { 0x1126, RGBDeviceType.Monitor, "MGP27C", LedMappings.MonitorOnehundredandthreeZone, SteelSeriesDeviceType.OneHundredAndThreeZone }, + + //Speaker + { 0x1A05, RGBDeviceType.Speaker, "Arena 9", LedMappings.SpeakerFourZone, SteelSeriesDeviceType.FourZone }, }; #endregion diff --git a/RGB.NET.Devices.WLED/Generic/WLedDeviceUpdateQueue.cs b/RGB.NET.Devices.WLED/Generic/WLedDeviceUpdateQueue.cs index d16834b5..7ebeef73 100644 --- a/RGB.NET.Devices.WLED/Generic/WLedDeviceUpdateQueue.cs +++ b/RGB.NET.Devices.WLED/Generic/WLedDeviceUpdateQueue.cs @@ -63,7 +63,7 @@ protected override void OnUpdate(object? sender, CustomUpdateData customData) } /// - protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet) { try { diff --git a/RGB.NET.Devices.WLED/RGB.NET.Devices.WLED.csproj b/RGB.NET.Devices.WLED/RGB.NET.Devices.WLED.csproj index 84ceafa6..65bd108e 100644 --- a/RGB.NET.Devices.WLED/RGB.NET.Devices.WLED.csproj +++ b/RGB.NET.Devices.WLED/RGB.NET.Devices.WLED.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net9.0;net8.0 latest enable @@ -51,6 +51,10 @@ RELEASE + + + + diff --git a/RGB.NET.Devices.WLED/WLedDeviceProvider.cs b/RGB.NET.Devices.WLED/WLedDeviceProvider.cs index 978565e7..e49b5e86 100644 --- a/RGB.NET.Devices.WLED/WLedDeviceProvider.cs +++ b/RGB.NET.Devices.WLED/WLedDeviceProvider.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; +using System.Threading; using RGB.NET.Core; namespace RGB.NET.Devices.WLED; @@ -23,7 +24,7 @@ public sealed class WledDeviceProvider : AbstractRGBDeviceProvider #region Properties & Fields // ReSharper disable once InconsistentNaming - private static readonly object _lock = new(); + private static readonly Lock _lock = new(); private static WledDeviceProvider? _instance; /// diff --git a/RGB.NET.Devices.WS281X/Generic/SerialPortUpdateQueue.cs b/RGB.NET.Devices.WS281X/Generic/SerialPortUpdateQueue.cs index f1aa16c8..699218d0 100644 --- a/RGB.NET.Devices.WS281X/Generic/SerialPortUpdateQueue.cs +++ b/RGB.NET.Devices.WS281X/Generic/SerialPortUpdateQueue.cs @@ -56,7 +56,7 @@ protected override void OnStartup(object? sender, CustomUpdateData customData) } /// - protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet) { try { diff --git a/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBUpdateQueue.cs b/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBUpdateQueue.cs index 38a51f1a..442c5b38 100644 --- a/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBUpdateQueue.cs +++ b/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBUpdateQueue.cs @@ -77,7 +77,7 @@ protected override void OnStartup(object? sender, CustomUpdateData customData) } /// - protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet) { try { diff --git a/RGB.NET.Devices.WS281X/RGB.NET.Devices.WS281X.csproj b/RGB.NET.Devices.WS281X/RGB.NET.Devices.WS281X.csproj index 39f4d520..f7a0dfd4 100644 --- a/RGB.NET.Devices.WS281X/RGB.NET.Devices.WS281X.csproj +++ b/RGB.NET.Devices.WS281X/RGB.NET.Devices.WS281X.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net9.0;net8.0 latest enable @@ -51,13 +51,17 @@ RELEASE + + + + - + diff --git a/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs b/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs index 109877a2..de7e6ee6 100644 --- a/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs +++ b/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; +using System.Threading; using RGB.NET.Core; namespace RGB.NET.Devices.WS281X; @@ -17,7 +18,7 @@ public sealed class WS281XDeviceProvider : AbstractRGBDeviceProvider #region Properties & Fields // ReSharper disable once InconsistentNaming - private static readonly object _lock = new(); + private static readonly Lock _lock = new(); private static WS281XDeviceProvider? _instance; /// diff --git a/RGB.NET.Devices.Wooting/Enum/WootingDeviceType.cs b/RGB.NET.Devices.Wooting/Enum/WootingDeviceType.cs index 63ff83a4..af2d4a37 100644 --- a/RGB.NET.Devices.Wooting/Enum/WootingDeviceType.cs +++ b/RGB.NET.Devices.Wooting/Enum/WootingDeviceType.cs @@ -26,4 +26,9 @@ public enum WootingDeviceType /// Three key keypad. E.g. Wooting Uwu /// Keypad3Keys = 4, + + /// + /// 80 percent keyboard. E.g. Wooting 80HE + /// + KeyboardEightyPercent = 5, } \ No newline at end of file diff --git a/RGB.NET.Devices.Wooting/Generic/WootingLedMappings.cs b/RGB.NET.Devices.Wooting/Generic/WootingLedMappings.cs index 081e9934..1ed07906 100644 --- a/RGB.NET.Devices.Wooting/Generic/WootingLedMappings.cs +++ b/RGB.NET.Devices.Wooting/Generic/WootingLedMappings.cs @@ -110,6 +110,105 @@ internal static class WootingLedMappings { LedId.Keyboard_ArrowDown, (5, 15) }, { LedId.Keyboard_ArrowRight, (5, 16) } }; + + private static readonly Dictionary EightyPercent = new() + { + { LedId.Keyboard_Escape, (0, 0) }, + { LedId.Keyboard_F1, (0, 1) }, + { LedId.Keyboard_F2, (0, 2) }, + { LedId.Keyboard_F3, (0, 3) }, + { LedId.Keyboard_F4, (0, 4) }, + { LedId.Keyboard_F5, (0, 5) }, + { LedId.Keyboard_F6, (0, 6) }, + { LedId.Keyboard_F7, (0, 7) }, + { LedId.Keyboard_F8, (0, 8) }, + { LedId.Keyboard_F9, (0, 10) }, + { LedId.Keyboard_F10, (0, 11) }, + { LedId.Keyboard_F11, (0, 12) }, + { LedId.Keyboard_F12, (0, 13) }, + { LedId.Keyboard_Custom1, (0, 14) }, + { LedId.Keyboard_PrintScreen, (0, 15) }, + { LedId.Keyboard_PauseBreak, (0, 16) }, + + { LedId.Keyboard_GraveAccentAndTilde, (1, 0) }, + { LedId.Keyboard_1, (1, 1) }, + { LedId.Keyboard_2, (1, 2) }, + { LedId.Keyboard_3, (1, 3) }, + { LedId.Keyboard_4, (1, 4) }, + { LedId.Keyboard_5, (1, 5) }, + { LedId.Keyboard_6, (1, 6) }, + { LedId.Keyboard_7, (1, 7) }, + { LedId.Keyboard_8, (1, 8) }, + { LedId.Keyboard_9, (1, 9) }, + { LedId.Keyboard_0, (1, 10) }, + { LedId.Keyboard_MinusAndUnderscore, (1, 11) }, + { LedId.Keyboard_EqualsAndPlus, (1, 12) }, + { LedId.Keyboard_International1, (1, 13) },//JIS key + { LedId.Keyboard_Backspace, (1, 14) }, + { LedId.Keyboard_Insert, (1, 15) }, + { LedId.Keyboard_Home, (1, 16) }, + + { LedId.Keyboard_Tab, (2, 0) }, + { LedId.Keyboard_Q, (2, 1) }, + { LedId.Keyboard_W, (2, 2) }, + { LedId.Keyboard_E, (2, 3) }, + { LedId.Keyboard_R, (2, 4) }, + { LedId.Keyboard_T, (2, 5) }, + { LedId.Keyboard_Y, (2, 6) }, + { LedId.Keyboard_U, (2, 7) }, + { LedId.Keyboard_I, (2, 8) }, + { LedId.Keyboard_O, (2, 9) }, + { LedId.Keyboard_P, (2, 10) }, + { LedId.Keyboard_BracketLeft, (2, 11) }, + { LedId.Keyboard_BracketRight, (2, 12) }, + { LedId.Keyboard_Backslash, (2, 14) }, + { LedId.Keyboard_Delete, (2, 15) }, + { LedId.Keyboard_End, (2, 16) }, + + { LedId.Keyboard_CapsLock, (3, 0) }, + { LedId.Keyboard_A, (3, 1) }, + { LedId.Keyboard_S, (3, 2) }, + { LedId.Keyboard_D, (3, 3) }, + { LedId.Keyboard_F, (3, 4) }, + { LedId.Keyboard_G, (3, 5) }, + { LedId.Keyboard_H, (3, 6) }, + { LedId.Keyboard_J, (3, 7) }, + { LedId.Keyboard_K, (3, 8) }, + { LedId.Keyboard_L, (3, 9) }, + { LedId.Keyboard_SemicolonAndColon, (3, 10) }, + { LedId.Keyboard_ApostropheAndDoubleQuote, (3, 11) }, + { LedId.Keyboard_NonUsTilde, (3, 12) }, + { LedId.Keyboard_Enter, (3, 14) }, + + { LedId.Keyboard_LeftShift, (4, 0) }, + { LedId.Keyboard_NonUsBackslash, (4, 1) }, + { LedId.Keyboard_Z, (4, 2) }, + { LedId.Keyboard_X, (4, 3) }, + { LedId.Keyboard_C, (4, 4) }, + { LedId.Keyboard_V, (4, 5) }, + { LedId.Keyboard_B, (4, 6) }, + { LedId.Keyboard_N, (4, 7) }, + { LedId.Keyboard_M, (4, 8) }, + { LedId.Keyboard_CommaAndLessThan, (4, 9) }, + { LedId.Keyboard_PeriodAndBiggerThan, (4, 10) }, + { LedId.Keyboard_SlashAndQuestionMark, (4, 11) }, + { LedId.Keyboard_International2, (4, 13) },//JIS key + { LedId.Keyboard_RightShift, (4, 14) }, + { LedId.Keyboard_ArrowUp, (4, 15) }, + + { LedId.Keyboard_LeftCtrl, (5, 0) }, + { LedId.Keyboard_LeftGui, (5, 1) }, + { LedId.Keyboard_LeftAlt, (5, 2) }, + { LedId.Keyboard_International3, (5, 3) },//JIS key + { LedId.Keyboard_Space, (5, 6) }, + { LedId.Keyboard_International4, (5, 9) },//JIS key + { LedId.Keyboard_RightAlt, (5, 10) }, + { LedId.Keyboard_RightGui, (5, 11) }, + { LedId.Keyboard_Function, (5, 12) }, + { LedId.Keyboard_ArrowLeft, (5, 14) }, + { LedId.Keyboard_ArrowDown, (5, 15) }, + { LedId.Keyboard_ArrowRight, (5, 16) } + }; private static readonly Dictionary Fullsize = new() { @@ -343,7 +442,8 @@ internal static class WootingLedMappings [WootingDeviceType.Keyboard] = Fullsize, [WootingDeviceType.KeyboardTKL] = TKL, [WootingDeviceType.KeyboardSixtyPercent] = SixtyPercent, - [WootingDeviceType.Keypad3Keys] = ThreeKeyKeypad + [WootingDeviceType.Keypad3Keys] = ThreeKeyKeypad, + [WootingDeviceType.KeyboardEightyPercent] = EightyPercent }; #endregion diff --git a/RGB.NET.Devices.Wooting/Generic/WootingUpdateQueue.cs b/RGB.NET.Devices.Wooting/Generic/WootingUpdateQueue.cs index 8a3012eb..be942cf6 100644 --- a/RGB.NET.Devices.Wooting/Generic/WootingUpdateQueue.cs +++ b/RGB.NET.Devices.Wooting/Generic/WootingUpdateQueue.cs @@ -33,7 +33,7 @@ public WootingUpdateQueue(IDeviceUpdateTrigger updateTrigger, byte deviceId) #region Methods /// - protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet) { try { diff --git a/RGB.NET.Devices.Wooting/Native/_WootingSDK.cs b/RGB.NET.Devices.Wooting/Native/_WootingSDK.cs index cc0018c1..0d4f7bbb 100644 --- a/RGB.NET.Devices.Wooting/Native/_WootingSDK.cs +++ b/RGB.NET.Devices.Wooting/Native/_WootingSDK.cs @@ -64,7 +64,7 @@ private static IEnumerable GetPossibleLibraryPaths() else if (OperatingSystem.IsMacOS()) possibleLibraryPaths = WootingDeviceProvider.PossibleNativePathsMacOS; else - possibleLibraryPaths = Enumerable.Empty(); + possibleLibraryPaths = []; return possibleLibraryPaths.Select(Environment.ExpandEnvironmentVariables); } diff --git a/RGB.NET.Devices.Wooting/RGB.NET.Devices.Wooting.csproj b/RGB.NET.Devices.Wooting/RGB.NET.Devices.Wooting.csproj index 37d84ab0..778d0b96 100644 --- a/RGB.NET.Devices.Wooting/RGB.NET.Devices.Wooting.csproj +++ b/RGB.NET.Devices.Wooting/RGB.NET.Devices.Wooting.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net9.0;net8.0 latest enable @@ -52,6 +52,10 @@ RELEASE + + + + diff --git a/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs b/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs index 8b36ff75..cb58d185 100644 --- a/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs +++ b/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Runtime.InteropServices; +using System.Threading; using RGB.NET.Core; using RGB.NET.Devices.Wooting.Enum; using RGB.NET.Devices.Wooting.Generic; @@ -19,7 +20,7 @@ public sealed class WootingDeviceProvider : AbstractRGBDeviceProvider #region Properties & Fields // ReSharper disable once InconsistentNaming - private static readonly object _lock = new(); + private static readonly Lock _lock = new(); private static WootingDeviceProvider? _instance; /// diff --git a/RGB.NET.HID/RGB.NET.HID.csproj b/RGB.NET.HID/RGB.NET.HID.csproj index 58b5b0f4..22196cea 100644 --- a/RGB.NET.HID/RGB.NET.HID.csproj +++ b/RGB.NET.HID/RGB.NET.HID.csproj @@ -1,6 +1,6 @@ - net8.0;net7.0;net6.0 + net9.0;net8.0 latest enable @@ -51,6 +51,10 @@ RELEASE + + + + diff --git a/RGB.NET.Layout/RGB.NET.Layout.csproj b/RGB.NET.Layout/RGB.NET.Layout.csproj index 473f4214..163c2045 100644 --- a/RGB.NET.Layout/RGB.NET.Layout.csproj +++ b/RGB.NET.Layout/RGB.NET.Layout.csproj @@ -1,6 +1,6 @@ - net8.0;net7.0;net6.0 + net9.0;net8.0 latest enable @@ -51,6 +51,10 @@ RELEASE + + + + diff --git a/RGB.NET.Presets/Decorators/FlashDecorator.cs b/RGB.NET.Presets/Decorators/FlashDecorator.cs index e30a5f28..ab70266d 100644 --- a/RGB.NET.Presets/Decorators/FlashDecorator.cs +++ b/RGB.NET.Presets/Decorators/FlashDecorator.cs @@ -90,7 +90,7 @@ public FlashDecorator(RGBSurface surface, bool updateIfDisabled = false) #region Methods /// - public void ManipulateColor(in Rectangle rectangle, in RenderTarget renderTarget, ref Color color) => color = color.SetA(_currentValue); + public void ManipulateColor(Rectangle rectangle, RenderTarget renderTarget, ref Color color) => color = color.SetA(_currentValue); /// protected override void Update(double deltaTime) diff --git a/RGB.NET.Presets/Extensions/HPPHExtensions.cs b/RGB.NET.Presets/Extensions/HPPHExtensions.cs new file mode 100644 index 00000000..e0b37dee --- /dev/null +++ b/RGB.NET.Presets/Extensions/HPPHExtensions.cs @@ -0,0 +1,27 @@ +using HPPH; +using RGB.NET.Core; + +namespace RGB.NET.Presets.Extensions; + +/// +/// Offers some extensions related to HPPH. +/// +public static class HPPHExtensions +{ + /// + /// Converts the given HPPH to a RGB.NET . + /// + /// The color to convert. + /// The converted color. + public static Color ToColor(this IColor color) => new(color.A, color.R, color.G, color.B); + + /// + /// Converts the given HPPH to a RGB.NET . + /// + /// The color to convert. + /// The color-type of the HPPH color. + /// The converted color. + public static Color ToColor(this T color) + where T : struct, IColor + => new(color.A, color.R, color.G, color.B); +} \ No newline at end of file diff --git a/RGB.NET.Presets/Helper/GradientHelper.cs b/RGB.NET.Presets/Helper/GradientHelper.cs index 2f6d68d9..86459790 100644 --- a/RGB.NET.Presets/Helper/GradientHelper.cs +++ b/RGB.NET.Presets/Helper/GradientHelper.cs @@ -20,7 +20,7 @@ public static class GradientHelper /// The end of the gradient. /// The on the gradient to which the offset is calculated. /// The offset of the on the gradient. - public static float CalculateLinearGradientOffset(in Point startPoint, in Point endPoint, in Point point) + public static float CalculateLinearGradientOffset(Point startPoint, Point endPoint, Point point) { Point intersectingPoint; if (startPoint.Y.EqualsInTolerance(endPoint.Y)) // Horizontal case @@ -57,7 +57,7 @@ public static float CalculateLinearGradientOffset(in Point startPoint, in Point /// The origin of the vector. /// The direction of the vector. /// The signed magnitude of a on a vector. - public static float CalculateDistance(in Point point, in Point origin, in Point direction) + public static float CalculateDistance(Point point, Point origin, Point direction) { float distance = CalculateDistance(point, origin); @@ -74,7 +74,7 @@ public static float CalculateDistance(in Point point, in Point origin, in Point /// The first . /// The second . /// The distance between the two . - public static float CalculateDistance(in Point point1, in Point point2) + public static float CalculateDistance(Point point1, Point point2) { float x = point1.X - point2.X; float y = point1.Y - point2.Y; diff --git a/RGB.NET.Presets/RGB.NET.Presets.csproj b/RGB.NET.Presets/RGB.NET.Presets.csproj index c7b6129e..04ecdb68 100644 --- a/RGB.NET.Presets/RGB.NET.Presets.csproj +++ b/RGB.NET.Presets/RGB.NET.Presets.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net9.0;net8.0 latest enable @@ -52,11 +52,19 @@ RELEASE + + + + + + + + diff --git a/RGB.NET.Presets/Textures/AbstractGradientTexture.cs b/RGB.NET.Presets/Textures/AbstractGradientTexture.cs index 3f2f73c2..e4b6b888 100644 --- a/RGB.NET.Presets/Textures/AbstractGradientTexture.cs +++ b/RGB.NET.Presets/Textures/AbstractGradientTexture.cs @@ -21,10 +21,10 @@ public abstract class AbstractGradientTexture : AbstractBindable, ITexture public Size Size { get; } /// - public Color this[in Point point] => GetColor(point); + public Color this[Point point] => GetColor(point); /// - public Color this[in Rectangle rectangle] => GetColor(rectangle.Center); + public Color this[Rectangle rectangle] => GetColor(rectangle.Center); #endregion @@ -50,7 +50,7 @@ protected AbstractGradientTexture(Size size, IGradient gradient) /// /// The location to get the color from. /// The color at the specified location. - protected abstract Color GetColor(in Point point); + protected abstract Color GetColor(Point point); #endregion } \ No newline at end of file diff --git a/RGB.NET.Presets/Textures/BytePixelTexture.cs b/RGB.NET.Presets/Textures/BytePixelTexture.cs index 103b2ae9..176b54fa 100644 --- a/RGB.NET.Presets/Textures/BytePixelTexture.cs +++ b/RGB.NET.Presets/Textures/BytePixelTexture.cs @@ -61,7 +61,7 @@ public BytePixelTexture(int with, int height, byte[] data, ISampler sample /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - protected override Color GetColor(in ReadOnlySpan pixel) + protected override Color GetColor(ReadOnlySpan pixel) { return ColorFormat switch { diff --git a/RGB.NET.Presets/Textures/ConicalGradientTexture.cs b/RGB.NET.Presets/Textures/ConicalGradientTexture.cs index c60d9e4e..b9110e43 100644 --- a/RGB.NET.Presets/Textures/ConicalGradientTexture.cs +++ b/RGB.NET.Presets/Textures/ConicalGradientTexture.cs @@ -88,7 +88,7 @@ public ConicalGradientTexture(Size size, IGradient gradient, Point center, float #region Methods /// - protected override Color GetColor(in Point point) + protected override Color GetColor(Point point) { float angle = MathF.Atan2(point.Y - Center.Y, point.X - Center.X) - Origin; if (angle < 0) angle += PI2; diff --git a/RGB.NET.Presets/Textures/FloatPixelTexture.cs b/RGB.NET.Presets/Textures/FloatPixelTexture.cs index f60b1778..4657ec3f 100644 --- a/RGB.NET.Presets/Textures/FloatPixelTexture.cs +++ b/RGB.NET.Presets/Textures/FloatPixelTexture.cs @@ -61,7 +61,7 @@ public FloatPixelTexture(int with, int height, float[] data, ISampler sam /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - protected override Color GetColor(in ReadOnlySpan pixel) + protected override Color GetColor(ReadOnlySpan pixel) { return ColorFormat switch { diff --git a/RGB.NET.Presets/Textures/ImageTexture.cs b/RGB.NET.Presets/Textures/ImageTexture.cs new file mode 100644 index 00000000..e63793a9 --- /dev/null +++ b/RGB.NET.Presets/Textures/ImageTexture.cs @@ -0,0 +1,91 @@ +using System; +using HPPH; +using RGB.NET.Core; +using RGB.NET.Presets.Extensions; + +namespace RGB.NET.Presets.Textures; + +/// +/// +/// Represents a texture drawing an . +/// +public sealed class ImageTexture : ITexture +{ + #region Properties & Fields + + private IImage _image; + + /// + /// The image drawn by this texture. + /// + public IImage Image + { + get => _image; + set + { + ArgumentNullException.ThrowIfNull(value); + _image = value; + } + } + + /// + public Size Size { get; } + + /// + public Color this[Point point] + { + get + { + int x = (int)MathF.Round((Size.Width - 1) * point.X.Clamp(0, 1)); + int y = (int)MathF.Round((Size.Height - 1) * point.Y.Clamp(0, 1)); + + return Image[x, y].ToColor(); + } + } + + /// + public Color this[Rectangle rectangle] + { + get + { + int x = (int)MathF.Round((Size.Width - 1) * rectangle.Location.X.Clamp(0, 1)); + int y = (int)MathF.Round((Size.Height - 1) * rectangle.Location.Y.Clamp(0, 1)); + int width = (int)MathF.Round(Size.Width * rectangle.Size.Width.Clamp(0, 1)); + int height = (int)MathF.Round(Size.Height * rectangle.Size.Height.Clamp(0, 1)); + + if ((width == 0) && (rectangle.Size.Width > 0)) width = 1; + if ((height == 0) && (rectangle.Size.Height > 0)) height = 1; + + return this[x, y, width, height]; + } + } + + /// + /// 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 Color this[int x, int y, int width, int height] => Image[x, y, width, height].Average().ToColor(); + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// The image represented by the texture. +#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. + public ImageTexture(IImage image) +#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. + { + this.Image = image; + + Size = new Size(image.Width, image.Height); + } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Presets/Textures/LinearGradientTexture.cs b/RGB.NET.Presets/Textures/LinearGradientTexture.cs index c5bc2f75..70db2ac5 100644 --- a/RGB.NET.Presets/Textures/LinearGradientTexture.cs +++ b/RGB.NET.Presets/Textures/LinearGradientTexture.cs @@ -71,7 +71,7 @@ public LinearGradientTexture(Size size, IGradient gradient, Point startPoint, Po #region Methods /// - protected override Color GetColor(in Point point) + protected override Color GetColor(Point point) { float offset = GradientHelper.CalculateLinearGradientOffset(StartPoint, EndPoint, point); return Gradient.GetColor(offset); diff --git a/RGB.NET.Presets/Textures/RadialGradientTexture.cs b/RGB.NET.Presets/Textures/RadialGradientTexture.cs index 3f96dedd..3f299fca 100644 --- a/RGB.NET.Presets/Textures/RadialGradientTexture.cs +++ b/RGB.NET.Presets/Textures/RadialGradientTexture.cs @@ -69,7 +69,7 @@ private void CalculateReferenceDistance() } /// - protected override Color GetColor(in Point point) + protected override Color GetColor(Point point) { float distance = GradientHelper.CalculateDistance(point, Center); float offset = distance / _referenceDistance; diff --git a/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs b/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs index bf5d7c6b..a45fe64b 100644 --- a/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs +++ b/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs @@ -18,7 +18,7 @@ public sealed class AverageByteSampler : ISampler #region Methods /// - public unsafe void Sample(in SamplerInfo info, in Span pixelData) + public unsafe void Sample(SamplerInfo info, Span pixelData) { int count = info.Width * info.Height; if (count == 0) return; diff --git a/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs b/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs index cea8f451..dd1d0a43 100644 --- a/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs +++ b/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs @@ -12,7 +12,7 @@ public sealed class AverageFloatSampler : ISampler #region Methods /// - public unsafe void Sample(in SamplerInfo info, in Span pixelData) + public unsafe void Sample(SamplerInfo info, Span pixelData) { int count = info.Width * info.Height; if (count == 0) return; diff --git a/RGB.NET.sln.DotSettings b/RGB.NET.sln.DotSettings index f0e61dd4..c7ee5e75 100644 --- a/RGB.NET.sln.DotSettings +++ b/RGB.NET.sln.DotSettings @@ -278,6 +278,7 @@ GEZ GSDK HID + HPPH HS HSV IBAN @@ -307,6 +308,11 @@ <Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /> <Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /> <Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /> + <Policy><Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static readonly fields (private)"><ElementKinds><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="AA_BB" /></Policy> + <Policy><Descriptor Staticness="Any" AccessRightKinds="Private" Description="Constant fields (private)"><ElementKinds><Kind Name="CONSTANT_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="AA_BB" /></Policy> + <Policy><Descriptor Staticness="Any" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Constant fields (not private)"><ElementKinds><Kind Name="CONSTANT_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="AA_BB" /></Policy> + <Policy><Descriptor Staticness="Any" AccessRightKinds="Any" Description="Local constants"><ElementKinds><Kind Name="LOCAL_CONSTANT" /></ElementKinds></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="AA_BB" /></Policy> + <Policy><Descriptor Staticness="Static" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Static readonly fields (not private)"><ElementKinds><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="AA_BB" /></Policy> <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> @@ -357,6 +363,7 @@ True True True + True True True True \ No newline at end of file diff --git a/Tests/RGB.NET.Core.Tests/RGB.NET.Core.Tests.csproj b/Tests/RGB.NET.Core.Tests/RGB.NET.Core.Tests.csproj index 7fb09e7c..ef3cd53f 100644 --- a/Tests/RGB.NET.Core.Tests/RGB.NET.Core.Tests.csproj +++ b/Tests/RGB.NET.Core.Tests/RGB.NET.Core.Tests.csproj @@ -1,15 +1,15 @@ - net8.0 + net9.0 false - - - + + + diff --git a/Tests/RGB.NET.Presets.Tests/RGB.NET.Presets.Tests.csproj b/Tests/RGB.NET.Presets.Tests/RGB.NET.Presets.Tests.csproj index ba91ec3c..52aff582 100644 --- a/Tests/RGB.NET.Presets.Tests/RGB.NET.Presets.Tests.csproj +++ b/Tests/RGB.NET.Presets.Tests/RGB.NET.Presets.Tests.csproj @@ -1,15 +1,15 @@ - net8.0 + net9.0 false - - - + + +