mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Profile editor - Fixed play on focus loss functionality
This commit is contained in:
1 parent
b82db7f453
commit
563389cab6
8 files changed
+124
-4
No files matched your search
@@ -321,7 +321,7 @@ public class DeviceVisualizer : Control
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}, DispatcherPriority.Background);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -14,6 +14,11 @@ public interface IMainWindowProvider
|
||||
/// </summary>
|
||||
bool IsMainWindowOpen { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a boolean indicating whether the main window is currently focused
|
||||
/// </summary>
|
||||
bool IsMainWindowFocused { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Opens the main window
|
||||
/// </summary>
|
||||
@@ -33,4 +38,14 @@ public interface IMainWindowProvider
|
||||
/// Occurs when the main window has been closed
|
||||
/// </summary>
|
||||
public event EventHandler? MainWindowClosed;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the main window has been focused
|
||||
/// </summary>
|
||||
public event EventHandler? MainWindowFocused;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the main window has been unfocused
|
||||
/// </summary>
|
||||
public event EventHandler? MainWindowUnfocused;
|
||||
}
|
||||
@@ -37,4 +37,14 @@ public interface IMainWindowService : IArtemisSharedUIService
|
||||
/// Occurs when the main window has been closed
|
||||
/// </summary>
|
||||
public event EventHandler? MainWindowClosed;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the main window has been focused
|
||||
/// </summary>
|
||||
public event EventHandler? MainWindowFocused;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the main window has been unfocused
|
||||
/// </summary>
|
||||
public event EventHandler? MainWindowUnfocused;
|
||||
}
|
||||
@@ -15,6 +15,16 @@ internal class MainWindowService : IMainWindowService
|
||||
{
|
||||
MainWindowClosed?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
protected virtual void OnMainWindowFocused()
|
||||
{
|
||||
MainWindowFocused?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
protected virtual void OnMainWindowUnfocused()
|
||||
{
|
||||
MainWindowUnfocused?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private void SyncWithManager()
|
||||
{
|
||||
@@ -43,6 +53,16 @@ internal class MainWindowService : IMainWindowService
|
||||
{
|
||||
SyncWithManager();
|
||||
}
|
||||
|
||||
private void HandleMainWindowFocused(object? sender, EventArgs e)
|
||||
{
|
||||
OnMainWindowFocused();
|
||||
}
|
||||
|
||||
private void HandleMainWindowUnfocused(object? sender, EventArgs e)
|
||||
{
|
||||
OnMainWindowUnfocused();
|
||||
}
|
||||
|
||||
public bool IsMainWindowOpen { get; private set; }
|
||||
|
||||
@@ -54,12 +74,16 @@ internal class MainWindowService : IMainWindowService
|
||||
{
|
||||
_mainWindowManager.MainWindowOpened -= HandleMainWindowOpened;
|
||||
_mainWindowManager.MainWindowClosed -= HandleMainWindowClosed;
|
||||
_mainWindowManager.MainWindowFocused -= HandleMainWindowFocused;
|
||||
_mainWindowManager.MainWindowUnfocused -= HandleMainWindowUnfocused;
|
||||
}
|
||||
|
||||
_mainWindowManager = mainWindowProvider;
|
||||
_mainWindowManager.MainWindowOpened += HandleMainWindowOpened;
|
||||
_mainWindowManager.MainWindowClosed += HandleMainWindowClosed;
|
||||
|
||||
_mainWindowManager.MainWindowFocused += HandleMainWindowFocused;
|
||||
_mainWindowManager.MainWindowUnfocused += HandleMainWindowUnfocused;
|
||||
|
||||
// Sync up with the new manager's state
|
||||
SyncWithManager();
|
||||
}
|
||||
@@ -76,4 +100,7 @@ internal class MainWindowService : IMainWindowService
|
||||
|
||||
public event EventHandler? MainWindowOpened;
|
||||
public event EventHandler? MainWindowClosed;
|
||||
|
||||
public event EventHandler? MainWindowFocused;
|
||||
public event EventHandler? MainWindowUnfocused;
|
||||
}
|
||||
Reference in new issue
Block a user