mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-13 01:58:30 +00:00
Compare commits
139 Commits
v2.0.0-pre
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| b0acc61618 | |||
| 13f3dde185 | |||
| 845efb6929 | |||
|
|
02d695c4dd | ||
|
|
35a4033521 | ||
|
|
dc6715b236 | ||
|
|
34b04523de | ||
|
|
a96b994e61 | ||
|
|
f26b3c193a | ||
| c0828c1d01 | |||
| 7c65b1d0bf | |||
| 826a5104de | |||
|
|
80b2365c31 | ||
| 8756ec98f3 | |||
| d5ce5fcee7 | |||
|
|
6a47887c18 | ||
| eb4ea71d01 | |||
|
|
b0f05ab399 | ||
| e1475859c6 | |||
|
|
9499b31c13 | ||
| 7fabc71b28 | |||
|
|
01bad00d8a | ||
|
|
1deb1b9f2f | ||
|
|
66843a21e5 | ||
| 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 | |||
| 1b9531a86f | |||
| 5f71ffdf1f | |||
| 835987155c | |||
| 31db13cb3d | |||
| 51373e4441 | |||
| 8f7e24ba33 | |||
| c0adbad599 | |||
| 4773e0df74 | |||
| 29e68ae8fe | |||
| 5aac20e982 | |||
| d1e71ef827 | |||
| 08d526a7a4 | |||
| acd4462b2a | |||
| e58d26d58d | |||
| 417b9be3f9 | |||
| ced13e9ec2 | |||
| 4f0f25e34e | |||
| 58ed8bb2f1 | |||
|
|
d82eebd769 | ||
|
|
3ca782a6a7 | ||
| a4bd797912 | |||
|
|
b56a50ab08 | ||
| 50e20a7bdd | |||
|
|
4959c6e8ad | ||
| ef980f754c | |||
| 1df23a6b36 | |||
| 16b2877dce | |||
| 657bca29b0 | |||
| 6ba7e44e3c | |||
| 9004c50d78 | |||
| b2848cfbaa | |||
| 23bd1119f2 | |||
| 67672be54c | |||
| 3400edcf93 | |||
|
|
1fe8cab0a4 | ||
| 95f162de2d | |||
| f07d228408 | |||
| 1312566eb0 | |||
| 9aee9a1640 | |||
| c89bbfea96 | |||
| af43c0ae87 | |||
| 7898c50eed | |||
| 505e7481f7 | |||
| 4f478879c2 | |||
|
|
8b1c5927d3 | ||
| 5a104eaf24 | |||
| 79f71bab29 | |||
| aeab93001f | |||
| d85f1559b3 | |||
|
|
1bd5b54892 | ||
|
|
c11965eb3a | ||
|
|
cadf96634e | ||
|
|
5cb5962c1e |
54
.github/workflows/ci.yml
vendored
54
.github/workflows/ci.yml
vendored
@ -1,12 +1,15 @@
|
|||||||
name: RGB.NET-CI
|
name: RGB.NET-CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
workflow_dispatch:
|
||||||
branches: [ Development ]
|
inputs:
|
||||||
paths:
|
version:
|
||||||
- '**.cs'
|
description: 'version'
|
||||||
- '**.csproj'
|
required: true
|
||||||
- '**.yml'
|
type: string
|
||||||
|
increment:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@ -14,48 +17,35 @@ jobs:
|
|||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4.1.1
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Setup .NET
|
- name: Setup .NET
|
||||||
uses: actions/setup-dotnet@v3
|
uses: actions/setup-dotnet@v4
|
||||||
with:
|
with:
|
||||||
dotnet-version: |
|
dotnet-version: |
|
||||||
|
9.0.x
|
||||||
8.0.x
|
8.0.x
|
||||||
7.0.x
|
|
||||||
6.0.x
|
|
||||||
- name: Git Semantic Version
|
|
||||||
id: versioning
|
|
||||||
uses: PaulHatch/semantic-version@v4.0.3
|
|
||||||
with:
|
|
||||||
short_tags: false
|
|
||||||
format: "${major}.${minor}.${patch}-prerelease.${increment}"
|
|
||||||
- name: Restore dependencies
|
- name: Restore dependencies
|
||||||
run: dotnet restore
|
run: dotnet restore
|
||||||
- name: Build
|
- name: Build
|
||||||
run: dotnet build --no-restore --configuration Release /p:Version=${{ steps.versioning.outputs.version }}
|
run: dotnet build --no-restore --configuration Release /p:Version=${{ github.event.inputs.version }}-prerelease.${{ github.event.inputs.increment }}
|
||||||
- name: Test
|
- name: Test
|
||||||
run: dotnet test --no-build --verbosity normal --configuration Release
|
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@v2.2.4
|
uses: actions/upload-artifact@v4.3.1
|
||||||
with:
|
with:
|
||||||
name: RGB.NET-NET6
|
name: RGB.NET-NET9
|
||||||
path: bin/net6.0/RGB.NET.*.dll
|
path: bin/net9.0/RGB.NET.*.dll
|
||||||
if-no-files-found: error
|
|
||||||
- name: Upload a Build Artifact NET7
|
|
||||||
uses: actions/upload-artifact@v2.2.4
|
|
||||||
with:
|
|
||||||
name: RGB.NET-NET7
|
|
||||||
path: bin/net7.0/RGB.NET.*.dll
|
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
- name: Upload a Build Artifact NET8
|
- name: Upload a Build Artifact NET8
|
||||||
uses: actions/upload-artifact@v2.2.4
|
uses: actions/upload-artifact@v4.3.1
|
||||||
with:
|
with:
|
||||||
name: RGB.NET-NET8
|
name: RGB.NET-NET8
|
||||||
path: bin/net8.0/RGB.NET.*.dll
|
path: bin/net8.0/RGB.NET.*.dll
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
- name: Upload Nuget Build Artifact
|
- name: Upload Nuget Build Artifact
|
||||||
uses: actions/upload-artifact@v2.2.4
|
uses: actions/upload-artifact@v4.3.1
|
||||||
with:
|
with:
|
||||||
name: RGB.NET-Nugets
|
name: RGB.NET-Nugets
|
||||||
path: bin/*nupkg
|
path: bin/*nupkg
|
||||||
@ -64,9 +54,3 @@ jobs:
|
|||||||
run: dotnet nuget push **\*.nupkg --skip-duplicate --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json
|
run: dotnet nuget push **\*.nupkg --skip-duplicate --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json
|
||||||
- name: Symbols Push
|
- name: Symbols Push
|
||||||
run: dotnet nuget push **\*.snupkg --skip-duplicate --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json
|
run: dotnet nuget push **\*.snupkg --skip-duplicate --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json
|
||||||
- name: Create Tag
|
|
||||||
uses: mathieudutour/github-tag-action@v6.1
|
|
||||||
with:
|
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
custom_tag: ${{ steps.versioning.outputs.version }}
|
|
||||||
tag_prefix: v
|
|
||||||
|
|||||||
7
.github/workflows/pr_verify.yml
vendored
7
.github/workflows/pr_verify.yml
vendored
@ -10,14 +10,13 @@ jobs:
|
|||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4.1.1
|
||||||
- name: Setup .NET
|
- name: Setup .NET
|
||||||
uses: actions/setup-dotnet@v3
|
uses: actions/setup-dotnet@v4
|
||||||
with:
|
with:
|
||||||
dotnet-version: |
|
dotnet-version: |
|
||||||
|
9.0.x
|
||||||
8.0.x
|
8.0.x
|
||||||
7.0.x
|
|
||||||
6.0.x
|
|
||||||
- name: Restore dependencies
|
- name: Restore dependencies
|
||||||
run: dotnet restore
|
run: dotnet restore
|
||||||
- name: Build
|
- name: Build
|
||||||
|
|||||||
49
.github/workflows/release.yml
vendored
49
.github/workflows/release.yml
vendored
@ -1,60 +1,47 @@
|
|||||||
name: RGB.NET-Release
|
name: RGB.NET-Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
workflow_dispatch:
|
||||||
branches: [ master ]
|
inputs:
|
||||||
paths:
|
version:
|
||||||
- '**.cs'
|
description: 'version'
|
||||||
- '**.csproj'
|
required: true
|
||||||
- '**.yml'
|
type: string
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4.1.1
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Setup .NET
|
- name: Setup .NET
|
||||||
uses: actions/setup-dotnet@v3
|
uses: actions/setup-dotnet@v4
|
||||||
with:
|
with:
|
||||||
dotnet-version: |
|
dotnet-version: |
|
||||||
|
9.0.x
|
||||||
8.0.x
|
8.0.x
|
||||||
7.0.x
|
|
||||||
6.0.x
|
|
||||||
- name: Git Semantic Version
|
|
||||||
id: versioning
|
|
||||||
uses: PaulHatch/semantic-version@v4.0.3
|
|
||||||
with:
|
|
||||||
short_tags: false
|
|
||||||
format: "${major}.${minor}.${patch}"
|
|
||||||
- name: Restore dependencies
|
- name: Restore dependencies
|
||||||
run: dotnet restore
|
run: dotnet restore
|
||||||
- name: Build
|
- name: Build
|
||||||
run: dotnet build --no-restore --configuration Release /p:Version=${{ steps.versioning.outputs.version }}
|
run: dotnet build --no-restore --configuration Release /p:Version=${{ github.event.inputs.version }}
|
||||||
- name: Test
|
- name: Test
|
||||||
run: dotnet test --no-build --verbosity normal --configuration Release
|
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@v2.2.4
|
uses: actions/upload-artifact@v4.3.1
|
||||||
with:
|
with:
|
||||||
name: RGB.NET-NET6
|
name: RGB.NET-NET9
|
||||||
path: bin/net6.0/RGB.NET.*.dll
|
path: bin/net9.0/RGB.NET.*.dll
|
||||||
if-no-files-found: error
|
|
||||||
- name: Upload a Build Artifact NET7
|
|
||||||
uses: actions/upload-artifact@v2.2.4
|
|
||||||
with:
|
|
||||||
name: RGB.NET-NET7
|
|
||||||
path: bin/net7.0/RGB.NET.*.dll
|
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
- name: Upload a Build Artifact NET8
|
- name: Upload a Build Artifact NET8
|
||||||
uses: actions/upload-artifact@v2.2.4
|
uses: actions/upload-artifact@v4.3.1
|
||||||
with:
|
with:
|
||||||
name: RGB.NET-NET8
|
name: RGB.NET-NET8
|
||||||
path: bin/net8.0/RGB.NET.*.dll
|
path: bin/net8.0/RGB.NET.*.dll
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
- name: Upload Nuget Build Artifact
|
- name: Upload Nuget Build Artifact
|
||||||
uses: actions/upload-artifact@v2.2.4
|
uses: actions/upload-artifact@v4.3.1
|
||||||
with:
|
with:
|
||||||
name: RGB.NET-Nugets
|
name: RGB.NET-Nugets
|
||||||
path: bin/*nupkg
|
path: bin/*nupkg
|
||||||
@ -62,8 +49,8 @@ jobs:
|
|||||||
- name: Release
|
- name: Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ steps.versioning.outputs.version_tag }}
|
tag_name: v${{ github.event.inputs.version }}
|
||||||
generate_release_notes: true
|
generate_release_notes: true
|
||||||
files: bin/net8.0/RGB.NET.*.dll
|
files: bin/net9.0/RGB.NET.*.dll
|
||||||
- name: Nuget Push
|
- name: Nuget Push
|
||||||
run: dotnet nuget push **\*.nupkg --skip-duplicate --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json
|
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.
|
/// Converts the individual byte values of this <see cref="Color"/> to a human-readable string.
|
||||||
/// </summary>
|
/// </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>
|
/// <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>
|
/// <summary>
|
||||||
/// Tests whether the specified object is a <see cref="Color" /> and is equivalent to this <see cref="Color" />.
|
/// 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="color">The color to test.</param>
|
||||||
/// <param name="obj">The object 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>
|
/// <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>
|
/// <summary>
|
||||||
/// Tests whether the specified object is a <see cref="Color" /> and is equivalent to this <see cref="Color" />.
|
/// 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="color">The first color to test.</param>
|
||||||
/// <param name="color2">The second 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>
|
/// <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.R.EqualsInTolerance(color2.R)
|
||||||
&& color.G.EqualsInTolerance(color2.G)
|
&& color.G.EqualsInTolerance(color2.G)
|
||||||
&& color.B.EqualsInTolerance(color2.B);
|
&& color.B.EqualsInTolerance(color2.B);
|
||||||
@ -39,14 +39,14 @@ public sealed class DefaultColorBehavior : IColorBehavior
|
|||||||
/// Returns a hash code for this <see cref="Color" />.
|
/// Returns a hash code for this <see cref="Color" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>An integer value that specifies the hash code for this <see cref="Color" />.</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Blends a <see cref="Color"/> over this color.
|
/// Blends a <see cref="Color"/> over this color.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="baseColor">The <see cref="Color"/> to to blend over.</param>
|
/// <param name="baseColor">The <see cref="Color"/> to to blend over.</param>
|
||||||
/// <param name="blendColor">The <see cref="Color"/> to blend.</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;
|
if (blendColor.A.EqualsInTolerance(0)) return baseColor;
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@ public interface IColorBehavior
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">The color to convert.</param>
|
/// <param name="color">The color to convert.</param>
|
||||||
/// <returns>The string representation of the specified color.</returns>
|
/// <returns>The string representation of the specified color.</returns>
|
||||||
string ToString(in Color color);
|
string ToString(Color color);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests whether the specified object is a <see cref="Color" /> and is equivalent to this <see cref="Color" />.
|
/// 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="color">The color to test.</param>
|
||||||
/// <param name="obj">The object 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>
|
/// <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>
|
/// <summary>
|
||||||
/// Tests whether the specified object is a <see cref="Color" /> and is equivalent to this <see cref="Color" />.
|
/// 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="color">The first color to test.</param>
|
||||||
/// <param name="color2">The second 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>
|
/// <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>
|
/// <summary>
|
||||||
/// Returns a hash code for this <see cref="Color" />.
|
/// Returns a hash code for this <see cref="Color" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>An integer value that specifies the hash code for this <see cref="Color" />.</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Blends a <see cref="Color"/> over this color.
|
/// Blends a <see cref="Color"/> over this color.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="baseColor">The <see cref="Color"/> to to blend over.</param>
|
/// <param name="baseColor">The <see cref="Color"/> to to blend over.</param>
|
||||||
/// <param name="blendColor">The <see cref="Color"/> to blend.</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" />.
|
/// 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>
|
/// </summary>
|
||||||
/// <param name="color">The <see cref="T:RGB.NET.Core.Color" /> the values are copied from.</param>
|
/// <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)
|
: 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"/>.
|
/// Blends a <see cref="Color"/> over this color, as defined by the current <see cref="Behavior"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">The <see cref="Color"/> to blend.</param>
|
/// <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
|
#endregion
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ public readonly struct Color : IEquatable<Color>
|
|||||||
/// <param name="color1">The base color.</param>
|
/// <param name="color1">The base color.</param>
|
||||||
/// <param name="color2">The color to blend.</param>
|
/// <param name="color2">The color to blend.</param>
|
||||||
/// <returns>The blended color.</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Returns a value that indicates whether two specified <see cref="Color" /> are equal.
|
/// 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="color1">The first <see cref="Color" /> to compare.</param>
|
||||||
/// <param name="color2">The second <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>
|
/// <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>
|
/// <summary>
|
||||||
/// Returns a value that indicates whether two specified <see cref="Color" /> are equal.
|
/// 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="color1">The first <see cref="Color" /> to compare.</param>
|
||||||
/// <param name="color2">The second <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>
|
/// <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>
|
/// <summary>
|
||||||
/// Converts a <see cref="ValueTuple"/> of ARGB-components to a <see cref="Color"/>.
|
/// Converts a <see cref="ValueTuple"/> of ARGB-components to a <see cref="Color"/>.
|
||||||
|
|||||||
@ -16,21 +16,21 @@ public static class HSVColor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">The color to get the value from.</param>
|
/// <param name="color">The color to get the value from.</param>
|
||||||
/// <returns>The hue component value of the color.</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Gets the saturation component value (HSV-color space) of this <see cref="Color"/> in the range [0..1].
|
/// Gets the saturation component value (HSV-color space) of this <see cref="Color"/> in the range [0..1].
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">The color to get the value from.</param>
|
/// <param name="color">The color to get the value from.</param>
|
||||||
/// <returns>The saturation component value of the color.</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Gets the value component value (HSV-color space) of this <see cref="Color"/> in the range [0..1].
|
/// Gets the value component value (HSV-color space) of this <see cref="Color"/> in the range [0..1].
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">The color to get the value from.</param>
|
/// <param name="color">The color to get the value from.</param>
|
||||||
/// <returns>The value component value of the color.</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Gets the hue, saturation and value component values (HSV-color space) of this <see cref="Color"/>.
|
/// 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>
|
/// </summary>
|
||||||
/// <param name="color">The color to get the value from.</param>
|
/// <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>
|
/// <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);
|
=> CaclulateHSVFromRGB(color.R, color.G, color.B);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -55,7 +55,7 @@ public static class HSVColor
|
|||||||
/// <param name="saturation">The saturation value to add.</param>
|
/// <param name="saturation">The saturation value to add.</param>
|
||||||
/// <param name="value">The value value to add.</param>
|
/// <param name="value">The value value to add.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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();
|
(float cHue, float cSaturation, float cValue) = color.GetHSV();
|
||||||
return Create(color.A, cHue + hue, cSaturation + saturation, cValue + value);
|
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="saturation">The saturation value to subtract.</param>
|
||||||
/// <param name="value">The value value to subtract.</param>
|
/// <param name="value">The value value to subtract.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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();
|
(float cHue, float cSaturation, float cValue) = color.GetHSV();
|
||||||
return Create(color.A, cHue - hue, cSaturation - saturation, cValue - value);
|
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="saturation">The saturation value to multiply.</param>
|
||||||
/// <param name="value">The value value to multiply.</param>
|
/// <param name="value">The value value to multiply.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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();
|
(float cHue, float cSaturation, float cValue) = color.GetHSV();
|
||||||
return Create(color.A, cHue * hue, cSaturation * saturation, cValue * value);
|
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="saturation">The saturation value to divide.</param>
|
||||||
/// <param name="value">The value value to divide.</param>
|
/// <param name="value">The value value to divide.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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();
|
(float cHue, float cSaturation, float cValue) = color.GetHSV();
|
||||||
return Create(color.A, cHue / hue, cSaturation / saturation, cValue / value);
|
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="saturation">The saturation value to set.</param>
|
||||||
/// <param name="value">The value value to set.</param>
|
/// <param name="value">The value value to set.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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();
|
(float cHue, float cSaturation, float cValue) = color.GetHSV();
|
||||||
return Create(color.A, hue ?? cHue, saturation ?? cSaturation, value ?? cValue);
|
return Create(color.A, hue ?? cHue, saturation ?? cSaturation, value ?? cValue);
|
||||||
|
|||||||
@ -16,21 +16,21 @@ public static class HclColor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">The color to get the value from.</param>
|
/// <param name="color">The color to get the value from.</param>
|
||||||
/// <returns>The H component value of the color. </returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Gets the c component value (Hcl-color space) of this <see cref="Color"/> in the range [0..1].
|
/// Gets the c component value (Hcl-color space) of this <see cref="Color"/> in the range [0..1].
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">The color to get the value from.</param>
|
/// <param name="color">The color to get the value from.</param>
|
||||||
/// <returns>The c component value of the color. </returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Gets the l component value (Hcl-color space) of this <see cref="Color"/> in the range [0..1].
|
/// Gets the l component value (Hcl-color space) of this <see cref="Color"/> in the range [0..1].
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">The color to get the value from.</param>
|
/// <param name="color">The color to get the value from.</param>
|
||||||
/// <returns>The l component value of the color. </returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Gets the H, c and l component values (Hcl-color space) of this <see cref="Color"/>.
|
/// 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>
|
/// </summary>
|
||||||
/// <param name="color">The color to get the value from.</param>
|
/// <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>
|
/// <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);
|
=> CalculateHclFromRGB(color.R, color.G, color.B);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -55,7 +55,7 @@ public static class HclColor
|
|||||||
/// <param name="c">The c value to add.</param>
|
/// <param name="c">The c value to add.</param>
|
||||||
/// <param name="l">The l value to add.</param>
|
/// <param name="l">The l value to add.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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();
|
(float cH, float cC, float cL) = color.GetHcl();
|
||||||
return Create(color.A, cH + h, cC + c, cL + l);
|
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="c">The c value to subtract.</param>
|
||||||
/// <param name="l">The l value to subtract.</param>
|
/// <param name="l">The l value to subtract.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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();
|
(float cH, float cC, float cL) = color.GetHcl();
|
||||||
return Create(color.A, cH - h, cC - c, cL - l);
|
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="c">The c value to multiply.</param>
|
||||||
/// <param name="l">The l value to multiply.</param>
|
/// <param name="l">The l value to multiply.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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();
|
(float cH, float cC, float cL) = color.GetHcl();
|
||||||
return Create(color.A, cH * h, cC * c, cL * l);
|
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="c">The c value to divide.</param>
|
||||||
/// <param name="l">The l value to divide.</param>
|
/// <param name="l">The l value to divide.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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();
|
(float cH, float cC, float cL) = color.GetHcl();
|
||||||
return Create(color.A, cH / h, cC / c, cL / l);
|
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="c">The c value to set.</param>
|
||||||
/// <param name="l">The l value to set.</param>
|
/// <param name="l">The l value to set.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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();
|
(float cH, float cC, float cL) = color.GetHcl();
|
||||||
return Create(color.A, h ?? cH, c ?? cC, l ?? cL);
|
return Create(color.A, h ?? cH, c ?? cC, l ?? cL);
|
||||||
|
|||||||
@ -16,21 +16,21 @@ public static class LabColor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">The color to get the value from.</param>
|
/// <param name="color">The color to get the value from.</param>
|
||||||
/// <returns>The L component value of the color.</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Gets the a component value (Lab-color space) of this <see cref="Color"/> in the range [0..1].
|
/// Gets the a component value (Lab-color space) of this <see cref="Color"/> in the range [0..1].
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">The color to get the value from.</param>
|
/// <param name="color">The color to get the value from.</param>
|
||||||
/// <returns>The a component value of the color.</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Gets the b component value (Lab-color space) of this <see cref="Color"/> in the range [0..1].
|
/// Gets the b component value (Lab-color space) of this <see cref="Color"/> in the range [0..1].
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">The color to get the value from.</param>
|
/// <param name="color">The color to get the value from.</param>
|
||||||
/// <returns>The b component value of the color.</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Gets the L, a and b component values (Lab-color space) of this <see cref="Color"/>.
|
/// 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>
|
/// </summary>
|
||||||
/// <param name="color">The color to get the value from.</param>
|
/// <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>
|
/// <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);
|
=> CalculateLabFromRGB(color.R, color.G, color.B);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -55,7 +55,7 @@ public static class LabColor
|
|||||||
/// <param name="a">The a value to add.</param>
|
/// <param name="a">The a value to add.</param>
|
||||||
/// <param name="b">The b value to add.</param>
|
/// <param name="b">The b value to add.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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();
|
(float cL, float cA, float cB) = color.GetLab();
|
||||||
return Create(color.A, cL + l, cA + a, cB + b);
|
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="a">The a value to subtract.</param>
|
||||||
/// <param name="b">The b value to subtract.</param>
|
/// <param name="b">The b value to subtract.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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();
|
(float cL, float cA, float cB) = color.GetLab();
|
||||||
return Create(color.A, cL - l, cA - a, cB - b);
|
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="a">The a value to multiply.</param>
|
||||||
/// <param name="b">The b value to multiply.</param>
|
/// <param name="b">The b value to multiply.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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();
|
(float cL, float cA, float cB) = color.GetLab();
|
||||||
return Create(color.A, cL * l, cA * a, cB * b);
|
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="a">The a value to divide.</param>
|
||||||
/// <param name="b">The b value to divide.</param>
|
/// <param name="b">The b value to divide.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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();
|
(float cL, float cA, float cB) = color.GetLab();
|
||||||
return Create(color.A, cL / l, cA / a, cB / b);
|
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="a">The a value to set.</param>
|
||||||
/// <param name="b">The b value to set.</param>
|
/// <param name="b">The b value to set.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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();
|
(float cL, float cA, float cB) = color.GetLab();
|
||||||
return Create(color.A, l ?? cL, a ?? cA, b ?? cB);
|
return Create(color.A, l ?? cL, a ?? cA, b ?? cB);
|
||||||
|
|||||||
@ -16,35 +16,35 @@ public static class RGBColor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">The color to get the value from.</param>
|
/// <param name="color">The color to get the value from.</param>
|
||||||
/// <returns>The A component value of the color.</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Gets the R component value of this <see cref="Color"/> as byte in the range [0..255].
|
/// Gets the R component value of this <see cref="Color"/> as byte in the range [0..255].
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">The color to get the value from.</param>
|
/// <param name="color">The color to get the value from.</param>
|
||||||
/// <returns>The R component value of the color.</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Gets the G component value of this <see cref="Color"/> as byte in the range [0..255].
|
/// Gets the G component value of this <see cref="Color"/> as byte in the range [0..255].
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">The color to get the value from.</param>
|
/// <param name="color">The color to get the value from.</param>
|
||||||
/// <returns>The G component value of the color.</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Gets the B component value of this <see cref="Color"/> as byte in the range [0..255].
|
/// Gets the B component value of this <see cref="Color"/> as byte in the range [0..255].
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">The color to get the value from.</param>
|
/// <param name="color">The color to get the value from.</param>
|
||||||
/// <returns>The B component value of the color.</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Gets the A, R, G and B component value of this <see cref="Color"/> as byte in the range [0..255].
|
/// Gets the A, R, G and B component value of this <see cref="Color"/> as byte in the range [0..255].
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">The color to get the value from.</param>
|
/// <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>
|
/// <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());
|
=> (color.GetA(), color.GetR(), color.GetG(), color.GetB());
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -52,7 +52,7 @@ public static class RGBColor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">The color to get the value from.</param>
|
/// <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>
|
/// <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);
|
=> (color.A, color.R, color.G, color.B);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -69,7 +69,7 @@ public static class RGBColor
|
|||||||
/// <param name="g">The green value to add.</param>
|
/// <param name="g">The green value to add.</param>
|
||||||
/// <param name="b">The blue value to add.</param>
|
/// <param name="b">The blue value to add.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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);
|
=> new(color.A, color.GetR() + r, color.GetG() + g, color.GetB() + b);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -80,7 +80,7 @@ public static class RGBColor
|
|||||||
/// <param name="g">The green value to add.</param>
|
/// <param name="g">The green value to add.</param>
|
||||||
/// <param name="b">The blue value to add.</param>
|
/// <param name="b">The blue value to add.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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);
|
=> new(color.A, color.R + r, color.G + g, color.B + b);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -89,7 +89,7 @@ public static class RGBColor
|
|||||||
/// <param name="color">The color to modify.</param>
|
/// <param name="color">The color to modify.</param>
|
||||||
/// <param name="a">The alpha value to add.</param>
|
/// <param name="a">The alpha value to add.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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);
|
=> new(color.GetA() + a, color.R, color.G, color.B);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -98,7 +98,7 @@ public static class RGBColor
|
|||||||
/// <param name="color">The color to modify.</param>
|
/// <param name="color">The color to modify.</param>
|
||||||
/// <param name="a">The alpha value to add.</param>
|
/// <param name="a">The alpha value to add.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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);
|
=> new(color.A + a, color.R, color.G, color.B);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -113,7 +113,7 @@ public static class RGBColor
|
|||||||
/// <param name="g">The green value to subtract.</param>
|
/// <param name="g">The green value to subtract.</param>
|
||||||
/// <param name="b">The blue value to subtract.</param>
|
/// <param name="b">The blue value to subtract.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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);
|
=> new(color.A, color.GetR() - r, color.GetG() - g, color.GetB() - b);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -124,7 +124,7 @@ public static class RGBColor
|
|||||||
/// <param name="g">The green value to subtract.</param>
|
/// <param name="g">The green value to subtract.</param>
|
||||||
/// <param name="b">The blue value to subtract.</param>
|
/// <param name="b">The blue value to subtract.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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);
|
=> new(color.A, color.R - r, color.G - g, color.B - b);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -133,7 +133,7 @@ public static class RGBColor
|
|||||||
/// <param name="color">The color to modify.</param>
|
/// <param name="color">The color to modify.</param>
|
||||||
/// <param name="a">The alpha value to subtract.</param>
|
/// <param name="a">The alpha value to subtract.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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);
|
=> new(color.GetA() - a, color.R, color.G, color.B);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -142,7 +142,7 @@ public static class RGBColor
|
|||||||
/// <param name="color">The color to modify.</param>
|
/// <param name="color">The color to modify.</param>
|
||||||
/// <param name="aPercent">The alpha value to subtract.</param>
|
/// <param name="aPercent">The alpha value to subtract.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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);
|
=> new(color.A - aPercent, color.R, color.G, color.B);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -157,7 +157,7 @@ public static class RGBColor
|
|||||||
/// <param name="g">The green value to multiply.</param>
|
/// <param name="g">The green value to multiply.</param>
|
||||||
/// <param name="b">The blue value to multiply.</param>
|
/// <param name="b">The blue value to multiply.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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);
|
=> new(color.A, color.R * r, color.G * g, color.B * b);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -166,7 +166,7 @@ public static class RGBColor
|
|||||||
/// <param name="color">The color to modify.</param>
|
/// <param name="color">The color to modify.</param>
|
||||||
/// <param name="a">The alpha value to multiply.</param>
|
/// <param name="a">The alpha value to multiply.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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);
|
=> new(color.A * a, color.R, color.G, color.B);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -181,7 +181,7 @@ public static class RGBColor
|
|||||||
/// <param name="g">The green value to divide.</param>
|
/// <param name="g">The green value to divide.</param>
|
||||||
/// <param name="b">The blue value to divide.</param>
|
/// <param name="b">The blue value to divide.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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);
|
=> new(color.A, color.R / r, color.G / g, color.B / b);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -190,7 +190,7 @@ public static class RGBColor
|
|||||||
/// <param name="color">The color to modify.</param>
|
/// <param name="color">The color to modify.</param>
|
||||||
/// <param name="a">The alpha value to divide.</param>
|
/// <param name="a">The alpha value to divide.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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);
|
=> new(color.A / a, color.R, color.G, color.B);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -205,7 +205,7 @@ public static class RGBColor
|
|||||||
/// <param name="g">The green value to set.</param>
|
/// <param name="g">The green value to set.</param>
|
||||||
/// <param name="b">The blue value to set.</param>
|
/// <param name="b">The blue value to set.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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());
|
=> new(color.A, r ?? color.GetR(), g ?? color.GetG(), b ?? color.GetB());
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -216,7 +216,7 @@ public static class RGBColor
|
|||||||
/// <param name="g">The green value to set.</param>
|
/// <param name="g">The green value to set.</param>
|
||||||
/// <param name="b">The blue value to set.</param>
|
/// <param name="b">The blue value to set.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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());
|
=> new(color.A, r ?? color.GetR(), g ?? color.GetG(), b ?? color.GetB());
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -227,7 +227,7 @@ public static class RGBColor
|
|||||||
/// <param name="g">The green value to set.</param>
|
/// <param name="g">The green value to set.</param>
|
||||||
/// <param name="b">The blue value to set.</param>
|
/// <param name="b">The blue value to set.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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);
|
=> new(color.A, r ?? color.R, g ?? color.G, b ?? color.B);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -236,7 +236,7 @@ public static class RGBColor
|
|||||||
/// <param name="color">The color to modify.</param>
|
/// <param name="color">The color to modify.</param>
|
||||||
/// <param name="a">The alpha value to set.</param>
|
/// <param name="a">The alpha value to set.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Sets the specified alpha value of this color.
|
/// 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="color">The color to modify.</param>
|
||||||
/// <param name="a">The alpha value to set.</param>
|
/// <param name="a">The alpha value to set.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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
|
#endregion
|
||||||
|
|
||||||
@ -256,13 +256,13 @@ public static class RGBColor
|
|||||||
/// Gets the current color as a RGB-HEX-string.
|
/// Gets the current color as a RGB-HEX-string.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The RGB-HEX-string.</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Gets the current color as a ARGB-HEX-string.
|
/// Gets the current color as a ARGB-HEX-string.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The ARGB-HEX-string.</returns>
|
/// <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
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@ -16,21 +16,21 @@ public static class XYZColor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">The color to get the value from.</param>
|
/// <param name="color">The color to get the value from.</param>
|
||||||
/// <returns>The X component value of the color.</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Gets the Y component value (XYZ-color space) of this <see cref="Color"/> in the range [0..100].
|
/// Gets the Y component value (XYZ-color space) of this <see cref="Color"/> in the range [0..100].
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">The color to get the value from.</param>
|
/// <param name="color">The color to get the value from.</param>
|
||||||
/// <returns>The Y component value of the color.</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Gets the Z component value (XYZ-color space) of this <see cref="Color"/> in the range [0..108.883].
|
/// Gets the Z component value (XYZ-color space) of this <see cref="Color"/> in the range [0..108.883].
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">The color to get the value from.</param>
|
/// <param name="color">The color to get the value from.</param>
|
||||||
/// <returns>The Z component value of the color.</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Gets the X, Y and Z component values (XYZ-color space) of this <see cref="Color"/>.
|
/// 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>
|
/// </summary>
|
||||||
/// <param name="color">The color to get the value from.</param>
|
/// <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>
|
/// <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);
|
=> CaclulateXYZFromRGB(color.R, color.G, color.B);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -55,7 +55,7 @@ public static class XYZColor
|
|||||||
/// <param name="y">The Y value to add.</param>
|
/// <param name="y">The Y value to add.</param>
|
||||||
/// <param name="z">The Z value to add.</param>
|
/// <param name="z">The Z value to add.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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();
|
(float cX, float cY, float cZ) = color.GetXYZ();
|
||||||
return Create(color.A, cX + x, cY + y, cZ + z);
|
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="y">The Y value to subtract.</param>
|
||||||
/// <param name="z">The Z value to subtract.</param>
|
/// <param name="z">The Z value to subtract.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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();
|
(float cX, float cY, float cZ) = color.GetXYZ();
|
||||||
return Create(color.A, cX - x, cY - y, cZ - z);
|
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="y">The Y value to multiply.</param>
|
||||||
/// <param name="z">The Z value to multiply.</param>
|
/// <param name="z">The Z value to multiply.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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();
|
(float cX, float cY, float cZ) = color.GetXYZ();
|
||||||
return Create(color.A, cX * x, cY * y, cZ * z);
|
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="y">The Y value to divide.</param>
|
||||||
/// <param name="z">The Z value to divide.</param>
|
/// <param name="z">The Z value to divide.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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();
|
(float cX, float cY, float cZ) = color.GetXYZ();
|
||||||
return Create(color.A, cX / x, cY / y, cZ / z);
|
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="y">The Y value to set.</param>
|
||||||
/// <param name="z">The Z value to set.</param>
|
/// <param name="z">The Z value to set.</param>
|
||||||
/// <returns>The new color after the modification.</returns>
|
/// <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();
|
(float cX, float cY, float cZ) = color.GetXYZ();
|
||||||
return Create(color.A, x ?? cX, y ?? cY, z ?? cZ);
|
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
|
||||||
@ -11,7 +11,7 @@ public abstract class AbstractDecoratable<T> : AbstractBindable, IDecoratable<T>
|
|||||||
{
|
{
|
||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
private readonly List<T> _decorators = new();
|
private readonly List<T> _decorators = [];
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IReadOnlyList<T> Decorators { get; }
|
public IReadOnlyList<T> Decorators { get; }
|
||||||
|
|||||||
@ -29,7 +29,7 @@ public abstract class AbstractDecorator : AbstractBindable, IDecorator
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a readonly-list of all <see cref="IDecoratable"/> this decorator is attached to.
|
/// Gets a readonly-list of all <see cref="IDecoratable"/> this decorator is attached to.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected List<IDecoratable> DecoratedObjects { get; } = new();
|
protected List<IDecoratable> DecoratedObjects { get; } = [];
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -46,14 +46,14 @@ public abstract class AbstractDecorator : AbstractBindable, IDecorator
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual void Detach()
|
protected virtual void Detach()
|
||||||
{
|
{
|
||||||
List<IDecoratable> decoratables = new(DecoratedObjects);
|
List<IDecoratable> decoratables = [..DecoratedObjects];
|
||||||
foreach (IDecoratable decoratable in decoratables)
|
foreach (IDecoratable decoratable in decoratables)
|
||||||
{
|
{
|
||||||
IEnumerable<Type> types = decoratable.GetType().GetInterfaces().Where(t => t.IsGenericType
|
IEnumerable<Type> types = decoratable.GetType().GetInterfaces().Where(t => t.IsGenericType
|
||||||
&& (t.Name == typeof(IDecoratable<>).Name)
|
&& (t.Name == typeof(IDecoratable<>).Name)
|
||||||
&& t.GenericTypeArguments[0].IsInstanceOfType(this));
|
&& t.GenericTypeArguments[0].IsInstanceOfType(this));
|
||||||
foreach (Type decoratableType in types)
|
foreach (Type decoratableType in types)
|
||||||
decoratableType.GetMethod(nameof(IDecoratable<IDecorator>.RemoveDecorator))?.Invoke(decoratable, new object[] { this });
|
decoratableType.GetMethod(nameof(IDecoratable<IDecorator>.RemoveDecorator))?.Invoke(decoratable, [this]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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="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="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>
|
/// <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);
|
||||||
}
|
}
|
||||||
@ -6,8 +6,7 @@ namespace RGB.NET.Core;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a basic decoratable.
|
/// Represents a basic decoratable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IDecoratable : INotifyPropertyChanged
|
public interface IDecoratable : INotifyPropertyChanged;
|
||||||
{ }
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -4,5 +4,4 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a basic decorator decorating a <see cref="T:RGB.NET.Core.ILedGroup" />.
|
/// Represents a basic decorator decorating a <see cref="T:RGB.NET.Core.ILedGroup" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ILedGroupDecorator : IDecorator
|
public interface ILedGroupDecorator : IDecorator;
|
||||||
{ }
|
|
||||||
@ -43,7 +43,7 @@ public abstract class AbstractRGBDevice<TDeviceInfo> : Placeable, IRGBDevice<TDe
|
|||||||
IRGBDeviceInfo IRGBDevice.DeviceInfo => DeviceInfo;
|
IRGBDeviceInfo IRGBDevice.DeviceInfo => DeviceInfo;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IList<IColorCorrection> ColorCorrections { get; } = new List<IColorCorrection>();
|
public IList<IColorCorrection> ColorCorrections { get; } = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets if the device needs to be flushed on every update.
|
/// Gets or sets if the device needs to be flushed on every update.
|
||||||
@ -53,7 +53,7 @@ public abstract class AbstractRGBDevice<TDeviceInfo> : Placeable, IRGBDevice<TDe
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a dictionary containing all <see cref="Led"/> of the <see cref="IRGBDevice"/>.
|
/// Gets a dictionary containing all <see cref="Led"/> of the <see cref="IRGBDevice"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected Dictionary<LedId, Led> LedMapping { get; } = new();
|
protected Dictionary<LedId, Led> LedMapping { get; } = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the update queue used to update this device.
|
/// Gets the update queue used to update this device.
|
||||||
@ -63,7 +63,7 @@ public abstract class AbstractRGBDevice<TDeviceInfo> : Placeable, IRGBDevice<TDe
|
|||||||
#region Indexer
|
#region Indexer
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
Led? IRGBDevice.this[LedId ledId] => LedMapping.TryGetValue(ledId, out Led? led) ? led : null;
|
Led? IRGBDevice.this[LedId ledId] => LedMapping.GetValueOrDefault(ledId);
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
Led? IRGBDevice.this[Point location] => LedMapping.Values.FirstOrDefault(x => x.Boundary.Contains(location));
|
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"/>.
|
/// Applies all <see cref="ColorCorrections"/>.
|
||||||
/// if no <see cref="Led.CustomData"/> ist specified the <see cref="Led.Id"/> is used.
|
/// if no <see cref="Led.CustomData"/> ist specified the <see cref="Led.Id"/> is used.
|
||||||
/// </remarks>
|
/// </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>
|
/// <returns>The enumerable of custom data and color tuples for the specified leds.</returns>
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
protected (object key, Color color) GetUpdateData(Led led)
|
protected (object key, Color color) GetUpdateData(Led led)
|
||||||
@ -179,7 +179,7 @@ public abstract class AbstractRGBDevice<TDeviceInfo> : Placeable, IRGBDevice<TDe
|
|||||||
{ }
|
{ }
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <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;
|
if ((ledId == LedId.Invalid) || LedMapping.ContainsKey(ledId)) return null;
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,7 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The list of devices managed by this device-provider.
|
/// The list of devices managed by this device-provider.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected List<IRGBDevice> InternalDevices { get; } = new();
|
protected List<IRGBDevice> InternalDevices { get; } = [];
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual IReadOnlyList<IRGBDevice> Devices => new ReadOnlyCollection<IRGBDevice>(InternalDevices);
|
public virtual IReadOnlyList<IRGBDevice> Devices => new ReadOnlyCollection<IRGBDevice>(InternalDevices);
|
||||||
@ -34,7 +34,7 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider
|
|||||||
/// Gets the dictionary containing the registered update triggers.
|
/// Gets the dictionary containing the registered update triggers.
|
||||||
/// Normally <see cref="UpdateTriggers"/> should be used to access them.
|
/// Normally <see cref="UpdateTriggers"/> should be used to access them.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected Dictionary<int, IDeviceUpdateTrigger> UpdateTriggerMapping { get; } = new();
|
protected Dictionary<int, IDeviceUpdateTrigger> UpdateTriggerMapping { get; } = [];
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IReadOnlyList<(int id, IDeviceUpdateTrigger trigger)> UpdateTriggers => new ReadOnlyCollection<(int id, IDeviceUpdateTrigger trigger)>(UpdateTriggerMapping.Select(x => (x.Key, x.Value)).ToList());
|
public IReadOnlyList<(int id, IDeviceUpdateTrigger trigger)> UpdateTriggers => new ReadOnlyCollection<(int id, IDeviceUpdateTrigger trigger)>(UpdateTriggerMapping.Select(x => (x.Key, x.Value)).ToList());
|
||||||
@ -116,7 +116,7 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider
|
|||||||
{
|
{
|
||||||
if (_isDisposed) throw new ObjectDisposedException(GetType().FullName);
|
if (_isDisposed) throw new ObjectDisposedException(GetType().FullName);
|
||||||
|
|
||||||
List<IRGBDevice> devices = new();
|
List<IRGBDevice> devices = [];
|
||||||
foreach (IRGBDevice device in LoadDevices())
|
foreach (IRGBDevice device in LoadDevices())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -189,7 +189,7 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider
|
|||||||
foreach (IRGBDevice device in Devices)
|
foreach (IRGBDevice device in Devices)
|
||||||
device.Dispose();
|
device.Dispose();
|
||||||
|
|
||||||
List<IRGBDevice> devices = new(InternalDevices);
|
List<IRGBDevice> devices = [..InternalDevices];
|
||||||
foreach (IRGBDevice device in devices)
|
foreach (IRGBDevice device in devices)
|
||||||
RemoveDevice(device);
|
RemoveDevice(device);
|
||||||
|
|
||||||
|
|||||||
@ -72,7 +72,7 @@ public interface IRGBDevice : IEnumerable<Led>, IPlaceable, IBindable, IDisposab
|
|||||||
/// <param name="size">The size of the led.</param>
|
/// <param name="size">The size of the led.</param>
|
||||||
/// <param name="customData">Custom data saved on 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>
|
/// <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>
|
/// <summary>
|
||||||
/// Removes the led with the specified id from the device.
|
/// Removes the led with the specified id from the device.
|
||||||
|
|||||||
@ -3,5 +3,4 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a cooler-device
|
/// Represents a cooler-device
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ICooler : IRGBDevice
|
public interface ICooler : IRGBDevice;
|
||||||
{ }
|
|
||||||
@ -3,5 +3,4 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a DRAM-device
|
/// Represents a DRAM-device
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IDRAM : IRGBDevice
|
public interface IDRAM : IRGBDevice;
|
||||||
{ }
|
|
||||||
@ -3,5 +3,4 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// represents a fan-device
|
/// represents a fan-device
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IFan : IRGBDevice
|
public interface IFan : IRGBDevice;
|
||||||
{ }
|
|
||||||
@ -3,5 +3,4 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a gamecontroller-device
|
/// Represents a gamecontroller-device
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IGameController: IRGBDevice
|
public interface IGameController: IRGBDevice;
|
||||||
{ }
|
|
||||||
@ -3,5 +3,4 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a graphics-card-device
|
/// Represents a graphics-card-device
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IGraphicsCard : IRGBDevice
|
public interface IGraphicsCard : IRGBDevice;
|
||||||
{ }
|
|
||||||
@ -3,5 +3,4 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a headset-device
|
/// Represents a headset-device
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IHeadset : IRGBDevice
|
public interface IHeadset : IRGBDevice;
|
||||||
{ }
|
|
||||||
@ -3,5 +3,4 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a headset-stand-device
|
/// Represents a headset-stand-device
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IHeadsetStand : IRGBDevice
|
public interface IHeadsetStand : IRGBDevice;
|
||||||
{ }
|
|
||||||
@ -3,5 +3,4 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a keypad-device
|
/// Represents a keypad-device
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IKeypad : IRGBDevice
|
public interface IKeypad : IRGBDevice;
|
||||||
{ }
|
|
||||||
@ -3,5 +3,4 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a led-matrix-device
|
/// Represents a led-matrix-device
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ILedMatrix : IRGBDevice
|
public interface ILedMatrix : IRGBDevice;
|
||||||
{ }
|
|
||||||
@ -3,5 +3,4 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a led-stripe-device
|
/// Represents a led-stripe-device
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ILedStripe : IRGBDevice
|
public interface ILedStripe : IRGBDevice;
|
||||||
{ }
|
|
||||||
@ -3,5 +3,4 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a mainboard-device
|
/// Represents a mainboard-device
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IMainboard : IRGBDevice
|
public interface IMainboard : IRGBDevice;
|
||||||
{ }
|
|
||||||
@ -3,5 +3,4 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a mouse-device
|
/// Represents a mouse-device
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IMouse : IRGBDevice
|
public interface IMouse : IRGBDevice;
|
||||||
{ }
|
|
||||||
@ -3,5 +3,4 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a mousepad-device
|
/// Represents a mousepad-device
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IMousepad : IRGBDevice
|
public interface IMousepad : IRGBDevice;
|
||||||
{ }
|
|
||||||
@ -3,5 +3,4 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a speaker-device
|
/// Represents a speaker-device
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ISpeaker : IRGBDevice
|
public interface ISpeaker : IRGBDevice;
|
||||||
{ }
|
|
||||||
@ -3,5 +3,4 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a device with unkown or not specified type.
|
/// Represents a device with unkown or not specified type.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IUnknownDevice : IRGBDevice
|
public interface IUnknownDevice : IRGBDevice;
|
||||||
{ }
|
|
||||||
@ -2,22 +2,13 @@
|
|||||||
|
|
||||||
namespace RGB.NET.Core;
|
namespace RGB.NET.Core;
|
||||||
|
|
||||||
public sealed class DevicesChangedEventArgs : EventArgs
|
public sealed class DevicesChangedEventArgs(IRGBDevice device, DevicesChangedEventArgs.DevicesChangedAction action)
|
||||||
|
: EventArgs
|
||||||
{
|
{
|
||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
public IRGBDevice Device { get; }
|
public IRGBDevice Device { get; } = device;
|
||||||
public DevicesChangedAction Action { get; }
|
public DevicesChangedAction Action { get; } = action;
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Constructors
|
|
||||||
|
|
||||||
public DevicesChangedEventArgs(IRGBDevice device, DevicesChangedAction action)
|
|
||||||
{
|
|
||||||
this.Device = device;
|
|
||||||
this.Action = action;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@ -6,5 +6,4 @@ namespace RGB.NET.Core;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the information supplied with an <see cref="E:RGB.NET.Core.RGBSurface.Updated" />-event.
|
/// Represents the information supplied with an <see cref="E:RGB.NET.Core.RGBSurface.Updated" />-event.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class UpdatedEventArgs : EventArgs
|
public class UpdatedEventArgs : EventArgs;
|
||||||
{ }
|
|
||||||
@ -16,7 +16,7 @@ public static class ColorExtensions
|
|||||||
/// <param name="color1">The start color of the distance calculation.</param>
|
/// <param name="color1">The start color of the distance calculation.</param>
|
||||||
/// <param name="color2">The end color fot 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>
|
/// <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 r1, byte g1, byte b1) = color1.GetRGBBytes();
|
||||||
(_, byte r2, byte g2, byte b2) = color2.GetRGBBytes();
|
(_, byte r2, byte g2, byte b2) = color2.GetRGBBytes();
|
||||||
|
|||||||
@ -91,10 +91,11 @@ public static class FloatExtensions
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static byte GetByteValueFromPercentage(this float percentage)
|
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 * 256.0f);
|
||||||
return (byte)(percentage >= 1.0f ? 255 : percentage * 256.0f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -16,7 +16,7 @@ public static class PointExtensions
|
|||||||
/// <param name="x">The x-ammount to move.</param>
|
/// <param name="x">The x-ammount to move.</param>
|
||||||
/// <param name="y">The y-ammount to move.</param>
|
/// <param name="y">The y-ammount to move.</param>
|
||||||
/// <returns>The new location of the point.</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Rotates the specified <see cref="Point"/> by the specified amuont around the specified origin.
|
/// 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="rotation">The rotation.</param>
|
||||||
/// <param name="origin">The origin to rotate around. [0,0] if not set.</param>
|
/// <param name="origin">The origin to rotate around. [0,0] if not set.</param>
|
||||||
/// <returns>The new location of the point.</returns>
|
/// <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 sin = MathF.Sin(rotation.Radians);
|
||||||
float cos = MathF.Cos(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="rect">The rectangle to modify.</param>
|
||||||
/// <param name="location">The new location of the rectangle.</param>
|
/// <param name="location">The new location of the rectangle.</param>
|
||||||
/// <returns>The modified <see cref="Rectangle"/>.</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Sets the <see cref="Point.X"/> of the <see cref="Rectangle.Location"/> of the specified rectangle.
|
/// 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="rect">The rectangle to modify.</param>
|
||||||
/// <param name="x">The new x-location of the rectangle.</param>
|
/// <param name="x">The new x-location of the rectangle.</param>
|
||||||
/// <returns>The modified <see cref="Rectangle"/>.</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Sets the <see cref="Point.Y"/> of the <see cref="Rectangle.Location"/> of the specified rectangle.
|
/// 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="rect">The rectangle to modify.</param>
|
||||||
/// <param name="y">The new y-location of the rectangle.</param>
|
/// <param name="y">The new y-location of the rectangle.</param>
|
||||||
/// <returns>The modified <see cref="Rectangle"/>.</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Sets the <see cref="Rectangle.Size"/> of the specified rectangle.
|
/// 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="rect">The rectangle to modify.</param>
|
||||||
/// <param name="size">The new size of the rectangle.</param>
|
/// <param name="size">The new size of the rectangle.</param>
|
||||||
/// <returns>The modified <see cref="Rectangle"/>.</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Sets the <see cref="Size.Width"/> of the <see cref="Rectangle.Size"/> of the specified rectangle.
|
/// 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="rect">The rectangle to modify.</param>
|
||||||
/// <param name="width">The new width of the rectangle.</param>
|
/// <param name="width">The new width of the rectangle.</param>
|
||||||
/// <returns>The modified <see cref="Rectangle"/>.</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Sets the <see cref="Size.Height"/> of the <see cref="Rectangle.Size"/> of the specified rectangle.
|
/// 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="rect">The rectangle to modify.</param>
|
||||||
/// <param name="height">The new height of the rectangle.</param>
|
/// <param name="height">The new height of the rectangle.</param>
|
||||||
/// <returns>The modified <see cref="Rectangle"/>.</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Calculates the percentage of intersection of a rectangle.
|
/// 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="rect">The rectangle to calculate the intersection for.</param>
|
||||||
/// <param name="intersectingRect">The intersecting rectangle.</param>
|
/// <param name="intersectingRect">The intersecting rectangle.</param>
|
||||||
/// <returns>The percentage of intersection.</returns>
|
/// <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;
|
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="rect">The rectangle to calculate the intersection for.</param>
|
||||||
/// <param name="intersectingRectangle">The intersecting <see cref="Rectangle"/>.</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>
|
/// <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 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);
|
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="rect">The containing rectangle.</param>
|
||||||
/// <param name="point">The <see cref="Point"/> to test.</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>
|
/// <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>
|
/// <summary>
|
||||||
/// Determines if the specified location is contained within this <see cref="Rectangle"/>.
|
/// 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="x">The X-location to test.</param>
|
||||||
/// <param name="y">The Y-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>
|
/// <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));
|
&& (rect.Location.Y <= y) && (y < (rect.Location.Y + rect.Size.Height));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -115,7 +115,7 @@ public static class RectangleExtensions
|
|||||||
/// <param name="rect">The containing rectangle.</param>
|
/// <param name="rect">The containing rectangle.</param>
|
||||||
/// <param name="rect2">The <see cref="Rectangle"/> to test.</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>
|
/// <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));
|
&& (rect.Location.Y <= rect2.Location.Y) && ((rect2.Location.Y + rect2.Size.Height) <= (rect.Location.Y + rect.Size.Height));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -124,7 +124,7 @@ public static class RectangleExtensions
|
|||||||
/// <param name="rect">The <see cref="Rectangle"/> to move.</param>
|
/// <param name="rect">The <see cref="Rectangle"/> to move.</param>
|
||||||
/// <param name="point">The amount to move.</param>
|
/// <param name="point">The amount to move.</param>
|
||||||
/// <returns>The moved rectangle.</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Moves the specified <see cref="Rectangle"/> by the specified amount.
|
/// 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="x">The x-ammount to move.</param>
|
||||||
/// <param name="y">The y-ammount to move.</param>
|
/// <param name="y">The y-ammount to move.</param>
|
||||||
/// <returns>The moved rectangle.</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Rotates the specified <see cref="Rectangle"/> by the specified amuont around the specified origin.
|
/// Rotates the specified <see cref="Rectangle"/> by the specified amuont around the specified origin.
|
||||||
@ -149,14 +149,15 @@ public static class RectangleExtensions
|
|||||||
/// <param name="rotation">The rotation.</param>
|
/// <param name="rotation">The rotation.</param>
|
||||||
/// <param name="origin">The origin to rotate around. [0,0] if not set.</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>
|
/// <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 = {
|
Point[] points =
|
||||||
rect.Location, // top left
|
[
|
||||||
new(rect.Location.X + rect.Size.Width, rect.Location.Y), // top right
|
rect.Location, // top left
|
||||||
new(rect.Location.X + rect.Size.Width, 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.Location.Y + rect.Size.Height), // bottom 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);
|
float sin = MathF.Sin(rotation.Radians);
|
||||||
float cos = MathF.Cos(rotation.Radians);
|
float cos = MathF.Cos(rotation.Radians);
|
||||||
|
|||||||
@ -20,7 +20,7 @@ public sealed class ListLedGroup : AbstractLedGroup
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the list containing the <see cref="Led"/> of this <see cref="ListLedGroup"/>.
|
/// Gets the list containing the <see cref="Led"/> of this <see cref="ListLedGroup"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly IList<Led> _groupLeds = new List<Led>();
|
private readonly IList<Led> _groupLeds = [];
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ public sealed class ListLedGroup : AbstractLedGroup
|
|||||||
public override IList<Led> ToList()
|
public override IList<Led> ToList()
|
||||||
{
|
{
|
||||||
lock (_groupLeds)
|
lock (_groupLeds)
|
||||||
return new List<Led>(_groupLeds);
|
return [.._groupLeds];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IDisposable ToListUnsafe(out IList<Led> leds)
|
protected override IDisposable ToListUnsafe(out IList<Led> leds)
|
||||||
|
|||||||
@ -40,7 +40,7 @@ public static class ConversionHelper
|
|||||||
public static byte[] HexToBytes(ReadOnlySpan<char> hexString)
|
public static byte[] HexToBytes(ReadOnlySpan<char> hexString)
|
||||||
{
|
{
|
||||||
if ((hexString.Length == 0) || ((hexString.Length % 2) != 0))
|
if ((hexString.Length == 0) || ((hexString.Length % 2) != 0))
|
||||||
return Array.Empty<byte>();
|
return [];
|
||||||
|
|
||||||
byte[] buffer = new byte[hexString.Length / 2];
|
byte[] buffer = new byte[hexString.Length / 2];
|
||||||
for (int bx = 0, sx = 0; bx < buffer.Length; ++bx, ++sx)
|
for (int bx = 0, sx = 0; bx < buffer.Length; ++bx, ++sx)
|
||||||
|
|||||||
@ -24,7 +24,7 @@ public static class TimerHelper
|
|||||||
|
|
||||||
#region Properties & Fields
|
#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;
|
private static bool _areHighResolutionTimersEnabled = false;
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ public static class TimerHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ReSharper disable once InconsistentNaming
|
// ReSharper disable once InconsistentNaming
|
||||||
private static readonly HashSet<HighResolutionTimerDisposable> _timerLeases = new();
|
private static readonly HashSet<HighResolutionTimerDisposable> _timerLeases = [];
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ public static class TimerHelper
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void DisposeAllHighResolutionTimerRequests()
|
public static void DisposeAllHighResolutionTimerRequests()
|
||||||
{
|
{
|
||||||
List<HighResolutionTimerDisposable> timerLeases = new(_timerLeases);
|
List<HighResolutionTimerDisposable> timerLeases = [.._timerLeases];
|
||||||
foreach (HighResolutionTimerDisposable timer in timerLeases)
|
foreach (HighResolutionTimerDisposable timer in timerLeases)
|
||||||
timer.Dispose();
|
timer.Dispose();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,9 +12,9 @@ public static class IdGenerator
|
|||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
// ReSharper disable InconsistentNaming
|
// ReSharper disable InconsistentNaming
|
||||||
private static readonly HashSet<string> _registeredIds = new();
|
private static readonly HashSet<string> _registeredIds = [];
|
||||||
private static readonly Dictionary<Assembly, Dictionary<string, string>> _idMappings = new();
|
private static readonly Dictionary<Assembly, Dictionary<string, string>> _idMappings = [];
|
||||||
private static readonly Dictionary<Assembly, Dictionary<string, int>> _counter = new();
|
private static readonly Dictionary<Assembly, Dictionary<string, int>> _counter = [];
|
||||||
// ReSharper restore InconsistentNaming
|
// ReSharper restore InconsistentNaming
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -33,8 +33,8 @@ public static class IdGenerator
|
|||||||
{
|
{
|
||||||
if (!_idMappings.TryGetValue(callingAssembly, out Dictionary<string, string>? idMapping))
|
if (!_idMappings.TryGetValue(callingAssembly, out Dictionary<string, string>? idMapping))
|
||||||
{
|
{
|
||||||
_idMappings.Add(callingAssembly, idMapping = new Dictionary<string, string>());
|
_idMappings.Add(callingAssembly, idMapping = []);
|
||||||
_counter.Add(callingAssembly, new Dictionary<string, int>());
|
_counter.Add(callingAssembly, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary<string, int> counterMapping = _counter[callingAssembly];
|
Dictionary<string, int> counterMapping = _counter[callingAssembly];
|
||||||
|
|||||||
@ -13,14 +13,14 @@ public sealed class LedMapping<T> : IEnumerable<(LedId ledId, T mapping)>
|
|||||||
{
|
{
|
||||||
#region Constants
|
#region Constants
|
||||||
|
|
||||||
public static LedMapping<T> Empty { get; } = new();
|
public static LedMapping<T> Empty { get; } = [];
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
private readonly Dictionary<LedId, T> _mapping = new();
|
private readonly Dictionary<LedId, T> _mapping = [];
|
||||||
private readonly Dictionary<T, LedId> _reverseMapping = new();
|
private readonly Dictionary<T, LedId> _reverseMapping = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the number of entries in this mapping.
|
/// Gets the number of entries in this mapping.
|
||||||
|
|||||||
@ -5,5 +5,4 @@ namespace RGB.NET.Core;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a basic bindable class which notifies when a property value changes.
|
/// Represents a basic bindable class which notifies when a property value changes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IBindable : INotifyPropertyChanged
|
public interface IBindable : INotifyPropertyChanged;
|
||||||
{ }
|
|
||||||
@ -6,7 +6,7 @@ public abstract class AbstractReferenceCounting : IReferenceCounting
|
|||||||
{
|
{
|
||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
private readonly HashSet<object> _referencingObjects = new();
|
private readonly HashSet<object> _referencingObjects = [];
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public int ActiveReferenceCount
|
public int ActiveReferenceCount
|
||||||
|
|||||||
@ -2,26 +2,11 @@
|
|||||||
|
|
||||||
namespace RGB.NET.Core;
|
namespace RGB.NET.Core;
|
||||||
|
|
||||||
public sealed class ActionDisposable : IDisposable
|
public sealed class ActionDisposable(Action onDispose) : IDisposable
|
||||||
{
|
{
|
||||||
#region Properties & Fields
|
|
||||||
|
|
||||||
private readonly Action _onDispose;
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Constructors
|
|
||||||
|
|
||||||
public ActionDisposable(Action onDispose)
|
|
||||||
{
|
|
||||||
this._onDispose = onDispose;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
public void Dispose() => _onDispose();
|
public void Dispose() => onDispose();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@ -90,7 +90,7 @@ public readonly struct Point : IEquatable<Point>
|
|||||||
/// <param name="point1">The first <see cref="Point" /> to compare.</param>
|
/// <param name="point1">The first <see cref="Point" /> to compare.</param>
|
||||||
/// <param name="point2">The second <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>
|
/// <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>
|
/// <summary>
|
||||||
/// Returns a value that indicates whether two specified <see cref="Point" /> are equal.
|
/// 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="point1">The first <see cref="Point" /> to compare.</param>
|
||||||
/// <param name="point2">The second <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>
|
/// <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>
|
/// <summary>
|
||||||
/// Returns a new <see cref="Point"/> representing the addition of the two provided <see cref="Point"/>.
|
/// 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="point1">The first <see cref="Point"/>.</param>
|
||||||
/// <param name="point2">The second <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>
|
/// <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>
|
/// <summary>
|
||||||
/// Returns a new <see cref="Rectangle"/> created from the provided <see cref="Point"/> and <see cref="Size"/>.
|
/// 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="point">The <see cref="Point"/> of the rectangle.</param>
|
||||||
/// <param name="size">The <see cref="Size"/> 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>
|
/// <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>
|
/// <summary>
|
||||||
/// Returns a new <see cref="Point"/> representing the subtraction of the two provided <see cref="Point"/>.
|
/// 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="point1">The first <see cref="Point"/>.</param>
|
||||||
/// <param name="point2">The second <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>
|
/// <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>
|
/// <summary>
|
||||||
/// Returns a new <see cref="Point"/> representing the multiplication of the two provided <see cref="Point"/>.
|
/// 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="point1">The first <see cref="Point"/>.</param>
|
||||||
/// <param name="point2">The second <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>
|
/// <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>
|
/// <summary>
|
||||||
/// Returns a new <see cref="Point"/> representing the division of the two provided <see cref="Point"/>.
|
/// 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="point1">The first <see cref="Point"/>.</param>
|
||||||
/// <param name="point2">The second <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>
|
/// <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;
|
if (point2.X.EqualsInTolerance(0) || point2.Y.EqualsInTolerance(0)) return Invalid;
|
||||||
return new Point(point1.X / point2.X, point1.Y / point2.Y);
|
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="point">The <see cref="Point"/>.</param>
|
||||||
/// <param name="scale">The <see cref="Scale"/>.</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>
|
/// <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
|
#endregion
|
||||||
}
|
}
|
||||||
@ -179,7 +179,7 @@ public readonly struct Rectangle : IEquatable<Rectangle>
|
|||||||
|
|
||||||
#region Methods
|
#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 posX = Math.Min(point1.X, point2.X);
|
||||||
float posY = Math.Min(point1.Y, point2.Y);
|
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="rectangle1">The first <see cref="Rectangle" /> to compare.</param>
|
||||||
/// <param name="rectangle2">The second <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>
|
/// <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>
|
/// <summary>
|
||||||
/// Returns a value that indicates whether two specified <see cref="Rectangle" /> are equal.
|
/// 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="rectangle1">The first <see cref="Rectangle" /> to compare.</param>
|
||||||
/// <param name="rectangle2">The second <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>
|
/// <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
|
// DarthAffe 20.02.2021: Used for normalization
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -242,7 +242,7 @@ public readonly struct Rectangle : IEquatable<Rectangle>
|
|||||||
/// <param name="rectangle1">The rectangle to nromalize.</param>
|
/// <param name="rectangle1">The rectangle to nromalize.</param>
|
||||||
/// <param name="rectangle2">The reference used for normalization.</param>
|
/// <param name="rectangle2">The reference used for normalization.</param>
|
||||||
/// <returns>A normalized rectangle.</returns>
|
/// <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 x = rectangle1.Location.X / (rectangle2.Size.Width - rectangle2.Location.X);
|
||||||
float y = rectangle1.Location.Y / (rectangle2.Size.Height - rectangle2.Location.Y);
|
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="rotation1">The first <see cref="Rotation" /> to compare.</param>
|
||||||
/// <param name="rotation2">The second <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>
|
/// <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>
|
/// <summary>
|
||||||
/// Returns a value that indicates whether two specified <see cref="Rotation" /> are equal.
|
/// 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="rotation1">The first <see cref="Rotation" /> to compare.</param>
|
||||||
/// <param name="rotation2">The second <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>
|
/// <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>
|
/// <summary>
|
||||||
/// Returns a new <see cref="Rotation"/> representing the addition of the <see cref="Rotation"/> and the provided value.
|
/// 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="rotation">The <see cref="Rotation"/>.</param>
|
||||||
/// <param name="value">The value to add.</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>
|
/// <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>
|
/// <summary>
|
||||||
/// Returns a new <see cref="Rotation"/> representing the subtraction of the <see cref="Rotation"/> and the provided value.
|
/// 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="rotation">The <see cref="Rotation"/>.</param>
|
||||||
/// <param name="value">The value to substract.</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>
|
/// <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>
|
/// <summary>
|
||||||
/// Returns a new <see cref="Rotation"/> representing the multiplication of the <see cref="Rotation"/> and the provided value.
|
/// 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="rotation">The <see cref="Rotation"/>.</param>
|
||||||
/// <param name="value">The value to multiply with.</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>
|
/// <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>
|
/// <summary>
|
||||||
/// Returns a new <see cref="Rotation"/> representing the division of the <see cref="Rotation"/> and the provided value.
|
/// 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="rotation">The <see cref="Rotation"/>.</param>
|
||||||
/// <param name="value">The value to device with.</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>
|
/// <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>
|
/// <summary>
|
||||||
/// Converts a float to a <see cref="Rotation" />.
|
/// 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.
|
/// Converts <see cref="Rotation" /> to a float representing the rotation in degrees.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="rotation">The rotatio to convert.</param>
|
/// <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
|
#endregion
|
||||||
}
|
}
|
||||||
@ -110,7 +110,7 @@ public readonly struct Size : IEquatable<Size>
|
|||||||
/// <param name="size1">The first <see cref="Size" /> to compare.</param>
|
/// <param name="size1">The first <see cref="Size" /> to compare.</param>
|
||||||
/// <param name="size2">The second <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>
|
/// <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>
|
/// <summary>
|
||||||
/// Returns a value that indicates whether two specified <see cref="Size" /> are equal.
|
/// 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="size1">The first <see cref="Size" /> to compare.</param>
|
||||||
/// <param name="size2">The second <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>
|
/// <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>
|
/// <summary>
|
||||||
/// Returns a new <see cref="Size"/> representing the addition of the two provided <see cref="Size"/>.
|
/// 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="size1">The first <see cref="Size"/>.</param>
|
||||||
/// <param name="size2">The second <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>
|
/// <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>
|
/// <summary>
|
||||||
/// Returns a new <see cref="Rectangle"/> created from the provided <see cref="Point"/> and <see cref="Size"/>.
|
/// 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="size">The <see cref="Size"/> of the rectangle.</param>
|
||||||
/// <param name="point">The <see cref="Point"/> 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>
|
/// <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>
|
/// <summary>
|
||||||
/// Returns a new <see cref="Size"/> representing the subtraction of the two provided <see cref="Size"/>.
|
/// 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="size1">The first <see cref="Size"/>.</param>
|
||||||
/// <param name="size2">The second <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>
|
/// <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>
|
/// <summary>
|
||||||
/// Returns a new <see cref="Size"/> representing the multiplication of the two provided <see cref="Size"/>.
|
/// 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="size1">The first <see cref="Size"/>.</param>
|
||||||
/// <param name="size2">The second <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>
|
/// <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>
|
/// <summary>
|
||||||
/// Returns a new <see cref="Size"/> representing the multiplication of the <see cref="Size"/> and the provided factor.
|
/// 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="size">The <see cref="Size"/>.</param>
|
||||||
/// <param name="factor">The factor by which the <see cref="Size"/> should be multiplied.</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>
|
/// <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>
|
/// <summary>
|
||||||
/// Returns a new <see cref="Size"/> representing the division of the two provided <see cref="Size"/>.
|
/// 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="size1">The first <see cref="Size"/>.</param>
|
||||||
/// <param name="size2">The second <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>
|
/// <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)
|
=> size2.Width.EqualsInTolerance(0) || size2.Height.EqualsInTolerance(0)
|
||||||
? Invalid : new Size(size1.Width / size2.Width, size1.Height / size2.Height);
|
? 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="size">The <see cref="Size"/>.</param>
|
||||||
/// <param name="factor">The factor by which the <see cref="Size"/> should be divided.</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>
|
/// <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>
|
/// <summary>
|
||||||
/// Returns a new <see cref="Size"/> representing the multiplication of the <see cref="Size"/> and the specified <see cref="Scale"/>.
|
/// 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="size">The <see cref="Size"/> to scale.</param>
|
||||||
/// <param name="scale">The scaling factor.</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>
|
/// <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
|
#endregion
|
||||||
}
|
}
|
||||||
@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
|
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|
||||||
@ -52,6 +52,10 @@
|
|||||||
<DefineConstants>RELEASE</DefineConstants>
|
<DefineConstants>RELEASE</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
|
||||||
|
<Using Include="RGB.NET.Core.Compatibility.Net8" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="..\Resources\icon.png" Link="icon.png" Pack="true" PackagePath="\" />
|
<Content Include="..\Resources\icon.png" Link="icon.png" Pack="true" PackagePath="\" />
|
||||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
<None Include="README.md" Pack="true" PackagePath="\" />
|
||||||
|
|||||||
@ -20,9 +20,9 @@ public sealed class RGBSurface : AbstractBindable, IDisposable
|
|||||||
|
|
||||||
private readonly Stopwatch _deltaTimeCounter;
|
private readonly Stopwatch _deltaTimeCounter;
|
||||||
|
|
||||||
private readonly IList<IRGBDevice> _devices = new List<IRGBDevice>();
|
private readonly IList<IRGBDevice> _devices = [];
|
||||||
private readonly IList<IUpdateTrigger> _updateTriggers = new List<IUpdateTrigger>();
|
private readonly IList<IUpdateTrigger> _updateTriggers = [];
|
||||||
private readonly List<ILedGroup> _ledGroups = new();
|
private readonly List<ILedGroup> _ledGroups = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a readonly list containing all loaded <see cref="IRGBDevice"/>.
|
/// Gets a readonly list containing all loaded <see cref="IRGBDevice"/>.
|
||||||
@ -184,7 +184,7 @@ public sealed class RGBSurface : AbstractBindable, IDisposable
|
|||||||
{
|
{
|
||||||
List<IRGBDevice> devices;
|
List<IRGBDevice> devices;
|
||||||
lock (Devices)
|
lock (Devices)
|
||||||
devices = new List<IRGBDevice>(_devices);
|
devices = [.._devices];
|
||||||
|
|
||||||
foreach (IRGBDevice device in devices)
|
foreach (IRGBDevice device in devices)
|
||||||
try { Detach(device); }
|
try { Detach(device); }
|
||||||
|
|||||||
@ -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="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="renderTarget">The target (key/point) from which the color should be taken.</param>
|
||||||
/// <param name="color">The <see cref="Color"/> to be modified.</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;
|
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="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="renderTarget">The target (key/point) from which the color should be taken.</param>
|
||||||
/// <returns>The color at the specified point.</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Finalizes the color by appliing the overall brightness and opacity.<br/>
|
/// Finalizes the color by appliing the overall brightness and opacity.<br/>
|
||||||
|
|||||||
@ -41,7 +41,7 @@ public sealed class SolidColorBrush : AbstractBrush
|
|||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override Color GetColorAtPoint(in Rectangle rectangle, in RenderTarget renderTarget) => Color;
|
protected override Color GetColorAtPoint(Rectangle rectangle, RenderTarget renderTarget) => Color;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,7 @@ public sealed class TextureBrush : AbstractBrush
|
|||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override Color GetColorAtPoint(in Rectangle rectangle, in RenderTarget renderTarget)
|
protected override Color GetColorAtPoint(Rectangle rectangle, RenderTarget renderTarget)
|
||||||
{
|
{
|
||||||
Rectangle normalizedRect = renderTarget.Rectangle / rectangle;
|
Rectangle normalizedRect = renderTarget.Rectangle / rectangle;
|
||||||
return Texture[normalizedRect];
|
return Texture[normalizedRect];
|
||||||
|
|||||||
@ -5,8 +5,8 @@ internal sealed class EmptyTexture : ITexture
|
|||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
public Size Size { get; } = new(0, 0);
|
public Size Size { get; } = new(0, 0);
|
||||||
public Color this[in Point point] => Color.Transparent;
|
public Color this[Point point] => Color.Transparent;
|
||||||
public Color this[in Rectangle rectangle] => Color.Transparent;
|
public Color this[Rectangle rectangle] => Color.Transparent;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@ -20,12 +20,12 @@ public interface ITexture
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="point">The location to get the color from.</param>
|
/// <param name="point">The location to get the color from.</param>
|
||||||
/// <returns>The color at the specified location.</returns>
|
/// <returns>The color at the specified location.</returns>
|
||||||
Color this[in Point point] { get; }
|
Color this[Point point] { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the sampled color inside the specified rectangle.
|
/// Gets the sampled color inside the specified rectangle.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="rectangle">The rectangle to get the color from.</param>
|
/// <param name="rectangle">The rectangle to get the color from.</param>
|
||||||
/// <returns>The sampled color.</returns>
|
/// <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; }
|
public Size Size { get; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual Color this[in Point point]
|
public virtual Color this[Point point]
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@ -52,7 +52,7 @@ public abstract class PixelTexture<T> : ITexture
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual Color this[in Rectangle rectangle]
|
public virtual Color this[Rectangle rectangle]
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@ -126,7 +126,7 @@ public abstract class PixelTexture<T> : ITexture
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="pixel">The pixel-data to convert.</param>
|
/// <param name="pixel">The pixel-data to convert.</param>
|
||||||
/// <returns>The color represented by the specified pixel-data.</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Gets the pixel-data at the specified location.
|
/// Gets the pixel-data at the specified location.
|
||||||
@ -189,7 +189,7 @@ public sealed class PixelTexture : PixelTexture<Color>
|
|||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
protected override Color GetColor(in ReadOnlySpan<Color> pixel) => pixel[0];
|
protected override Color GetColor(ReadOnlySpan<Color> pixel) => pixel[0];
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@ -22,7 +22,7 @@ public sealed class AverageColorSampler : ISampler<Color>
|
|||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <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;
|
int count = info.Width * info.Height;
|
||||||
if (count == 0) return;
|
if (count == 0) return;
|
||||||
|
|||||||
@ -13,5 +13,5 @@ public interface ISampler<T>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="info">The information containing the data to sample.</param>
|
/// <param name="info">The information containing the data to sample.</param>
|
||||||
/// <param name="pixelData">The buffer used to write the resulting pixel to.</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="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="height">The height of region the data comes from.</param>
|
||||||
/// <param name="data">The data to sample.</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._x = x;
|
||||||
this._y = y;
|
this._y = y;
|
||||||
|
|||||||
@ -29,13 +29,13 @@ public abstract class AbstractUpdateTrigger : AbstractBindable, IUpdateTrigger
|
|||||||
/// Invokes the <see cref="Starting"/>-event.
|
/// Invokes the <see cref="Starting"/>-event.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="updateData">Optional custom-data passed to the subscribers of the <see cref="Starting"/>.event.</param>
|
/// <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>
|
/// <summary>
|
||||||
/// Invokes the <see cref="Update"/>-event.
|
/// Invokes the <see cref="Update"/>-event.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="updateData">Optional custom-data passed to the subscribers of the <see cref="Update"/>.event.</param>
|
/// <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 />
|
/// <inheritdoc />
|
||||||
public abstract void Start();
|
public abstract void Start();
|
||||||
|
|||||||
@ -52,7 +52,10 @@ public sealed class CustomUpdateData : ICustomUpdateData
|
|||||||
{
|
{
|
||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
private readonly Dictionary<string, object?> _data = new();
|
// ReSharper disable once InconsistentNaming
|
||||||
|
public static readonly CustomUpdateData Empty = new();
|
||||||
|
|
||||||
|
private readonly Dictionary<string, object?> _data = [];
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -65,7 +68,7 @@ public sealed class CustomUpdateData : ICustomUpdateData
|
|||||||
/// <returns>The value represented by the specified key.</returns>
|
/// <returns>The value represented by the specified key.</returns>
|
||||||
public object? this[string key]
|
public object? this[string key]
|
||||||
{
|
{
|
||||||
get => _data.TryGetValue(key, out object? data) ? data : default;
|
get => _data.GetValueOrDefault(key);
|
||||||
set => _data[key] = value;
|
set => _data[key] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -31,5 +31,4 @@ public interface IUpdateQueue<TIdentifier, TData> : IReferenceCounting, IDisposa
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a generic update queue processing <see cref="Color"/>-data using <see cref="object"/>-identifiers.
|
/// Represents a generic update queue processing <see cref="Color"/>-data using <see cref="object"/>-identifiers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IUpdateQueue : IUpdateQueue<object, Color>
|
public interface IUpdateQueue : IUpdateQueue<object, Color>;
|
||||||
{ }
|
|
||||||
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Buffers;
|
using System.Buffers;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
namespace RGB.NET.Core;
|
namespace RGB.NET.Core;
|
||||||
|
|
||||||
@ -14,9 +15,9 @@ public abstract class UpdateQueue<TIdentifier, TData> : AbstractReferenceCountin
|
|||||||
{
|
{
|
||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
private readonly object _dataLock = new();
|
private readonly Lock _dataLock = new();
|
||||||
private readonly IDeviceUpdateTrigger _updateTrigger;
|
private readonly IDeviceUpdateTrigger _updateTrigger;
|
||||||
private readonly Dictionary<TIdentifier, TData> _currentDataSet = new();
|
private readonly Dictionary<TIdentifier, TData> _currentDataSet = [];
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public bool RequiresFlush { get; private set; }
|
public bool RequiresFlush { get; private set; }
|
||||||
@ -80,7 +81,7 @@ public abstract class UpdateQueue<TIdentifier, TData> : AbstractReferenceCountin
|
|||||||
/// Performs the update this queue is responsible for.
|
/// Performs the update this queue is responsible for.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dataSet">The set of data that needs to be updated.</param>
|
/// <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>
|
/// <summary>
|
||||||
/// Sets or merges the provided data set in the current dataset and notifies the trigger that there is new data available.
|
/// 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
|
#region Properties & Fields
|
||||||
|
|
||||||
private readonly object _lock = new();
|
private readonly Lock _lock = new();
|
||||||
|
|
||||||
private readonly CustomUpdateData? _customUpdateData;
|
private readonly CustomUpdateData? _customUpdateData;
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Threading;
|
||||||
using AuraServiceLib;
|
using AuraServiceLib;
|
||||||
using RGB.NET.Core;
|
using RGB.NET.Core;
|
||||||
|
|
||||||
@ -17,7 +18,7 @@ public sealed class AsusDeviceProvider : AbstractRGBDeviceProvider
|
|||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
// ReSharper disable once InconsistentNaming
|
// ReSharper disable once InconsistentNaming
|
||||||
private static readonly object _lock = new();
|
private static readonly Lock _lock = new();
|
||||||
|
|
||||||
private static AsusDeviceProvider? _instance;
|
private static AsusDeviceProvider? _instance;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -76,7 +77,7 @@ public sealed class AsusDeviceProvider : AbstractRGBDeviceProvider
|
|||||||
|
|
||||||
yield return (AsusDeviceType)device.Type switch
|
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.MB_ADDRESABLE => new AsusUnspecifiedRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.LedStripe, device), LedId.LedStripe1, GetUpdateTrigger()),
|
||||||
AsusDeviceType.VGA_RGB => new AsusGraphicsCardRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.GraphicsCard, device), GetUpdateTrigger()),
|
AsusDeviceType.VGA_RGB => new AsusGraphicsCardRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.GraphicsCard, device), GetUpdateTrigger()),
|
||||||
AsusDeviceType.HEADSET_RGB => new AsusHeadsetRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Headset, device), GetUpdateTrigger()),
|
AsusDeviceType.HEADSET_RGB => new AsusHeadsetRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Headset, device), GetUpdateTrigger()),
|
||||||
|
|||||||
@ -43,7 +43,7 @@ public sealed class AsusUpdateQueue : UpdateQueue
|
|||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@ -5,5 +5,4 @@ namespace RGB.NET.Devices.Asus;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a asus RGB-device.
|
/// Represents a asus RGB-device.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IAsusRGBDevice : IRGBDevice
|
public interface IAsusRGBDevice : IRGBDevice;
|
||||||
{ }
|
|
||||||
@ -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
|
|
||||||
}
|
|
||||||
@ -25,8 +25,8 @@ public sealed class AsusKeyboardRGBDevice : AsusRGBDevice<AsusKeyboardRGBDeviceI
|
|||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
private readonly LedMapping<AsusLedId>? _ledMapping;
|
private readonly LedMapping<AsusLedId>? _ledMapping;
|
||||||
private readonly Dictionary<LedId, AsusLedId> _ledAsusLed = new();
|
private readonly Dictionary<LedId, AsusLedId> _ledAsusLed = [];
|
||||||
private readonly Dictionary<LedId, int> _ledAsusLights = new();
|
private readonly Dictionary<LedId, int> _ledAsusLights = [];
|
||||||
|
|
||||||
IKeyboardDeviceInfo IKeyboard.DeviceInfo => DeviceInfo;
|
IKeyboardDeviceInfo IKeyboard.DeviceInfo => DeviceInfo;
|
||||||
|
|
||||||
@ -35,11 +35,11 @@ public sealed class AsusKeyboardRGBDevice : AsusRGBDevice<AsusKeyboardRGBDeviceI
|
|||||||
/// <para>Note: These LED mappings should be based on light indexes.</para>
|
/// <para>Note: These LED mappings should be based on light indexes.</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
// ReSharper disable once InconsistentNaming
|
// ReSharper disable once InconsistentNaming
|
||||||
public static readonly List<AsusKeyboardExtraMapping> ExtraLedMappings = new()
|
public static readonly List<AsusKeyboardExtraMapping> ExtraLedMappings =
|
||||||
{
|
[
|
||||||
new AsusKeyboardExtraMapping(new Regex("(ROG Zephyrus Duo 15).*?"), LedMappings.ROGZephyrusDuo15),
|
new(new Regex("(ROG Zephyrus Duo 15).*?"), LedMappings.ROGZephyrusDuo15),
|
||||||
new AsusKeyboardExtraMapping(new Regex("(ROG Strix G513QM).*?"), LedMappings.ROGStrixG15)
|
new(new Regex("(ROG Strix G513QM).*?"), LedMappings.ROGStrixG15)
|
||||||
};
|
];
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ public sealed class AsusKeyboardRGBDevice : AsusRGBDevice<AsusKeyboardRGBDeviceI
|
|||||||
|
|
||||||
private void InitializeLayout()
|
private void InitializeLayout()
|
||||||
{
|
{
|
||||||
if (DeviceInfo.Device.Type != (uint)AsusDeviceType.NB_KB_4ZONE_RGB && DeviceInfo.Device.Type !=(uint)AsusDeviceType.KEYBOARD_5ZONE_RGB)
|
if ((DeviceInfo.Device.Type != (uint)AsusDeviceType.NB_KB_4ZONE_RGB) && (DeviceInfo.Device.Type !=(uint)AsusDeviceType.KEYBOARD_5ZONE_RGB))
|
||||||
{
|
{
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
int unknownLed = (int)LedId.Unknown1;
|
int unknownLed = (int)LedId.Unknown1;
|
||||||
|
|||||||
@ -13,9 +13,8 @@ public sealed class AsusKeyboardRGBDeviceInfo : AsusRGBDeviceInfo, IKeyboardDevi
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The ASUS SDK returns useless names for notebook keyboards, possibly for others as well.
|
/// 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>
|
/// </summary>
|
||||||
private static readonly List<string> GENERIC_DEVICE_NAMES = new() { "NotebookKeyboard" };
|
private static readonly List<string> GENERIC_DEVICE_NAMES = ["NotebookKeyboard"];
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public KeyboardLayoutType Layout => KeyboardLayoutType.Unknown;
|
public KeyboardLayoutType Layout => KeyboardLayoutType.Unknown;
|
||||||
@ -37,7 +36,7 @@ public sealed class AsusKeyboardRGBDeviceInfo : AsusRGBDeviceInfo, IKeyboardDevi
|
|||||||
|
|
||||||
#region Methods
|
#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
|
#endregion
|
||||||
}
|
}
|
||||||
@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
|
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|
||||||
@ -51,13 +51,13 @@
|
|||||||
<DefineConstants>RELEASE</DefineConstants>
|
<DefineConstants>RELEASE</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
|
||||||
<Content Include="..\Resources\icon.png" Link="icon.png" Pack="true" PackagePath="\" />
|
<Using Include="RGB.NET.Core.Compatibility.Net8" />
|
||||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<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>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Threading;
|
||||||
using RGB.NET.Core;
|
using RGB.NET.Core;
|
||||||
using RGB.NET.Devices.CoolerMaster.Helper;
|
using RGB.NET.Devices.CoolerMaster.Helper;
|
||||||
using RGB.NET.Devices.CoolerMaster.Native;
|
using RGB.NET.Devices.CoolerMaster.Native;
|
||||||
@ -18,7 +19,7 @@ public sealed class CoolerMasterDeviceProvider : AbstractRGBDeviceProvider
|
|||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
// ReSharper disable once InconsistentNaming
|
// ReSharper disable once InconsistentNaming
|
||||||
private static readonly object _lock = new();
|
private static readonly Lock _lock = new();
|
||||||
|
|
||||||
private static CoolerMasterDeviceProvider? _instance;
|
private static CoolerMasterDeviceProvider? _instance;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -37,13 +38,13 @@ public sealed class CoolerMasterDeviceProvider : AbstractRGBDeviceProvider
|
|||||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications.
|
/// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications.
|
||||||
/// The first match will be used.
|
/// The first match will be used.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static List<string> PossibleX86NativePaths { get; } = new() { "x86/CMSDK.dll" };
|
public static List<string> PossibleX86NativePaths { get; } = ["x86/CMSDK.dll"];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x64 applications.
|
/// Gets a modifiable list of paths used to find the native SDK-dlls for x64 applications.
|
||||||
/// The first match will be used.
|
/// The first match will be used.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static List<string> PossibleX64NativePaths { get; } = new() { "x64/CMSDK.dll" };
|
public static List<string> PossibleX64NativePaths { get; } = ["x64/CMSDK.dll"];
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,7 @@ public sealed class CoolerMasterUpdateQueue : UpdateQueue
|
|||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@ -5,5 +5,4 @@ namespace RGB.NET.Devices.CoolerMaster;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a CoolerMaster RGB-device.
|
/// Represents a CoolerMaster RGB-device.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ICoolerMasterRGBDevice : IRGBDevice
|
public interface ICoolerMasterRGBDevice : IRGBDevice;
|
||||||
{ }
|
|
||||||
@ -16,14 +16,14 @@ internal static class _CoolerMasterSDK
|
|||||||
{
|
{
|
||||||
#region Libary Management
|
#region Libary Management
|
||||||
|
|
||||||
private static IntPtr _handle = IntPtr.Zero;
|
private static nint _handle = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reloads the SDK.
|
/// Reloads the SDK.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static void Reload()
|
internal static void Reload()
|
||||||
{
|
{
|
||||||
if (_handle != IntPtr.Zero)
|
if (_handle != 0)
|
||||||
{
|
{
|
||||||
foreach (CoolerMasterDevicesIndexes index in Enum.GetValues(typeof(CoolerMasterDevicesIndexes)))
|
foreach (CoolerMasterDevicesIndexes index in Enum.GetValues(typeof(CoolerMasterDevicesIndexes)))
|
||||||
EnableLedControl(false, index);
|
EnableLedControl(false, index);
|
||||||
@ -34,7 +34,7 @@ internal static class _CoolerMasterSDK
|
|||||||
|
|
||||||
private static void LoadCMSDK()
|
private static void LoadCMSDK()
|
||||||
{
|
{
|
||||||
if (_handle != IntPtr.Zero) return;
|
if (_handle != 0) return;
|
||||||
|
|
||||||
// HACK: Load library at runtime to support both, x86 and x64 with one managed dll
|
// HACK: Load library at runtime to support both, x86 and x64 with one managed dll
|
||||||
List<string> possiblePathList = (Environment.Is64BitProcess ? CoolerMasterDeviceProvider.PossibleX64NativePaths : CoolerMasterDeviceProvider.PossibleX86NativePaths)
|
List<string> possiblePathList = (Environment.Is64BitProcess ? CoolerMasterDeviceProvider.PossibleX64NativePaths : CoolerMasterDeviceProvider.PossibleX86NativePaths)
|
||||||
@ -47,7 +47,7 @@ internal static class _CoolerMasterSDK
|
|||||||
#if NET6_0
|
#if NET6_0
|
||||||
if (_handle == IntPtr.Zero) throw new RGBDeviceException($"CoolerMaster LoadLibrary failed with error code {Marshal.GetLastPInvokeError()}");
|
if (_handle == IntPtr.Zero) throw new RGBDeviceException($"CoolerMaster LoadLibrary failed with error code {Marshal.GetLastPInvokeError()}");
|
||||||
#else
|
#else
|
||||||
if (_handle == IntPtr.Zero) throw new RGBDeviceException($"CoolerMaster LoadLibrary failed with error code {Marshal.GetLastWin32Error()}");
|
if (_handle == 0) throw new RGBDeviceException($"CoolerMaster LoadLibrary failed with error code {Marshal.GetLastWin32Error()}");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_getSDKVersionPointer = (GetSDKVersionPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_handle, "GetCM_SDK_DllVer"), typeof(GetSDKVersionPointer));
|
_getSDKVersionPointer = (GetSDKVersionPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_handle, "GetCM_SDK_DllVer"), typeof(GetSDKVersionPointer));
|
||||||
@ -62,7 +62,7 @@ internal static class _CoolerMasterSDK
|
|||||||
|
|
||||||
internal static void UnloadCMSDK()
|
internal static void UnloadCMSDK()
|
||||||
{
|
{
|
||||||
if (_handle == IntPtr.Zero) return;
|
if (_handle == 0) return;
|
||||||
|
|
||||||
_getSDKVersionPointer = null;
|
_getSDKVersionPointer = null;
|
||||||
_setControlDevicenPointer = null;
|
_setControlDevicenPointer = null;
|
||||||
@ -74,14 +74,14 @@ internal static class _CoolerMasterSDK
|
|||||||
_setAllLedColorPointer = null;
|
_setAllLedColorPointer = null;
|
||||||
|
|
||||||
NativeLibrary.Free(_handle);
|
NativeLibrary.Free(_handle);
|
||||||
_handle = IntPtr.Zero;
|
_handle = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
|
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
|
||||||
private static extern IntPtr LoadLibrary(string dllToLoad);
|
private static extern nint LoadLibrary(string dllToLoad);
|
||||||
|
|
||||||
[DllImport("kernel32.dll", CharSet = CharSet.Ansi)]
|
[DllImport("kernel32.dll", CharSet = CharSet.Ansi)]
|
||||||
private static extern IntPtr GetProcAddress(IntPtr dllHandle, string name);
|
private static extern nint GetProcAddress(nint dllHandle, string name);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
|
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|
||||||
@ -51,6 +51,10 @@
|
|||||||
<DefineConstants>RELEASE</DefineConstants>
|
<DefineConstants>RELEASE</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
|
||||||
|
<Using Include="RGB.NET.Core.Compatibility.Net8" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="..\Resources\icon.png" Link="icon.png" Pack="true" PackagePath="\" />
|
<Content Include="..\Resources\icon.png" Link="icon.png" Pack="true" PackagePath="\" />
|
||||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
<None Include="README.md" Pack="true" PackagePath="\" />
|
||||||
|
|||||||
@ -18,7 +18,7 @@ public sealed class CorsairDeviceProvider : AbstractRGBDeviceProvider
|
|||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
// ReSharper disable once InconsistentNaming
|
// ReSharper disable once InconsistentNaming
|
||||||
private static readonly object _lock = new();
|
private static readonly Lock _lock = new();
|
||||||
|
|
||||||
private static CorsairDeviceProvider? _instance;
|
private static CorsairDeviceProvider? _instance;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -37,13 +37,13 @@ public sealed class CorsairDeviceProvider : AbstractRGBDeviceProvider
|
|||||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications.
|
/// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications.
|
||||||
/// The first match will be used.
|
/// The first match will be used.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static List<string> PossibleX86NativePaths { get; } = new() { "x86/iCUESDK.dll", "x86/CUESDK_2019.dll" };
|
public static List<string> PossibleX86NativePaths { get; } = ["x86/iCUESDK.dll", "x86/CUESDK_2019.dll"];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x64 applications.
|
/// Gets a modifiable list of paths used to find the native SDK-dlls for x64 applications.
|
||||||
/// The first match will be used.
|
/// The first match will be used.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static List<string> PossibleX64NativePaths { get; } = new() { "x64/iCUESDK.dll", "x64/iCUESDK.x64_2019.dll", "x64/CUESDK.dll", "x64/CUESDK.x64_2019.dll" };
|
public static List<string> PossibleX64NativePaths { get; } = ["x64/iCUESDK.dll", "x64/iCUESDK.x64_2019.dll", "x64/CUESDK.dll", "x64/CUESDK.x64_2019.dll"];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the timeout used when connecting to the SDK.
|
/// Gets or sets the timeout used when connecting to the SDK.
|
||||||
@ -273,7 +273,12 @@ public sealed class CorsairDeviceProvider : AbstractRGBDeviceProvider
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CorsairChannelDeviceType.EightLedSeriesFan:
|
case CorsairChannelDeviceType.EightLedSeriesFan:
|
||||||
yield return new CorsairFanRGBDevice(new CorsairFanRGBDeviceInfo(device, ledCount, offset, "8-Led-Series Fan Fan"), updateQueue);
|
string fanModelName = "8-Led-Series Fan";
|
||||||
|
|
||||||
|
if (device.model == "iCUE LINK System Hub")
|
||||||
|
fanModelName = "RX Fan";
|
||||||
|
|
||||||
|
yield return new CorsairFanRGBDevice(new CorsairFanRGBDeviceInfo(device, ledCount, offset, fanModelName), updateQueue);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CorsairChannelDeviceType.DAP:
|
case CorsairChannelDeviceType.DAP:
|
||||||
@ -289,20 +294,20 @@ public sealed class CorsairDeviceProvider : AbstractRGBDeviceProvider
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CorsairChannelDeviceType.Strip:
|
case CorsairChannelDeviceType.Strip:
|
||||||
string modelName = "LED Strip";
|
string stripModelName = "LED Strip";
|
||||||
|
|
||||||
// LS100 Led Strips are reported as one big strip if configured in monitor mode in iCUE, 138 LEDs for dual monitor, 84 for single
|
// 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 ((device.model == "LS100 Starter Kit") && (ledCount == 138))
|
if ((device.model == "LS100 Starter Kit") && (ledCount == 138))
|
||||||
modelName = "LS100 LED Strip (dual monitor)";
|
stripModelName = "LS100 LED Strip (dual monitor)";
|
||||||
else if ((device.model == "LS100 Starter Kit") && (ledCount == 84))
|
else if ((device.model == "LS100 Starter Kit") && (ledCount == 84))
|
||||||
modelName = "LS100 LED Strip (single monitor)";
|
stripModelName = "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
|
// Any other value means an "External LED Strip" in iCUE, these are reported per-strip, 15 for short strips, 27 for long
|
||||||
else if ((device.model == "LS100 Starter Kit") && (ledCount == 15))
|
else if ((device.model == "LS100 Starter Kit") && (ledCount == 15))
|
||||||
modelName = "LS100 LED Strip (short)";
|
stripModelName = "LS100 LED Strip (short)";
|
||||||
else if ((device.model == "LS100 Starter Kit") && (ledCount == 27))
|
else if ((device.model == "LS100 Starter Kit") && (ledCount == 27))
|
||||||
modelName = "LS100 LED Strip (long)";
|
stripModelName = "LS100 LED Strip (long)";
|
||||||
|
|
||||||
yield return new CorsairLedStripRGBDevice(new CorsairLedStripRGBDeviceInfo(device, ledCount, offset, modelName), updateQueue);
|
yield return new CorsairLedStripRGBDevice(new CorsairLedStripRGBDeviceInfo(device, ledCount, offset, stripModelName), updateQueue);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CorsairChannelDeviceType.DRAM:
|
case CorsairChannelDeviceType.DRAM:
|
||||||
@ -310,7 +315,12 @@ public sealed class CorsairDeviceProvider : AbstractRGBDeviceProvider
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Throw(new RGBDeviceException("Unknown Device-Type"));
|
|
||||||
|
//Workaround to support LX Fans because they have an invalid ChannelDeviceType
|
||||||
|
if ((device.model == "iCUE LINK System Hub") && (ledCount == 18))
|
||||||
|
yield return new CorsairFanRGBDevice(new CorsairFanRGBDeviceInfo(device, ledCount, offset, "LX Fan"), updateQueue);
|
||||||
|
else
|
||||||
|
Throw(new RGBDeviceException("Unknown Device-Type"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,7 @@ public sealed class CorsairDeviceUpdateQueue : UpdateQueue
|
|||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <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
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@ -165,7 +165,7 @@ internal static class LedMappings
|
|||||||
|
|
||||||
internal static LedMapping<CorsairLedId> CreateMapping(IEnumerable<CorsairLedId> ids, LedId referenceId)
|
internal static LedMapping<CorsairLedId> CreateMapping(IEnumerable<CorsairLedId> ids, LedId referenceId)
|
||||||
{
|
{
|
||||||
LedMapping<CorsairLedId> mapping = new();
|
LedMapping<CorsairLedId> mapping = [];
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
foreach (CorsairLedId corsairLedId in ids.OrderBy(x => x))
|
foreach (CorsairLedId corsairLedId in ids.OrderBy(x => x))
|
||||||
mapping.Add(referenceId + counter++, corsairLedId);
|
mapping.Add(referenceId + counter++, corsairLedId);
|
||||||
|
|||||||
@ -47,6 +47,9 @@ internal static unsafe class _CUESDK
|
|||||||
|
|
||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
|
// ReSharper disable once NotAccessedField.Local - This is important, the delegate can be collected if it's not stored!
|
||||||
|
private static readonly CorsairSessionStateChangedHandler SESSION_STATE_CHANGED_CALLBACK;
|
||||||
|
|
||||||
internal static bool IsConnected => SesionState == CorsairSessionState.Connected;
|
internal static bool IsConnected => SesionState == CorsairSessionState.Connected;
|
||||||
internal static CorsairSessionState SesionState { get; private set; }
|
internal static CorsairSessionState SesionState { get; private set; }
|
||||||
|
|
||||||
@ -58,6 +61,15 @@ internal static unsafe class _CUESDK
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
|
static _CUESDK()
|
||||||
|
{
|
||||||
|
SESSION_STATE_CHANGED_CALLBACK = CorsairSessionStateChangedCallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
private static void CorsairSessionStateChangedCallback(nint context, _CorsairSessionStateChanged eventdata)
|
private static void CorsairSessionStateChangedCallback(nint context, _CorsairSessionStateChanged eventdata)
|
||||||
@ -121,7 +133,7 @@ internal static unsafe class _CUESDK
|
|||||||
if (OperatingSystem.IsWindows())
|
if (OperatingSystem.IsWindows())
|
||||||
possibleLibraryPaths = Environment.Is64BitProcess ? CorsairDeviceProvider.PossibleX64NativePaths : CorsairDeviceProvider.PossibleX86NativePaths;
|
possibleLibraryPaths = Environment.Is64BitProcess ? CorsairDeviceProvider.PossibleX64NativePaths : CorsairDeviceProvider.PossibleX86NativePaths;
|
||||||
else
|
else
|
||||||
possibleLibraryPaths = Enumerable.Empty<string>();
|
possibleLibraryPaths = [];
|
||||||
|
|
||||||
return possibleLibraryPaths.Select(Environment.ExpandEnvironmentVariables);
|
return possibleLibraryPaths.Select(Environment.ExpandEnvironmentVariables);
|
||||||
}
|
}
|
||||||
@ -174,7 +186,7 @@ internal static unsafe class _CUESDK
|
|||||||
{
|
{
|
||||||
if (_corsairConnectPtr == null) throw new RGBDeviceException("The Corsair-SDK is not initialized.");
|
if (_corsairConnectPtr == null) throw new RGBDeviceException("The Corsair-SDK is not initialized.");
|
||||||
if (IsConnected) throw new RGBDeviceException("The Corsair-SDK is already connected.");
|
if (IsConnected) throw new RGBDeviceException("The Corsair-SDK is already connected.");
|
||||||
return _corsairConnectPtr(CorsairSessionStateChangedCallback, 0);
|
return _corsairConnectPtr(SESSION_STATE_CHANGED_CALLBACK, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static CorsairError CorsairGetSessionDetails(out _CorsairSessionDetails? details)
|
internal static CorsairError CorsairGetSessionDetails(out _CorsairSessionDetails? details)
|
||||||
|
|||||||
@ -19,6 +19,7 @@ internal sealed class _CorsairDeviceFilter
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// iCUE-SDK: mask that describes device types, formed as logical “or” of CorsairDeviceType enum values
|
/// iCUE-SDK: mask that describes device types, formed as logical “or” of CorsairDeviceType enum values
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
// ReSharper disable once NotAccessedField.Global
|
||||||
internal CorsairDeviceType deviceTypeMask;
|
internal CorsairDeviceType deviceTypeMask;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
|
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|
||||||
@ -52,6 +52,10 @@
|
|||||||
<DefineConstants>RELEASE</DefineConstants>
|
<DefineConstants>RELEASE</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
|
||||||
|
<Using Include="RGB.NET.Core.Compatibility.Net8" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="..\Resources\icon.png" Link="icon.png" Pack="true" PackagePath="\" />
|
<Content Include="..\Resources\icon.png" Link="icon.png" Pack="true" PackagePath="\" />
|
||||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
<None Include="README.md" Pack="true" PackagePath="\" />
|
||||||
|
|||||||
@ -5,6 +5,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Threading;
|
||||||
using RGB.NET.Core;
|
using RGB.NET.Core;
|
||||||
using RGB.NET.Devices.CorsairLegacy.Native;
|
using RGB.NET.Devices.CorsairLegacy.Native;
|
||||||
|
|
||||||
@ -19,7 +20,7 @@ public sealed class CorsairLegacyDeviceProvider : AbstractRGBDeviceProvider
|
|||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
// ReSharper disable once InconsistentNaming
|
// ReSharper disable once InconsistentNaming
|
||||||
private static readonly object _lock = new();
|
private static readonly Lock _lock = new();
|
||||||
|
|
||||||
private static CorsairLegacyDeviceProvider? _instance;
|
private static CorsairLegacyDeviceProvider? _instance;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -38,13 +39,13 @@ public sealed class CorsairLegacyDeviceProvider : AbstractRGBDeviceProvider
|
|||||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications.
|
/// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications.
|
||||||
/// The first match will be used.
|
/// The first match will be used.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static List<string> PossibleX86NativePaths { get; } = new() { "x86/CUESDK.dll", "x86/CUESDK_2019.dll", "x86/CUESDK_2017.dll", "x86/CUESDK_2015.dll", "x86/CUESDK_2013.dll" };
|
public static List<string> PossibleX86NativePaths { get; } = ["x86/CUESDK.dll", "x86/CUESDK_2019.dll", "x86/CUESDK_2017.dll", "x86/CUESDK_2015.dll", "x86/CUESDK_2013.dll"];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x64 applications.
|
/// Gets a modifiable list of paths used to find the native SDK-dlls for x64 applications.
|
||||||
/// The first match will be used.
|
/// The first match will be used.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static List<string> PossibleX64NativePaths { get; } = new() { "x64/CUESDK.dll", "x64/CUESDK.x64_2019.dll", "x64/CUESDK.x64_2017.dll", "x64/CUESDK_2019.dll", "x64/CUESDK_2017.dll", "x64/CUESDK_2015.dll", "x64/CUESDK_2013.dll" };
|
public static List<string> PossibleX64NativePaths { get; } = ["x64/CUESDK.dll", "x64/CUESDK.x64_2019.dll", "x64/CUESDK.x64_2017.dll", "x64/CUESDK_2019.dll", "x64/CUESDK_2017.dll", "x64/CUESDK_2015.dll", "x64/CUESDK_2013.dll"];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the protocol details for the current SDK-connection.
|
/// Gets the protocol details for the current SDK-connection.
|
||||||
@ -170,7 +171,7 @@ public sealed class CorsairLegacyDeviceProvider : AbstractRGBDeviceProvider
|
|||||||
foreach (_CorsairChannelInfo channelInfo in channels)
|
foreach (_CorsairChannelInfo channelInfo in channels)
|
||||||
{
|
{
|
||||||
int channelDeviceInfoStructSize = Marshal.SizeOf(typeof(_CorsairChannelDeviceInfo));
|
int channelDeviceInfoStructSize = Marshal.SizeOf(typeof(_CorsairChannelDeviceInfo));
|
||||||
IntPtr channelDeviceInfoPtr = channelInfo.devices;
|
nint channelDeviceInfoPtr = channelInfo.devices;
|
||||||
for (int device = 0; (device < channelInfo.devicesCount) && (ledOffset < nativeDeviceInfo.ledsCount); device++)
|
for (int device = 0; (device < channelInfo.devicesCount) && (ledOffset < nativeDeviceInfo.ledsCount); device++)
|
||||||
{
|
{
|
||||||
_CorsairChannelDeviceInfo channelDeviceInfo = (_CorsairChannelDeviceInfo)Marshal.PtrToStructure(channelDeviceInfoPtr, typeof(_CorsairChannelDeviceInfo))!;
|
_CorsairChannelDeviceInfo channelDeviceInfo = (_CorsairChannelDeviceInfo)Marshal.PtrToStructure(channelDeviceInfoPtr, typeof(_CorsairChannelDeviceInfo))!;
|
||||||
@ -178,7 +179,7 @@ public sealed class CorsairLegacyDeviceProvider : AbstractRGBDeviceProvider
|
|||||||
yield return new CorsairCustomRGBDevice(new CorsairCustomRGBDeviceInfo(i, nativeDeviceInfo, channelDeviceInfo, ledOffset), updateQueue);
|
yield return new CorsairCustomRGBDevice(new CorsairCustomRGBDeviceInfo(i, nativeDeviceInfo, channelDeviceInfo, ledOffset), updateQueue);
|
||||||
|
|
||||||
ledOffset += channelDeviceInfo.deviceLedCount;
|
ledOffset += channelDeviceInfo.deviceLedCount;
|
||||||
channelDeviceInfoPtr = new IntPtr(channelDeviceInfoPtr.ToInt64() + channelDeviceInfoStructSize);
|
channelDeviceInfoPtr += channelDeviceInfoStructSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -195,13 +196,13 @@ public sealed class CorsairLegacyDeviceProvider : AbstractRGBDeviceProvider
|
|||||||
_CorsairChannelsInfo? channelsInfo = deviceInfo.channels;
|
_CorsairChannelsInfo? channelsInfo = deviceInfo.channels;
|
||||||
if (channelsInfo == null) yield break;
|
if (channelsInfo == null) yield break;
|
||||||
|
|
||||||
IntPtr channelInfoPtr = channelsInfo.channels;
|
nint channelInfoPtr = channelsInfo.channels;
|
||||||
for (int channel = 0; channel < channelsInfo.channelsCount; channel++)
|
for (int channel = 0; channel < channelsInfo.channelsCount; channel++)
|
||||||
{
|
{
|
||||||
yield return (_CorsairChannelInfo)Marshal.PtrToStructure(channelInfoPtr, typeof(_CorsairChannelInfo))!;
|
yield return (_CorsairChannelInfo)Marshal.PtrToStructure(channelInfoPtr, typeof(_CorsairChannelInfo))!;
|
||||||
|
|
||||||
int channelInfoStructSize = Marshal.SizeOf(typeof(_CorsairChannelInfo));
|
int channelInfoStructSize = Marshal.SizeOf(typeof(_CorsairChannelInfo));
|
||||||
channelInfoPtr = new IntPtr(channelInfoPtr.ToInt64() + channelInfoStructSize);
|
channelInfoPtr += channelInfoStructSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
// ReSharper disable MemberCanBePrivate.Global
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
// ReSharper disable UnusedMember.Global
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using RGB.NET.Core;
|
using RGB.NET.Core;
|
||||||
@ -24,7 +23,7 @@ public class CorsairCustomRGBDevice : CorsairRGBDevice<CorsairCustomRGBDeviceInf
|
|||||||
/// <param name="info">The specific information provided by CUE for the custom-device.</param>
|
/// <param name="info">The specific information provided by CUE for the custom-device.</param>
|
||||||
/// <param name="updateQueue">The queue used to update this device.</param>
|
/// <param name="updateQueue">The queue used to update this device.</param>
|
||||||
internal CorsairCustomRGBDevice(CorsairCustomRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
|
internal CorsairCustomRGBDevice(CorsairCustomRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
|
||||||
: base(info, new LedMapping<CorsairLedId>(), updateQueue)
|
: base(info, [], updateQueue)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -40,7 +39,7 @@ public class CorsairCustomRGBDevice : CorsairRGBDevice<CorsairCustomRGBDeviceInf
|
|||||||
if (nativeLedPositions == null) return;
|
if (nativeLedPositions == null) return;
|
||||||
|
|
||||||
int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition));
|
int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition));
|
||||||
IntPtr ptr = new(nativeLedPositions.pLedPosition.ToInt64() + (structSize * DeviceInfo.LedOffset));
|
nint ptr = nativeLedPositions.pLedPosition + (structSize * DeviceInfo.LedOffset);
|
||||||
|
|
||||||
LedId referenceLedId = GetReferenceLed(DeviceInfo.DeviceType);
|
LedId referenceLedId = GetReferenceLed(DeviceInfo.DeviceType);
|
||||||
for (int i = 0; i < DeviceInfo.LedCount; i++)
|
for (int i = 0; i < DeviceInfo.LedCount; i++)
|
||||||
@ -49,7 +48,7 @@ public class CorsairCustomRGBDevice : CorsairRGBDevice<CorsairCustomRGBDeviceInf
|
|||||||
_CorsairLedPosition? ledPosition = (_CorsairLedPosition?)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition));
|
_CorsairLedPosition? ledPosition = (_CorsairLedPosition?)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition));
|
||||||
if (ledPosition == null)
|
if (ledPosition == null)
|
||||||
{
|
{
|
||||||
ptr = new IntPtr(ptr.ToInt64() + structSize);
|
ptr += structSize;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +59,7 @@ public class CorsairCustomRGBDevice : CorsairRGBDevice<CorsairCustomRGBDeviceInf
|
|||||||
Rectangle rectangle = ledPosition.ToRectangle();
|
Rectangle rectangle = ledPosition.ToRectangle();
|
||||||
AddLed(ledId, rectangle.Location, rectangle.Size);
|
AddLed(ledId, rectangle.Location, rectangle.Size);
|
||||||
|
|
||||||
ptr = new IntPtr(ptr.ToInt64() + structSize);
|
ptr += structSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DeviceInfo.LedOffset > 0)
|
if (DeviceInfo.LedOffset > 0)
|
||||||
|
|||||||
@ -41,7 +41,7 @@ public class CorsairCustomRGBDeviceInfo : CorsairRGBDeviceInfo
|
|||||||
/// <param name="ledOffset">The offset used to find the LEDs of this device.</param>
|
/// <param name="ledOffset">The offset used to find the LEDs of this device.</param>
|
||||||
internal CorsairCustomRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo, _CorsairChannelDeviceInfo channelDeviceInfo, int ledOffset)
|
internal CorsairCustomRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo, _CorsairChannelDeviceInfo channelDeviceInfo, int ledOffset)
|
||||||
: base(deviceIndex, GetDeviceType(channelDeviceInfo.type), nativeInfo,
|
: base(deviceIndex, GetDeviceType(channelDeviceInfo.type), nativeInfo,
|
||||||
GetModelName(nativeInfo.model == IntPtr.Zero ? string.Empty : Regex.Replace(Marshal.PtrToStringAnsi(nativeInfo.model) ?? string.Empty, " ?DEMO", string.Empty, RegexOptions.IgnoreCase), channelDeviceInfo))
|
GetModelName(nativeInfo.model == 0 ? string.Empty : Regex.Replace(Marshal.PtrToStringAnsi(nativeInfo.model) ?? string.Empty, " ?DEMO", string.Empty, RegexOptions.IgnoreCase), channelDeviceInfo))
|
||||||
{
|
{
|
||||||
this.LedOffset = ledOffset;
|
this.LedOffset = ledOffset;
|
||||||
|
|
||||||
@ -124,16 +124,19 @@ 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
|
// 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))
|
if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 138))
|
||||||
return "LS100 LED Strip (dual monitor)";
|
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)";
|
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
|
// 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)";
|
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)";
|
return "LS100 LED Strip (long)";
|
||||||
|
|
||||||
// Device model is "Commander Pro" for regular LED strips
|
// Device model is "Commander Pro" for regular LED strips
|
||||||
else
|
return "LED Strip";
|
||||||
return "LED Strip";
|
|
||||||
|
|
||||||
case CorsairChannelDeviceType.DAP:
|
case CorsairChannelDeviceType.DAP:
|
||||||
return "DAP Fan";
|
return "DAP Fan";
|
||||||
|
|||||||
@ -35,13 +35,13 @@ public class CorsairDeviceUpdateQueue : UpdateQueue
|
|||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int structSize = Marshal.SizeOf(typeof(_CorsairLedColor));
|
int structSize = Marshal.SizeOf(typeof(_CorsairLedColor));
|
||||||
IntPtr ptr = Marshal.AllocHGlobal(structSize * dataSet.Length);
|
nint ptr = Marshal.AllocHGlobal(structSize * dataSet.Length);
|
||||||
IntPtr addPtr = new(ptr.ToInt64());
|
nint addPtr = ptr;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
foreach ((object key, Color color) in dataSet)
|
foreach ((object key, Color color) in dataSet)
|
||||||
@ -55,7 +55,7 @@ public class CorsairDeviceUpdateQueue : UpdateQueue
|
|||||||
};
|
};
|
||||||
|
|
||||||
Marshal.StructureToPtr(corsairColor, addPtr, false);
|
Marshal.StructureToPtr(corsairColor, addPtr, false);
|
||||||
addPtr = new IntPtr(addPtr.ToInt64() + structSize);
|
addPtr += structSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
_CUESDK.CorsairSetLedsColorsBufferByDeviceIndex(_deviceIndex, dataSet.Length, ptr);
|
_CUESDK.CorsairSetLedsColorsBufferByDeviceIndex(_deviceIndex, dataSet.Length, ptr);
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
// ReSharper disable MemberCanBePrivate.Global
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using RGB.NET.Devices.CorsairLegacy.Native;
|
using RGB.NET.Devices.CorsairLegacy.Native;
|
||||||
|
|
||||||
@ -54,8 +53,8 @@ public class CorsairProtocolDetails
|
|||||||
/// <param name="nativeDetails">The native CorsairProtocolDetails-struct</param>
|
/// <param name="nativeDetails">The native CorsairProtocolDetails-struct</param>
|
||||||
internal CorsairProtocolDetails(_CorsairProtocolDetails nativeDetails)
|
internal CorsairProtocolDetails(_CorsairProtocolDetails nativeDetails)
|
||||||
{
|
{
|
||||||
this.SdkVersion = nativeDetails.sdkVersion == IntPtr.Zero ? null : Marshal.PtrToStringAnsi(nativeDetails.sdkVersion);
|
this.SdkVersion = nativeDetails.sdkVersion == 0 ? null : Marshal.PtrToStringAnsi(nativeDetails.sdkVersion);
|
||||||
this.ServerVersion = nativeDetails.serverVersion == IntPtr.Zero ? null : Marshal.PtrToStringAnsi(nativeDetails.serverVersion);
|
this.ServerVersion = nativeDetails.serverVersion == 0 ? null : Marshal.PtrToStringAnsi(nativeDetails.serverVersion);
|
||||||
this.SdkProtocolVersion = nativeDetails.sdkProtocolVersion;
|
this.SdkProtocolVersion = nativeDetails.sdkProtocolVersion;
|
||||||
this.ServerProtocolVersion = nativeDetails.serverProtocolVersion;
|
this.ServerProtocolVersion = nativeDetails.serverProtocolVersion;
|
||||||
this.BreakingChanges = nativeDetails.breakingChanges != 0;
|
this.BreakingChanges = nativeDetails.breakingChanges != 0;
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.Runtime.InteropServices;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using RGB.NET.Core;
|
using RGB.NET.Core;
|
||||||
using RGB.NET.Devices.CorsairLegacy.Native;
|
using RGB.NET.Devices.CorsairLegacy.Native;
|
||||||
|
|
||||||
@ -50,14 +49,14 @@ public abstract class CorsairRGBDevice<TDeviceInfo> : AbstractRGBDevice<TDeviceI
|
|||||||
if (nativeLedPositions == null) return;
|
if (nativeLedPositions == null) return;
|
||||||
|
|
||||||
int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition));
|
int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition));
|
||||||
IntPtr ptr = nativeLedPositions.pLedPosition;
|
nint ptr = nativeLedPositions.pLedPosition;
|
||||||
|
|
||||||
for (int i = 0; i < nativeLedPositions.numberOfLed; i++)
|
for (int i = 0; i < nativeLedPositions.numberOfLed; i++)
|
||||||
{
|
{
|
||||||
_CorsairLedPosition? ledPosition = (_CorsairLedPosition?)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition));
|
_CorsairLedPosition? ledPosition = (_CorsairLedPosition?)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition));
|
||||||
if (ledPosition == null)
|
if (ledPosition == null)
|
||||||
{
|
{
|
||||||
ptr = new IntPtr(ptr.ToInt64() + structSize);
|
ptr += structSize;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +64,7 @@ public abstract class CorsairRGBDevice<TDeviceInfo> : AbstractRGBDevice<TDeviceI
|
|||||||
Rectangle rectangle = ledPosition.ToRectangle();
|
Rectangle rectangle = ledPosition.ToRectangle();
|
||||||
AddLed(ledId, rectangle.Location, rectangle.Size);
|
AddLed(ledId, rectangle.Location, rectangle.Size);
|
||||||
|
|
||||||
ptr = new IntPtr(ptr.ToInt64() + structSize);
|
ptr += structSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.Runtime.InteropServices;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using RGB.NET.Core;
|
using RGB.NET.Core;
|
||||||
using RGB.NET.Devices.CorsairLegacy.Native;
|
using RGB.NET.Devices.CorsairLegacy.Native;
|
||||||
@ -65,7 +64,7 @@ public class CorsairRGBDeviceInfo : IRGBDeviceInfo
|
|||||||
this.CorsairDeviceIndex = deviceIndex;
|
this.CorsairDeviceIndex = deviceIndex;
|
||||||
this.DeviceType = deviceType;
|
this.DeviceType = deviceType;
|
||||||
this.CorsairDeviceType = nativeInfo.type;
|
this.CorsairDeviceType = nativeInfo.type;
|
||||||
this.Model = nativeInfo.model == IntPtr.Zero ? string.Empty : Regex.Replace(Marshal.PtrToStringAnsi(nativeInfo.model) ?? string.Empty, " ?DEMO", string.Empty, RegexOptions.IgnoreCase);
|
this.Model = nativeInfo.model == 0 ? string.Empty : Regex.Replace(Marshal.PtrToStringAnsi(nativeInfo.model) ?? string.Empty, " ?DEMO", string.Empty, RegexOptions.IgnoreCase);
|
||||||
this.DeviceId = nativeInfo.deviceId ?? string.Empty;
|
this.DeviceId = nativeInfo.deviceId ?? string.Empty;
|
||||||
this.CapsMask = (CorsairDeviceCaps)nativeInfo.capsMask;
|
this.CapsMask = (CorsairDeviceCaps)nativeInfo.capsMask;
|
||||||
|
|
||||||
|
|||||||
@ -34,27 +34,27 @@ public static class LedMappings
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the mapping for graphics cards.
|
/// Gets the mapping for graphics cards.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static LedMapping<CorsairLedId> GraphicsCard { get; } = new();
|
public static LedMapping<CorsairLedId> GraphicsCard { get; } = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the mapping for headsets.
|
/// Gets the mapping for headsets.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static LedMapping<CorsairLedId> HeadsetStand { get; } = new();
|
public static LedMapping<CorsairLedId> HeadsetStand { get; } = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the mapping for mainboards.
|
/// Gets the mapping for mainboards.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static LedMapping<CorsairLedId> Mainboard { get; } = new();
|
public static LedMapping<CorsairLedId> Mainboard { get; } = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the mapping for memory.
|
/// Gets the mapping for memory.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static LedMapping<CorsairLedId> Memory { get; } = new();
|
public static LedMapping<CorsairLedId> Memory { get; } = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the mapping for mousepads.
|
/// Gets the mapping for mousepads.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static LedMapping<CorsairLedId> Mousepad { get; } = new();
|
public static LedMapping<CorsairLedId> Mousepad { get; } = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the mapping for headsets.
|
/// Gets the mapping for headsets.
|
||||||
|
|||||||
@ -7,7 +7,7 @@ internal static class NativeExtensions
|
|||||||
{
|
{
|
||||||
internal static Rectangle ToRectangle(this _CorsairLedPosition position)
|
internal static Rectangle ToRectangle(this _CorsairLedPosition position)
|
||||||
{
|
{
|
||||||
//HACK DarthAffe 08.07.2018: It seems like corsair introduced a bug here - it's always 0.
|
//HACK DarthAffe 08.07.2018: It seems like corsair introduced a issue here - it's always 0.
|
||||||
float width = position.width < 0.5f ? 10 : (float)position.width;
|
float width = position.width < 0.5f ? 10 : (float)position.width;
|
||||||
float height = position.height < 0.5f ? 10 : (float)position.height;
|
float height = position.height < 0.5f ? 10 : (float)position.height;
|
||||||
float posX = (float)position.left;
|
float posX = (float)position.left;
|
||||||
|
|||||||
@ -16,7 +16,7 @@ internal static class _CUESDK
|
|||||||
{
|
{
|
||||||
#region Libary Management
|
#region Libary Management
|
||||||
|
|
||||||
private static IntPtr _handle = IntPtr.Zero;
|
private static nint _handle = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reloads the SDK.
|
/// Reloads the SDK.
|
||||||
@ -29,7 +29,7 @@ internal static class _CUESDK
|
|||||||
|
|
||||||
private static void LoadCUESDK()
|
private static void LoadCUESDK()
|
||||||
{
|
{
|
||||||
if (_handle != IntPtr.Zero) return;
|
if (_handle != 0) return;
|
||||||
|
|
||||||
List<string> possiblePathList = GetPossibleLibraryPaths().ToList();
|
List<string> possiblePathList = GetPossibleLibraryPaths().ToList();
|
||||||
|
|
||||||
@ -64,30 +64,30 @@ internal static class _CUESDK
|
|||||||
if (OperatingSystem.IsWindows())
|
if (OperatingSystem.IsWindows())
|
||||||
possibleLibraryPaths = Environment.Is64BitProcess ? CorsairLegacyDeviceProvider.PossibleX64NativePaths : CorsairLegacyDeviceProvider.PossibleX86NativePaths;
|
possibleLibraryPaths = Environment.Is64BitProcess ? CorsairLegacyDeviceProvider.PossibleX64NativePaths : CorsairLegacyDeviceProvider.PossibleX86NativePaths;
|
||||||
else
|
else
|
||||||
possibleLibraryPaths = Enumerable.Empty<string>();
|
possibleLibraryPaths = [];
|
||||||
|
|
||||||
return possibleLibraryPaths.Select(Environment.ExpandEnvironmentVariables);
|
return possibleLibraryPaths.Select(Environment.ExpandEnvironmentVariables);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void UnloadCUESDK()
|
internal static void UnloadCUESDK()
|
||||||
{
|
{
|
||||||
if (_handle == IntPtr.Zero) return;
|
if (_handle == 0) return;
|
||||||
|
|
||||||
_corsairSetLedsColorsBufferByDeviceIndexPointer = IntPtr.Zero;
|
_corsairSetLedsColorsBufferByDeviceIndexPointer = 0;
|
||||||
_corsairSetLedsColorsFlushBufferPointer = IntPtr.Zero;
|
_corsairSetLedsColorsFlushBufferPointer = 0;
|
||||||
_corsairGetLedsColorsByDeviceIndexPointer = IntPtr.Zero;
|
_corsairGetLedsColorsByDeviceIndexPointer = 0;
|
||||||
_corsairSetLayerPriorityPointer = IntPtr.Zero;
|
_corsairSetLayerPriorityPointer = 0;
|
||||||
_corsairGetDeviceCountPointer = IntPtr.Zero;
|
_corsairGetDeviceCountPointer = 0;
|
||||||
_corsairGetDeviceInfoPointer = IntPtr.Zero;
|
_corsairGetDeviceInfoPointer = 0;
|
||||||
_corsairGetLedIdForKeyNamePointer = IntPtr.Zero;
|
_corsairGetLedIdForKeyNamePointer = 0;
|
||||||
_corsairGetLedPositionsByDeviceIndexPointer = IntPtr.Zero;
|
_corsairGetLedPositionsByDeviceIndexPointer = 0;
|
||||||
_corsairRequestControlPointer = IntPtr.Zero;
|
_corsairRequestControlPointer = 0;
|
||||||
_corsairReleaseControlPointer = IntPtr.Zero;
|
_corsairReleaseControlPointer = 0;
|
||||||
_corsairPerformProtocolHandshakePointer = IntPtr.Zero;
|
_corsairPerformProtocolHandshakePointer = 0;
|
||||||
_corsairGetLastErrorPointer = IntPtr.Zero;
|
_corsairGetLastErrorPointer = 0;
|
||||||
|
|
||||||
NativeLibrary.Free(_handle);
|
NativeLibrary.Free(_handle);
|
||||||
_handle = IntPtr.Zero;
|
_handle = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -96,18 +96,18 @@ internal static class _CUESDK
|
|||||||
|
|
||||||
#region Pointers
|
#region Pointers
|
||||||
|
|
||||||
private static IntPtr _corsairSetLedsColorsBufferByDeviceIndexPointer;
|
private static nint _corsairSetLedsColorsBufferByDeviceIndexPointer;
|
||||||
private static IntPtr _corsairSetLedsColorsFlushBufferPointer;
|
private static nint _corsairSetLedsColorsFlushBufferPointer;
|
||||||
private static IntPtr _corsairGetLedsColorsByDeviceIndexPointer;
|
private static nint _corsairGetLedsColorsByDeviceIndexPointer;
|
||||||
private static IntPtr _corsairSetLayerPriorityPointer;
|
private static nint _corsairSetLayerPriorityPointer;
|
||||||
private static IntPtr _corsairGetDeviceCountPointer;
|
private static nint _corsairGetDeviceCountPointer;
|
||||||
private static IntPtr _corsairGetDeviceInfoPointer;
|
private static nint _corsairGetDeviceInfoPointer;
|
||||||
private static IntPtr _corsairGetLedIdForKeyNamePointer;
|
private static nint _corsairGetLedIdForKeyNamePointer;
|
||||||
private static IntPtr _corsairGetLedPositionsByDeviceIndexPointer;
|
private static nint _corsairGetLedPositionsByDeviceIndexPointer;
|
||||||
private static IntPtr _corsairRequestControlPointer;
|
private static nint _corsairRequestControlPointer;
|
||||||
private static IntPtr _corsairReleaseControlPointer;
|
private static nint _corsairReleaseControlPointer;
|
||||||
private static IntPtr _corsairPerformProtocolHandshakePointer;
|
private static nint _corsairPerformProtocolHandshakePointer;
|
||||||
private static IntPtr _corsairGetLastErrorPointer;
|
private static nint _corsairGetLastErrorPointer;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -118,8 +118,8 @@ internal static class _CUESDK
|
|||||||
/// and follows after one or more calls of CorsairSetLedsColorsBufferByDeviceIndex to set the LEDs buffer.
|
/// and follows after one or more calls of CorsairSetLedsColorsBufferByDeviceIndex to set the LEDs buffer.
|
||||||
/// This function does not take logical layout into account.
|
/// This function does not take logical layout into account.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static unsafe bool CorsairSetLedsColorsBufferByDeviceIndex(int deviceIndex, int size, IntPtr ledsColors)
|
internal static unsafe bool CorsairSetLedsColorsBufferByDeviceIndex(int deviceIndex, int size, nint ledsColors)
|
||||||
=> ((delegate* unmanaged[Cdecl]<int, int, IntPtr, bool>)ThrowIfZero(_corsairSetLedsColorsBufferByDeviceIndexPointer))(deviceIndex, size, ledsColors);
|
=> ((delegate* unmanaged[Cdecl]<int, int, nint, bool>)ThrowIfZero(_corsairSetLedsColorsBufferByDeviceIndexPointer))(deviceIndex, size, ledsColors);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// CUE-SDK: writes to the devices LEDs colors buffer which is previously filled by the CorsairSetLedsColorsBufferByDeviceIndex function.
|
/// CUE-SDK: writes to the devices LEDs colors buffer which is previously filled by the CorsairSetLedsColorsBufferByDeviceIndex function.
|
||||||
@ -132,8 +132,8 @@ internal static class _CUESDK
|
|||||||
/// The color should represent the actual state of the hardware LED, which could be a combination of SDK and/or CUE input.
|
/// The color should represent the actual state of the hardware LED, which could be a combination of SDK and/or CUE input.
|
||||||
/// This function works for keyboard, mouse, mousemat, headset, headset stand and DIY-devices.
|
/// This function works for keyboard, mouse, mousemat, headset, headset stand and DIY-devices.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static unsafe bool CorsairGetLedsColorsByDeviceIndex(int deviceIndex, int size, IntPtr ledsColors)
|
internal static unsafe bool CorsairGetLedsColorsByDeviceIndex(int deviceIndex, int size, nint ledsColors)
|
||||||
=> ((delegate* unmanaged[Cdecl]<int, int, IntPtr, bool>)ThrowIfZero(_corsairGetLedsColorsByDeviceIndexPointer))(deviceIndex, size, ledsColors);
|
=> ((delegate* unmanaged[Cdecl]<int, int, nint, bool>)ThrowIfZero(_corsairGetLedsColorsByDeviceIndexPointer))(deviceIndex, size, ledsColors);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// CUE-SDK: set layer priority for this shared client.
|
/// CUE-SDK: set layer priority for this shared client.
|
||||||
@ -150,12 +150,12 @@ internal static class _CUESDK
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// CUE-SDK: returns information about device at provided index.
|
/// CUE-SDK: returns information about device at provided index.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static unsafe IntPtr CorsairGetDeviceInfo(int deviceIndex) => ((delegate* unmanaged[Cdecl]<int, IntPtr>)ThrowIfZero(_corsairGetDeviceInfoPointer))(deviceIndex);
|
internal static unsafe nint CorsairGetDeviceInfo(int deviceIndex) => ((delegate* unmanaged[Cdecl]<int, nint>)ThrowIfZero(_corsairGetDeviceInfoPointer))(deviceIndex);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// CUE-SDK: provides list of keyboard or mousepad LEDs with their physical positions.
|
/// CUE-SDK: provides list of keyboard or mousepad LEDs with their physical positions.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static unsafe IntPtr CorsairGetLedPositionsByDeviceIndex(int deviceIndex) => ((delegate* unmanaged[Cdecl]<int, IntPtr>)ThrowIfZero(_corsairGetLedPositionsByDeviceIndexPointer))(deviceIndex);
|
internal static unsafe nint CorsairGetLedPositionsByDeviceIndex(int deviceIndex) => ((delegate* unmanaged[Cdecl]<int, nint>)ThrowIfZero(_corsairGetLedPositionsByDeviceIndexPointer))(deviceIndex);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// CUE-SDK: retrieves led id for key name taking logical layout into account.
|
/// CUE-SDK: retrieves led id for key name taking logical layout into account.
|
||||||
@ -183,9 +183,9 @@ internal static class _CUESDK
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal static unsafe CorsairError CorsairGetLastError() => ((delegate* unmanaged[Cdecl]<CorsairError>)ThrowIfZero(_corsairGetLastErrorPointer))();
|
internal static unsafe CorsairError CorsairGetLastError() => ((delegate* unmanaged[Cdecl]<CorsairError>)ThrowIfZero(_corsairGetLastErrorPointer))();
|
||||||
|
|
||||||
private static IntPtr ThrowIfZero(IntPtr ptr)
|
private static nint ThrowIfZero(nint ptr)
|
||||||
{
|
{
|
||||||
if (ptr == IntPtr.Zero) throw new RGBDeviceException("The Corsair-SDK is not initialized.");
|
if (ptr == 0) throw new RGBDeviceException("The Corsair-SDK is not initialized.");
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,6 @@
|
|||||||
#pragma warning disable 649 // Field 'x' is never assigned
|
#pragma warning disable 649 // Field 'x' is never assigned
|
||||||
#pragma warning disable IDE1006 // Naming Styles
|
#pragma warning disable IDE1006 // Naming Styles
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace RGB.NET.Devices.CorsairLegacy.Native;
|
namespace RGB.NET.Devices.CorsairLegacy.Native;
|
||||||
@ -29,5 +28,5 @@ internal class _CorsairChannelInfo
|
|||||||
/// CUE-SDK: array containing information about each separate LED-device connected to the channel controlled by the DIY device.
|
/// CUE-SDK: array containing information about each separate LED-device connected to the channel controlled by the DIY device.
|
||||||
/// Index of the LED-device in array is same as the index of the LED-device connected to the DIY-device.
|
/// Index of the LED-device in array is same as the index of the LED-device connected to the DIY-device.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal IntPtr devices;
|
internal nint devices;
|
||||||
}
|
}
|
||||||
@ -3,7 +3,6 @@
|
|||||||
#pragma warning disable 649 // Field 'x' is never assigned
|
#pragma warning disable 649 // Field 'x' is never assigned
|
||||||
#pragma warning disable IDE1006 // Naming Styles
|
#pragma warning disable IDE1006 // Naming Styles
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace RGB.NET.Devices.CorsairLegacy.Native;
|
namespace RGB.NET.Devices.CorsairLegacy.Native;
|
||||||
@ -24,5 +23,5 @@ internal class _CorsairChannelsInfo
|
|||||||
/// CUE-SDK: array containing information about each separate channel of the DIY-device.
|
/// CUE-SDK: array containing information about each separate channel of the DIY-device.
|
||||||
/// Index of the channel in the array is same as index of the channel on the DIY-device.
|
/// Index of the channel in the array is same as index of the channel on the DIY-device.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal IntPtr channels;
|
internal nint channels;
|
||||||
}
|
}
|
||||||
@ -3,7 +3,6 @@
|
|||||||
#pragma warning disable 649 // Field 'x' is never assigned
|
#pragma warning disable 649 // Field 'x' is never assigned
|
||||||
#pragma warning disable IDE1006 // Naming Styles
|
#pragma warning disable IDE1006 // Naming Styles
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace RGB.NET.Devices.CorsairLegacy.Native;
|
namespace RGB.NET.Devices.CorsairLegacy.Native;
|
||||||
@ -23,7 +22,7 @@ internal class _CorsairDeviceInfo
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// CUE-SDK: null - terminated device model(like “K95RGB”)
|
/// CUE-SDK: null - terminated device model(like “K95RGB”)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal IntPtr model;
|
internal nint model;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// CUE-SDK: enum describing physical layout of the keyboard or mouse
|
/// CUE-SDK: enum describing physical layout of the keyboard or mouse
|
||||||
|
|||||||
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