fix:退出确认按钮

This commit is contained in:
2025-07-31 10:03:29 +08:00
parent b25a5aac8c
commit 78f8d9a271
3 changed files with 40 additions and 14 deletions
+3 -1
View File
@@ -1,2 +1,4 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> <wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/PencilsConfiguration/ActualSeverity/@EntryValue">WARNING</s:String></wpf:ResourceDictionary> <s:String x:Key="/Default/CodeInspection/PencilsConfiguration/ActualSeverity/@EntryValue">WARNING</s:String>
<s:String x:Key="/Default/Environment/Hierarchy/Build/BuildTool/CustomBuildToolPath/@EntryValue">C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\MSBuild.exe</s:String>
<s:Int64 x:Key="/Default/Environment/Hierarchy/Build/BuildTool/MsbuildVersion/@EntryValue">1114112</s:Int64></wpf:ResourceDictionary>
+33 -8
View File
@@ -482,14 +482,39 @@ namespace Ink_Canvas {
private void Window_Closing(object sender, CancelEventArgs e) { private void Window_Closing(object sender, CancelEventArgs e) {
LogHelper.WriteLogToFile("Ink Canvas closing", LogHelper.LogType.Event); LogHelper.WriteLogToFile("Ink Canvas closing", LogHelper.LogType.Event);
if (!CloseIsFromButton && Settings.Advanced.IsSecondConfirmWhenShutdownApp) { if (!CloseIsFromButton && Settings.Advanced.IsSecondConfirmWhenShutdownApp) {
e.Cancel = true; // 第一个确认对话框
if (MessageBox.Show("是否继续关闭 InkCanvasForClass,这将丢失当前未保存的墨迹。", "InkCanvasForClass", var result1 = MessageBox.Show("是否继续关闭 InkCanvasForClass,这将丢失当前未保存的墨迹。", "InkCanvasForClass",
MessageBoxButton.OKCancel, MessageBoxImage.Warning) == MessageBoxResult.OK) MessageBoxButton.OKCancel, MessageBoxImage.Warning);
if (MessageBox.Show("真的狠心关闭 InkCanvasForClass吗?", "InkCanvasForClass", MessageBoxButton.OKCancel,
MessageBoxImage.Error) == MessageBoxResult.OK) if (result1 == MessageBoxResult.Cancel) {
if (MessageBox.Show("是否取消关闭 InkCanvasForClass", "InkCanvasForClass", MessageBoxButton.OKCancel, e.Cancel = true;
MessageBoxImage.Error) != MessageBoxResult.OK) LogHelper.WriteLogToFile("Ink Canvas closing cancelled at first confirmation", LogHelper.LogType.Event);
e.Cancel = false; return;
}
// 第二个确认对话框
var result2 = MessageBox.Show("真的狠心关闭 InkCanvasForClass吗?", "InkCanvasForClass",
MessageBoxButton.OKCancel, MessageBoxImage.Error);
if (result2 == MessageBoxResult.Cancel) {
e.Cancel = true;
LogHelper.WriteLogToFile("Ink Canvas closing cancelled at second confirmation", LogHelper.LogType.Event);
return;
}
// 第三个最终确认对话框
var result3 = MessageBox.Show("最后确认:确定要关闭 InkCanvasForClass 吗?", "InkCanvasForClass",
MessageBoxButton.OKCancel, MessageBoxImage.Question);
if (result3 == MessageBoxResult.Cancel) {
e.Cancel = true;
LogHelper.WriteLogToFile("Ink Canvas closing cancelled at final confirmation", LogHelper.LogType.Event);
return;
}
// 所有确认都通过,允许关闭
e.Cancel = false;
LogHelper.WriteLogToFile("Ink Canvas closing confirmed by user", LogHelper.LogType.Event);
} }
if (e.Cancel) LogHelper.WriteLogToFile("Ink Canvas closing cancelled", LogHelper.LogType.Event); if (e.Cancel) LogHelper.WriteLogToFile("Ink Canvas closing cancelled", LogHelper.LogType.Event);
@@ -1701,16 +1701,15 @@ namespace Ink_Canvas {
public void BtnExit_Click(object sender, RoutedEventArgs e) { public void BtnExit_Click(object sender, RoutedEventArgs e) {
App.IsAppExitByUser = true; App.IsAppExitByUser = true;
Application.Current.Shutdown(); // 不设置 CloseIsFromButton = true,让它也经过确认流程
// CloseIsFromButton = true; Close();
// Close();
} }
public void BtnRestart_Click(object sender, RoutedEventArgs e) { public void BtnRestart_Click(object sender, RoutedEventArgs e) {
Process.Start(System.Windows.Forms.Application.ExecutablePath, "-m"); Process.Start(System.Windows.Forms.Application.ExecutablePath, "-m");
App.IsAppExitByUser = true; App.IsAppExitByUser = true;
CloseIsFromButton = true; // 不设置 CloseIsFromButton = true,让它也经过确认流程
Application.Current.Shutdown(); Close();
} }
private void SettingsOverlayClick(object sender, MouseButtonEventArgs e) { private void SettingsOverlayClick(object sender, MouseButtonEventArgs e) {