123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- using Caliburn.Micro;
- using System;
- using System.Linq;
- using System.Windows;
- namespace OpenSEMI.ClientBase
- {
- public class DialogBox
- {
- public static DialogButton ShowError(MESSAGE msgEnum, params object[] param)
- {
- string msg = GetMsg(msgEnum);
- return ShowError(msg, param);
- }
- public static DialogButton ShowError(string msg, params object[] param)
- {
- return ShowDialog(DialogButton.OK, DialogType.ERROR, msg, param);
- }
- public static DialogButton ShowWarning(MESSAGE msgEnum, params object[] param)
- {
- string msg = GetMsg(msgEnum);
- return ShowWarning(msg, param);
- }
- public static DialogButton ShowWarning(string msg, params object[] param)
- {
- return ShowDialog(DialogButton.OK, DialogType.WARNING, msg, param);
- }
- public static DialogButton ShowInfo(MESSAGE msgEnum, params object[] param)
- {
- string msg = GetMsg(msgEnum);
- return ShowInfo(msg, param);
- }
- public static DialogButton ShowInfo(string msg, params object[] param)
- {
- return ShowDialog(DialogButton.OK, DialogType.INFO, msg, param);
- }
- public static bool Confirm(MESSAGE msgEnum, params object[] param)
- {
- string msg = GetMsg(msgEnum);
- return Confirm(msg, param);
- }
- public static bool Confirm(string msg, params object[] param)
- {
- DialogButton dialogButton = ShowDialog(DialogButton.Yes | DialogButton.No, DialogType.CONFIRM, msg, param);
- if (dialogButton == DialogButton.Yes)
- {
- return true;
- }
- return false;
- }
- public static string GetMsg(MESSAGE msgEnum)
- {
- string text = Application.Current.Resources[msgEnum.ToString()] as string;
- string[] array = text.Split(new string[1]
- {
- "\\n"
- }, StringSplitOptions.RemoveEmptyEntries);
- string text2 = string.Empty;
- int num = 0;
- string[] array2 = array;
- foreach (string str in array2)
- {
- text2 = ((num != array.Count() - 1) ? (text2 + str + Environment.NewLine) : (text2 + str));
- num++;
- }
- return text2;
- }
- public static DialogButton ShowDialog(DialogButton buttons, DialogType type, MESSAGE msgEnum, params object[] param)
- {
- string msg = GetMsg(msgEnum);
- return ShowDialog(buttons, type, msg, param);
- }
- public static DialogButton ShowDialog(DialogButton buttons, DialogType type, string msg, params object[] Params)
- {
- WindowManager windowManager = new WindowManager();
- MessageDialogViewModel messageDialogViewModel = new MessageDialogViewModel();
- messageDialogViewModel.DialogButton = buttons;
- if (Params != null && Params.Length != 0)
- {
- msg = string.Format(msg, Params);
- }
- messageDialogViewModel.Text = msg;
- messageDialogViewModel.DialogType = type;
- windowManager.ShowDialogWithNoStyle(messageDialogViewModel, null);
- return messageDialogViewModel.DialogResult;
- }
- }
- }
|