Skip to content

Commit 25534c1

Browse files
authored
Merge pull request #157 from DarthAffe/Development
Merge development to master
2 parents 0b76199 + bfb024d commit 25534c1

File tree

176 files changed

+3616
-708
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

176 files changed

+3616
-708
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ This is the easiest and therefore preferred way to include RGB.NET in your proje
1212
Since there aren't any release-packages right now you'll have to use the CI-feed from [http://nuget.arge.be](http://nuget.arge.be).
1313
You can include it either by adding ```http://nuget.arge.be/v3/index.json``` to your Visual Studio package sources or by adding this [NuGet.Config](https://github.com/DarthAffe/RGB.NET/tree/master/Documentation/NuGet.Config) to your project (at the same level as your solution).
1414

15+
### .NET 4.5 Support ###
16+
At the end of the year with the release of .NET 5 the support for old .NET-Framwork versions will be droppped!
17+
It's not recommended to use RGB.NET in projects targeting .NET 4.x that aren't planned to be moved to Core/.NET 5 in the future.
18+
1519

1620
### Device-Layouts
1721
To be able to have devices with correct LED-locations and sizes they need to be layouted. Pre-created layouts can be found at https://github.com/DarthAffe/RGB.NET-Resources.

RGB.NET.Brushes/RGB.NET.Brushes.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
<RootNamespace>RGB.NET.Brushes</RootNamespace>
1515
<Description>Brushes-Presets of RGB.NET</Description>
1616
<Summary>Brushes-Presets of RGB.NET, a C# (.NET) library for accessing various RGB-peripherals</Summary>
17-
<Copyright>Copyright © Wyrez 2017</Copyright>
18-
<PackageCopyright>Copyright © Wyrez 2017</PackageCopyright>
17+
<Copyright>Copyright © Darth Affe 2020</Copyright>
18+
<PackageCopyright>Copyright © Darth Affe 2020</PackageCopyright>
1919
<PackageIconUrl>http://lib.arge.be/icon.png</PackageIconUrl>
2020
<PackageProjectUrl>https://github.com/DarthAffe/RGB.NET</PackageProjectUrl>
2121
<PackageLicenseUrl>https://raw.githubusercontent.com/DarthAffe/RGB.NET/master/LICENSE</PackageLicenseUrl>
@@ -63,6 +63,6 @@
6363
</ItemGroup>
6464

6565
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
66-
<PackageReference Include="System.ValueTuple" Version="4.4.0" />
66+
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
6767
</ItemGroup>
6868
</Project>

RGB.NET.Core/Brushes/AbstractBrush.cs

+10-4
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,20 @@ public virtual void PerformFinalize()
110110
/// <returns>The finalized color.</returns>
111111
protected virtual Color FinalizeColor(Color color)
112112
{
113-
foreach (IColorCorrection colorCorrection in ColorCorrections)
114-
color = colorCorrection.ApplyTo(color);
113+
if (ColorCorrections.Count > 0)
114+
foreach (IColorCorrection colorCorrection in ColorCorrections)
115+
color = colorCorrection.ApplyTo(color);
115116

116117
// Since we use HSV to calculate there is no way to make a color 'brighter' than 100%
117118
// Be carefull with the naming: Since we use HSV the correct term is 'value' but outside we call it 'brightness'
118119
// THIS IS NOT A HSB CALCULATION!!!
119-
return color.MultiplyHSV(value: Brightness.Clamp(0, 1))
120-
.MultiplyA(Opacity.Clamp(0, 1));
120+
if (Brightness < 1)
121+
color = color.MultiplyHSV(value: Brightness.Clamp(0, 1));
122+
123+
if (Opacity < 1)
124+
color = color.MultiplyA(Opacity.Clamp(0, 1));
125+
126+
return color;
121127
}
122128

123129
#endregion

RGB.NET.Core/Decorators/AbstractDecorateable.cs

+7-10
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,15 @@ public abstract class AbstractDecoratable<T> : AbstractBindable, IDecoratable<T>
1212
#region Properties & Fields
1313

1414
private readonly List<T> _decorators = new List<T>();
15-
/// <summary>
16-
/// Gets a readonly-list of all <see cref="IDecorator"/> attached to this <see cref="IDecoratable{T}"/>.
17-
/// </summary>
18-
protected IReadOnlyCollection<T> Decorators { get; }
1915

20-
#endregion
21-
22-
#region Constructors
23-
24-
protected AbstractDecoratable()
16+
/// <inheritdoc />
17+
public IReadOnlyCollection<T> Decorators
2518
{
26-
Decorators = new ReadOnlyCollection<T>(_decorators);
19+
get
20+
{
21+
lock (_decorators)
22+
return new ReadOnlyCollection<T>(_decorators);
23+
}
2724
}
2825

2926
#endregion

RGB.NET.Core/Decorators/AbstractDecorator.cs

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
24

35
namespace RGB.NET.Core
46
{
@@ -42,16 +44,17 @@ public int Order
4244
/// <summary>
4345
/// Detaches the decorator from all <see cref="IDecoratable"/> it is currently attached to.
4446
/// </summary>
45-
/// <typeparam name="TDecoratable">The type of the <see cref="IDecoratable"/> this decorator is attached to.</typeparam>
46-
/// <typeparam name="TDecorator">The type of this <see cref="IDecorator"/>.</typeparam>
47-
protected virtual void Detach<TDecoratable, TDecorator>()
48-
where TDecoratable : IDecoratable<TDecorator>
49-
where TDecorator : AbstractDecorator
47+
protected virtual void Detach()
5048
{
5149
List<IDecoratable> decoratables = new List<IDecoratable>(DecoratedObjects);
5250
foreach (IDecoratable decoratable in decoratables)
53-
if (decoratable is TDecoratable typedDecoratable)
54-
typedDecoratable.RemoveDecorator((TDecorator)this);
51+
{
52+
IEnumerable<Type> types = decoratable.GetType().GetInterfaces().Where(t => t.IsGenericType
53+
&& (t.Name == typeof(IDecoratable<>).Name)
54+
&& t.GenericTypeArguments[0].IsInstanceOfType(this));
55+
foreach (Type decoratableType in types)
56+
decoratableType.GetMethod(nameof(IDecoratable<IDecorator>.RemoveDecorator))?.Invoke(decoratable, new object[] { this });
57+
}
5558
}
5659

5760
#endregion

RGB.NET.Core/Decorators/IDecoratable.cs

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.ComponentModel;
1+
using System.Collections.Generic;
2+
using System.ComponentModel;
23

34
namespace RGB.NET.Core
45
{
@@ -13,9 +14,14 @@ public interface IDecoratable : INotifyPropertyChanged
1314
/// Represents a basic decoratable for a specific type of <see cref="T:RGB.NET.Core.IDecorator" />
1415
/// </summary>
1516
/// <typeparam name="T"></typeparam>
16-
public interface IDecoratable<in T> : IDecoratable
17+
public interface IDecoratable<T> : IDecoratable
1718
where T : IDecorator
1819
{
20+
/// <summary>
21+
/// Gets a readonly-list of all <see cref="IDecorator"/> attached to this <see cref="IDecoratable{T}"/>.
22+
/// </summary>
23+
IReadOnlyCollection<T> Decorators { get; }
24+
1925
/// <summary>
2026
/// Adds an <see cref="IDecorator"/> to the <see cref="IDecoratable"/>.
2127
/// </summary>

RGB.NET.Core/Devices/AbstractRGBDevice.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,12 @@ public virtual void SyncBack()
157157
/// <inheritdoc />
158158
public virtual void Dispose()
159159
{
160-
SpecialDeviceParts.Clear();
161-
LedMapping.Clear();
160+
try
161+
{
162+
SpecialDeviceParts.Clear();
163+
LedMapping.Clear();
164+
}
165+
catch { /* this really shouldn't happen */ }
162166
}
163167

164168
/// <summary>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace RGB.NET.Core
2+
{
3+
/// <summary>
4+
/// Represents a cooler-device
5+
/// </summary>
6+
public interface ICooler : IRGBDevice
7+
{ }
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace RGB.NET.Core
2+
{
3+
/// <summary>
4+
/// Represents a DRAM-device
5+
/// </summary>
6+
public interface IDRAM : IRGBDevice
7+
{ }
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace RGB.NET.Core
2+
{
3+
/// <summary>
4+
/// represents a fan-device
5+
/// </summary>
6+
public interface IFan : IRGBDevice
7+
{ }
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace RGB.NET.Core
2+
{
3+
/// <summary>
4+
/// Represents a graphics-card-device
5+
/// </summary>
6+
public interface IGraphicsCard : IRGBDevice
7+
{ }
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace RGB.NET.Core
2+
{
3+
/// <summary>
4+
/// Represents a headset-device
5+
/// </summary>
6+
public interface IHeadset : IRGBDevice
7+
{ }
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace RGB.NET.Core
2+
{
3+
/// <summary>
4+
/// Represents a headset-stand-device
5+
/// </summary>
6+
public interface IHeadsetStand : IRGBDevice
7+
{ }
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace RGB.NET.Core
2+
{
3+
/// <summary>
4+
/// Represents a keyboard-device
5+
/// </summary>
6+
public interface IKeyboard : IRGBDevice
7+
{ }
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace RGB.NET.Core
2+
{
3+
/// <summary>
4+
/// Represents a keypad-device
5+
/// </summary>
6+
public interface IKeypad : IRGBDevice
7+
{ }
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace RGB.NET.Core
2+
{
3+
/// <summary>
4+
/// Represents a led-matrix-device
5+
/// </summary>
6+
public interface ILedMatrix : IRGBDevice
7+
{ }
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace RGB.NET.Core
2+
{
3+
/// <summary>
4+
/// Represents a led-stripe-device
5+
/// </summary>
6+
public interface ILedStripe : IRGBDevice
7+
{ }
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace RGB.NET.Core
2+
{
3+
/// <summary>
4+
/// Represents a mainboard-device
5+
/// </summary>
6+
public interface IMainboard : IRGBDevice
7+
{ }
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace RGB.NET.Core
2+
{
3+
/// <summary>
4+
/// Represents a mouse-device
5+
/// </summary>
6+
public interface IMouse : IRGBDevice
7+
{ }
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace RGB.NET.Core
2+
{
3+
/// <summary>
4+
/// Represents a mousepad-device
5+
/// </summary>
6+
public interface IMousepad : IRGBDevice
7+
{ }
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace RGB.NET.Core
2+
{
3+
/// <summary>
4+
/// Represents a speaker-device
5+
/// </summary>
6+
public interface ISpeaker : IRGBDevice
7+
{ }
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace RGB.NET.Core
2+
{
3+
/// <summary>
4+
/// Represents a device with unkown or not specified type.
5+
/// </summary>
6+
public interface IUnknownDevice : IRGBDevice
7+
{ }
8+
}
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
3+
namespace RGB.NET.Core
4+
{
5+
public static class ColorExtensions
6+
{
7+
#region Methods
8+
9+
/// <summary>
10+
/// Calculates the distance between the two given colors using the redmean algorithm.
11+
/// For more infos check https://www.compuphase.com/cmetric.htm
12+
/// </summary>
13+
/// <param name="color1">The start color of the distance calculation.</param>
14+
/// <param name="color2">The end color fot the distance calculation.</param>
15+
/// <returns></returns>
16+
public static double DistanceTo(this Color color1, Color color2)
17+
{
18+
(_, byte r1, byte g1, byte b1) = color1.GetRGBBytes();
19+
(_, byte r2, byte g2, byte b2) = color2.GetRGBBytes();
20+
21+
long rmean = (r1 + r2) / 2;
22+
long r = r1 - r2;
23+
long g = g1 - g2;
24+
long b = b1 - b2;
25+
return Math.Sqrt((((512 + rmean) * r * r) >> 8) + (4 * g * g) + (((767 - rmean) * b * b) >> 8));
26+
}
27+
28+
#endregion
29+
}
30+
}

RGB.NET.Core/Groups/AbstractLedGroup.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protected AbstractLedGroup(bool autoAttach)
3636
#region Methods
3737

3838
/// <inheritdoc />
39-
public abstract IEnumerable<Led> GetLeds();
39+
public abstract IList<Led> GetLeds();
4040

4141
/// <inheritdoc />
4242
public virtual void OnAttach()

RGB.NET.Core/Groups/ILedGroup.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public interface ILedGroup : IDecoratable<ILedGroupDecorator>
2525
/// Gets a list containing all <see cref="Led"/> of this <see cref="ILedGroup"/>.
2626
/// </summary>
2727
/// <returns>The list containing all <see cref="Led"/> of this <see cref="ILedGroup"/>.</returns>
28-
IEnumerable<Led> GetLeds();
28+
IList<Led> GetLeds();
2929

3030
/// <summary>
3131
/// Called when the <see cref="ILedGroup"/> is attached to the <see cref="RGBSurface"/>.

RGB.NET.Core/Leds/LedId.cs

+32
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,38 @@ public enum LedId
213213
Keyboard_Custom30 = 0x0000701E,
214214
Keyboard_Custom31 = 0x0000701F,
215215
Keyboard_Custom32 = 0x00007020,
216+
Keyboard_Custom33 = 0x00007021,
217+
Keyboard_Custom34 = 0x00007022,
218+
Keyboard_Custom35 = 0x00007023,
219+
Keyboard_Custom36 = 0x00007024,
220+
Keyboard_Custom37 = 0x00007025,
221+
Keyboard_Custom38 = 0x00007026,
222+
Keyboard_Custom39 = 0x00007027,
223+
Keyboard_Custom40 = 0x00007028,
224+
Keyboard_Custom41 = 0x00007029,
225+
Keyboard_Custom42 = 0x0000702A,
226+
Keyboard_Custom43 = 0x0000702B,
227+
Keyboard_Custom44 = 0x0000702C,
228+
Keyboard_Custom45 = 0x0000702D,
229+
Keyboard_Custom46 = 0x0000702E,
230+
Keyboard_Custom47 = 0x0000702F,
231+
Keyboard_Custom48 = 0x00007030,
232+
Keyboard_Custom49 = 0x00007031,
233+
Keyboard_Custom50 = 0x00007032,
234+
Keyboard_Custom51 = 0x00007033,
235+
Keyboard_Custom52 = 0x00007034,
236+
Keyboard_Custom53 = 0x00007035,
237+
Keyboard_Custom54 = 0x00007036,
238+
Keyboard_Custom55 = 0x00007037,
239+
Keyboard_Custom56 = 0x00007038,
240+
Keyboard_Custom57 = 0x00007039,
241+
Keyboard_Custom58 = 0x0000703A,
242+
Keyboard_Custom59 = 0x0000703B,
243+
Keyboard_Custom60 = 0x0000703C,
244+
Keyboard_Custom61 = 0x0000703D,
245+
Keyboard_Custom62 = 0x0000703E,
246+
Keyboard_Custom63 = 0x0000703F,
247+
Keyboard_Custom64 = 0x00007040,
216248

217249
/*### Mouse ###*/
218250
Mouse1 = 0x00100001,

RGB.NET.Core/RGB.NET.Core.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
<RootNamespace>RGB.NET.Core</RootNamespace>
1515
<Description>Core-Module of RGB.NET</Description>
1616
<Summary>Core-Module of RGB.NET, a C# (.NET) library for accessing various RGB-peripherals</Summary>
17-
<Copyright>Copyright © Wyrez 2017</Copyright>
18-
<PackageCopyright>Copyright © Wyrez 2017</PackageCopyright>
17+
<Copyright>Copyright © Darth Affe 2020</Copyright>
18+
<PackageCopyright>Copyright © Darth Affe 2020</PackageCopyright>
1919
<PackageIconUrl>http://lib.arge.be/icon.png</PackageIconUrl>
2020
<PackageProjectUrl>https://github.com/DarthAffe/RGB.NET</PackageProjectUrl>
2121
<PackageLicenseUrl>https://raw.githubusercontent.com/DarthAffe/RGB.NET/master/LICENSE</PackageLicenseUrl>
@@ -59,6 +59,6 @@
5959
</PropertyGroup>
6060

6161
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
62-
<PackageReference Include="System.ValueTuple" Version="4.4.0" />
62+
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
6363
</ItemGroup>
6464
</Project>

0 commit comments

Comments
 (0)