diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 51d84a3..fa83fad 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -98,7 +98,7 @@ public MainWindow() } else { - Close(); + closeExe(); return; } } @@ -270,7 +270,7 @@ void WebView_KeyDown(object sender, KeyEventArgs e) if (e.KeyboardDevice.IsKeyDown(Key.Escape)) { - Close(); + closeExe(); } /* bool ctrl = e.KeyboardDevice.IsKeyDown(Key.LeftCtrl) || e.KeyboardDevice.IsKeyDown(Key.RightCtrl); @@ -284,7 +284,7 @@ void WebView_KeyDown(object sender, KeyEventArgs e) } else if (e.Key == Key.W && ctrl && !alt && !shift) { - Close(); + closeExe(); e.Handled = true; } */ @@ -427,7 +427,7 @@ void WebView_CoreWebView2InitializationCompleted(object sender, CoreWebView2Init if (e.InitializationException.HResult == -2147024593) { MessageBox.Show($"Failed to create webview, because the profile's name has been marked as deleted, please use a different profile's name."); - Close(); + closeExe(); return; } MessageBox.Show($"WebView2 creation failed with exception = {e.InitializationException}"); @@ -529,7 +529,7 @@ private void CloseWebViewForUpdate() private void sourceChanged(object sender, CoreWebView2SourceChangedEventArgs e) { - if (webView.Source.AbsoluteUri.Contains("webdemoexe_exit")) Close(); + if (webView.Source.AbsoluteUri.Contains("webdemoexe_exit")) closeExe(); } @@ -567,6 +567,13 @@ void WebView_PermissionRequested(object sender, CoreWebView2PermissionRequestedE } // - + + void closeExe() + { + webView.Source = new Uri("about:blank"); + webView.Dispose(); + Close(); + System.Environment.Exit(1); + } } }