1
0
mirror of https://github.com/DarthAffe/RGB.NET.git synced 2025-12-13 01:58:30 +00:00

Changed the surface to work with update-triggers instead of fixed update-modes. Adapted device-update-triggers to match the general concept

This commit is contained in:
Darth Affe 2018-04-07 10:46:23 +02:00
parent 72414d2110
commit 33c8e69f93
50 changed files with 224 additions and 162 deletions

View File

@ -1,12 +0,0 @@
using System;
namespace RGB.NET.Core
{
public interface IUpdateTrigger
{
event EventHandler Starting;
event EventHandler Update;
void TriggerHasData();
}
}

View File

@ -18,6 +18,10 @@ namespace RGB.NET.Core
/// </summary>
public double DeltaTime { get; }
public IUpdateTrigger Trigger { get; }
public CustomUpdateData CustomData { get; }
#endregion
#region Constructors
@ -27,9 +31,11 @@ namespace RGB.NET.Core
/// Initializes a new instance of the <see cref="T:RGB.NET.Core.UpdatingEventArgs" /> class.
/// </summary>
/// <param name="deltaTime">The elapsed time (in seconds) since the last update.</param>
public UpdatingEventArgs(double deltaTime)
public UpdatingEventArgs(double deltaTime, IUpdateTrigger trigger, CustomUpdateData customData)
{
this.DeltaTime = deltaTime;
this.Trigger = trigger;
this.CustomData = customData;
}
#endregion

View File

