using Sid.Windows.Controls; using System; using System.Windows.Input; using System.Windows.Media; namespace SSWMS.Common { public class MessageDialog { public static bool ShowDialog(string sMessage) { TaskDialog td = new TaskDialog { SystemSound = TaskDialogSound.Beep, Header = "确认信息", HeaderIcon = TaskDialogIcon.Question, Content = sMessage, TaskDialogButton = TaskDialogButton.Custom, IsButton1Enabled = true, Button1Text = "确认", IsButton2Enabled = true, Button2Text = "取消" }; td.TaskDialogWindow.Title = "系统提示"; bool bResult = td.Show() == TaskDialogResult.Button1; if (bResult) { td.Cursor = Cursors.Wait; } return bResult; } public static void Show(string sMessage) { TaskDialog td = new TaskDialog { SystemSound = TaskDialogSound.Beep, Header = "操作成功", HeaderIcon = TaskDialogIcon.Information, Content = sMessage, TaskDialogButton = TaskDialogButton.Custom, IsButton1Enabled = true, Button1Text = "关闭" }; td.TaskDialogWindow.Title = "系统提示"; td.Show(); } public static void ShowException(string sMessage) { TaskDialog td = new TaskDialog { SystemSound = TaskDialogSound.Hand, Header = "操作失败", HeaderIcon = TaskDialogIcon.Error, HeaderBackground = Brushes.Red, HeaderForeground = Brushes.White, Content = sMessage, TaskDialogButton = TaskDialogButton.Custom, IsButton1Enabled = true, Button1Text = "关闭" }; td.TaskDialogWindow.Title = "系统提示"; td.Show(); } public static void ShowException(Exception ex) { TaskDialog td = new TaskDialog { SystemSound = TaskDialogSound.Hand, Header = "异常信息", HeaderIcon = TaskDialogIcon.Error, HeaderBackground = Brushes.Red, HeaderForeground = Brushes.White, Content = ex.Message, Detail = ex.StackTrace, TaskDialogButton = TaskDialogButton.Custom, IsButton1Enabled = true, Button1Text = "关闭" }; td.TaskDialogWindow.Title = "系统提示"; td.Show(); } public static void ShowResult(bool bResult, string sResult) { if (bResult) { MessageDialog.Show(sResult); } else { MessageDialog.ShowException(sResult); } } } }