| | |
| | | using Panuon.WPF.UI; |
| | | using HMI.Core.Util; |
| | | using Panuon.WPF.UI; |
| | | using System; |
| | | using System.Windows; |
| | | using System.Windows.Controls; |
| | | |
| | |
| | | if (Instance == null) { Instance = helper; } |
| | | } |
| | | |
| | | public static void Success(Window window, |
| | | public static void Success(string message, |
| | | MessageBoxIcon icon = MessageBoxIcon.Success, |
| | | ToastPosition position = ToastPosition.Top, double offset = 0, int durationMs = 3000, |
| | | ToastWindow targetWindow = ToastWindow.ActiveWindow) |
| | | { |
| | | Application.Current.Dispatcher.BeginInvoke(new Action(() => |
| | | { |
| | | 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) |
| | | { |
| | | Application.Current.Dispatcher.BeginInvoke(new Action(() => |
| | | { |
| | | 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) |
| | | { |
| | | Application.Current.Dispatcher.BeginInvoke(new Action(() => |
| | | { |
| | | 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) |
| | | { |
| | | Application.Current.Dispatcher.BeginInvoke(new Action(() => |
| | | { |
| | | 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, |
| | | ToastPosition position = ToastPosition.Top, double offset = 0, int durationMs = 3000, |
| | | ToastWindow targetWindow = ToastWindow.ActiveWindow) |
| | | { |
| | | if (!(dp is Window window)) |
| | | { |
| | | window = Window.GetWindow(dp); |
| | | } |
| | | Instance.Success(window, message, icon, position, offset, durationMs, targetWindow); |
| | | } |
| | | |
| | | public static void Warning(Window window, |
| | | public static void Warning(DependencyObject dp, |
| | | string message, |
| | | MessageBoxIcon icon = MessageBoxIcon.Warning, |
| | | ToastPosition position = ToastPosition.Top, double offset = 0, int durationMs = 3000, |
| | | ToastWindow targetWindow = ToastWindow.ActiveWindow) |
| | | { |
| | | if (!(dp is Window window)) |
| | | { |
| | | window = Window.GetWindow(dp); |
| | | } |
| | | Instance.Warning(window, message, icon, position, offset, durationMs, targetWindow); |
| | | } |
| | | |
| | | public static void Error(Window window, |
| | | public static void Error(DependencyObject dp, |
| | | string message, |
| | | MessageBoxIcon icon = MessageBoxIcon.Error, |
| | | ToastPosition position = ToastPosition.Top, double offset = 0, int durationMs = 3000, |
| | | ToastWindow targetWindow = ToastWindow.ActiveWindow) |
| | | { |
| | | if (!(dp is Window window)) |
| | | { |
| | | window = Window.GetWindow(dp); |
| | | } |
| | | Instance.Error(window, message, icon, position, offset, durationMs, targetWindow); |
| | | } |
| | | |
| | | public static void Info(Window window, |
| | | public static void Info(DependencyObject dp, |
| | | string message, |
| | | MessageBoxIcon icon = MessageBoxIcon.Info, |
| | | ToastPosition position = ToastPosition.Top, double offset = 0, int durationMs = 3000, |
| | | ToastWindow targetWindow = ToastWindow.ActiveWindow) |
| | | { |
| | | if (!(dp is Window window)) |
| | | { |
| | | window = Window.GetWindow(dp); |
| | | } |
| | | Instance.Info(window, message, icon, position, offset, durationMs, targetWindow); |
| | | } |
| | | } |