fix:修复崩溃自动重启的误判

This commit is contained in:
CJK_mkp
2025-06-13 09:19:44 +08:00
parent a9b64d2899
commit a9baf47823
10 changed files with 13 additions and 55 deletions
+3 -4
View File
@@ -1,4 +1,4 @@
using Hardcodet.Wpf.TaskbarNotification;
using Hardcodet.Wpf.TaskbarNotification;
using Ink_Canvas.Helpers;
using iNKORE.UI.WPF.Modern.Controls;
using System;
@@ -49,12 +49,11 @@ namespace Ink_Canvas
LogHelper.NewLog(e.Exception.ToString());
e.Handled = true;
// 新增:根据设置自动处理崩溃
if (CrashAction == CrashActionType.SilentRestart)
// 修改:仅当非用户主动退出时才触发自动重启
if (CrashAction == CrashActionType.SilentRestart && !IsAppExitByUser)
{
try
{
// 静默重启:启动新进程并退出当前进程
string exePath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
System.Diagnostics.Process.Start(exePath);
}
+2 -2
View File
@@ -292,8 +292,8 @@ namespace Ink_Canvas {
[DllImport("user32.dll", SetLastError = true)]
public static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
private void MainWindow_OnSizeChanged(object sender, SizeChangedEventArgs e) {
private void MainWindow_OnSizeChanged(object sender, SizeChangedEventArgs e) {
if (Settings.Advanced.IsEnableForceFullScreen) {
if (isLoaded) ShowNotification(
$"检测到窗口大小变化,已自动恢复到全屏:{System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width}x{System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height}(缩放比例为{System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width / SystemParameters.PrimaryScreenWidth}x{System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height / SystemParameters.PrimaryScreenHeight}");
@@ -1585,7 +1585,7 @@ namespace Ink_Canvas {
public void BtnRestart_Click(object sender, RoutedEventArgs e) {
Process.Start(System.Windows.Forms.Application.ExecutablePath, "-m");
App.IsAppExitByUser = true;
CloseIsFromButton = true;
Application.Current.Shutdown();
}
+5 -1
View File
@@ -63,7 +63,11 @@ namespace Ink_Canvas
private void RestartAppTrayIconMenuItem_Clicked(object sender, RoutedEventArgs e) {
var mainWin = (MainWindow)Application.Current.MainWindow;
if (mainWin.IsLoaded) mainWin.BtnRestart_Click(null,null);
if (mainWin.IsLoaded) {
App.IsAppExitByUser = true;
Application.Current.Shutdown();
// mainWin.BtnExit_Click(null,null);
}
}
private void ForceFullScreenTrayIconMenuItem_Clicked(object sender, RoutedEventArgs e) {
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -1,4 +1,4 @@
#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "DBB5B5D5CB8F12743D815ED76ACFDEDD4BE69F19"
#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "796FF054FB09C7AB91AFE4FAED2E71154DA26166"
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
@@ -1,4 +1,4 @@
#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "DBB5B5D5CB8F12743D815ED76ACFDEDD4BE69F19"
#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "796FF054FB09C7AB91AFE4FAED2E71154DA26166"
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
@@ -1,45 +0,0 @@
#region
/// <summary>
/// 计算任务栏高度,桌面模式下仅计算任务栏自身高度
/// </summary>
private double CalculateToolbarHeight(bool isDesktopMode)
{
if (isDesktopMode)
{
// 桌面模式: 任务栏高度 = 主屏幕高度 - 全屏可用高度
return SystemParameters.PrimaryScreenHeight - SystemParameters.FullPrimaryScreenHeight;
}
else
{
// 其他模式: 原有计算方式(包含窗口标题栏)
return SystemParameters.PrimaryScreenHeight
- SystemParameters.FullPrimaryScreenHeight
- SystemParameters.WindowCaptionHeight;
}
}
#endregion
public async void ViewboxFloatingBarMarginAnimation(int MarginFromEdge,
bool PosXCaculatedWithTaskbarHeight = false)
{
// 删除旧计算方式
// var toolbarHeight = System.Windows.SystemParameters.PrimaryScreenHeight - System.Windows.SystemParameters.FullPrimaryScreenHeight - System.Windows.SystemParameters.WindowCaptionHeight;
// 替换为新计算方式
var toolbarHeight = CalculateToolbarHeight(Topmost == false);
}
public async void PureViewboxFloatingBarMarginAnimationInDesktopMode()
{
// 删除旧计算方式
// var toolbarHeight = System.Windows.SystemParameters.PrimaryScreenHeight - System.Windows.SystemParameters.FullPrimaryScreenHeight - System.Windows.SystemParameters.WindowCaptionHeight;
// 替换为新计算方式(桌面模式专用)
var toolbarHeight = System.Windows.SystemParameters.PrimaryScreenHeight
- System.Windows.SystemParameters.FullPrimaryScreenHeight;
}