130 public bool?
ShowBlink(Window? owner, BlinkPopupOptions options, out Window windowRef)
138 win.WindowStartupLocation = WindowStartupLocation.CenterOwner;
142 var active =
GetActive() ?? Application.Current?.MainWindow;
146 win.WindowStartupLocation = WindowStartupLocation.CenterOwner;
150 win.WindowStartupLocation = WindowStartupLocation.CenterScreen;
159 win.Closed += (_, __) =>
170 return win.ShowDialog();
466 BlinkPopupOptions options,
467 TimeSpan? autoCloseAfter =
null,
468 CancellationToken cancellationToken =
default)
471 var dispatcher = (owner ?? Application.Current?.MainWindow)?.Dispatcher
472 ?? Application.Current!.Dispatcher;
474 if (dispatcher ==
null)
475 throw new InvalidOperationException(
"Dispatcher not available.");
477 var tcs =
new TaskCompletionSource<bool?>(TaskCreationOptions.RunContinuationsAsynchronously);
479 bool wasOwnerEnabled =
false;
481 await dispatcher.InvokeAsync(() =>
489 win.WindowStartupLocation = WindowStartupLocation.CenterOwner;
493 var active =
GetActive() ?? Application.Current?.MainWindow;
497 win.WindowStartupLocation = WindowStartupLocation.CenterOwner;
501 win.WindowStartupLocation = WindowStartupLocation.CenterScreen;
510 win.Closed += (_, __) =>
516 if (options.IsModal && win.Owner !=
null && wasOwnerEnabled)
517 win.Owner.IsEnabled =
true;
521 ?? (win as Window)?.DialogResult;
522 _ = tcs.TrySetResult(result);
526 if (options.IsModal && win.Owner !=
null)
528 wasOwnerEnabled = win.Owner.IsEnabled;
529 win.Owner.IsEnabled =
false;
536 if (autoCloseAfter is TimeSpan delay && delay > TimeSpan.Zero)
538 var timer =
new DispatcherTimer { Interval = delay };
539 timer.Tick += (s, e) =>
542 if (win.IsLoaded) win.Close();
549 using (cancellationToken.Register(() =>
553 _ = dispatcher.InvokeAsync(() =>
555 if (win.IsLoaded) win.Close();
560 return await tcs.Task.ConfigureAwait(
false);