From 99df058a665ea04065a23e729ec79a2f23f79881 Mon Sep 17 00:00:00 2001
From: alielie <alielie@git.com>
Date: 星期二, 20 五月 2025 16:59:43 +0800
Subject: [PATCH] 优化
---
HMI.UI/Util/MsgBoxHelper.cs | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/HMI.UI/Util/MsgBoxHelper.cs b/HMI.UI/Util/MsgBoxHelper.cs
index 8c01e3f..79174a2 100644
--- a/HMI.UI/Util/MsgBoxHelper.cs
+++ b/HMI.UI/Util/MsgBoxHelper.cs
@@ -71,12 +71,19 @@
MessageBoxResult res = MessageBoxResult.None;
if (!(owner is Window window))
{
- window = Window.GetWindow(owner);
+ owner.Dispatcher.Invoke(() =>
+ {
+ window = Window.GetWindow(owner) ?? Application.Current.MainWindow;
+ res = MessageBoxX.Show(window, message, caption, button, icon, defaultButton, setting, countdown);
+ });
}
- window.Dispatcher.Invoke(() =>
+ else
{
- res = MessageBoxX.Show(window, message, caption, button, icon, defaultButton, setting, countdown);
- });
+ window.Dispatcher.Invoke(() =>
+ {
+ res = MessageBoxX.Show(window, message, caption, button, icon, defaultButton, setting, countdown);
+ });
+ }
return res;
}
}
--
Gitblit v1.9.1