App: Add ShutdownNow() and ShutdownGracefully()
This commit is contained in:
@@ -50,27 +50,23 @@ namespace Elwig.Windows {
|
||||
_syncTimer.Start();
|
||||
}
|
||||
|
||||
private async void Window_Closing(object sender, CancelEventArgs evt) {
|
||||
evt.Cancel = !App.ForceShutdown;
|
||||
|
||||
private void Window_Closing(object sender, CancelEventArgs evt) {
|
||||
if (App.NumWindows > 1 && !App.ForceShutdown) {
|
||||
foreach (var w in Application.Current.Windows.Cast<Window>().Where(w => ((w as AdministrationWindow)?.IsEditing ?? false) || ((w as AdministrationWindow)?.IsCreating ?? false))) {
|
||||
foreach (var w in Application.Current.Windows.Cast<Window>().Where(w => w is AdministrationWindow adm && (adm.IsEditing || adm.IsCreating))) {
|
||||
try {
|
||||
w.Close();
|
||||
} catch { }
|
||||
}
|
||||
Thread.Sleep(100);
|
||||
if (App.NumWindows > 1 && !Application.Current.Windows.Cast<Window>().Any(w => ((w as AdministrationWindow)?.IsEditing ?? false) || ((w as AdministrationWindow)?.IsCreating ?? false))) {
|
||||
if (!InteractionService.AskConfirmation("Elwig beenden", "Es sind noch weitere Fenster geöffnet.\nSollen alle Fenster geschlossen werden?")) {
|
||||
if (App.NumWindows > 1) {
|
||||
var areAdminWindowsOpen = Application.Current.Windows.Cast<Window>().Any(w => w is AdministrationWindow adm && (adm.IsEditing || adm.IsCreating));
|
||||
if (areAdminWindowsOpen && !InteractionService.AskConfirmation("Elwig beenden", "Es sind noch weitere Fenster geöffnet.\nSollen alle Fenster geschlossen werden?")) {
|
||||
evt.Cancel = true;
|
||||
return;
|
||||
}
|
||||
App.ForceShutdown = true;
|
||||
}
|
||||
}
|
||||
|
||||
Mouse.OverrideCursor = Cursors.AppStarting;
|
||||
await (Application.Current as App)!.OnClosing();
|
||||
Application.Current.Shutdown();
|
||||
App.CurrentApp.ShutdownGracefully();
|
||||
}
|
||||
|
||||
private void Menu_Help_About_Click(object sender, RoutedEventArgs evt) {
|
||||
|
||||
Reference in New Issue
Block a user