Skip to content

Commit

Permalink
feat: add event for when OpenRGB started changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewBabbitt97 committed Aug 7, 2024
1 parent 8227e46 commit 90c61a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/ChromaControl.SDK.OpenRGB/IOpenRGBService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public interface IOpenRGBService
/// </summary>
bool Started { get; }

/// <summary>
/// Occurs when <see cref="Started"/> changes.
/// </summary>
event EventHandler<bool>? StartedChanged;

/// <summary>
/// The devices available in OpenRGB.
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions src/ChromaControl.SDK.OpenRGB/OpenRGBService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public class OpenRGBService : IOpenRGBService, IAsyncDisposable
/// <inheritdoc/>
public bool Started { get; internal set; }

/// <inheritdoc/>
public event EventHandler<bool>? StartedChanged;

/// <inheritdoc/>
public ImmutableList<OpenRGBDevice> Devices => [.. _devices];

Expand Down Expand Up @@ -51,6 +54,7 @@ public async Task Restart(CancellationToken cancellationToken = default)
if (Started)
{
Started = false;
StartedChanged?.Invoke(this, Started);

_service.DeviceListUpdated -= OnDeviceListUpdated;
await _service.DisposeAsync();
Expand Down Expand Up @@ -242,5 +246,6 @@ private async void OnDeviceListUpdated(object? sender, EventArgs e)
await UpdateDeviceListAsync();

Started = true;
StartedChanged?.Invoke(this, Started);
}
}

0 comments on commit 90c61a2

Please sign in to comment.