From f8e4732dcdfc1ca9e2f45e3cb2ede6f1e8a5a796 Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Mon, 28 Jul 2025 17:44:15 +0800 Subject: [PATCH] fix:issue #110 --- Ink Canvas/App.xaml.cs | 6 +++--- Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs | 12 ++++++++---- Ink Canvas/MainWindow_cs/MW_TrayIcon.cs | 9 +++++---- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Ink Canvas/App.xaml.cs b/Ink Canvas/App.xaml.cs index 672d65f1..c04eb9d3 100644 --- a/Ink Canvas/App.xaml.cs +++ b/Ink Canvas/App.xaml.cs @@ -423,7 +423,7 @@ namespace Ink_Canvas try { string exePath = Process.GetCurrentProcess().MainModule.FileName; - Process.Start(exePath); + Process.Start(exePath, "-m"); } catch { } Environment.Exit(1); @@ -644,7 +644,7 @@ namespace Ink_Canvas try { string exePath = Process.GetCurrentProcess().MainModule.FileName; - Process.Start(exePath); + Process.Start(exePath, "-m"); } catch { } Environment.Exit(1); @@ -704,7 +704,7 @@ namespace Ink_Canvas Environment.Exit(1); } string exePath = Process.GetCurrentProcess().MainModule.FileName; - Process.Start(exePath); + Process.Start(exePath, "-m"); } // CrashActionType.NoAction 时不重启,直接退出 } diff --git a/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs b/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs index ca43fe69..5cefce4c 100644 --- a/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs +++ b/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs @@ -1643,10 +1643,14 @@ 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(); + try { + Process.Start(System.Windows.Forms.Application.ExecutablePath, "-m"); + App.IsAppExitByUser = true; + CloseIsFromButton = true; + Application.Current.Shutdown(); + } catch (Exception ex) { + LogHelper.NewLog($"重启程序时出错: {ex.Message}"); + } } private void SettingsOverlayClick(object sender, MouseButtonEventArgs e) { diff --git a/Ink Canvas/MainWindow_cs/MW_TrayIcon.cs b/Ink Canvas/MainWindow_cs/MW_TrayIcon.cs index d3c22217..c182ced8 100644 --- a/Ink Canvas/MainWindow_cs/MW_TrayIcon.cs +++ b/Ink Canvas/MainWindow_cs/MW_TrayIcon.cs @@ -62,20 +62,21 @@ namespace Ink_Canvas var mainWin = (MainWindow)Current.MainWindow; if (mainWin.IsLoaded) { IsAppExitByUser = true; - + try { - // 启动新实例 + // 启动新实例,添加 -m 参数允许多实例启动 string exePath = Process.GetCurrentProcess().MainModule.FileName; ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = exePath; + startInfo.Arguments = "-m"; startInfo.UseShellExecute = true; - + // 启动进程但不等待 Process.Start(startInfo); } catch (Exception ex) { LogHelper.NewLog($"重启程序时出错: {ex.Message}"); } - + // 退出当前实例 Current.Shutdown(); }