From a061384ba628a09bf4df91f50321ab22c03129aa Mon Sep 17 00:00:00 2001
From: alielie <alielie@git.com>
Date: 星期二, 18 三月 2025 20:58:36 +0800
Subject: [PATCH] Winform支持遮罩层;

---
 HMI.UI/Util/ToastHelper.cs |   71 +++++++++++++++++++++++++++++++++++
 1 files changed, 70 insertions(+), 1 deletions(-)

diff --git a/HMI.UI/Util/ToastHelper.cs b/HMI.UI/Util/ToastHelper.cs
index 2156bdc..90a409b 100644
--- a/HMI.UI/Util/ToastHelper.cs
+++ b/HMI.UI/Util/ToastHelper.cs
@@ -1,4 +1,6 @@
-锘縰sing Panuon.WPF.UI;
+锘縰sing HMI.Core.Util;
+using Panuon.WPF.UI;
+using System.Runtime.CompilerServices;
 using System.Windows;
 using System.Windows.Controls;
 
@@ -40,6 +42,73 @@
             if (Instance == null) { Instance = helper; }
         }
 
+        public static void Success(string message,
+            MessageBoxIcon icon = MessageBoxIcon.Success,
+            ToastPosition position = ToastPosition.Top, double offset = 0, int durationMs = 3000,
+            ToastWindow targetWindow = ToastWindow.ActiveWindow)
+        {
+            var window = Application.Current.MainWindow;
+            if (window is WindowX)
+            {
+                Instance.Success(window, message, icon, position, offset, durationMs, targetWindow);
+            }
+            else
+            {
+                MessageBox.Show(message, LangUtil.Get("App.Success"));
+            }
+        }
+
+        public static void Warning(string message,
+            MessageBoxIcon icon = MessageBoxIcon.Warning,
+            ToastPosition position = ToastPosition.Top, double offset = 0, int durationMs = 3000,
+            ToastWindow targetWindow = ToastWindow.ActiveWindow)
+        {
+            var window = Application.Current.MainWindow;
+            if (window is WindowX)
+            {
+                Instance.Warning(window, message, icon, position, offset, durationMs, targetWindow);
+            }
+            else
+            {
+                MessageBox.Show(message, LangUtil.Get("App.Warn"));
+            }
+        }
+
+        public static void Error(string message,
+            MessageBoxIcon icon = MessageBoxIcon.Error,
+            ToastPosition position = ToastPosition.Top, double offset = 0, int durationMs = 3000,
+            ToastWindow targetWindow = ToastWindow.ActiveWindow)
+        {
+            var window = Application.Current.MainWindow;
+            if (window is WindowX)
+            {
+
+                Instance.Error(window, message, icon, position, offset, durationMs, targetWindow);
+            }
+            else
+            {
+                MessageBox.Show(message, LangUtil.Get("App.Error"));
+            }
+        }
+
+        public static void Info(string message,
+            MessageBoxIcon icon = MessageBoxIcon.Info,
+            ToastPosition position = ToastPosition.Top, double offset = 0, int durationMs = 3000,
+            ToastWindow targetWindow = ToastWindow.ActiveWindow)
+        {
+            var window = Application.Current.MainWindow;
+            if (window is WindowX)
+            {
+
+                Instance.Info(window, message, icon, position, offset, durationMs, targetWindow);
+            }
+            else
+            {
+                MessageBox.Show(message, LangUtil.Get("App.Info"));
+            }
+        }
+
+
         public static void Success(DependencyObject dp,
             string message,
             MessageBoxIcon icon = MessageBoxIcon.Success,

--
Gitblit v1.9.1