@ -13,4 +13,6 @@
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=leds/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=mvvm/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=positioning/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=surfaces/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=surfaces/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=update/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=update_005Cdevices/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@ -27,6 +27,7 @@ namespace RGB.NET.Core
private IList<IRGBDeviceProvider> _deviceProvider = new List<IRGBDeviceProvider>();
private IList<IRGBDevice> _devices = new List<IRGBDevice>();
private IList<IUpdateTrigger> _updateTriggers = new List<IUpdateTrigger>();
// ReSharper disable InconsistentNaming
@ -41,6 +42,8 @@ namespace RGB.NET.Core
/// </summary>
public IEnumerable<IRGBDevice> Devices => new ReadOnlyCollection<IRGBDevice>(_devices);
public IEnumerable<IUpdateTrigger> UpdateTriggers => new ReadOnlyCollection<IUpdateTrigger>(_updateTriggers);
/// <summary>
/// Gets a copy of the <see cref="Rectangle"/> representing this <see cref="RGBSurface"/>.
/// </summary>
@ -61,9 +64,6 @@ namespace RGB.NET.Core
private RGBSurface()
{
_deltaTimeCounter = Stopwatch.StartNew();
_sleepCounter = new Stopwatch();
CheckUpdateLoop();
}
#endregion
@ -74,31 +74,49 @@ namespace RGB.NET.Core
/// Perform a full update for all devices. Updates only dirty <see cref="Led"/> by default, or all <see cref="Led"/>, if flushLeds is set to true.
/// </summary>
/// <param name="flushLeds">Specifies whether all <see cref="Led"/>, (including clean ones) should be updated.</param>
public void Update(bool flushLeds = false)
public void Update(bool flushLeds = false) => Update(null, new CustomUpdateData(("flushLeds", flushLeds)));
private void Update(object updateTrigger, CustomUpdateData customData) => Update(updateTrigger as IUpdateTrigger, customData);
private void Update(IUpdateTrigger updateTrigger, CustomUpdateData customData)
{
if (customData == null)
customData = new CustomUpdateData();
try
{
OnUpdating();
bool flushLeds = customData["flushLeds"] as bool? ?? false;
bool syncBack = customData["syncBack"] as bool? ?? true;
bool render = customData["render"] as bool? ?? true;
bool updateDevices = customData["updateDevices"] as bool? ?? true;
foreach (IRGBDevice device in Devices)
if (device.UpdateMode.HasFlag(DeviceUpdateMode.SyncBack) && device.DeviceInfo.SupportsSyncBack)
try { device.SyncBack(); }
catch (Exception ex) { OnException(ex); }
lock (_ledGroups)
lock (_updateTriggers)
{
// Render brushes
foreach (ILedGroup ledGroup in _ledGroups.OrderBy(x => x.ZIndex))
try { Render(ledGroup); }
catch (Exception ex) { OnException(ex); }
OnUpdating(updateTrigger, customData);
if (syncBack)
foreach (IRGBDevice device in Devices)
if (device.UpdateMode.HasFlag(DeviceUpdateMode.SyncBack) && device.DeviceInfo.SupportsSyncBack)
try { device.SyncBack(); }
catch (Exception ex) { OnException(ex); }
if (render)
lock (_ledGroups)
{
// Render brushes
foreach (ILedGroup ledGroup in _ledGroups.OrderBy(x => x.ZIndex))
try { Render(ledGroup); }
catch (Exception ex) { OnException(ex); }
}
if (updateDevices)
foreach (IRGBDevice device in Devices)
if (!device.UpdateMode.HasFlag(DeviceUpdateMode.NoUpdate))
try { device.Update(flushLeds); }
catch (Exception ex) { OnException(ex); }
OnUpdated();
}
foreach (IRGBDevice device in Devices)
if (!device.UpdateMode.HasFlag(DeviceUpdateMode.NoUpdate))
try { device.Update(flushLeds); }
catch (Exception ex) { OnException(ex); }
OnUpdated();
}
catch (Exception ex)
{
@ -109,8 +127,8 @@ namespace RGB.NET.Core
/// <inheritdoc />
public void Dispose()
{
if (_updateTokenSource?.IsCancellationRequested == false)
_updateTokenSource.Cancel();
//if (_updateTokenSource?.IsCancellationRequested == false)
// _updateTokenSource.Cancel();
foreach (IRGBDevice device in _devices)
try { device.Dispose(); }
@ -231,6 +249,21 @@ namespace RGB.NET.Core
public IList<IRGBDevice> GetDevices(RGBDeviceType deviceType)
=> new ReadOnlyCollection<IRGBDevice>(_devices.Where(x => x.DeviceInfo.DeviceType == deviceType).ToList());
public void RegisterUpdateTrigger(IUpdateTrigger updateTrigger)
{
if (!_updateTriggers.Contains(updateTrigger))
{
_updateTriggers.Add(updateTrigger);
updateTrigger.Update += Update;
}
}
public void UnregisterUpdateTrigger(IUpdateTrigger updateTrigger)
{
if (_updateTriggers.Remove(updateTrigger))
updateTrigger.Update -= Update;
}
#endregion
}
}

View File

@ -78,13 +78,13 @@ namespace RGB.NET.Core
/// <summary>
/// Handles the needed event-calls before updating.
/// </summary>
private void OnUpdating()
private void OnUpdating(IUpdateTrigger trigger, CustomUpdateData customData)
{
try
{
double deltaTime = _deltaTimeCounter.Elapsed.TotalSeconds;
_deltaTimeCounter.Restart();
Updating?.Invoke(new UpdatingEventArgs(deltaTime));
Updating?.Invoke(new UpdatingEventArgs(deltaTime, trigger, customData));
}
catch { /* Well ... that's not my fault */ }
}

View File

@ -0,0 +1,28 @@
using System;
namespace RGB.NET.Core
{
public class AbstractUpdateTrigger : AbstractBindable, IUpdateTrigger
{
#region Events
/// <inheritdoc />
public event EventHandler<CustomUpdateData> Starting;
/// <inheritdoc />
public event EventHandler<CustomUpdateData> Update;
#endregion
#region Methods
protected virtual void OnStartup(CustomUpdateData updateData = null) => Starting?.Invoke(this, updateData);
protected virtual void OnUpdate(CustomUpdateData updateData = null) => Update?.Invoke(this, updateData);
/// <inheritdoc />
public virtual void Dispose()
{ }
#endregion
}
}

View File

@ -0,0 +1,36 @@
using System.Collections.Generic;
namespace RGB.NET.Core
{
public class CustomUpdateData
{
#region Properties & Fields
private Dictionary<string, object> _data = new Dictionary<string, object>();
#endregion
#region Indexer
public object this[string key]
{
get => _data.TryGetValue(key?.ToUpperInvariant(), out object data) ? data : default;
set => _data[key?.ToUpperInvariant()] = value;
}
#endregion
#region Constructors
public CustomUpdateData()
{ }
public CustomUpdateData(params (string key, object value)[] values)
{
foreach ((string key, object value) in values)
this[key] = value;
}
#endregion
}
}

View File

@ -1,11 +1,10 @@
using System;
using System.Diagnostics;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
namespace RGB.NET.Core
{
public class UpdateTrigger : IUpdateTrigger
public class DeviceUpdateTrigger : AbstractUpdateTrigger, IDeviceUpdateTrigger
{
#region Properties & Fields
@ -44,21 +43,12 @@ namespace RGB.NET.Core
#endregion
#region Events
/// <inheritdoc />
public event EventHandler Starting;
/// <inheritdoc />
public event EventHandler Update;
#endregion
#region Constructors
public UpdateTrigger()
public DeviceUpdateTrigger()
{ }
public UpdateTrigger(double updateRateHardLimit)
public DeviceUpdateTrigger(double updateRateHardLimit)
{
this._updateRateHardLimit = updateRateHardLimit;
}
@ -76,7 +66,6 @@ namespace RGB.NET.Core
_updateTokenSource?.Dispose();
_updateTokenSource = new CancellationTokenSource();
_updateTask = Task.Factory.StartNew(UpdateLoop, (_updateToken = _updateTokenSource.Token), TaskCreationOptions.LongRunning, TaskScheduler.Default);
}
public async void Stop()
@ -93,14 +82,14 @@ namespace RGB.NET.Core
private void UpdateLoop()
{
Starting?.Invoke(this, null);
OnStartup();
while (!_updateToken.IsCancellationRequested)
{
if (_hasDataEvent.WaitOne(Timeout))
{
long preUpdateTicks = Stopwatch.GetTimestamp();
Update?.Invoke(this, null);
OnUpdate();
if (UpdateFrequency > 0)
{

View File

@ -0,0 +1,7 @@
namespace RGB.NET.Core
{
public interface IDeviceUpdateTrigger : IUpdateTrigger
{
void TriggerHasData();
}
}

View File

@ -9,14 +9,14 @@ namespace RGB.NET.Core
#region Properties & Fields
private readonly object _dataLock = new object();
private readonly IUpdateTrigger _updateTrigger;
private readonly IDeviceUpdateTrigger _updateTrigger;
private Dictionary<TIdentifier, TData> _currentDataSet;
#endregion
#region Constructors
public UpdateQueue(IUpdateTrigger updateTrigger)
public UpdateQueue(IDeviceUpdateTrigger updateTrigger)
{
this._updateTrigger = updateTrigger;
@ -28,7 +28,7 @@ namespace RGB.NET.Core
#region Methods
protected virtual void OnUpdate(object sender, EventArgs e)
protected virtual void OnUpdate(object sender, CustomUpdateData customData)
{
Dictionary<TIdentifier, TData> dataSet;
lock (_dataLock)
@ -77,7 +77,7 @@ namespace RGB.NET.Core
#region Constructors
/// <inheritdoc />
protected UpdateQueue(IUpdateTrigger updateTrigger)
protected UpdateQueue(IDeviceUpdateTrigger updateTrigger)
: base(updateTrigger)
{ }

View File

@ -0,0 +1,10 @@
using System;
namespace RGB.NET.Core
{
public interface IUpdateTrigger : IDisposable
{
event EventHandler<CustomUpdateData> Starting;
event EventHandler<CustomUpdateData> Update;
}
}

View File

@ -1,11 +1,10 @@
using System;
using System.Diagnostics;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
namespace RGB.NET.Core
{
public partial class RGBSurface
public class TimerUpdateTrigger : AbstractUpdateTrigger
{
#region Properties & Fields
@ -14,8 +13,6 @@ namespace RGB.NET.Core
private Task _updateTask;
private Stopwatch _sleepCounter;
// ReSharper disable MemberCanBePrivate.Global
private double _updateFrequency = 1.0 / 30.0;
/// <summary>
/// Gets or sets the update-frequency in seconds. (Calculate by using '1.0 / updates per second')
@ -31,51 +28,35 @@ namespace RGB.NET.Core
/// </summary>
public double LastUpdateTime { get; private set; }
private UpdateMode _updateMode = UpdateMode.Continuous;
/// <summary>
/// Gets or sets the update-mode.
/// </summary>
public UpdateMode UpdateMode
#endregion
#region Constructors
public TimerUpdateTrigger(bool autostart = true)
{
get => _updateMode;
set
{
if (SetProperty(ref _updateMode, value))
CheckUpdateLoop();
}
_sleepCounter = new Stopwatch();
if (autostart)
Start();
}
// ReSharper restore MemberCanBePrivate.Global
#endregion
#region Methods
/// <summary>
/// Checks if automatic updates should occur and starts/stops the update-loop if needed.
/// </summary>
/// <exception cref="ArgumentOutOfRangeException">Thrown if the requested update-mode is not available.</exception>
private async void CheckUpdateLoop()
public void Start()
{
bool shouldRun;
switch (UpdateMode)
{
case UpdateMode.Manual:
shouldRun = false;
break;
case UpdateMode.Continuous:
shouldRun = true;
break;
default:
throw new ArgumentOutOfRangeException();
}
if (shouldRun && (_updateTask == null)) // Start task
if (_updateTask == null)
{
_updateTokenSource?.Dispose();
_updateTokenSource = new CancellationTokenSource();
_updateTask = Task.Factory.StartNew(UpdateLoop, (_updateToken = _updateTokenSource.Token), TaskCreationOptions.LongRunning, TaskScheduler.Default);
}
else if (!shouldRun && (_updateTask != null)) // Stop task
}
public async void Stop()
{
if (_updateTask != null)
{
_updateTokenSource.Cancel();
await _updateTask;
@ -90,7 +71,7 @@ namespace RGB.NET.Core
{
_sleepCounter.Restart();
Update();
OnUpdate();
_sleepCounter.Stop();
LastUpdateTime = _sleepCounter.Elapsed.TotalSeconds;

View File

@ -1,18 +0,0 @@
namespace RGB.NET.Core
{
/// <summary>
/// Contains list of available update modes.
/// </summary>
public enum UpdateMode
{
/// <summary>
/// The <see cref="RGBSurface"/> will not perform automatic updates. Updates will only occur if <see cref="RGBSurface.Update" /> is called.
/// </summary>
Manual,
/// <summary>
/// The <see cref="RGBSurface"/> will perform automatic updates at the rate set in <see cref="RGBSurface.UpdateFrequency" />.
/// </summary>
Continuous
}
}

View File

@ -63,7 +63,7 @@ namespace RGB.NET.Devices.Asus
// ReSharper disable once AutoPropertyCanBeMadeGetOnly.Global
public Func<CultureInfo> GetCulture { get; set; } = CultureHelper.GetCurrentCulture;
public UpdateTrigger UpdateTrigger { get; private set; }
public DeviceUpdateTrigger UpdateTrigger { get; private set; }
#endregion
@ -78,7 +78,7 @@ namespace RGB.NET.Devices.Asus
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(AsusDeviceProvider)}");
_instance = this;
UpdateTrigger = new UpdateTrigger();
UpdateTrigger = new DeviceUpdateTrigger();
}
#endregion

View File

@ -45,7 +45,7 @@ namespace RGB.NET.Devices.Asus
/// <summary>
/// Initializes the device.
/// </summary>
public void Initialize(IUpdateTrigger updateTrigger)
public void Initialize(IDeviceUpdateTrigger updateTrigger)
{
InitializeLayout();

View File

@ -20,7 +20,7 @@ namespace RGB.NET.Devices.Asus.Generic
#region Constructors
public AsusUpdateQueue(IUpdateTrigger updateTrigger)
public AsusUpdateQueue(IDeviceUpdateTrigger updateTrigger)
: base(updateTrigger)
{ }

View File

@ -7,6 +7,6 @@ namespace RGB.NET.Devices.Asus
/// </summary>
internal interface IAsusRGBDevice : IRGBDevice
{
void Initialize(IUpdateTrigger updateTrigger);
void Initialize(IDeviceUpdateTrigger updateTrigger);
}
}

View File

@ -63,7 +63,7 @@ namespace RGB.NET.Devices.CoolerMaster
// ReSharper disable once AutoPropertyCanBeMadeGetOnly.Global
public Func<CultureInfo> GetCulture { get; set; } = CultureHelper.GetCurrentCulture;
public UpdateTrigger UpdateTrigger { get; private set; }
public DeviceUpdateTrigger UpdateTrigger { get; private set; }
#endregion
@ -78,7 +78,7 @@ namespace RGB.NET.Devices.CoolerMaster
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(CoolerMasterDeviceProvider)}");
_instance = this;
UpdateTrigger = new UpdateTrigger();
UpdateTrigger = new DeviceUpdateTrigger();
}
#endregion

View File

@ -45,7 +45,7 @@ namespace RGB.NET.Devices.CoolerMaster
/// <summary>
/// Initializes the device.
/// </summary>
public void Initialize(IUpdateTrigger updateTrigger)
public void Initialize(IDeviceUpdateTrigger updateTrigger)
{
InitializeLayout();

View File

@ -14,7 +14,7 @@ namespace RGB.NET.Devices.CoolerMaster
#region Constructors
public CoolerMasterUpdateQueue(IUpdateTrigger updateTrigger, CoolerMasterDevicesIndexes deviceIndex)
public CoolerMasterUpdateQueue(IDeviceUpdateTrigger updateTrigger, CoolerMasterDevicesIndexes deviceIndex)
: base(updateTrigger)
{
this._deviceIndex = deviceIndex;

View File

@ -7,6 +7,6 @@ namespace RGB.NET.Devices.CoolerMaster
/// </summary>
internal interface ICoolerMasterRGBDevice : IRGBDevice
{
void Initialize(IUpdateTrigger updateTrigger);
void Initialize(IDeviceUpdateTrigger updateTrigger);
}
}

View File

@ -66,7 +66,7 @@ namespace RGB.NET.Devices.Corsair
/// <inheritdoc />
public IEnumerable<IRGBDevice> Devices { get; private set; }
public UpdateTrigger UpdateTrigger { get; private set; }
public DeviceUpdateTrigger UpdateTrigger { get; private set; }
private CorsairUpdateQueue _updateQueue;
#endregion
@ -82,7 +82,7 @@ namespace RGB.NET.Devices.Corsair
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(CorsairDeviceProvider)}");
_instance = this;
UpdateTrigger = new UpdateTrigger();
UpdateTrigger = new DeviceUpdateTrigger();
_updateQueue = new CorsairUpdateQueue(UpdateTrigger);
}

View File

@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair
{
#region Constructors
public CorsairUpdateQueue(IUpdateTrigger updateTrigger)
public CorsairUpdateQueue(IDeviceUpdateTrigger updateTrigger)
: base(updateTrigger)
{ }

View File

@ -37,7 +37,7 @@ namespace RGB.NET.Devices.DMX
/// </summary>
public List<IDMXDeviceDefinition> DeviceDefinitions { get; } = new List<IDMXDeviceDefinition>();
public UpdateTrigger UpdateTrigger { get; private set; }
public DeviceUpdateTrigger UpdateTrigger { get; private set; }
#endregion
@ -52,7 +52,7 @@ namespace RGB.NET.Devices.DMX
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(DMXDeviceProvider)}");
_instance = this;
UpdateTrigger = new UpdateTrigger();
UpdateTrigger = new DeviceUpdateTrigger();
}
#endregion

View File

@ -34,7 +34,7 @@ namespace RGB.NET.Devices.DMX.E131
#region Methods
internal void Initialize(IUpdateTrigger updateTrigger)
internal void Initialize(IDeviceUpdateTrigger updateTrigger)
{
int count = 0;
foreach (LedId id in _ledMappings.Keys)

View File

@ -29,7 +29,7 @@ namespace RGB.NET.Devices.DMX.E131
#region Constructors
public E131UpdateQueue(IUpdateTrigger updateTrigger, string hostname, int port)
public E131UpdateQueue(IDeviceUpdateTrigger updateTrigger, string hostname, int port)
: base(updateTrigger)
{
_socket = new UdpClient();

View File

@ -56,7 +56,7 @@ namespace RGB.NET.Devices.Logitech
/// </summary>
public Func<CultureInfo> GetCulture { get; set; } = CultureHelper.GetCurrentCulture;
public UpdateTrigger UpdateTrigger { get; private set; }
public DeviceUpdateTrigger UpdateTrigger { get; private set; }
private LogitechPerDeviceUpdateQueue _perDeviceUpdateQueue;
private LogitechPerKeyUpdateQueue _perKeyUpdateQueue;
@ -73,7 +73,7 @@ namespace RGB.NET.Devices.Logitech
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(LogitechDeviceProvider)}");
_instance = this;
UpdateTrigger = new UpdateTrigger();
UpdateTrigger = new DeviceUpdateTrigger();
_perDeviceUpdateQueue = new LogitechPerDeviceUpdateQueue(UpdateTrigger);
_perKeyUpdateQueue = new LogitechPerKeyUpdateQueue(UpdateTrigger);
}

View File

@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Logitech
{
#region Constructors
public LogitechPerDeviceUpdateQueue(IUpdateTrigger updateTrigger)
public LogitechPerDeviceUpdateQueue(IDeviceUpdateTrigger updateTrigger)
: base(updateTrigger)
{ }

View File

@ -15,7 +15,7 @@ namespace RGB.NET.Devices.Logitech
#region Constructors
public LogitechPerKeyUpdateQueue(IUpdateTrigger updateTrigger)
public LogitechPerKeyUpdateQueue(IDeviceUpdateTrigger updateTrigger)
: base(updateTrigger)
{
_bitmap = BitmapMapping.CreateBitmap();

View File

@ -7,6 +7,6 @@ namespace RGB.NET.Devices.Novation
/// </summary>
internal interface INovationRGBDevice : IRGBDevice
{
void Initialize(IUpdateTrigger updateTrigger);
void Initialize(IDeviceUpdateTrigger updateTrigger);
}
}

View File

@ -9,7 +9,7 @@ namespace RGB.NET.Devices.Novation
{
#region Constructors
public LimitedColorUpdateQueue(IUpdateTrigger updateTrigger, int deviceId)
public LimitedColorUpdateQueue(IDeviceUpdateTrigger updateTrigger, int deviceId)
: base(updateTrigger, deviceId)
{ }

View File

@ -15,7 +15,7 @@ namespace RGB.NET.Devices.Novation
#region Constructors
public MidiUpdateQueue(IUpdateTrigger updateTrigger, int deviceId)
public MidiUpdateQueue(IDeviceUpdateTrigger updateTrigger, int deviceId)
: base(updateTrigger)
{
_outputDevice = new OutputDevice(deviceId);

View File

@ -43,7 +43,7 @@ namespace RGB.NET.Devices.Novation
/// <summary>
/// Initializes the device.
/// </summary>
public void Initialize(IUpdateTrigger updateTrigger)
public void Initialize(IDeviceUpdateTrigger updateTrigger)
{
InitializeLayout();

View File

@ -39,7 +39,7 @@ namespace RGB.NET.Devices.Novation
/// <inheritdoc />
public IEnumerable<IRGBDevice> Devices { get; private set; }
public UpdateTrigger UpdateTrigger { get; private set; }
public DeviceUpdateTrigger UpdateTrigger { get; private set; }
#endregion
@ -54,7 +54,7 @@ namespace RGB.NET.Devices.Novation
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(NovationDeviceProvider)}");
_instance = this;
UpdateTrigger = new UpdateTrigger();
UpdateTrigger = new DeviceUpdateTrigger();
}
#endregion

View File

@ -42,7 +42,7 @@ namespace RGB.NET.Devices.Razer
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Custom1;
/// <inheritdoc />
protected override RazerUpdateQueue CreateUpdateQueue(IUpdateTrigger updateTrigger) => new RazerChromaLinkUpdateQueue(updateTrigger, DeviceInfo.DeviceId);
protected override RazerUpdateQueue CreateUpdateQueue(IDeviceUpdateTrigger updateTrigger) => new RazerChromaLinkUpdateQueue(updateTrigger, DeviceInfo.DeviceId);
#endregion
}

View File

@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Razer
{
#region Constructors
public RazerChromaLinkUpdateQueue(IUpdateTrigger updateTrigger, Guid deviceId)
public RazerChromaLinkUpdateQueue(IDeviceUpdateTrigger updateTrigger, Guid deviceId)
: base(updateTrigger, deviceId)
{ }

View File

@ -7,7 +7,7 @@ namespace RGB.NET.Devices.Razer
/// </summary>
internal interface IRazerRGBDevice : IRGBDevice
{
void Initialize(IUpdateTrigger updateTrigger);
void Initialize(IDeviceUpdateTrigger updateTrigger);
void Reset();
}
}

View File

@ -44,7 +44,7 @@ namespace RGB.NET.Devices.Razer
/// <summary>
/// Initializes the device.
/// </summary>
public void Initialize(IUpdateTrigger updateTrigger)
public void Initialize(IDeviceUpdateTrigger updateTrigger)
{
InitializeLayout();
@ -57,7 +57,7 @@ namespace RGB.NET.Devices.Razer
UpdateQueue = CreateUpdateQueue(updateTrigger);
}
protected abstract RazerUpdateQueue CreateUpdateQueue(IUpdateTrigger updateTrigger);
protected abstract RazerUpdateQueue CreateUpdateQueue(IDeviceUpdateTrigger updateTrigger);
/// <summary>
/// Initializes the <see cref="Led"/> and <see cref="Size"/> of the device.

View File

@ -16,7 +16,7 @@ namespace RGB.NET.Devices.Razer
#region Constructors
protected RazerUpdateQueue(IUpdateTrigger updateTrigger, Guid deviceId)
protected RazerUpdateQueue(IDeviceUpdateTrigger updateTrigger, Guid deviceId)
: base(updateTrigger)
{
this._deviceId = deviceId;

View File

@ -42,7 +42,7 @@ namespace RGB.NET.Devices.Razer
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Headset1;
/// <inheritdoc />
protected override RazerUpdateQueue CreateUpdateQueue(IUpdateTrigger updateTrigger) => new RazerHeadsetUpdateQueue(updateTrigger, DeviceInfo.DeviceId);
protected override RazerUpdateQueue CreateUpdateQueue(IDeviceUpdateTrigger updateTrigger) => new RazerHeadsetUpdateQueue(updateTrigger, DeviceInfo.DeviceId);
#endregion
}

View File

@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Razer
{
#region Constructors
public RazerHeadsetUpdateQueue(IUpdateTrigger updateTrigger, Guid deviceId)
public RazerHeadsetUpdateQueue(IDeviceUpdateTrigger updateTrigger, Guid deviceId)
: base(updateTrigger, deviceId)
{ }

View File

@ -48,7 +48,7 @@ namespace RGB.NET.Devices.Razer
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Keyboard_Escape;
/// <inheritdoc />
protected override RazerUpdateQueue CreateUpdateQueue(IUpdateTrigger updateTrigger) => new RazerKeyboardUpdateQueue(updateTrigger, DeviceInfo.DeviceId);
protected override RazerUpdateQueue CreateUpdateQueue(IDeviceUpdateTrigger updateTrigger) => new RazerKeyboardUpdateQueue(updateTrigger, DeviceInfo.DeviceId);
#endregion
}

View File

@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Razer
{
#region Constructors
public RazerKeyboardUpdateQueue(IUpdateTrigger updateTrigger, Guid deviceId)
public RazerKeyboardUpdateQueue(IDeviceUpdateTrigger updateTrigger, Guid deviceId)
: base(updateTrigger, deviceId)
{ }

View File

@ -45,7 +45,7 @@ namespace RGB.NET.Devices.Razer
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Keypad1;
/// <inheritdoc />
protected override RazerUpdateQueue CreateUpdateQueue(IUpdateTrigger updateTrigger) => new RazerKeypadUpdateQueue(updateTrigger, DeviceInfo.DeviceId);
protected override RazerUpdateQueue CreateUpdateQueue(IDeviceUpdateTrigger updateTrigger) => new RazerKeypadUpdateQueue(updateTrigger, DeviceInfo.DeviceId);
#endregion
}

View File

@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Razer
{
#region Constructors
public RazerKeypadUpdateQueue(IUpdateTrigger updateTrigger, Guid deviceId)
public RazerKeypadUpdateQueue(IDeviceUpdateTrigger updateTrigger, Guid deviceId)
: base(updateTrigger, deviceId)
{ }

View File

@ -45,7 +45,7 @@ namespace RGB.NET.Devices.Razer
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Mouse1;
/// <inheritdoc />
protected override RazerUpdateQueue CreateUpdateQueue(IUpdateTrigger updateTrigger) => new RazerMouseUpdateQueue(updateTrigger, DeviceInfo.DeviceId);
protected override RazerUpdateQueue CreateUpdateQueue(IDeviceUpdateTrigger updateTrigger) => new RazerMouseUpdateQueue(updateTrigger, DeviceInfo.DeviceId);
#endregion
}

View File

@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Razer
{
#region Constructors
public RazerMouseUpdateQueue(IUpdateTrigger updateTrigger, Guid deviceId)
public RazerMouseUpdateQueue(IDeviceUpdateTrigger updateTrigger, Guid deviceId)
: base(updateTrigger, deviceId)
{ }

View File

@ -42,7 +42,7 @@ namespace RGB.NET.Devices.Razer
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Mousepad1;
/// <inheritdoc />
protected override RazerUpdateQueue CreateUpdateQueue(IUpdateTrigger updateTrigger) => new RazerMousepadUpdateQueue(updateTrigger, DeviceInfo.DeviceId);
protected override RazerUpdateQueue CreateUpdateQueue(IDeviceUpdateTrigger updateTrigger) => new RazerMousepadUpdateQueue(updateTrigger, DeviceInfo.DeviceId);
#endregion
}

View File

@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Razer
{
#region Constructors
public RazerMousepadUpdateQueue(IUpdateTrigger updateTrigger, Guid deviceId)
public RazerMousepadUpdateQueue(IDeviceUpdateTrigger updateTrigger, Guid deviceId)
: base(updateTrigger, deviceId)
{ }

View File

@ -68,7 +68,7 @@ namespace RGB.NET.Devices.Razer
/// </summary>
public bool LoadEmulatorDevices { get; set; } = false;
public UpdateTrigger UpdateTrigger { get; private set; }
public DeviceUpdateTrigger UpdateTrigger { get; private set; }
#endregion
@ -83,7 +83,7 @@ namespace RGB.NET.Devices.Razer
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(RazerDeviceProvider)}");
_instance = this;
UpdateTrigger = new UpdateTrigger();
UpdateTrigger = new DeviceUpdateTrigger();
}
#endregion