1
0
mirror of https://github.com/DarthAffe/RGB.NET.git synced 2025-12-13 10:08:31 +00:00

Merge branch 'Development' into SDK/SteelSeries

This commit is contained in:
Darth Affe 2020-07-09 21:04:31 +02:00
commit 237baf9313
9 changed files with 44 additions and 25 deletions

View File

@ -12,18 +12,15 @@ namespace RGB.NET.Core
#region Properties & Fields #region Properties & Fields
private readonly List<T> _decorators = new List<T>(); private readonly List<T> _decorators = new List<T>();
/// <summary>
/// Gets a readonly-list of all <see cref="IDecorator"/> attached to this <see cref="IDecoratable{T}"/>.
/// </summary>
protected IReadOnlyCollection<T> Decorators { get; }
#endregion /// <inheritdoc />
public IReadOnlyCollection<T> Decorators
#region Constructors
protected AbstractDecoratable()
{ {
Decorators = new ReadOnlyCollection<T>(_decorators); get
{
lock (_decorators)
return new ReadOnlyCollection<T>(_decorators);
}
} }
#endregion #endregion

View File

@ -1,4 +1,6 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.Linq;
namespace RGB.NET.Core namespace RGB.NET.Core
{ {
@ -42,16 +44,17 @@ namespace RGB.NET.Core
/// <summary> /// <summary>
/// Detaches the decorator from all <see cref="IDecoratable"/> it is currently attached to. /// Detaches the decorator from all <see cref="IDecoratable"/> it is currently attached to.
/// </summary> /// </summary>
/// <typeparam name="TDecoratable">The type of the <see cref="IDecoratable"/> this decorator is attached to.</typeparam> protected virtual void Detach()
/// <typeparam name="TDecorator">The type of this <see cref="IDecorator"/>.</typeparam>
protected virtual void Detach<TDecoratable, TDecorator>()
where TDecoratable : IDecoratable<TDecorator>
where TDecorator : AbstractDecorator
{ {
List<IDecoratable> decoratables = new List<IDecoratable>(DecoratedObjects); List<IDecoratable> decoratables = new List<IDecoratable>(DecoratedObjects);
foreach (IDecoratable decoratable in decoratables) foreach (IDecoratable decoratable in decoratables)
if (decoratable is TDecoratable typedDecoratable) {
typedDecoratable.RemoveDecorator((TDecorator)this); IEnumerable<Type> types = decoratable.GetType().GetInterfaces().Where(t => t.IsGenericType
&& (t.Name == typeof(IDecoratable<>).Name)
&& t.GenericTypeArguments[0].IsInstanceOfType(this));
foreach (Type decoratableType in types)
decoratableType.GetMethod(nameof(IDecoratable<IDecorator>.RemoveDecorator))?.Invoke(decoratable, new object[] { this });
}
} }
#endregion #endregion

View File

@ -1,4 +1,5 @@
using System.ComponentModel; using System.Collections.Generic;
using System.ComponentModel;
namespace RGB.NET.Core namespace RGB.NET.Core
{ {
@ -13,9 +14,14 @@ namespace RGB.NET.Core
/// Represents a basic decoratable for a specific type of <see cref="T:RGB.NET.Core.IDecorator" /> /// Represents a basic decoratable for a specific type of <see cref="T:RGB.NET.Core.IDecorator" />
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
public interface IDecoratable<in T> : IDecoratable public interface IDecoratable<T> : IDecoratable
where T : IDecorator where T : IDecorator
{ {
/// <summary>
/// Gets a readonly-list of all <see cref="IDecorator"/> attached to this <see cref="IDecoratable{T}"/>.
/// </summary>
IReadOnlyCollection<T> Decorators { get; }
/// <summary> /// <summary>
/// Adds an <see cref="IDecorator"/> to the <see cref="IDecoratable"/>. /// Adds an <see cref="IDecorator"/> to the <see cref="IDecoratable"/>.
/// </summary> /// </summary>

View File

@ -129,7 +129,7 @@ namespace RGB.NET.Decorators.Brush
else else
{ {
if ((++_repetitionCount >= Repetitions) && (Repetitions > 0)) if ((++_repetitionCount >= Repetitions) && (Repetitions > 0))
Detach<IBrush, FlashDecorator>(); Detach();
_currentPhaseValue = Attack; _currentPhaseValue = Attack;
_currentPhase = ADSRPhase.Attack; _currentPhase = ADSRPhase.Attack;
} }

View File

@ -132,7 +132,8 @@ namespace RGB.NET.Devices.CoolerMaster
continue; continue;
} }
_CoolerMasterSDK.EnableLedControl(true, index); if (!_CoolerMasterSDK.EnableLedControl(true, index))
throw new RGBDeviceException("Failed to enable LED control for device " + index);
device.Initialize(UpdateTrigger); device.Initialize(UpdateTrigger);
devices.Add(device); devices.Add(device);

View File

@ -69,6 +69,18 @@ namespace RGB.NET.Devices.CoolerMaster
[DeviceType(RGBDeviceType.Keyboard)] [DeviceType(RGBDeviceType.Keyboard)]
CK551 = 13, CK551 = 13,
[Description("MM830")]
[DeviceType(RGBDeviceType.Mouse)]
MM830 = 14,
[Description("CK530")]
[DeviceType(RGBDeviceType.Keyboard)]
CK530 = 15,
[Description("MK850")]
[DeviceType(RGBDeviceType.Keyboard)]
MK850 = 16,
[DeviceType(RGBDeviceType.None)] [DeviceType(RGBDeviceType.None)]
Default = 0xFFFF Default = 0xFFFF
} }

View File

@ -41,7 +41,7 @@ namespace RGB.NET.Devices.Msi
} }
//TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images? //TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images?
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\MSI\GraphicsCard\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, $@"Layouts\MSI\GraphicsCard\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null);
} }
/// <inheritdoc /> /// <inheritdoc />

View File

@ -39,7 +39,7 @@ namespace RGB.NET.Devices.Msi
} }
//TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images? //TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images?
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\MSI\Mainboards\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, $@"Layouts\MSI\Mainboards\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null);
} }
/// <inheritdoc /> /// <inheritdoc />

View File

@ -39,7 +39,7 @@ namespace RGB.NET.Devices.Msi
} }
//TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images? //TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images?
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\MSI\Mouses\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, $@"Layouts\MSI\Mouses\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null);
} }
/// <inheritdoc /> /// <inheritdoc />