mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-12 17:48:31 +00:00
Compare commits
67 Commits
1b9531a86f
...
4e575e8d3d
| Author | SHA1 | Date | |
|---|---|---|---|
| 4e575e8d3d | |||
| f8e4cc6b49 | |||
| aae509b275 | |||
| 5633f82b3b | |||
| 47770c00b8 | |||
| 654a7624cd | |||
| f9fefe4667 | |||
| f40190da01 | |||
| f34033a3fe | |||
| e151b3f194 | |||
| 899fc697e4 | |||
| d97293ec87 | |||
| 12a353574a | |||
|
|
77f55d2eb3 | ||
| 9945a5f7cb | |||
| ed98714439 | |||
| 39da0fd59c | |||
| 1d47894dac | |||
| 197be1f986 | |||
|
|
a2a25bc40a | ||
| 505e5c6d80 | |||
| f8a530e313 | |||
|
|
aa7bfd3976 | ||
| 71f1115c31 | |||
|
|
da51871e04 | ||
| a26eaf9a9a | |||
| 54c09a1d6f | |||
| a0198e3991 | |||
| f2491038a3 | |||
| 5c864a03e5 | |||
|
|
7cfe08921e | ||
|
|
c34435b958 | ||
| 2bf081d16e | |||
| 466d136089 | |||
| 13a5a6162d | |||
|
|
54b4eac1f3 | ||
| 9346948bfb | |||
| 9a997694a5 | |||
| 1396e978db | |||
| 681adcb1cb | |||
| cfbbdc6069 | |||
| 0d41314f7e | |||
| b1cf26b1e6 | |||
| 4c3875e561 | |||
| 3e53b51bac | |||
| fdfd35eff8 | |||
| c39849949a | |||
|
|
d207fdf495 | ||
| 4e80764015 | |||
| 9de1233c93 | |||
|
|
976ee6d007 | ||
|
|
9f0c3be7bb | ||
|
|
5e895f5806 | ||
| 41a1d5d97b | |||
| 6f0711564c | |||
| f21acbd767 | |||
| da2c2a678b | |||
| 5a13fcef7f | |||
| bc7c2374f9 | |||
| ed7ff76210 | |||
| f4cf5c3286 | |||
| 83d1b2472b | |||
|
|
8b1c5927d3 | ||
|
|
1bd5b54892 | ||
|
|
c11965eb3a | ||
|
|
cadf96634e | ||
|
|
5cb5962c1e |
15
.github/workflows/ci.yml
vendored
15
.github/workflows/ci.yml
vendored
@ -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
|
||||
|
||||
3
.github/workflows/pr_verify.yml
vendored
3
.github/workflows/pr_verify.yml
vendored
@ -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
|
||||
|
||||
17
.github/workflows/release.yml
vendored
17
.github/workflows/release.yml
vendored
@ -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
|
||||
|
||||
@ -14,7 +14,7 @@ public sealed class DefaultColorBehavior : IColorBehavior
|
||||
/// Converts the individual byte values of this <see cref="Color"/> to a human-readable string.
|
||||
/// </summary>
|
||||
/// <returns>A string that contains the individual byte values of this <see cref="Color"/>. For example "[A: 255, R: 255, G: 0, B: 0]".</returns>
|
||||
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()}]";
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether the specified object is a <see cref="Color" /> and is equivalent to this <see cref="Color" />.
|
||||
@ -22,7 +22,7 @@ public sealed class DefaultColorBehavior : IColorBehavior
|
||||
/// <param name="color">The color to test.</param>
|
||||
/// <param name="obj">The object to test.</param>
|
||||
/// <returns><c>true</c> if <paramref name="obj" /> is a <see cref="Color" /> equivalent to this <see cref="Color" />; otherwise, <c>false</c>.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether the specified object is a <see cref="Color" /> and is equivalent to this <see cref="Color" />.
|
||||
@ -30,7 +30,7 @@ public sealed class DefaultColorBehavior : IColorBehavior
|
||||
/// <param name="color">The first color to test.</param>
|
||||
/// <param name="color2">The second color to test.</param>
|
||||
/// <returns><c>true</c> if <paramref name="color2" /> equivalent to this <see cref="Color" />; otherwise, <c>false</c>.</returns>
|
||||
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 sealed class DefaultColorBehavior : IColorBehavior
|
||||
/// Returns a hash code for this <see cref="Color" />.
|
||||
/// </summary>
|
||||
/// <returns>An integer value that specifies the hash code for this <see cref="Color" />.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Blends a <see cref="Color"/> over this color.
|
||||
/// </summary>
|
||||
/// <param name="baseColor">The <see cref="Color"/> to to blend over.</param>
|
||||
/// <param name="blendColor">The <see cref="Color"/> to blend.</param>
|
||||
public Color Blend(in Color baseColor, in Color blendColor)
|
||||
public Color Blend(Color baseColor, Color blendColor)
|
||||
{
|
||||
if (blendColor.A.EqualsInTolerance(0)) return baseColor;
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ public interface IColorBehavior
|
||||
/// </summary>
|
||||
/// <param name="color">The color to convert.</param>
|
||||
/// <returns>The string representation of the specified color.</returns>
|
||||
string ToString(in Color color);
|
||||
string ToString(Color color);
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether the specified object is a <see cref="Color" /> and is equivalent to this <see cref="Color" />.
|
||||
@ -18,7 +18,7 @@ public interface IColorBehavior
|
||||
/// <param name="color">The color to test.</param>
|
||||
/// <param name="obj">The object to test.</param>
|
||||
/// <returns><c>true</c> if <paramref name="obj" /> is a <see cref="Color" /> equivalent to this <see cref="Color" />; otherwise, <c>false</c>.</returns>
|
||||
bool Equals(in Color color, object? obj);
|
||||
bool Equals(Color color, object? obj);
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether the specified object is a <see cref="Color" /> and is equivalent to this <see cref="Color" />.
|
||||
@ -26,18 +26,18 @@ public interface IColorBehavior
|
||||
/// <param name="color">The first color to test.</param>
|
||||
/// <param name="color2">The second color to test.</param>
|
||||
/// <returns><c>true</c> if <paramref name="color2" /> equivalent to this <see cref="Color" />; otherwise, <c>false</c>.</returns>
|
||||
bool Equals(in Color color, in Color color2);
|
||||
bool Equals(Color color, Color color2);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a hash code for this <see cref="Color" />.
|
||||
/// </summary>
|
||||
/// <returns>An integer value that specifies the hash code for this <see cref="Color" />.</returns>
|
||||
int GetHashCode(in Color color);
|
||||
int GetHashCode(Color color);
|
||||
|
||||
/// <summary>
|
||||
/// Blends a <see cref="Color"/> over this color.
|
||||
/// </summary>
|
||||
/// <param name="baseColor">The <see cref="Color"/> to to blend over.</param>
|
||||
/// <param name="blendColor">The <see cref="Color"/> to blend.</param>
|
||||
Color Blend(in Color baseColor, in Color blendColor);
|
||||
Color Blend(Color baseColor, Color blendColor);
|
||||
}
|
||||
@ -175,7 +175,7 @@ public readonly struct Color : IEquatable<Color>
|
||||
/// Initializes a new instance of the <see cref="T:RGB.NET.Core.Color" /> struct by cloning a existing <see cref="T:RGB.NET.Core.Color" />.
|
||||
/// </summary>
|
||||
/// <param name="color">The <see cref="T:RGB.NET.Core.Color" /> the values are copied from.</param>
|
||||
public Color(in Color color)
|
||||
public Color(Color color)
|
||||
: this(color.A, color.R, color.G, color.B)
|
||||
{ }
|
||||
|
||||
@ -214,7 +214,7 @@ public readonly struct Color : IEquatable<Color>
|
||||
/// Blends a <see cref="Color"/> over this color, as defined by the current <see cref="Behavior"/>.
|
||||
/// </summary>
|
||||
/// <param name="color">The <see cref="Color"/> to blend.</param>
|
||||
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 readonly struct Color : IEquatable<Color>
|
||||
/// <param name="color1">The base color.</param>
|
||||
/// <param name="color2">The color to blend.</param>
|
||||
/// <returns>The blended color.</returns>
|
||||
public static Color operator +(in Color color1, in Color color2) => color1.Blend(color2);
|
||||
public static Color operator +(Color color1, Color color2) => color1.Blend(color2);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value that indicates whether two specified <see cref="Color" /> are equal.
|
||||
@ -234,7 +234,7 @@ public readonly struct Color : IEquatable<Color>
|
||||
/// <param name="color1">The first <see cref="Color" /> to compare.</param>
|
||||
/// <param name="color2">The second <see cref="Color" /> to compare.</param>
|
||||
/// <returns><c>true</c> if <paramref name="color1" /> and <paramref name="color2" /> are equal; otherwise, <c>false</c>.</returns>
|
||||
public static bool operator ==(in Color color1, in Color color2) => color1.Equals(color2);
|
||||
public static bool operator ==(Color color1, Color color2) => color1.Equals(color2);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value that indicates whether two specified <see cref="Color" /> are equal.
|
||||
@ -242,7 +242,7 @@ public readonly struct Color : IEquatable<Color>
|
||||
/// <param name="color1">The first <see cref="Color" /> to compare.</param>
|
||||
/// <param name="color2">The second <see cref="Color" /> to compare.</param>
|
||||
/// <returns><c>true</c> if <paramref name="color1" /> and <paramref name="color2" /> are not equal; otherwise, <c>false</c>.</returns>
|
||||
public static bool operator !=(in Color color1, in Color color2) => !(color1 == color2);
|
||||
public static bool operator !=(Color color1, Color color2) => !(color1 == color2);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="ValueTuple"/> of ARGB-components to a <see cref="Color"/>.
|
||||
|
||||
@ -16,21 +16,21 @@ public static class HSVColor
|
||||
/// </summary>
|
||||
/// <param name="color">The color to get the value from.</param>
|
||||
/// <returns>The hue component value of the color.</returns>
|
||||
public static float GetHue(this in Color color) => color.GetHSV().hue;
|
||||
public static float GetHue(this Color color) => color.GetHSV().hue;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the saturation component value (HSV-color space) of this <see cref="Color"/> in the range [0..1].
|
||||
/// </summary>
|
||||
/// <param name="color">The color to get the value from.</param>
|
||||
/// <returns>The saturation component value of the color.</returns>
|
||||
public static float GetSaturation(this in Color color) => color.GetHSV().saturation;
|
||||
public static float GetSaturation(this Color color) => color.GetHSV().saturation;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value component value (HSV-color space) of this <see cref="Color"/> in the range [0..1].
|
||||
/// </summary>
|
||||
/// <param name="color">The color to get the value from.</param>
|
||||
/// <returns>The value component value of the color.</returns>
|
||||
public static float GetValue(this in Color color) => color.GetHSV().value;
|
||||
public static float GetValue(this Color color) => color.GetHSV().value;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the hue, saturation and value component values (HSV-color space) of this <see cref="Color"/>.
|
||||
@ -40,7 +40,7 @@ public static class HSVColor
|
||||
/// </summary>
|
||||
/// <param name="color">The color to get the value from.</param>
|
||||
/// <returns>A tuple containing the hue, saturation and value component value of the color.</returns>
|
||||
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 class HSVColor
|
||||
/// <param name="saturation">The saturation value to add.</param>
|
||||
/// <param name="value">The value value to add.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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 class HSVColor
|
||||
/// <param name="saturation">The saturation value to subtract.</param>
|
||||
/// <param name="value">The value value to subtract.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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 class HSVColor
|
||||
/// <param name="saturation">The saturation value to multiply.</param>
|
||||
/// <param name="value">The value value to multiply.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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 class HSVColor
|
||||
/// <param name="saturation">The saturation value to divide.</param>
|
||||
/// <param name="value">The value value to divide.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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 class HSVColor
|
||||
/// <param name="saturation">The saturation value to set.</param>
|
||||
/// <param name="value">The value value to set.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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);
|
||||
|
||||
@ -16,21 +16,21 @@ public static class HclColor
|
||||
/// </summary>
|
||||
/// <param name="color">The color to get the value from.</param>
|
||||
/// <returns>The H component value of the color. </returns>
|
||||
public static float GetHclH(this in Color color) => color.GetHcl().h;
|
||||
public static float GetHclH(this Color color) => color.GetHcl().h;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the c component value (Hcl-color space) of this <see cref="Color"/> in the range [0..1].
|
||||
/// </summary>
|
||||
/// <param name="color">The color to get the value from.</param>
|
||||
/// <returns>The c component value of the color. </returns>
|
||||
public static float GetHclC(this in Color color) => color.GetHcl().c;
|
||||
public static float GetHclC(this Color color) => color.GetHcl().c;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the l component value (Hcl-color space) of this <see cref="Color"/> in the range [0..1].
|
||||
/// </summary>
|
||||
/// <param name="color">The color to get the value from.</param>
|
||||
/// <returns>The l component value of the color. </returns>
|
||||
public static float GetHclL(this in Color color) => color.GetHcl().l;
|
||||
public static float GetHclL(this Color color) => color.GetHcl().l;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the H, c and l component values (Hcl-color space) of this <see cref="Color"/>.
|
||||
@ -40,7 +40,7 @@ public static class HclColor
|
||||
/// </summary>
|
||||
/// <param name="color">The color to get the value from.</param>
|
||||
/// <returns>A tuple containing the H, c and l component value of the color.</returns>
|
||||
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 class HclColor
|
||||
/// <param name="c">The c value to add.</param>
|
||||
/// <param name="l">The l value to add.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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 class HclColor
|
||||
/// <param name="c">The c value to subtract.</param>
|
||||
/// <param name="l">The l value to subtract.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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 class HclColor
|
||||
/// <param name="c">The c value to multiply.</param>
|
||||
/// <param name="l">The l value to multiply.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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 class HclColor
|
||||
/// <param name="c">The c value to divide.</param>
|
||||
/// <param name="l">The l value to divide.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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 class HclColor
|
||||
/// <param name="c">The c value to set.</param>
|
||||
/// <param name="l">The l value to set.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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);
|
||||
|
||||
@ -16,21 +16,21 @@ public static class LabColor
|
||||
/// </summary>
|
||||
/// <param name="color">The color to get the value from.</param>
|
||||
/// <returns>The L component value of the color.</returns>
|
||||
public static float GetLabL(this in Color color) => color.GetLab().l;
|
||||
public static float GetLabL(this Color color) => color.GetLab().l;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the a component value (Lab-color space) of this <see cref="Color"/> in the range [0..1].
|
||||
/// </summary>
|
||||
/// <param name="color">The color to get the value from.</param>
|
||||
/// <returns>The a component value of the color.</returns>
|
||||
public static float GetLabA(this in Color color) => color.GetLab().a;
|
||||
public static float GetLabA(this Color color) => color.GetLab().a;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the b component value (Lab-color space) of this <see cref="Color"/> in the range [0..1].
|
||||
/// </summary>
|
||||
/// <param name="color">The color to get the value from.</param>
|
||||
/// <returns>The b component value of the color.</returns>
|
||||
public static float GetLabB(this in Color color) => color.GetLab().b;
|
||||
public static float GetLabB(this Color color) => color.GetLab().b;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the L, a and b component values (Lab-color space) of this <see cref="Color"/>.
|
||||
@ -40,7 +40,7 @@ public static class LabColor
|
||||
/// </summary>
|
||||
/// <param name="color">The color to get the value from.</param>
|
||||
/// <returns>A tuple containing the L, a and b component value of the color.</returns>
|
||||
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 class LabColor
|
||||
/// <param name="a">The a value to add.</param>
|
||||
/// <param name="b">The b value to add.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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 class LabColor
|
||||
/// <param name="a">The a value to subtract.</param>
|
||||
/// <param name="b">The b value to subtract.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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 class LabColor
|
||||
/// <param name="a">The a value to multiply.</param>
|
||||
/// <param name="b">The b value to multiply.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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 class LabColor
|
||||
/// <param name="a">The a value to divide.</param>
|
||||
/// <param name="b">The b value to divide.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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 class LabColor
|
||||
/// <param name="a">The a value to set.</param>
|
||||
/// <param name="b">The b value to set.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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);
|
||||
|
||||
@ -16,35 +16,35 @@ public static class RGBColor
|
||||
/// </summary>
|
||||
/// <param name="color">The color to get the value from.</param>
|
||||
/// <returns>The A component value of the color.</returns>
|
||||
public static byte GetA(this in Color color) => color.A.GetByteValueFromPercentage();
|
||||
public static byte GetA(this Color color) => color.A.GetByteValueFromPercentage();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the R component value of this <see cref="Color"/> as byte in the range [0..255].
|
||||
/// </summary>
|
||||
/// <param name="color">The color to get the value from.</param>
|
||||
/// <returns>The R component value of the color.</returns>
|
||||
public static byte GetR(this in Color color) => color.R.GetByteValueFromPercentage();
|
||||
public static byte GetR(this Color color) => color.R.GetByteValueFromPercentage();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the G component value of this <see cref="Color"/> as byte in the range [0..255].
|
||||
/// </summary>
|
||||
/// <param name="color">The color to get the value from.</param>
|
||||
/// <returns>The G component value of the color.</returns>
|
||||
public static byte GetG(this in Color color) => color.G.GetByteValueFromPercentage();
|
||||
public static byte GetG(this Color color) => color.G.GetByteValueFromPercentage();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the B component value of this <see cref="Color"/> as byte in the range [0..255].
|
||||
/// </summary>
|
||||
/// <param name="color">The color to get the value from.</param>
|
||||
/// <returns>The B component value of the color.</returns>
|
||||
public static byte GetB(this in Color color) => color.B.GetByteValueFromPercentage();
|
||||
public static byte GetB(this Color color) => color.B.GetByteValueFromPercentage();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the A, R, G and B component value of this <see cref="Color"/> as byte in the range [0..255].
|
||||
/// </summary>
|
||||
/// <param name="color">The color to get the value from.</param>
|
||||
/// <returns>A tuple containing the A, R, G and B component value of the color.</returns>
|
||||
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());
|
||||
|
||||
/// <summary>
|
||||
@ -52,7 +52,7 @@ public static class RGBColor
|
||||
/// </summary>
|
||||
/// <param name="color">The color to get the value from.</param>
|
||||
/// <returns>A tuple containing the A, R, G and B component value of the color.</returns>
|
||||
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 class RGBColor
|
||||
/// <param name="g">The green value to add.</param>
|
||||
/// <param name="b">The blue value to add.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
@ -80,7 +80,7 @@ public static class RGBColor
|
||||
/// <param name="g">The green value to add.</param>
|
||||
/// <param name="b">The blue value to add.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
@ -89,7 +89,7 @@ public static class RGBColor
|
||||
/// <param name="color">The color to modify.</param>
|
||||
/// <param name="a">The alpha value to add.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
@ -98,7 +98,7 @@ public static class RGBColor
|
||||
/// <param name="color">The color to modify.</param>
|
||||
/// <param name="a">The alpha value to add.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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 class RGBColor
|
||||
/// <param name="g">The green value to subtract.</param>
|
||||
/// <param name="b">The blue value to subtract.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
@ -124,7 +124,7 @@ public static class RGBColor
|
||||
/// <param name="g">The green value to subtract.</param>
|
||||
/// <param name="b">The blue value to subtract.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
@ -133,7 +133,7 @@ public static class RGBColor
|
||||
/// <param name="color">The color to modify.</param>
|
||||
/// <param name="a">The alpha value to subtract.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
@ -142,7 +142,7 @@ public static class RGBColor
|
||||
/// <param name="color">The color to modify.</param>
|
||||
/// <param name="aPercent">The alpha value to subtract.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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 class RGBColor
|
||||
/// <param name="g">The green value to multiply.</param>
|
||||
/// <param name="b">The blue value to multiply.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
@ -166,7 +166,7 @@ public static class RGBColor
|
||||
/// <param name="color">The color to modify.</param>
|
||||
/// <param name="a">The alpha value to multiply.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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 class RGBColor
|
||||
/// <param name="g">The green value to divide.</param>
|
||||
/// <param name="b">The blue value to divide.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
@ -190,7 +190,7 @@ public static class RGBColor
|
||||
/// <param name="color">The color to modify.</param>
|
||||
/// <param name="a">The alpha value to divide.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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 class RGBColor
|
||||
/// <param name="g">The green value to set.</param>
|
||||
/// <param name="b">The blue value to set.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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());
|
||||
|
||||
/// <summary>
|
||||
@ -216,7 +216,7 @@ public static class RGBColor
|
||||
/// <param name="g">The green value to set.</param>
|
||||
/// <param name="b">The blue value to set.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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());
|
||||
|
||||
/// <summary>
|
||||
@ -227,7 +227,7 @@ public static class RGBColor
|
||||
/// <param name="g">The green value to set.</param>
|
||||
/// <param name="b">The blue value to set.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
@ -236,7 +236,7 @@ public static class RGBColor
|
||||
/// <param name="color">The color to modify.</param>
|
||||
/// <param name="a">The alpha value to set.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the specified alpha value of this color.
|
||||
@ -244,7 +244,7 @@ public static class RGBColor
|
||||
/// <param name="color">The color to modify.</param>
|
||||
/// <param name="a">The alpha value to set.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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 class RGBColor
|
||||
/// Gets the current color as a RGB-HEX-string.
|
||||
/// </summary>
|
||||
/// <returns>The RGB-HEX-string.</returns>
|
||||
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());
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current color as a ARGB-HEX-string.
|
||||
/// </summary>
|
||||
/// <returns>The ARGB-HEX-string.</returns>
|
||||
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
|
||||
|
||||
|
||||
@ -16,21 +16,21 @@ public static class XYZColor
|
||||
/// </summary>
|
||||
/// <param name="color">The color to get the value from.</param>
|
||||
/// <returns>The X component value of the color.</returns>
|
||||
public static float GetX(this in Color color) => color.GetXYZ().x;
|
||||
public static float GetX(this Color color) => color.GetXYZ().x;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Y component value (XYZ-color space) of this <see cref="Color"/> in the range [0..100].
|
||||
/// </summary>
|
||||
/// <param name="color">The color to get the value from.</param>
|
||||
/// <returns>The Y component value of the color.</returns>
|
||||
public static float GetY(this in Color color) => color.GetXYZ().y;
|
||||
public static float GetY(this Color color) => color.GetXYZ().y;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Z component value (XYZ-color space) of this <see cref="Color"/> in the range [0..108.883].
|
||||
/// </summary>
|
||||
/// <param name="color">The color to get the value from.</param>
|
||||
/// <returns>The Z component value of the color.</returns>
|
||||
public static float GetZ(this in Color color) => color.GetXYZ().z;
|
||||
public static float GetZ(this Color color) => color.GetXYZ().z;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the X, Y and Z component values (XYZ-color space) of this <see cref="Color"/>.
|
||||
@ -40,7 +40,7 @@ public static class XYZColor
|
||||
/// </summary>
|
||||
/// <param name="color">The color to get the value from.</param>
|
||||
/// <returns>A tuple containing the X, Y and Z component value of the color.</returns>
|
||||
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 class XYZColor
|
||||
/// <param name="y">The Y value to add.</param>
|
||||
/// <param name="z">The Z value to add.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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 class XYZColor
|
||||
/// <param name="y">The Y value to subtract.</param>
|
||||
/// <param name="z">The Z value to subtract.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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 class XYZColor
|
||||
/// <param name="y">The Y value to multiply.</param>
|
||||
/// <param name="z">The Z value to multiply.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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 class XYZColor
|
||||
/// <param name="y">The Y value to divide.</param>
|
||||
/// <param name="z">The Z value to divide.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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 class XYZColor
|
||||
/// <param name="y">The Y value to set.</param>
|
||||
/// <param name="z">The Z value to set.</param>
|
||||
/// <returns>The new color after the modification.</returns>
|
||||
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);
|
||||
|
||||
8
RGB.NET.Core/Compatibility/Lock.cs
Normal file
8
RGB.NET.Core/Compatibility/Lock.cs
Normal file
@ -0,0 +1,8 @@
|
||||
#if NET8_0
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace RGB.NET.Core.Compatibility.Net8;
|
||||
|
||||
public sealed class Lock;
|
||||
|
||||
#endif
|
||||
@ -12,5 +12,5 @@ public interface IBrushDecorator : IDecorator
|
||||
/// <param name="rectangle">The rectangle in which the <see cref="IBrush"/> should be drawn.</param>
|
||||
/// <param name="renderTarget">The target (key/point) from which the <see cref="Color"/> should be taken.</param>
|
||||
/// <param name="color">The <see cref="Color"/> to be modified.</param>
|
||||
void ManipulateColor(in Rectangle rectangle, in RenderTarget renderTarget, ref Color color);
|
||||
void ManipulateColor(Rectangle rectangle, RenderTarget renderTarget, ref Color color);
|
||||
}
|
||||
@ -43,7 +43,7 @@ public abstract class AbstractRGBDevice<TDeviceInfo> : Placeable, IRGBDevice<TDe
|
||||
IRGBDeviceInfo IRGBDevice.DeviceInfo => DeviceInfo;
|
||||
|
||||
/// <inheritdoc />
|
||||
public IList<IColorCorrection> ColorCorrections { get; } = new List<IColorCorrection>();
|
||||
public IList<IColorCorrection> ColorCorrections { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets if the device needs to be flushed on every update.
|
||||
@ -63,7 +63,7 @@ public abstract class AbstractRGBDevice<TDeviceInfo> : Placeable, IRGBDevice<TDe
|
||||
#region Indexer
|
||||
|
||||
/// <inheritdoc />
|
||||
Led? IRGBDevice.this[LedId ledId] => LedMapping.TryGetValue(ledId, out Led? led) ? led : null;
|
||||
Led? IRGBDevice.this[LedId ledId] => LedMapping.GetValueOrDefault(ledId);
|
||||
|
||||
/// <inheritdoc />
|
||||
Led? IRGBDevice.this[Point location] => LedMapping.Values.FirstOrDefault(x => x.Boundary.Contains(location));
|
||||
@ -119,7 +119,7 @@ public abstract class AbstractRGBDevice<TDeviceInfo> : Placeable, IRGBDevice<TDe
|
||||
/// Applies all <see cref="ColorCorrections"/>.
|
||||
/// if no <see cref="Led.CustomData"/> ist specified the <see cref="Led.Id"/> is used.
|
||||
/// </remarks>
|
||||
/// <param name="leds">The enumerable of leds to convert.</param>
|
||||
/// <param name="led">The of led to convert.</param>
|
||||
/// <returns>The enumerable of custom data and color tuples for the specified leds.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected (object key, Color color) GetUpdateData(Led led)
|
||||
@ -179,7 +179,7 @@ public abstract class AbstractRGBDevice<TDeviceInfo> : Placeable, IRGBDevice<TDe
|
||||
{ }
|
||||
|
||||
/// <inheritdoc />
|
||||
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;
|
||||
|
||||
|
||||
@ -72,7 +72,7 @@ public interface IRGBDevice : IEnumerable<Led>, IPlaceable, IBindable, IDisposab
|
||||
/// <param name="size">The size of the led.</param>
|
||||
/// <param name="customData">Custom data saved on the led.</param>
|
||||
/// <returns>The newly added led or <c>null</c> if a led with this id is already added.</returns>
|
||||
Led? AddLed(LedId ledId, in Point location, in Size size, object? customData = null);
|
||||
Led? AddLed(LedId ledId, Point location, Size size, object? customData = null);
|
||||
|
||||
/// <summary>
|
||||
/// Removes the led with the specified id from the device.
|
||||
|
||||
@ -16,7 +16,7 @@ public static class ColorExtensions
|
||||
/// <param name="color1">The start color of the distance calculation.</param>
|
||||
/// <param name="color2">The end color fot the distance calculation.</param>
|
||||
/// <returns>The redmean distance between the two specified colors.</returns>
|
||||
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();
|
||||
|
||||
@ -91,10 +91,11 @@ public static class FloatExtensions
|
||||
[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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -16,7 +16,7 @@ public static class PointExtensions
|
||||
/// <param name="x">The x-ammount to move.</param>
|
||||
/// <param name="y">The y-ammount to move.</param>
|
||||
/// <returns>The new location of the point.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Rotates the specified <see cref="Point"/> by the specified amuont around the specified origin.
|
||||
@ -25,7 +25,7 @@ public static class PointExtensions
|
||||
/// <param name="rotation">The rotation.</param>
|
||||
/// <param name="origin">The origin to rotate around. [0,0] if not set.</param>
|
||||
/// <returns>The new location of the point.</returns>
|
||||
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);
|
||||
|
||||
@ -15,7 +15,7 @@ public static class RectangleExtensions
|
||||
/// <param name="rect">The rectangle to modify.</param>
|
||||
/// <param name="location">The new location of the rectangle.</param>
|
||||
/// <returns>The modified <see cref="Rectangle"/>.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the <see cref="Point.X"/> of the <see cref="Rectangle.Location"/> of the specified rectangle.
|
||||
@ -23,7 +23,7 @@ public static class RectangleExtensions
|
||||
/// <param name="rect">The rectangle to modify.</param>
|
||||
/// <param name="x">The new x-location of the rectangle.</param>
|
||||
/// <returns>The modified <see cref="Rectangle"/>.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the <see cref="Point.Y"/> of the <see cref="Rectangle.Location"/> of the specified rectangle.
|
||||
@ -31,7 +31,7 @@ public static class RectangleExtensions
|
||||
/// <param name="rect">The rectangle to modify.</param>
|
||||
/// <param name="y">The new y-location of the rectangle.</param>
|
||||
/// <returns>The modified <see cref="Rectangle"/>.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the <see cref="Rectangle.Size"/> of the specified rectangle.
|
||||
@ -39,7 +39,7 @@ public static class RectangleExtensions
|
||||
/// <param name="rect">The rectangle to modify.</param>
|
||||
/// <param name="size">The new size of the rectangle.</param>
|
||||
/// <returns>The modified <see cref="Rectangle"/>.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the <see cref="Size.Width"/> of the <see cref="Rectangle.Size"/> of the specified rectangle.
|
||||
@ -47,7 +47,7 @@ public static class RectangleExtensions
|
||||
/// <param name="rect">The rectangle to modify.</param>
|
||||
/// <param name="width">The new width of the rectangle.</param>
|
||||
/// <returns>The modified <see cref="Rectangle"/>.</returns>
|
||||
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));
|
||||
|
||||
/// <summary>
|
||||
/// Sets the <see cref="Size.Height"/> of the <see cref="Rectangle.Size"/> of the specified rectangle.
|
||||
@ -55,7 +55,7 @@ public static class RectangleExtensions
|
||||
/// <param name="rect">The rectangle to modify.</param>
|
||||
/// <param name="height">The new height of the rectangle.</param>
|
||||
/// <returns>The modified <see cref="Rectangle"/>.</returns>
|
||||
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));
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the percentage of intersection of a rectangle.
|
||||
@ -63,7 +63,7 @@ public static class RectangleExtensions
|
||||
/// <param name="rect">The rectangle to calculate the intersection for.</param>
|
||||
/// <param name="intersectingRect">The intersecting rectangle.</param>
|
||||
/// <returns>The percentage of intersection.</returns>
|
||||
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 class RectangleExtensions
|
||||
/// <param name="rect">The rectangle to calculate the intersection for.</param>
|
||||
/// <param name="intersectingRectangle">The intersecting <see cref="Rectangle"/>.</param>
|
||||
/// <returns>A new <see cref="Rectangle"/> representing the intersection this <see cref="Rectangle"/> and the one provided as parameter.</returns>
|
||||
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 class RectangleExtensions
|
||||
/// <param name="rect">The containing rectangle.</param>
|
||||
/// <param name="point">The <see cref="Point"/> to test.</param>
|
||||
/// <returns><c>true</c> if the rectangle contains the specified point; otherwise <c>false</c>.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the specified location is contained within this <see cref="Rectangle"/>.
|
||||
@ -106,7 +106,7 @@ public static class RectangleExtensions
|
||||
/// <param name="x">The X-location to test.</param>
|
||||
/// <param name="y">The Y-location to test.</param>
|
||||
/// <returns><c>true</c> if the rectangle contains the specified coordinates; otherwise <c>false</c>.</returns>
|
||||
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));
|
||||
|
||||
/// <summary>
|
||||
@ -115,7 +115,7 @@ public static class RectangleExtensions
|
||||
/// <param name="rect">The containing rectangle.</param>
|
||||
/// <param name="rect2">The <see cref="Rectangle"/> to test.</param>
|
||||
/// <returns><c>true</c> if the rectangle contains the specified rect; otherwise <c>false</c>.</returns>
|
||||
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));
|
||||
|
||||
/// <summary>
|
||||
@ -124,7 +124,7 @@ public static class RectangleExtensions
|
||||
/// <param name="rect">The <see cref="Rectangle"/> to move.</param>
|
||||
/// <param name="point">The amount to move.</param>
|
||||
/// <returns>The moved rectangle.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Moves the specified <see cref="Rectangle"/> by the specified amount.
|
||||
@ -133,7 +133,7 @@ public static class RectangleExtensions
|
||||
/// <param name="x">The x-ammount to move.</param>
|
||||
/// <param name="y">The y-ammount to move.</param>
|
||||
/// <returns>The moved rectangle.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Rotates the specified <see cref="Rectangle"/> by the specified amuont around the specified origin.
|
||||
@ -149,14 +149,14 @@ public static class RectangleExtensions
|
||||
/// <param name="rotation">The rotation.</param>
|
||||
/// <param name="origin">The origin to rotate around. [0,0] if not set.</param>
|
||||
/// <returns>A array of <see cref="Point"/> containing the new locations of the corners of the original rectangle.</returns>
|
||||
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);
|
||||
|
||||
@ -20,7 +20,7 @@ public sealed class ListLedGroup : AbstractLedGroup
|
||||
/// <summary>
|
||||
/// Gets the list containing the <see cref="Led"/> of this <see cref="ListLedGroup"/>.
|
||||
/// </summary>
|
||||
private readonly IList<Led> _groupLeds = new List<Led>();
|
||||
private readonly IList<Led> _groupLeds = [];
|
||||
|
||||
#endregion
|
||||
|
||||
@ -142,7 +142,7 @@ public sealed class ListLedGroup : AbstractLedGroup
|
||||
public override IList<Led> ToList()
|
||||
{
|
||||
lock (_groupLeds)
|
||||
return new List<Led>(_groupLeds);
|
||||
return [.._groupLeds];
|
||||
}
|
||||
|
||||
protected override IDisposable ToListUnsafe(out IList<Led> leds)
|
||||
|
||||
@ -40,7 +40,7 @@ public static class ConversionHelper
|
||||
public static byte[] HexToBytes(ReadOnlySpan<char> hexString)
|
||||
{
|
||||
if ((hexString.Length == 0) || ((hexString.Length % 2) != 0))
|
||||
return Array.Empty<byte>();
|
||||
return [];
|
||||
|
||||
byte[] buffer = new byte[hexString.Length / 2];
|
||||
for (int bx = 0, sx = 0; bx < buffer.Length; ++bx, ++sx)
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -90,7 +90,7 @@ public readonly struct Point : IEquatable<Point>
|
||||
/// <param name="point1">The first <see cref="Point" /> to compare.</param>
|
||||
/// <param name="point2">The second <see cref="Point" /> to compare.</param>
|
||||
/// <returns><c>true</c> if <paramref name="point1" /> and <paramref name="point2" /> are equal; otherwise, <c>false</c>.</returns>
|
||||
public static bool operator ==(in Point point1, in Point point2) => point1.Equals(point2);
|
||||
public static bool operator ==(Point point1, Point point2) => point1.Equals(point2);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value that indicates whether two specified <see cref="Point" /> are equal.
|
||||
@ -98,7 +98,7 @@ public readonly struct Point : IEquatable<Point>
|
||||
/// <param name="point1">The first <see cref="Point" /> to compare.</param>
|
||||
/// <param name="point2">The second <see cref="Point" /> to compare.</param>
|
||||
/// <returns><c>true</c> if <paramref name="point1" /> and <paramref name="point2" /> are not equal; otherwise, <c>false</c>.</returns>
|
||||
public static bool operator !=(in Point point1, in Point point2) => !(point1 == point2);
|
||||
public static bool operator !=(Point point1, Point point2) => !(point1 == point2);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a new <see cref="Point"/> representing the addition of the two provided <see cref="Point"/>.
|
||||
@ -106,7 +106,7 @@ public readonly struct Point : IEquatable<Point>
|
||||
/// <param name="point1">The first <see cref="Point"/>.</param>
|
||||
/// <param name="point2">The second <see cref="Point"/>.</param>
|
||||
/// <returns>A new <see cref="Point"/> representing the addition of the two provided <see cref="Point"/>.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a new <see cref="Rectangle"/> created from the provided <see cref="Point"/> and <see cref="Size"/>.
|
||||
@ -114,7 +114,7 @@ public readonly struct Point : IEquatable<Point>
|
||||
/// <param name="point">The <see cref="Point"/> of the rectangle.</param>
|
||||
/// <param name="size">The <see cref="Size"/> of the rectangle.</param>
|
||||
/// <returns>The rectangle created from the provided <see cref="Point"/> and <see cref="Size"/>.</returns>
|
||||
public static Rectangle operator +(in Point point, in Size size) => new(point, size);
|
||||
public static Rectangle operator +(Point point, Size size) => new(point, size);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a new <see cref="Point"/> representing the subtraction of the two provided <see cref="Point"/>.
|
||||
@ -122,7 +122,7 @@ public readonly struct Point : IEquatable<Point>
|
||||
/// <param name="point1">The first <see cref="Point"/>.</param>
|
||||
/// <param name="point2">The second <see cref="Point"/>.</param>
|
||||
/// <returns>A new <see cref="Point"/> representing the subtraction of the two provided <see cref="Point"/>.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a new <see cref="Point"/> representing the multiplication of the two provided <see cref="Point"/>.
|
||||
@ -130,7 +130,7 @@ public readonly struct Point : IEquatable<Point>
|
||||
/// <param name="point1">The first <see cref="Point"/>.</param>
|
||||
/// <param name="point2">The second <see cref="Point"/>.</param>
|
||||
/// <returns>A new <see cref="Point"/> representing the multiplication of the two provided <see cref="Point"/>.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a new <see cref="Point"/> representing the division of the two provided <see cref="Point"/>.
|
||||
@ -138,7 +138,7 @@ public readonly struct Point : IEquatable<Point>
|
||||
/// <param name="point1">The first <see cref="Point"/>.</param>
|
||||
/// <param name="point2">The second <see cref="Point"/>.</param>
|
||||
/// <returns>A new <see cref="Point"/> representing the division of the two provided <see cref="Point"/>.</returns>
|
||||
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 readonly struct Point : IEquatable<Point>
|
||||
/// <param name="point">The <see cref="Point"/>.</param>
|
||||
/// <param name="scale">The <see cref="Scale"/>.</param>
|
||||
/// <returns>A new <see cref="Point"/> representing the multiplication of the <see cref="Point"/> and the provided <see cref="Scale"/>.</returns>
|
||||
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
|
||||
}
|
||||
@ -179,7 +179,7 @@ public readonly struct Rectangle : IEquatable<Rectangle>
|
||||
|
||||
#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 @@ public readonly struct Rectangle : IEquatable<Rectangle>
|
||||
/// <param name="rectangle1">The first <see cref="Rectangle" /> to compare.</param>
|
||||
/// <param name="rectangle2">The second <see cref="Rectangle" /> to compare.</param>
|
||||
/// <returns><c>true</c> if <paramref name="rectangle1" /> and <paramref name="rectangle2" /> are equal; otherwise, <c>false</c>.</returns>
|
||||
public static bool operator ==(in Rectangle rectangle1, in Rectangle rectangle2) => rectangle1.Equals(rectangle2);
|
||||
public static bool operator ==(Rectangle rectangle1, Rectangle rectangle2) => rectangle1.Equals(rectangle2);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value that indicates whether two specified <see cref="Rectangle" /> are equal.
|
||||
@ -233,7 +233,7 @@ public readonly struct Rectangle : IEquatable<Rectangle>
|
||||
/// <param name="rectangle1">The first <see cref="Rectangle" /> to compare.</param>
|
||||
/// <param name="rectangle2">The second <see cref="Rectangle" /> to compare.</param>
|
||||
/// <returns><c>true</c> if <paramref name="rectangle1" /> and <paramref name="rectangle2" /> are not equal; otherwise, <c>false</c>.</returns>
|
||||
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
|
||||
/// <summary>
|
||||
@ -242,7 +242,7 @@ public readonly struct Rectangle : IEquatable<Rectangle>
|
||||
/// <param name="rectangle1">The rectangle to nromalize.</param>
|
||||
/// <param name="rectangle2">The reference used for normalization.</param>
|
||||
/// <returns>A normalized rectangle.</returns>
|
||||
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);
|
||||
|
||||
@ -103,7 +103,7 @@ public readonly struct Rotation : IEquatable<Rotation>
|
||||
/// <param name="rotation1">The first <see cref="Rotation" /> to compare.</param>
|
||||
/// <param name="rotation2">The second <see cref="Rotation" /> to compare.</param>
|
||||
/// <returns><c>true</c> if <paramref name="rotation1" /> and <paramref name="rotation2" /> are equal; otherwise, <c>false</c>.</returns>
|
||||
public static bool operator ==(in Rotation rotation1, in Rotation rotation2) => rotation1.Equals(rotation2);
|
||||
public static bool operator ==(Rotation rotation1, Rotation rotation2) => rotation1.Equals(rotation2);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value that indicates whether two specified <see cref="Rotation" /> are equal.
|
||||
@ -111,7 +111,7 @@ public readonly struct Rotation : IEquatable<Rotation>
|
||||
/// <param name="rotation1">The first <see cref="Rotation" /> to compare.</param>
|
||||
/// <param name="rotation2">The second <see cref="Rotation" /> to compare.</param>
|
||||
/// <returns><c>true</c> if <paramref name="rotation1" /> and <paramref name="rotation2" /> are not equal; otherwise, <c>false</c>.</returns>
|
||||
public static bool operator !=(in Rotation rotation1, in Rotation rotation2) => !(rotation1 == rotation2);
|
||||
public static bool operator !=(Rotation rotation1, Rotation rotation2) => !(rotation1 == rotation2);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a new <see cref="Rotation"/> representing the addition of the <see cref="Rotation"/> and the provided value.
|
||||
@ -119,7 +119,7 @@ public readonly struct Rotation : IEquatable<Rotation>
|
||||
/// <param name="rotation">The <see cref="Rotation"/>.</param>
|
||||
/// <param name="value">The value to add.</param>
|
||||
/// <returns>A new <see cref="Rotation"/> representing the addition of the <see cref="Rotation"/> and the provided value.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a new <see cref="Rotation"/> representing the subtraction of the <see cref="Rotation"/> and the provided value.
|
||||
@ -127,7 +127,7 @@ public readonly struct Rotation : IEquatable<Rotation>
|
||||
/// <param name="rotation">The <see cref="Rotation"/>.</param>
|
||||
/// <param name="value">The value to substract.</param>
|
||||
/// <returns>A new <see cref="Rotation"/> representing the subtraction of the <see cref="Rotation"/> and the provided value.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a new <see cref="Rotation"/> representing the multiplication of the <see cref="Rotation"/> and the provided value.
|
||||
@ -135,7 +135,7 @@ public readonly struct Rotation : IEquatable<Rotation>
|
||||
/// <param name="rotation">The <see cref="Rotation"/>.</param>
|
||||
/// <param name="value">The value to multiply with.</param>
|
||||
/// <returns>A new <see cref="Rotation"/> representing the multiplication of the <see cref="Rotation"/> and the provided value.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a new <see cref="Rotation"/> representing the division of the <see cref="Rotation"/> and the provided value.
|
||||
@ -143,7 +143,7 @@ public readonly struct Rotation : IEquatable<Rotation>
|
||||
/// <param name="rotation">The <see cref="Rotation"/>.</param>
|
||||
/// <param name="value">The value to device with.</param>
|
||||
/// <returns>A new <see cref="Rotation"/> representing the division of the <see cref="Rotation"/> and the provided value.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a float to a <see cref="Rotation" />.
|
||||
@ -155,7 +155,7 @@ public readonly struct Rotation : IEquatable<Rotation>
|
||||
/// Converts <see cref="Rotation" /> to a float representing the rotation in degrees.
|
||||
/// </summary>
|
||||
/// <param name="rotation">The rotatio to convert.</param>
|
||||
public static implicit operator float(in Rotation rotation) => rotation.Degrees;
|
||||
public static implicit operator float(Rotation rotation) => rotation.Degrees;
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -110,7 +110,7 @@ public readonly struct Size : IEquatable<Size>
|
||||
/// <param name="size1">The first <see cref="Size" /> to compare.</param>
|
||||
/// <param name="size2">The second <see cref="Size" /> to compare.</param>
|
||||
/// <returns><c>true</c> if <paramref name="size1" /> and <paramref name="size2" /> are equal; otherwise, <c>false</c>.</returns>
|
||||
public static bool operator ==(in Size size1, in Size size2) => size1.Equals(size2);
|
||||
public static bool operator ==(Size size1, Size size2) => size1.Equals(size2);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value that indicates whether two specified <see cref="Size" /> are equal.
|
||||
@ -118,7 +118,7 @@ public readonly struct Size : IEquatable<Size>
|
||||
/// <param name="size1">The first <see cref="Size" /> to compare.</param>
|
||||
/// <param name="size2">The second <see cref="Size" /> to compare.</param>
|
||||
/// <returns><c>true</c> if <paramref name="size1" /> and <paramref name="size2" /> are not equal; otherwise, <c>false</c>.</returns>
|
||||
public static bool operator !=(in Size size1, in Size size2) => !(size1 == size2);
|
||||
public static bool operator !=(Size size1, Size size2) => !(size1 == size2);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a new <see cref="Size"/> representing the addition of the two provided <see cref="Size"/>.
|
||||
@ -126,7 +126,7 @@ public readonly struct Size : IEquatable<Size>
|
||||
/// <param name="size1">The first <see cref="Size"/>.</param>
|
||||
/// <param name="size2">The second <see cref="Size"/>.</param>
|
||||
/// <returns>A new <see cref="Size"/> representing the addition of the two provided <see cref="Size"/>.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a new <see cref="Rectangle"/> created from the provided <see cref="Point"/> and <see cref="Size"/>.
|
||||
@ -134,7 +134,7 @@ public readonly struct Size : IEquatable<Size>
|
||||
/// <param name="size">The <see cref="Size"/> of the rectangle.</param>
|
||||
/// <param name="point">The <see cref="Point"/> of the rectangle.</param>
|
||||
/// <returns>The rectangle created from the provided <see cref="Point"/> and <see cref="Size"/>.</returns>
|
||||
public static Rectangle operator +(in Size size, in Point point) => new(point, size);
|
||||
public static Rectangle operator +(Size size, Point point) => new(point, size);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a new <see cref="Size"/> representing the subtraction of the two provided <see cref="Size"/>.
|
||||
@ -142,7 +142,7 @@ public readonly struct Size : IEquatable<Size>
|
||||
/// <param name="size1">The first <see cref="Size"/>.</param>
|
||||
/// <param name="size2">The second <see cref="Size"/>.</param>
|
||||
/// <returns>A new <see cref="Size"/> representing the subtraction of the two provided <see cref="Size"/>.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a new <see cref="Size"/> representing the multiplication of the two provided <see cref="Size"/>.
|
||||
@ -150,7 +150,7 @@ public readonly struct Size : IEquatable<Size>
|
||||
/// <param name="size1">The first <see cref="Size"/>.</param>
|
||||
/// <param name="size2">The second <see cref="Size"/>.</param>
|
||||
/// <returns>A new <see cref="Size"/> representing the multiplication of the two provided <see cref="Size"/>.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a new <see cref="Size"/> representing the multiplication of the <see cref="Size"/> and the provided factor.
|
||||
@ -158,7 +158,7 @@ public readonly struct Size : IEquatable<Size>
|
||||
/// <param name="size">The <see cref="Size"/>.</param>
|
||||
/// <param name="factor">The factor by which the <see cref="Size"/> should be multiplied.</param>
|
||||
/// <returns>A new <see cref="Size"/> representing the multiplication of the <see cref="Size"/> and the provided factor.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a new <see cref="Size"/> representing the division of the two provided <see cref="Size"/>.
|
||||
@ -166,7 +166,7 @@ public readonly struct Size : IEquatable<Size>
|
||||
/// <param name="size1">The first <see cref="Size"/>.</param>
|
||||
/// <param name="size2">The second <see cref="Size"/>.</param>
|
||||
/// <returns>A new <see cref="Size"/> representing the division of the two provided <see cref="Size"/>.</returns>
|
||||
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 readonly struct Size : IEquatable<Size>
|
||||
/// <param name="size">The <see cref="Size"/>.</param>
|
||||
/// <param name="factor">The factor by which the <see cref="Size"/> should be divided.</param>
|
||||
/// <returns>A new <see cref="Size"/> representing the division of the <see cref="Size"/> and the provided factor.</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a new <see cref="Size"/> representing the multiplication of the <see cref="Size"/> and the specified <see cref="Scale"/>.
|
||||
@ -184,7 +184,7 @@ public readonly struct Size : IEquatable<Size>
|
||||
/// <param name="size">The <see cref="Size"/> to scale.</param>
|
||||
/// <param name="scale">The scaling factor.</param>
|
||||
/// <returns>A new <see cref="Size"/> representing the multiplication of the <see cref="Size"/> and the specified <see cref="Scale"/>.</returns>
|
||||
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
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
|
||||
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
@ -52,6 +52,10 @@
|
||||
<DefineConstants>RELEASE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
|
||||
<Using Include="RGB.NET.Core.Compatibility.Net8" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="..\Resources\icon.png" Link="icon.png" Pack="true" PackagePath="\" />
|
||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
||||
|
||||
@ -20,8 +20,8 @@ public sealed class RGBSurface : AbstractBindable, IDisposable
|
||||
|
||||
private readonly Stopwatch _deltaTimeCounter;
|
||||
|
||||
private readonly IList<IRGBDevice> _devices = new List<IRGBDevice>();
|
||||
private readonly IList<IUpdateTrigger> _updateTriggers = new List<IUpdateTrigger>();
|
||||
private readonly IList<IRGBDevice> _devices = [];
|
||||
private readonly IList<IUpdateTrigger> _updateTriggers = [];
|
||||
private readonly List<ILedGroup> _ledGroups = [];
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -69,7 +69,7 @@ public abstract class AbstractBrush : AbstractDecoratable<IBrushDecorator>, IBru
|
||||
/// <param name="rectangle">The rectangle in which the brush should be drawn.</param>
|
||||
/// <param name="renderTarget">The target (key/point) from which the color should be taken.</param>
|
||||
/// <param name="color">The <see cref="Color"/> to be modified.</param>
|
||||
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 @@ public abstract class AbstractBrush : AbstractDecoratable<IBrushDecorator>, IBru
|
||||
/// <param name="rectangle">The rectangle in which the brush should be drawn.</param>
|
||||
/// <param name="renderTarget">The target (key/point) from which the color should be taken.</param>
|
||||
/// <returns>The color at the specified point.</returns>
|
||||
protected abstract Color GetColorAtPoint(in Rectangle rectangle, in RenderTarget renderTarget);
|
||||
protected abstract Color GetColorAtPoint(Rectangle rectangle, RenderTarget renderTarget);
|
||||
|
||||
/// <summary>
|
||||
/// Finalizes the color by appliing the overall brightness and opacity.<br/>
|
||||
|
||||
@ -41,7 +41,7 @@ public sealed class SolidColorBrush : AbstractBrush
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override Color GetColorAtPoint(in Rectangle rectangle, in RenderTarget renderTarget) => Color;
|
||||
protected override Color GetColorAtPoint(Rectangle rectangle, RenderTarget renderTarget) => Color;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ public sealed class TextureBrush : AbstractBrush
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
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];
|
||||
|
||||
@ -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
|
||||
}
|
||||
@ -20,12 +20,12 @@ public interface ITexture
|
||||
/// </summary>
|
||||
/// <param name="point">The location to get the color from.</param>
|
||||
/// <returns>The color at the specified location.</returns>
|
||||
Color this[in Point point] { get; }
|
||||
Color this[Point point] { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sampled color inside the specified rectangle.
|
||||
/// </summary>
|
||||
/// <param name="rectangle">The rectangle to get the color from.</param>
|
||||
/// <returns>The sampled color.</returns>
|
||||
Color this[in Rectangle rectangle] { get; }
|
||||
Color this[Rectangle rectangle] { get; }
|
||||
}
|
||||
@ -39,7 +39,7 @@ public abstract class PixelTexture<T> : ITexture
|
||||
public Size Size { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual Color this[in Point point]
|
||||
public virtual Color this[Point point]
|
||||
{
|
||||
get
|
||||
{
|
||||
@ -52,7 +52,7 @@ public abstract class PixelTexture<T> : ITexture
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual Color this[in Rectangle rectangle]
|
||||
public virtual Color this[Rectangle rectangle]
|
||||
{
|
||||
get
|
||||
{
|
||||
@ -126,7 +126,7 @@ public abstract class PixelTexture<T> : ITexture
|
||||
/// </summary>
|
||||
/// <param name="pixel">The pixel-data to convert.</param>
|
||||
/// <returns>The color represented by the specified pixel-data.</returns>
|
||||
protected abstract Color GetColor(in ReadOnlySpan<T> pixel);
|
||||
protected abstract Color GetColor(ReadOnlySpan<T> pixel);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the pixel-data at the specified location.
|
||||
@ -189,7 +189,7 @@ public sealed class PixelTexture : PixelTexture<Color>
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected override Color GetColor(in ReadOnlySpan<Color> pixel) => pixel[0];
|
||||
protected override Color GetColor(ReadOnlySpan<Color> pixel) => pixel[0];
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -22,7 +22,7 @@ public sealed class AverageColorSampler : ISampler<Color>
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
public unsafe void Sample(in SamplerInfo<Color> info, in Span<Color> pixelData)
|
||||
public unsafe void Sample(SamplerInfo<Color> info, Span<Color> pixelData)
|
||||
{
|
||||
int count = info.Width * info.Height;
|
||||
if (count == 0) return;
|
||||
|
||||
@ -13,5 +13,5 @@ public interface ISampler<T>
|
||||
/// </summary>
|
||||
/// <param name="info">The information containing the data to sample.</param>
|
||||
/// <param name="pixelData">The buffer used to write the resulting pixel to.</param>
|
||||
void Sample(in SamplerInfo<T> info, in Span<T> pixelData);
|
||||
void Sample(SamplerInfo<T> info, Span<T> pixelData);
|
||||
}
|
||||
@ -44,7 +44,7 @@ public readonly ref struct SamplerInfo<T>
|
||||
/// <param name="width">The width of the region the data comes from.</param>
|
||||
/// <param name="height">The height of region the data comes from.</param>
|
||||
/// <param name="data">The data to sample.</param>
|
||||
public SamplerInfo(int x, int y, int width, int height, int stride, int dataPerPixel, in ReadOnlySpan<T> data)
|
||||
public SamplerInfo(int x, int y, int width, int height, int stride, int dataPerPixel, ReadOnlySpan<T> data)
|
||||
{
|
||||
this._x = x;
|
||||
this._y = y;
|
||||
|
||||
@ -29,13 +29,13 @@ public abstract class AbstractUpdateTrigger : AbstractBindable, IUpdateTrigger
|
||||
/// Invokes the <see cref="Starting"/>-event.
|
||||
/// </summary>
|
||||
/// <param name="updateData">Optional custom-data passed to the subscribers of the <see cref="Starting"/>.event.</param>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Invokes the <see cref="Update"/>-event.
|
||||
/// </summary>
|
||||
/// <param name="updateData">Optional custom-data passed to the subscribers of the <see cref="Update"/>.event.</param>
|
||||
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);
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract void Start();
|
||||
|
||||
@ -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<string, object?> _data = [];
|
||||
|
||||
#endregion
|
||||
@ -65,7 +68,7 @@ public sealed class CustomUpdateData : ICustomUpdateData
|
||||
/// <returns>The value represented by the specified key.</returns>
|
||||
public object? this[string key]
|
||||
{
|
||||
get => _data.TryGetValue(key, out object? data) ? data : default;
|
||||
get => _data.GetValueOrDefault(key);
|
||||
set => _data[key] = value;
|
||||
}
|
||||
|
||||
|
||||
@ -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<TIdentifier, TData> : AbstractReferenceCountin
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
private readonly object _dataLock = new();
|
||||
private readonly Lock _dataLock = new();
|
||||
private readonly IDeviceUpdateTrigger _updateTrigger;
|
||||
private readonly Dictionary<TIdentifier, TData> _currentDataSet = [];
|
||||
|
||||
@ -80,7 +81,7 @@ public abstract class UpdateQueue<TIdentifier, TData> : AbstractReferenceCountin
|
||||
/// Performs the update this queue is responsible for.
|
||||
/// </summary>
|
||||
/// <param name="dataSet">The set of data that needs to be updated.</param>
|
||||
protected abstract bool Update(in ReadOnlySpan<(TIdentifier key, TData color)> dataSet);
|
||||
protected abstract bool Update(ReadOnlySpan<(TIdentifier key, TData color)> dataSet);
|
||||
|
||||
/// <summary>
|
||||
/// Sets or merges the provided data set in the current dataset and notifies the trigger that there is new data available.
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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;
|
||||
/// <summary>
|
||||
@ -76,7 +77,7 @@ public sealed class AsusDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
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()),
|
||||
|
||||
@ -43,7 +43,7 @@ public sealed class AsusUpdateQueue : UpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@ -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
|
||||
}
|
||||
@ -37,8 +37,8 @@ public sealed class AsusKeyboardRGBDevice : AsusRGBDevice<AsusKeyboardRGBDeviceI
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public static readonly List<AsusKeyboardExtraMapping> 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
|
||||
|
||||
@ -13,7 +13,6 @@ public sealed class AsusKeyboardRGBDeviceInfo : AsusRGBDeviceInfo, IKeyboardDevi
|
||||
|
||||
/// <summary>
|
||||
/// The ASUS SDK returns useless names for notebook keyboards, possibly for others as well.
|
||||
/// Keep a list of those and rely on <see cref="WMIHelper.GetSystemModelInfo()"/> to get the real model
|
||||
/// </summary>
|
||||
private static readonly List<string> GENERIC_DEVICE_NAMES = ["NotebookKeyboard"];
|
||||
|
||||
@ -37,7 +36,7 @@ public sealed class AsusKeyboardRGBDeviceInfo : AsusRGBDeviceInfo, IKeyboardDevi
|
||||
|
||||
#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
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
|
||||
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
@ -51,13 +51,13 @@
|
||||
<DefineConstants>RELEASE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="..\Resources\icon.png" Link="icon.png" Pack="true" PackagePath="\" />
|
||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
|
||||
<Using Include="RGB.NET.Core.Compatibility.Net8" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Management" Version="7.0.0" />
|
||||
<Content Include="..\Resources\icon.png" Link="icon.png" Pack="true" PackagePath="\" />
|
||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -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;
|
||||
/// <summary>
|
||||
|
||||
@ -37,7 +37,7 @@ public sealed class CoolerMasterUpdateQueue : UpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
|
||||
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
@ -51,6 +51,10 @@
|
||||
<DefineConstants>RELEASE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
|
||||
<Using Include="RGB.NET.Core.Compatibility.Net8" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="..\Resources\icon.png" Link="icon.png" Pack="true" PackagePath="\" />
|
||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
||||
|
||||
@ -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;
|
||||
/// <summary>
|
||||
|
||||
@ -40,7 +40,7 @@ public sealed class CorsairDeviceUpdateQueue : UpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override unsafe bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
protected override unsafe bool Update(ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@ -133,7 +133,7 @@ internal static unsafe class _CUESDK
|
||||
if (OperatingSystem.IsWindows())
|
||||
possibleLibraryPaths = Environment.Is64BitProcess ? CorsairDeviceProvider.PossibleX64NativePaths : CorsairDeviceProvider.PossibleX86NativePaths;
|
||||
else
|
||||
possibleLibraryPaths = Enumerable.Empty<string>();
|
||||
possibleLibraryPaths = [];
|
||||
|
||||
return possibleLibraryPaths.Select(Environment.ExpandEnvironmentVariables);
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
|
||||
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
@ -52,6 +52,10 @@
|
||||
<DefineConstants>RELEASE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
|
||||
<Using Include="RGB.NET.Core.Compatibility.Net8" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="..\Resources\icon.png" Link="icon.png" Pack="true" PackagePath="\" />
|
||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
||||
|
||||
@ -5,6 +5,7 @@ using System;
|
||||
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;
|
||||
/// <summary>
|
||||
|
||||
@ -124,15 +124,18 @@ public class CorsairCustomRGBDeviceInfo : CorsairRGBDeviceInfo
|
||||
// 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";
|
||||
|
||||
case CorsairChannelDeviceType.DAP:
|
||||
|
||||
@ -35,7 +35,7 @@ public class CorsairDeviceUpdateQueue : UpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@ -64,7 +64,7 @@ internal static class _CUESDK
|
||||
if (OperatingSystem.IsWindows())
|
||||
possibleLibraryPaths = Environment.Is64BitProcess ? CorsairLegacyDeviceProvider.PossibleX64NativePaths : CorsairLegacyDeviceProvider.PossibleX86NativePaths;
|
||||
else
|
||||
possibleLibraryPaths = Enumerable.Empty<string>();
|
||||
possibleLibraryPaths = [];
|
||||
|
||||
return possibleLibraryPaths.Select(Environment.ExpandEnvironmentVariables);
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
|
||||
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
@ -52,6 +52,10 @@
|
||||
<DefineConstants>RELEASE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
|
||||
<Using Include="RGB.NET.Core.Compatibility.Net8" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="..\Resources\icon.png" Link="icon.png" Pack="true" PackagePath="\" />
|
||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
||||
|
||||
@ -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;
|
||||
/// <summary>
|
||||
|
||||
@ -59,7 +59,7 @@ public sealed class E131UpdateQueue : UpdateQueue
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
|
||||
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
@ -51,6 +51,10 @@
|
||||
<DefineConstants>RELEASE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
|
||||
<Using Include="RGB.NET.Core.Compatibility.Net8" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="..\Resources\icon.png" Link="icon.png" Pack="true" PackagePath="\" />
|
||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
||||
|
||||
@ -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;
|
||||
/// <summary>
|
||||
|
||||
@ -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
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
|
||||
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
@ -51,6 +51,10 @@
|
||||
<DefineConstants>RELEASE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
|
||||
<Using Include="RGB.NET.Core.Compatibility.Net8" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="..\Resources\icon.png" Link="icon.png" Pack="true" PackagePath="\" />
|
||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
||||
|
||||
@ -104,7 +104,9 @@ public sealed class LightspeedHIDLoader<TLed, TData> : IEnumerable<HIDDeviceDefi
|
||||
Dictionary<byte, HidDevice> 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 @@ public sealed class LightspeedHIDLoader<TLed, TData> : IEnumerable<HIDDeviceDefi
|
||||
getConnectedDevices.Init(LOGITECH_RECEIVER_ADDRESS, LOGITECH_GET_REGISTER_REQUEST);
|
||||
|
||||
stream.Write(getConnectedDevices.AsSpan());
|
||||
stream.Read(response.AsSpan());
|
||||
stream.ReadExactly(response.AsSpan());
|
||||
|
||||
bool wirelessNotifications = (response.Data01 & 1) == 1;
|
||||
if (!wirelessNotifications)
|
||||
@ -148,7 +150,7 @@ public sealed class LightspeedHIDLoader<TLed, TData> : IEnumerable<HIDDeviceDefi
|
||||
getConnectedDevices.Data1 = 1;
|
||||
|
||||
stream.Write(getConnectedDevices.AsSpan());
|
||||
stream.Read(response.AsSpan());
|
||||
stream.ReadExactly(response.AsSpan());
|
||||
|
||||
if (getConnectedDevices.FeatureIndex == 0x8f)
|
||||
{
|
||||
@ -162,7 +164,7 @@ public sealed class LightspeedHIDLoader<TLed, TData> : IEnumerable<HIDDeviceDefi
|
||||
getConnectedDevices.FeatureCommand = 0x02;
|
||||
|
||||
stream.Write(getConnectedDevices.AsSpan());
|
||||
stream.Read(response.AsSpan());
|
||||
stream.ReadExactly(response.AsSpan());
|
||||
int deviceCount = response.Data01;
|
||||
if (deviceCount <= 0)
|
||||
return map;
|
||||
@ -178,7 +180,7 @@ public sealed class LightspeedHIDLoader<TLed, TData> : IEnumerable<HIDDeviceDefi
|
||||
for (int i = 0; i < deviceCount; i++)
|
||||
{
|
||||
FapResponse devices = new();
|
||||
stream.Read(devices.AsSpan());
|
||||
stream.ReadExactly(devices.AsSpan());
|
||||
int wirelessPid = (devices.Data02 << 8) | devices.Data01;
|
||||
if (devices.DeviceIndex != 0xff)
|
||||
map.Add(wirelessPid, devices.DeviceIndex);
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using HidSharp;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.Logitech.Native;
|
||||
@ -21,7 +22,7 @@ public class LogitechDeviceProvider : AbstractRGBDeviceProvider
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly object _lock = new();
|
||||
private static readonly Lock _lock = new();
|
||||
|
||||
private static LogitechDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
@ -70,6 +71,8 @@ public class LogitechDeviceProvider : AbstractRGBDeviceProvider
|
||||
{ 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 },
|
||||
|
||||
@ -63,7 +63,7 @@ internal static class _LogitechGSDK
|
||||
if (OperatingSystem.IsWindows())
|
||||
possibleLibraryPaths = Environment.Is64BitProcess ? LogitechDeviceProvider.PossibleX64NativePaths : LogitechDeviceProvider.PossibleX86NativePaths;
|
||||
else
|
||||
possibleLibraryPaths = Enumerable.Empty<string>();
|
||||
possibleLibraryPaths = [];
|
||||
|
||||
return possibleLibraryPaths.Select(Environment.ExpandEnvironmentVariables);
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ public sealed class LogitechPerDeviceUpdateQueue : UpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@ -24,7 +24,7 @@ public sealed class LogitechPerKeyUpdateQueue : UpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
|
||||
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
@ -52,6 +52,10 @@
|
||||
<DefineConstants>RELEASE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
|
||||
<Using Include="RGB.NET.Core.Compatibility.Net8" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="..\Resources\icon.png" Link="icon.png" Pack="true" PackagePath="\" />
|
||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
||||
|
||||
@ -33,7 +33,7 @@ public sealed class LogitechZoneUpdateQueue : UpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@ -34,7 +34,7 @@ public sealed class MsiDeviceUpdateQueue : UpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@ -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;
|
||||
/// <summary>
|
||||
|
||||
@ -68,7 +68,7 @@ internal static class _MsiSDK
|
||||
if (OperatingSystem.IsWindows())
|
||||
possibleLibraryPaths = Environment.Is64BitProcess ? MsiDeviceProvider.PossibleX64NativePaths : MsiDeviceProvider.PossibleX86NativePaths;
|
||||
else
|
||||
possibleLibraryPaths = Enumerable.Empty<string>();
|
||||
possibleLibraryPaths = [];
|
||||
|
||||
return possibleLibraryPaths.Select(Environment.ExpandEnvironmentVariables);
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
|
||||
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
@ -51,6 +51,10 @@
|
||||
<DefineConstants>RELEASE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
|
||||
<Using Include="RGB.NET.Core.Compatibility.Net8" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="..\Resources\icon.png" Link="icon.png" Pack="true" PackagePath="\" />
|
||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
||||
|
||||
@ -25,7 +25,7 @@ public sealed class LimitedColorUpdateQueue : MidiUpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
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 @@ public sealed class LimitedColorUpdateQueue : MidiUpdateQueue
|
||||
/// </summary>
|
||||
/// <param name="color">The <see cref="Color"/> to convert.</param>
|
||||
/// <returns>The novation-representation of the <see cref="Color"/>.</returns>
|
||||
private static int ConvertColor(in Color color)
|
||||
private static int ConvertColor(Color color)
|
||||
{
|
||||
(double hue, double _, double value) = color.GetHSV();
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ public abstract class MidiUpdateQueue : UpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
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 @@ public abstract class MidiUpdateQueue : UpdateQueue
|
||||
/// <param name="key">The key used to identify the LED to update.</param>
|
||||
/// <param name="color">The color to send.</param>
|
||||
/// <returns>The message created out of the data set.</returns>
|
||||
protected abstract ShortMessage? CreateMessage(object key, in Color color);
|
||||
protected abstract ShortMessage? CreateMessage(object key, Color color);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Dispose()
|
||||
|
||||
@ -151,7 +151,7 @@ public sealed class RGBColorUpdateQueue : MidiUpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
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 sealed class RGBColorUpdateQueue : MidiUpdateQueue
|
||||
/// </summary>
|
||||
/// <param name="color">The <see cref="Color"/> to convert.</param>
|
||||
/// <returns>The novation-representation of the <see cref="Color"/>.</returns>
|
||||
private static int ConvertColor(in Color color)
|
||||
private static int ConvertColor(Color color)
|
||||
{
|
||||
int bestVelocity = 0;
|
||||
double bestMatchDistance = double.MaxValue;
|
||||
|
||||
@ -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;
|
||||
/// <summary>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
|
||||
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
@ -51,6 +51,10 @@
|
||||
<DefineConstants>RELEASE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
|
||||
<Using Include="RGB.NET.Core.Compatibility.Net8" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="..\Resources\icon.png" Link="icon.png" Pack="true" PackagePath="\" />
|
||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
||||
|
||||
@ -48,7 +48,7 @@ public sealed class OpenRGBUpdateQueue : UpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@ -3,6 +3,7 @@ using RGB.NET.Core;
|
||||
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<OpenRgbClient> _clients = [];
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
|
||||
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
@ -51,13 +51,17 @@
|
||||
<DefineConstants>RELEASE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
|
||||
<Using Include="RGB.NET.Core.Compatibility.Net8" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="..\Resources\icon.png" Link="icon.png" Pack="true" PackagePath="\" />
|
||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="OpenRGB.NET" Version="2.2.0" />
|
||||
<PackageReference Include="OpenRGB.NET" Version="3.1.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -44,7 +44,7 @@ public sealed class PicoPiBulkUpdateQueue : UpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@ -41,7 +41,7 @@ public sealed class PicoPiHIDUpdateQueue : UpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@ -212,7 +212,7 @@ public sealed class PicoPiSDK : IDisposable
|
||||
/// </summary>
|
||||
/// <param name="data">The data to send.</param>
|
||||
/// <param name="channel">The channel to update.</param>
|
||||
public void SendHidUpdate(in Span<byte> buffer, int channel)
|
||||
public void SendHidUpdate(Span<byte> buffer, int channel)
|
||||
{
|
||||
int chunks = buffer.Length / HID_OFFSET_MULTIPLIER;
|
||||
if ((chunks * HID_OFFSET_MULTIPLIER) < buffer.Length) chunks++;
|
||||
@ -232,7 +232,7 @@ public sealed class PicoPiSDK : IDisposable
|
||||
/// <param name="channel">The channel to update.</param>
|
||||
/// <param name="chunk">The chunk id of the packet. (Required if packets are fragmented.)</param>
|
||||
/// <param name="update">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.)</param>
|
||||
public void SendHidUpdate(in Span<byte> data, int channel, int chunk, bool update)
|
||||
public void SendHidUpdate(Span<byte> data, int channel, int chunk, bool update)
|
||||
{
|
||||
if (data.Length == 0) return;
|
||||
|
||||
@ -253,7 +253,7 @@ public sealed class PicoPiSDK : IDisposable
|
||||
/// </remarks>
|
||||
/// <param name="data">The data packet to send.</param>
|
||||
/// <param name="channel">The channel to update.</param>
|
||||
public void SendBulkUpdate(in Span<byte> data, int channel)
|
||||
public void SendBulkUpdate(Span<byte> data, int channel)
|
||||
{
|
||||
if ((data.Length == 0) || !IsBulkSupported) return;
|
||||
|
||||
|
||||
@ -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;
|
||||
/// <summary>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
|
||||
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
@ -51,6 +51,10 @@
|
||||
<DefineConstants>RELEASE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
|
||||
<Using Include="RGB.NET.Core.Compatibility.Net8" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="..\Resources\icon.png" Link="icon.png" Pack="true" PackagePath="\" />
|
||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
||||
|
||||
@ -25,7 +25,7 @@ public sealed class RazerChromaLinkUpdateQueue : RazerUpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
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];
|
||||
|
||||
|
||||
@ -13,10 +13,17 @@ public static class LedMappings
|
||||
/// </summary>
|
||||
public static LedMapping<int> 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
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ public abstract class RazerUpdateQueue : UpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
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 abstract class RazerUpdateQueue : UpdateQueue
|
||||
/// </summary>
|
||||
/// <param name="dataSet">The data to be updated.</param>
|
||||
/// <returns>An <see cref="IntPtr"/> pointing to the effect parameter struct.</returns>
|
||||
protected abstract nint CreateEffectParams(in ReadOnlySpan<(object key, Color color)> dataSet);
|
||||
protected abstract nint CreateEffectParams(ReadOnlySpan<(object key, Color color)> dataSet);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -25,7 +25,7 @@ public sealed class RazerHeadsetUpdateQueue : RazerUpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
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];
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ public sealed class RazerKeyboardUpdateQueue : RazerUpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
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];
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ public sealed class RazerKeypadUpdateQueue : RazerUpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
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];
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ public sealed class RazerMouseUpdateQueue : RazerUpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
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];
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ public sealed class RazerMousepadUpdateQueue : RazerUpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
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];
|
||||
|
||||
|
||||
@ -64,7 +64,7 @@ internal static class _RazerSDK
|
||||
if (OperatingSystem.IsWindows())
|
||||
possibleLibraryPaths = Environment.Is64BitProcess ? RazerDeviceProvider.PossibleX64NativePaths : RazerDeviceProvider.PossibleX86NativePaths;
|
||||
else
|
||||
possibleLibraryPaths = Enumerable.Empty<string>();
|
||||
possibleLibraryPaths = [];
|
||||
|
||||
return possibleLibraryPaths.Select(Environment.ExpandEnvironmentVariables);
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
|
||||
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
@ -52,6 +52,10 @@
|
||||
<DefineConstants>RELEASE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
|
||||
<Using Include="RGB.NET.Core.Compatibility.Net8" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="..\Resources\icon.png" Link="icon.png" Pack="true" PackagePath="\" />
|
||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
||||
|
||||
@ -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;
|
||||
/// <summary>
|
||||
@ -139,9 +140,10 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider
|
||||
{ 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 sealed class RazerDeviceProvider : AbstractRGBDeviceProvider
|
||||
{ 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 sealed class RazerDeviceProvider : AbstractRGBDeviceProvider
|
||||
{ 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 sealed class RazerDeviceProvider : AbstractRGBDeviceProvider
|
||||
{ 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 sealed class RazerDeviceProvider : AbstractRGBDeviceProvider
|
||||
{ 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
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user