|
|
@ -13,26 +13,18 @@ internal class BrowserSingleViewLifetime : ISingleViewApplicationLifetime, IActi |
|
|
{ |
|
|
{ |
|
|
public BrowserSingleViewLifetime() |
|
|
public BrowserSingleViewLifetime() |
|
|
{ |
|
|
{ |
|
|
bool? initiallyVisible = InputHelper.SubscribeVisibilityChange(visible => |
|
|
_initiallyVisible = InputHelper.SubscribeVisibilityChange(visible => |
|
|
{ |
|
|
{ |
|
|
initiallyVisible = null; |
|
|
_initiallyVisible = null; |
|
|
(visible ? Activated : Deactivated)?.Invoke(this, new ActivatedEventArgs(ActivationKind.Background)); |
|
|
var eventToTrigger = (visible ? Activated : Deactivated); |
|
|
|
|
|
Dispatcher.UIThread.Invoke( |
|
|
|
|
|
() => eventToTrigger?.Invoke(this, new ActivatedEventArgs(ActivationKind.Background)), |
|
|
|
|
|
DispatcherPriority.Background); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// Trigger Activated as an initial state, if web page is visible, and wasn't hidden during initialization.
|
|
|
|
|
|
if (initiallyVisible == true) |
|
|
|
|
|
{ |
|
|
|
|
|
Dispatcher.UIThread.Invoke(() => |
|
|
|
|
|
{ |
|
|
|
|
|
if (initiallyVisible == true) |
|
|
|
|
|
{ |
|
|
|
|
|
Activated?.Invoke(this, new ActivatedEventArgs(ActivationKind.Background)); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public AvaloniaView? View; |
|
|
public AvaloniaView? View; |
|
|
|
|
|
private bool? _initiallyVisible; |
|
|
|
|
|
|
|
|
public Control? MainView |
|
|
public Control? MainView |
|
|
{ |
|
|
{ |
|
|
@ -61,5 +53,17 @@ internal class BrowserSingleViewLifetime : ISingleViewApplicationLifetime, IActi |
|
|
public event EventHandler<ActivatedEventArgs>? Deactivated; |
|
|
public event EventHandler<ActivatedEventArgs>? Deactivated; |
|
|
|
|
|
|
|
|
public bool TryLeaveBackground() => false; |
|
|
public bool TryLeaveBackground() => false; |
|
|
public bool TryEnterBackground() => true; |
|
|
public bool TryEnterBackground() => false; |
|
|
|
|
|
|
|
|
|
|
|
internal void CompleteSetup() |
|
|
|
|
|
{ |
|
|
|
|
|
// Trigger Activated as an initial state, if web page is visible, and wasn't hidden during initialization.
|
|
|
|
|
|
Dispatcher.UIThread.Invoke(() => |
|
|
|
|
|
{ |
|
|
|
|
|
if (_initiallyVisible == true) |
|
|
|
|
|
{ |
|
|
|
|
|
Activated?.Invoke(this, new ActivatedEventArgs(ActivationKind.Background)); |
|
|
|
|
|
} |
|
|
|
|
|
}, DispatcherPriority.Background); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|