diff --git a/RGB.NET.Core/Devices/Update/IUpdateTrigger.cs b/RGB.NET.Core/Devices/Update/IUpdateTrigger.cs deleted file mode 100644 index 91d5c22..0000000 --- a/RGB.NET.Core/Devices/Update/IUpdateTrigger.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace RGB.NET.Core -{ - public interface IUpdateTrigger - { - event EventHandler Starting; - event EventHandler Update; - - void TriggerHasData(); - } -} diff --git a/RGB.NET.Core/Events/UpdatingEventArgs.cs b/RGB.NET.Core/Events/UpdatingEventArgs.cs index e905f31..42e87cd 100644 --- a/RGB.NET.Core/Events/UpdatingEventArgs.cs +++ b/RGB.NET.Core/Events/UpdatingEventArgs.cs @@ -18,6 +18,10 @@ namespace RGB.NET.Core /// 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 class. /// /// The elapsed time (in seconds) since the last update. - public UpdatingEventArgs(double deltaTime) + public UpdatingEventArgs(double deltaTime, IUpdateTrigger trigger, CustomUpdateData customData) { this.DeltaTime = deltaTime; + this.Trigger = trigger; + this.CustomData = customData; } #endregion diff --git a/RGB.NET.Core/RGB.NET.Core.csproj.DotSettings b/RGB.NET.Core/RGB.NET.Core.csproj.DotSettings index 372a92a..d88c562 100644 --- a/RGB.NET.Core/RGB.NET.Core.csproj.DotSettings +++ b/RGB.NET.Core/RGB.NET.Core.csproj.DotSettings @@ -13,4 +13,6 @@ True True True - True \ No newline at end of file + True + True + True \ No newline at end of file diff --git a/RGB.NET.Core/RGBSurface.cs b/RGB.NET.Core/RGBSurface.cs index e7d8bed..5613d77 100644 --- a/RGB.NET.Core/RGBSurface.cs +++ b/RGB.NET.Core/RGBSurface.cs @@ -27,6 +27,7 @@ namespace RGB.NET.Core private IList _deviceProvider = new List(); private IList _devices = new List(); + private IList _updateTriggers = new List(); // ReSharper disable InconsistentNaming @@ -41,6 +42,8 @@ namespace RGB.NET.Core /// public IEnumerable Devices => new ReadOnlyCollection(_devices); + public IEnumerable UpdateTriggers => new ReadOnlyCollection(_updateTriggers); + /// /// Gets a copy of the representing this . /// @@ -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 by default, or all , if flushLeds is set to true. /// /// Specifies whether all , (including clean ones) should be updated. - 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 /// 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 GetDevices(RGBDeviceType deviceType) => new ReadOnlyCollection(_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 } } diff --git a/RGB.NET.Core/RGBSurfaceDeviceEvents.cs b/RGB.NET.Core/RGBSurfaceDeviceEvents.cs index 5d094eb..8af4f06 100644 --- a/RGB.NET.Core/RGBSurfaceDeviceEvents.cs +++ b/RGB.NET.Core/RGBSurfaceDeviceEvents.cs @@ -78,13 +78,13 @@ namespace RGB.NET.Core /// /// Handles the needed event-calls before updating. /// - 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 */ } } diff --git a/RGB.NET.Core/Update/AbstractUpdateTrigger.cs b/RGB.NET.Core/Update/AbstractUpdateTrigger.cs new file mode 100644 index 0000000..0769aeb --- /dev/null +++ b/RGB.NET.Core/Update/AbstractUpdateTrigger.cs @@ -0,0 +1,28 @@ +using System; + +namespace RGB.NET.Core +{ + public class AbstractUpdateTrigger : AbstractBindable, IUpdateTrigger + { + #region Events + + /// + public event EventHandler Starting; + /// + public event EventHandler 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); + + /// + public virtual void Dispose() + { } + + #endregion + } +} diff --git a/RGB.NET.Core/Update/CustomUpdateData.cs b/RGB.NET.Core/Update/CustomUpdateData.cs new file mode 100644 index 0000000..a92a182 --- /dev/null +++ b/RGB.NET.Core/Update/CustomUpdateData.cs @@ -0,0 +1,36 @@ +using System.Collections.Generic; + +namespace RGB.NET.Core +{ + public class CustomUpdateData + { + #region Properties & Fields + + private Dictionary _data = new Dictionary(); + + #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 + } +} diff --git a/RGB.NET.Core/Devices/Update/UpdateTrigger.cs b/RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs similarity index 86% rename from RGB.NET.Core/Devices/Update/UpdateTrigger.cs rename to RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs index 854a035..453ba04 100644 --- a/RGB.NET.Core/Devices/Update/UpdateTrigger.cs +++ b/RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs @@ -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 - - /// - public event EventHandler Starting; - /// - 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) { diff --git a/RGB.NET.Core/Update/Devices/IDeviceUpdateTrigger.cs b/RGB.NET.Core/Update/Devices/IDeviceUpdateTrigger.cs new file mode 100644 index 0000000..1ad117d --- /dev/null +++ b/RGB.NET.Core/Update/Devices/IDeviceUpdateTrigger.cs @@ -0,0 +1,7 @@ +namespace RGB.NET.Core +{ + public interface IDeviceUpdateTrigger : IUpdateTrigger + { + void TriggerHasData(); + } +} diff --git a/RGB.NET.Core/Devices/Update/UpdateQueue.cs b/RGB.NET.Core/Update/Devices/UpdateQueue.cs similarity index 88% rename from RGB.NET.Core/Devices/Update/UpdateQueue.cs rename to RGB.NET.Core/Update/Devices/UpdateQueue.cs index 558c2d9..c73eb0e 100644 --- a/RGB.NET.Core/Devices/Update/UpdateQueue.cs +++ b/RGB.NET.Core/Update/Devices/UpdateQueue.cs @@ -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 _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 dataSet; lock (_dataLock) @@ -77,7 +77,7 @@ namespace RGB.NET.Core #region Constructors /// - protected UpdateQueue(IUpdateTrigger updateTrigger) + protected UpdateQueue(IDeviceUpdateTrigger updateTrigger) : base(updateTrigger) { } diff --git a/RGB.NET.Core/Update/IUpdateTrigger.cs b/RGB.NET.Core/Update/IUpdateTrigger.cs new file mode 100644 index 0000000..693dec1 --- /dev/null +++ b/RGB.NET.Core/Update/IUpdateTrigger.cs @@ -0,0 +1,10 @@ +using System; + +namespace RGB.NET.Core +{ + public interface IUpdateTrigger : IDisposable + { + event EventHandler Starting; + event EventHandler Update; + } +} diff --git a/RGB.NET.Core/RGBSurfaceUpdater.cs b/RGB.NET.Core/Update/TimerUpdateTrigger.cs similarity index 57% rename from RGB.NET.Core/RGBSurfaceUpdater.cs rename to RGB.NET.Core/Update/TimerUpdateTrigger.cs index 01a7c80..2a5fa23 100644 --- a/RGB.NET.Core/RGBSurfaceUpdater.cs +++ b/RGB.NET.Core/Update/TimerUpdateTrigger.cs @@ -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; /// /// Gets or sets the update-frequency in seconds. (Calculate by using '1.0 / updates per second') @@ -31,51 +28,35 @@ namespace RGB.NET.Core /// public double LastUpdateTime { get; private set; } - private UpdateMode _updateMode = UpdateMode.Continuous; - /// - /// Gets or sets the update-mode. - /// - 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 - /// - /// Checks if automatic updates should occur and starts/stops the update-loop if needed. - /// - /// Thrown if the requested update-mode is not available. - 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; diff --git a/RGB.NET.Core/UpdateMode.cs b/RGB.NET.Core/UpdateMode.cs deleted file mode 100644 index 960a03b..0000000 --- a/RGB.NET.Core/UpdateMode.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace RGB.NET.Core -{ - /// - /// Contains list of available update modes. - /// - public enum UpdateMode - { - /// - /// The will not perform automatic updates. Updates will only occur if is called. - /// - Manual, - - /// - /// The will perform automatic updates at the rate set in . - /// - Continuous - } -} diff --git a/RGB.NET.Devices.Asus/AsusDeviceProvider.cs b/RGB.NET.Devices.Asus/AsusDeviceProvider.cs index 579a05f..bf8da51 100644 --- a/RGB.NET.Devices.Asus/AsusDeviceProvider.cs +++ b/RGB.NET.Devices.Asus/AsusDeviceProvider.cs @@ -63,7 +63,7 @@ namespace RGB.NET.Devices.Asus // ReSharper disable once AutoPropertyCanBeMadeGetOnly.Global public Func 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 diff --git a/RGB.NET.Devices.Asus/Generic/AsusRGBDevice.cs b/RGB.NET.Devices.Asus/Generic/AsusRGBDevice.cs index 133048f..df8d06d 100644 --- a/RGB.NET.Devices.Asus/Generic/AsusRGBDevice.cs +++ b/RGB.NET.Devices.Asus/Generic/AsusRGBDevice.cs @@ -45,7 +45,7 @@ namespace RGB.NET.Devices.Asus /// /// Initializes the device. /// - public void Initialize(IUpdateTrigger updateTrigger) + public void Initialize(IDeviceUpdateTrigger updateTrigger) { InitializeLayout(); diff --git a/RGB.NET.Devices.Asus/Generic/AsusUpdateQueue.cs b/RGB.NET.Devices.Asus/Generic/AsusUpdateQueue.cs index 0dad595..cd4d505 100644 --- a/RGB.NET.Devices.Asus/Generic/AsusUpdateQueue.cs +++ b/RGB.NET.Devices.Asus/Generic/AsusUpdateQueue.cs @@ -20,7 +20,7 @@ namespace RGB.NET.Devices.Asus.Generic #region Constructors - public AsusUpdateQueue(IUpdateTrigger updateTrigger) + public AsusUpdateQueue(IDeviceUpdateTrigger updateTrigger) : base(updateTrigger) { } diff --git a/RGB.NET.Devices.Asus/Generic/IAsusRGBDevice.cs b/RGB.NET.Devices.Asus/Generic/IAsusRGBDevice.cs index 3bba7bd..720fd3c 100644 --- a/RGB.NET.Devices.Asus/Generic/IAsusRGBDevice.cs +++ b/RGB.NET.Devices.Asus/Generic/IAsusRGBDevice.cs @@ -7,6 +7,6 @@ namespace RGB.NET.Devices.Asus /// internal interface IAsusRGBDevice : IRGBDevice { - void Initialize(IUpdateTrigger updateTrigger); + void Initialize(IDeviceUpdateTrigger updateTrigger); } } diff --git a/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs b/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs index 30d332e..25c6daa 100644 --- a/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs +++ b/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs @@ -63,7 +63,7 @@ namespace RGB.NET.Devices.CoolerMaster // ReSharper disable once AutoPropertyCanBeMadeGetOnly.Global public Func 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 diff --git a/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDevice.cs b/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDevice.cs index cace83e..f6d40e8 100644 --- a/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDevice.cs +++ b/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDevice.cs @@ -45,7 +45,7 @@ namespace RGB.NET.Devices.CoolerMaster /// /// Initializes the device. /// - public void Initialize(IUpdateTrigger updateTrigger) + public void Initialize(IDeviceUpdateTrigger updateTrigger) { InitializeLayout(); diff --git a/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterUpdateQueue.cs b/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterUpdateQueue.cs index 93e32eb..8469620 100644 --- a/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterUpdateQueue.cs +++ b/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterUpdateQueue.cs @@ -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; diff --git a/RGB.NET.Devices.CoolerMaster/Generic/ICoolerMasterRGBDevice.cs b/RGB.NET.Devices.CoolerMaster/Generic/ICoolerMasterRGBDevice.cs index e7786ac..8483843 100644 --- a/RGB.NET.Devices.CoolerMaster/Generic/ICoolerMasterRGBDevice.cs +++ b/RGB.NET.Devices.CoolerMaster/Generic/ICoolerMasterRGBDevice.cs @@ -7,6 +7,6 @@ namespace RGB.NET.Devices.CoolerMaster /// internal interface ICoolerMasterRGBDevice : IRGBDevice { - void Initialize(IUpdateTrigger updateTrigger); + void Initialize(IDeviceUpdateTrigger updateTrigger); } } diff --git a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs index 213ef34..442493a 100644 --- a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs +++ b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs @@ -66,7 +66,7 @@ namespace RGB.NET.Devices.Corsair /// public IEnumerable 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); } diff --git a/RGB.NET.Devices.Corsair/Generic/CorsairUpdateQueue.cs b/RGB.NET.Devices.Corsair/Generic/CorsairUpdateQueue.cs index 46e84e6..ab71e60 100644 --- a/RGB.NET.Devices.Corsair/Generic/CorsairUpdateQueue.cs +++ b/RGB.NET.Devices.Corsair/Generic/CorsairUpdateQueue.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair { #region Constructors - public CorsairUpdateQueue(IUpdateTrigger updateTrigger) + public CorsairUpdateQueue(IDeviceUpdateTrigger updateTrigger) : base(updateTrigger) { } diff --git a/RGB.NET.Devices.DMX/DMXDeviceProvider.cs b/RGB.NET.Devices.DMX/DMXDeviceProvider.cs index d8cdb24..1320530 100644 --- a/RGB.NET.Devices.DMX/DMXDeviceProvider.cs +++ b/RGB.NET.Devices.DMX/DMXDeviceProvider.cs @@ -37,7 +37,7 @@ namespace RGB.NET.Devices.DMX /// public List DeviceDefinitions { get; } = new List(); - 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 diff --git a/RGB.NET.Devices.DMX/E131/E131Device.cs b/RGB.NET.Devices.DMX/E131/E131Device.cs index cf430df..871466e 100644 --- a/RGB.NET.Devices.DMX/E131/E131Device.cs +++ b/RGB.NET.Devices.DMX/E131/E131Device.cs @@ -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) diff --git a/RGB.NET.Devices.DMX/E131/E131UpdateQueue.cs b/RGB.NET.Devices.DMX/E131/E131UpdateQueue.cs index b67ffca..adc4dd8 100644 --- a/RGB.NET.Devices.DMX/E131/E131UpdateQueue.cs +++ b/RGB.NET.Devices.DMX/E131/E131UpdateQueue.cs @@ -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(); diff --git a/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs b/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs index 3363b6d..706d01c 100644 --- a/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs +++ b/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs @@ -56,7 +56,7 @@ namespace RGB.NET.Devices.Logitech /// public Func 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); } diff --git a/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceUpdateQueue.cs b/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceUpdateQueue.cs index dc97ef6..04d8820 100644 --- a/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceUpdateQueue.cs +++ b/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceUpdateQueue.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Logitech { #region Constructors - public LogitechPerDeviceUpdateQueue(IUpdateTrigger updateTrigger) + public LogitechPerDeviceUpdateQueue(IDeviceUpdateTrigger updateTrigger) : base(updateTrigger) { } diff --git a/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyUpdateQueue.cs b/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyUpdateQueue.cs index a14ef60..3701cb1 100644 --- a/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyUpdateQueue.cs +++ b/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyUpdateQueue.cs @@ -15,7 +15,7 @@ namespace RGB.NET.Devices.Logitech #region Constructors - public LogitechPerKeyUpdateQueue(IUpdateTrigger updateTrigger) + public LogitechPerKeyUpdateQueue(IDeviceUpdateTrigger updateTrigger) : base(updateTrigger) { _bitmap = BitmapMapping.CreateBitmap(); diff --git a/RGB.NET.Devices.Novation/Generic/INovationRGBDevice.cs b/RGB.NET.Devices.Novation/Generic/INovationRGBDevice.cs index 76332cd..544df33 100644 --- a/RGB.NET.Devices.Novation/Generic/INovationRGBDevice.cs +++ b/RGB.NET.Devices.Novation/Generic/INovationRGBDevice.cs @@ -7,6 +7,6 @@ namespace RGB.NET.Devices.Novation /// internal interface INovationRGBDevice : IRGBDevice { - void Initialize(IUpdateTrigger updateTrigger); + void Initialize(IDeviceUpdateTrigger updateTrigger); } } diff --git a/RGB.NET.Devices.Novation/Generic/LimitedColorUpdateQueue.cs b/RGB.NET.Devices.Novation/Generic/LimitedColorUpdateQueue.cs index 49e5a9d..62f4284 100644 --- a/RGB.NET.Devices.Novation/Generic/LimitedColorUpdateQueue.cs +++ b/RGB.NET.Devices.Novation/Generic/LimitedColorUpdateQueue.cs @@ -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) { } diff --git a/RGB.NET.Devices.Novation/Generic/MidiUpdateQueue.cs b/RGB.NET.Devices.Novation/Generic/MidiUpdateQueue.cs index 1e31b9b..3a8ee36 100644 --- a/RGB.NET.Devices.Novation/Generic/MidiUpdateQueue.cs +++ b/RGB.NET.Devices.Novation/Generic/MidiUpdateQueue.cs @@ -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); diff --git a/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs b/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs index 6942c3b..f5a6cd6 100644 --- a/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs +++ b/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs @@ -43,7 +43,7 @@ namespace RGB.NET.Devices.Novation /// /// Initializes the device. /// - public void Initialize(IUpdateTrigger updateTrigger) + public void Initialize(IDeviceUpdateTrigger updateTrigger) { InitializeLayout(); diff --git a/RGB.NET.Devices.Novation/NovationDeviceProvider.cs b/RGB.NET.Devices.Novation/NovationDeviceProvider.cs index 08a06a7..aeae69a 100644 --- a/RGB.NET.Devices.Novation/NovationDeviceProvider.cs +++ b/RGB.NET.Devices.Novation/NovationDeviceProvider.cs @@ -39,7 +39,7 @@ namespace RGB.NET.Devices.Novation /// public IEnumerable 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 diff --git a/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkRGBDevice.cs b/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkRGBDevice.cs index ee98391..069aab8 100644 --- a/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkRGBDevice.cs +++ b/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkRGBDevice.cs @@ -42,7 +42,7 @@ namespace RGB.NET.Devices.Razer protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Custom1; /// - protected override RazerUpdateQueue CreateUpdateQueue(IUpdateTrigger updateTrigger) => new RazerChromaLinkUpdateQueue(updateTrigger, DeviceInfo.DeviceId); + protected override RazerUpdateQueue CreateUpdateQueue(IDeviceUpdateTrigger updateTrigger) => new RazerChromaLinkUpdateQueue(updateTrigger, DeviceInfo.DeviceId); #endregion } diff --git a/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkUpdateQueue.cs b/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkUpdateQueue.cs index 22ba06f..eb1ba84 100644 --- a/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkUpdateQueue.cs @@ -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) { } diff --git a/RGB.NET.Devices.Razer/Generic/IRazerRGBDevice.cs b/RGB.NET.Devices.Razer/Generic/IRazerRGBDevice.cs index 7eca600..9cf89ad 100644 --- a/RGB.NET.Devices.Razer/Generic/IRazerRGBDevice.cs +++ b/RGB.NET.Devices.Razer/Generic/IRazerRGBDevice.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Devices.Razer /// internal interface IRazerRGBDevice : IRGBDevice { - void Initialize(IUpdateTrigger updateTrigger); + void Initialize(IDeviceUpdateTrigger updateTrigger); void Reset(); } } diff --git a/RGB.NET.Devices.Razer/Generic/RazerRGBDevice.cs b/RGB.NET.Devices.Razer/Generic/RazerRGBDevice.cs index b931371..54e59ab 100644 --- a/RGB.NET.Devices.Razer/Generic/RazerRGBDevice.cs +++ b/RGB.NET.Devices.Razer/Generic/RazerRGBDevice.cs @@ -44,7 +44,7 @@ namespace RGB.NET.Devices.Razer /// /// Initializes the device. /// - 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); /// /// Initializes the and of the device. diff --git a/RGB.NET.Devices.Razer/Generic/RazerUpdateQueue.cs b/RGB.NET.Devices.Razer/Generic/RazerUpdateQueue.cs index 0da1d49..4dec4e4 100644 --- a/RGB.NET.Devices.Razer/Generic/RazerUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/Generic/RazerUpdateQueue.cs @@ -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; diff --git a/RGB.NET.Devices.Razer/Headset/RazerHeadsetRGBDevice.cs b/RGB.NET.Devices.Razer/Headset/RazerHeadsetRGBDevice.cs index f4c0d1a..a5ef0ab 100644 --- a/RGB.NET.Devices.Razer/Headset/RazerHeadsetRGBDevice.cs +++ b/RGB.NET.Devices.Razer/Headset/RazerHeadsetRGBDevice.cs @@ -42,7 +42,7 @@ namespace RGB.NET.Devices.Razer protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Headset1; /// - protected override RazerUpdateQueue CreateUpdateQueue(IUpdateTrigger updateTrigger) => new RazerHeadsetUpdateQueue(updateTrigger, DeviceInfo.DeviceId); + protected override RazerUpdateQueue CreateUpdateQueue(IDeviceUpdateTrigger updateTrigger) => new RazerHeadsetUpdateQueue(updateTrigger, DeviceInfo.DeviceId); #endregion } diff --git a/RGB.NET.Devices.Razer/Headset/RazerHeadsetUpdateQueue.cs b/RGB.NET.Devices.Razer/Headset/RazerHeadsetUpdateQueue.cs index f038e4c..2a12cb2 100644 --- a/RGB.NET.Devices.Razer/Headset/RazerHeadsetUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/Headset/RazerHeadsetUpdateQueue.cs @@ -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) { } diff --git a/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardRGBDevice.cs b/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardRGBDevice.cs index 06d4383..763fd47 100644 --- a/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardRGBDevice.cs @@ -48,7 +48,7 @@ namespace RGB.NET.Devices.Razer protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Keyboard_Escape; /// - protected override RazerUpdateQueue CreateUpdateQueue(IUpdateTrigger updateTrigger) => new RazerKeyboardUpdateQueue(updateTrigger, DeviceInfo.DeviceId); + protected override RazerUpdateQueue CreateUpdateQueue(IDeviceUpdateTrigger updateTrigger) => new RazerKeyboardUpdateQueue(updateTrigger, DeviceInfo.DeviceId); #endregion } diff --git a/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardUpdateQueue.cs b/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardUpdateQueue.cs index 85eab50..323c520 100644 --- a/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardUpdateQueue.cs @@ -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) { } diff --git a/RGB.NET.Devices.Razer/Keypad/RazerKeypadRGBDevice.cs b/RGB.NET.Devices.Razer/Keypad/RazerKeypadRGBDevice.cs index 6c94347..589faae 100644 --- a/RGB.NET.Devices.Razer/Keypad/RazerKeypadRGBDevice.cs +++ b/RGB.NET.Devices.Razer/Keypad/RazerKeypadRGBDevice.cs @@ -45,7 +45,7 @@ namespace RGB.NET.Devices.Razer protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Keypad1; /// - protected override RazerUpdateQueue CreateUpdateQueue(IUpdateTrigger updateTrigger) => new RazerKeypadUpdateQueue(updateTrigger, DeviceInfo.DeviceId); + protected override RazerUpdateQueue CreateUpdateQueue(IDeviceUpdateTrigger updateTrigger) => new RazerKeypadUpdateQueue(updateTrigger, DeviceInfo.DeviceId); #endregion } diff --git a/RGB.NET.Devices.Razer/Keypad/RazerKeypadUpdateQueue.cs b/RGB.NET.Devices.Razer/Keypad/RazerKeypadUpdateQueue.cs index ef5932f..0f4afa0 100644 --- a/RGB.NET.Devices.Razer/Keypad/RazerKeypadUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/Keypad/RazerKeypadUpdateQueue.cs @@ -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) { } diff --git a/RGB.NET.Devices.Razer/Mouse/RazerMouseRGBDevice.cs b/RGB.NET.Devices.Razer/Mouse/RazerMouseRGBDevice.cs index 3fe4b0b..2eeba61 100644 --- a/RGB.NET.Devices.Razer/Mouse/RazerMouseRGBDevice.cs +++ b/RGB.NET.Devices.Razer/Mouse/RazerMouseRGBDevice.cs @@ -45,7 +45,7 @@ namespace RGB.NET.Devices.Razer protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Mouse1; /// - protected override RazerUpdateQueue CreateUpdateQueue(IUpdateTrigger updateTrigger) => new RazerMouseUpdateQueue(updateTrigger, DeviceInfo.DeviceId); + protected override RazerUpdateQueue CreateUpdateQueue(IDeviceUpdateTrigger updateTrigger) => new RazerMouseUpdateQueue(updateTrigger, DeviceInfo.DeviceId); #endregion } diff --git a/RGB.NET.Devices.Razer/Mouse/RazerMouseUpdateQueue.cs b/RGB.NET.Devices.Razer/Mouse/RazerMouseUpdateQueue.cs index 914fe68..2dfde03 100644 --- a/RGB.NET.Devices.Razer/Mouse/RazerMouseUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/Mouse/RazerMouseUpdateQueue.cs @@ -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) { } diff --git a/RGB.NET.Devices.Razer/Mousepad/RazerMousepadRGBDevice.cs b/RGB.NET.Devices.Razer/Mousepad/RazerMousepadRGBDevice.cs index 3fd96bf..d0d8e1c 100644 --- a/RGB.NET.Devices.Razer/Mousepad/RazerMousepadRGBDevice.cs +++ b/RGB.NET.Devices.Razer/Mousepad/RazerMousepadRGBDevice.cs @@ -42,7 +42,7 @@ namespace RGB.NET.Devices.Razer protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Mousepad1; /// - protected override RazerUpdateQueue CreateUpdateQueue(IUpdateTrigger updateTrigger) => new RazerMousepadUpdateQueue(updateTrigger, DeviceInfo.DeviceId); + protected override RazerUpdateQueue CreateUpdateQueue(IDeviceUpdateTrigger updateTrigger) => new RazerMousepadUpdateQueue(updateTrigger, DeviceInfo.DeviceId); #endregion } diff --git a/RGB.NET.Devices.Razer/Mousepad/RazerMousepadUpdateQueue.cs b/RGB.NET.Devices.Razer/Mousepad/RazerMousepadUpdateQueue.cs index 13046c2..47150c1 100644 --- a/RGB.NET.Devices.Razer/Mousepad/RazerMousepadUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/Mousepad/RazerMousepadUpdateQueue.cs @@ -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) { } diff --git a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs index 3eae9f1..0023295 100644 --- a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs +++ b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs @@ -68,7 +68,7 @@ namespace RGB.NET.Devices.Razer /// 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