fix:修复崩溃自动重启的误判
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
using Hardcodet.Wpf.TaskbarNotification;
|
using Hardcodet.Wpf.TaskbarNotification;
|
||||||
using Ink_Canvas.Helpers;
|
using Ink_Canvas.Helpers;
|
||||||
using iNKORE.UI.WPF.Modern.Controls;
|
using iNKORE.UI.WPF.Modern.Controls;
|
||||||
using System;
|
using System;
|
||||||
@@ -49,12 +49,11 @@ namespace Ink_Canvas
|
|||||||
LogHelper.NewLog(e.Exception.ToString());
|
LogHelper.NewLog(e.Exception.ToString());
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
|
|
||||||
// 新增:根据设置自动处理崩溃
|
// 修改:仅当非用户主动退出时才触发自动重启
|
||||||
if (CrashAction == CrashActionType.SilentRestart)
|
if (CrashAction == CrashActionType.SilentRestart && !IsAppExitByUser)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// 静默重启:启动新进程并退出当前进程
|
|
||||||
string exePath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
|
string exePath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
|
||||||
System.Diagnostics.Process.Start(exePath);
|
System.Diagnostics.Process.Start(exePath);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ namespace Ink_Canvas {
|
|||||||
[DllImport("user32.dll", SetLastError = true)]
|
[DllImport("user32.dll", SetLastError = true)]
|
||||||
public static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
|
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 (Settings.Advanced.IsEnableForceFullScreen) {
|
||||||
if (isLoaded) ShowNotification(
|
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})");
|
$"检测到窗口大小变化,已自动恢复到全屏:{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) {
|
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;
|
||||||
CloseIsFromButton = true;
|
CloseIsFromButton = true;
|
||||||
Application.Current.Shutdown();
|
Application.Current.Shutdown();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,11 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
private void RestartAppTrayIconMenuItem_Clicked(object sender, RoutedEventArgs e) {
|
private void RestartAppTrayIconMenuItem_Clicked(object sender, RoutedEventArgs e) {
|
||||||
var mainWin = (MainWindow)Application.Current.MainWindow;
|
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) {
|
private void ForceFullScreenTrayIconMenuItem_Clicked(object sender, RoutedEventArgs e) {
|
||||||
|
|||||||
Vendored
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
@@ -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>
|
// <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>
|
// <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;
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user