From 09d8d743900184e608fe69444039ee02462220ac Mon Sep 17 00:00:00 2001 From: Elivo Date: Sun, 20 Jul 2025 02:45:57 +0800 Subject: [PATCH] =?UTF-8?q?Tray=EF=BC=9A=E5=A2=9E=E5=8A=A0=20FormBeginInvo?= =?UTF-8?q?ke=20=E5=92=8C=E8=87=AA=E5=AE=9A=E4=B9=89=E9=80=80=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Apewer.Windows/WinForm/Tray.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Apewer.Windows/WinForm/Tray.cs b/Apewer.Windows/WinForm/Tray.cs index 8546e43..4a303af 100644 --- a/Apewer.Windows/WinForm/Tray.cs +++ b/Apewer.Windows/WinForm/Tray.cs @@ -76,7 +76,12 @@ namespace Apewer.WinForm } /// 获取 EXE 文件的图标。 - public static Icon GetExeIcon() => System.Drawing.Icon.ExtractAssociatedIcon(RuntimeUtility.ExecutablePath); + public static Icon GetExeIcon() + { + var exePath = RuntimeUtility.ExecutablePath; + var exeIcon = System.Drawing.Icon.ExtractAssociatedIcon(exePath); + return exeIcon; + } /// 获取 EXE 文件的图标。 /// @@ -258,6 +263,14 @@ namespace Apewer.WinForm action.Invoke(); } + /// + public void FormBeginInvoke(Action action) + { + if (action == null) return; + if (_form == null) return; + _form.BeginInvoke(action); + } + /// 显示对话框,并获取结果。 /// public DialogResult ShowDialog(CommonDialog dialog) @@ -287,6 +300,13 @@ namespace Apewer.WinForm Application.Exit(); } + /// + public void Exit(Action customExit) + { + if (!_disposed) Dispose(); + customExit.Invoke(); + } + #endregion #region run