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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 10 additions & 4 deletions
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

Lines changed: 7 additions & 10 deletions
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

Lines changed: 11 additions & 8 deletions
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

Lines changed: 8 additions & 2 deletions
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

Lines changed: 6 additions & 2 deletions
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>
Lines changed: 8 additions & 0 deletions
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+
}
Lines changed: 8 additions & 0 deletions
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+
}
Lines changed: 8 additions & 0 deletions
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+
}

0 commit comments

Comments
 (0)