功能更改

This commit is contained in:
2026-01-05 21:27:56 +08:00
parent e10cf7ae74
commit 74ddab2abd
3 changed files with 40 additions and 7 deletions

View File

@@ -316,7 +316,7 @@ namespace CapMachine.Wpf
void App_Exit(object sender, ExitEventArgs e) void App_Exit(object sender, ExitEventArgs e)
{ {
//程序退出时需要处理的业务 //程序退出时需要处理的业务
LogService.Error("程序退出"); LogService.Error($"程序退出:{e.ToString()}");
} }
@@ -331,12 +331,14 @@ namespace CapMachine.Wpf
try try
{ {
HandleException(e.Exception); HandleException(e.Exception);
MessageBox.Show("UI线程异常:" + e.Exception.Message); //MessageBox.Show("UI线程异常:" + e.Exception.Message);
LogService.Error("UI线程异常:" + e.Exception.Message);
} }
catch (Exception ex) catch (Exception ex)
{ {
HandleException(ex); HandleException(ex);
MessageBox.Show("UI线程发生致命错误"); //MessageBox.Show("UI线程发生致命错误");
LogService.Error("UI线程发生致命错误");
} }
finally finally
{ {
@@ -373,12 +375,14 @@ namespace CapMachine.Wpf
{ {
sbEx.Append(e.ExceptionObject); sbEx.Append(e.ExceptionObject);
} }
MessageBox.Show(sbEx.ToString()); LogService.Error(sbEx.ToString());
//MessageBox.Show(sbEx.ToString());
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
LogService.Error(ex.ToString());
HandleException(ex); HandleException(ex);
} }
finally finally
@@ -401,7 +405,8 @@ namespace CapMachine.Wpf
{ {
HandleException(exception); HandleException(exception);
//task线程内未处理捕获 //task线程内未处理捕获
MessageBox.Show("Task线程异常" + e.Exception.Message); LogService.Error($"Task线程异常" + e.Exception.Message);
//MessageBox.Show("Task线程异常" + e.Exception.Message);
} }
} }
catch (Exception ex) catch (Exception ex)

View File

@@ -19,7 +19,7 @@
WindowStartupLocation="CenterScreen" WindowStartupLocation="CenterScreen"
WindowState="Maximized" WindowState="Maximized"
WindowStyle="SingleBorderWindow" WindowStyle="SingleBorderWindow"
mc:Ignorable="d"> mc:Ignorable="d" Closing="Window_Closing" Closed="Window_Closed">
<Window.Resources> <Window.Resources>
<localEx:BindingProxy x:Key="Proxy" Data="{Binding}" /> <localEx:BindingProxy x:Key="Proxy" Data="{Binding}" />
</Window.Resources> </Window.Resources>

View File

@@ -26,6 +26,34 @@ namespace CapMachine.Wpf.Views
LogService.Info($"Windows状态{this.WindowState}-Visibility: {this.Visibility}"); LogService.Info($"Windows状态{this.WindowState}-Visibility: {this.Visibility}");
} }
/// <summary>
/// 主界面正要关闭
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
// 弹窗提示是否确定要退出
MessageBoxResult result = MessageBox.Show("您确定要退出程序吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.None, MessageBoxResult.Cancel);
//System.Console.WriteLine(result);
if (result == MessageBoxResult.Cancel)
{
e.Cancel = true; // 中断点击事件
}
else
{
LogService.Info("Windows关闭");
}
}
/// <summary>
/// 主界面完成关闭
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Window_Closed(object sender, EventArgs e)
{
Environment.Exit(0); // 强制结束
}
} }
} }