/// <summary> /// Gets the localized names of all buttons that are currently visible in the GUI /// as comma seperated list. /// </summary> /// <param name="buttonOption"></param> /// <returns></returns> private string GetVisibleButtonDescription(MsgBoxButtons buttonOption) { switch (buttonOption) { case MsgBoxButtons.OKCancel: case MsgBoxButtons.OKCancelCopy: return(String.Format("{0}, {1}", MsgBox.Local.Strings.OK, MsgBox.Local.Strings.Cancel)); case MsgBoxButtons.YesNo: case MsgBoxButtons.YesNoCopy: return(String.Format("{0}, {1}", MsgBox.Local.Strings.Yes, MsgBox.Local.Strings.No)); case MsgBoxButtons.YesNoCancel: case MsgBoxButtons.YesNoCancelCopy: return(String.Format("{0}, {1}, {2}", MsgBox.Local.Strings.Yes, MsgBox.Local.Strings.No, MsgBox.Local.Strings.Cancel)); case MsgBoxButtons.Close: case MsgBoxButtons.CloseCopy: return(String.Format("{0}", MsgBox.Local.Strings.Close)); case MsgBoxButtons.OKClose: case MsgBoxButtons.OKCloseCopy: return(String.Format("{0}, {1}", MsgBox.Local.Strings.OK, MsgBox.Local.Strings.Close)); case MsgBoxButtons.OK: case MsgBoxButtons.OKCopy: default: return(String.Format("{0}", MsgBox.Local.Strings.OK)); } }
internal MsgBoxExForm(string message, string caption, MsgBoxButtons msgBoxButtons, MsgBoxIcon icon, MsgBoxDefaultButton defaultButton, MsgBoxCheckBox checkBox, string textColor, string formBackGroundColor) : this(message, caption, msgBoxButtons, icon, defaultButton, checkBox, textColor) { // Set the color of the form background. FormColor = formBackGroundColor; }
public static MsgBoxResult Show(string messageBoxText, string caption, string details, MsgBoxButtons buttonOption, MsgBoxImage image, MsgBoxResult btnDefault = MsgBoxResult.None, object helpLink = null, string helpLinkTitle = "", string helpLabel = "", Func <object, bool> navigateHelplinkMethod = null, bool enableCopyFunction = false) { // Construct the message box viewmodel ViewModel.MsgBoxViewModel viewModel = new ViewModel.MsgBoxViewModel(messageBoxText, caption, details, buttonOption, image, btnDefault, helpLink, helpLinkTitle, navigateHelplinkMethod, enableCopyFunction); viewModel.HyperlinkLabel = helpLabel; // Construct the message box view and add the viewmodel to it MsgBox.mMessageBox = new MsgBox(); MsgBox.mMessageBox.DataContext = viewModel; MsgBox.mMessageBox.ShowDialog(); return(viewModel.Result); }
/// <summary> /// Determine a default button (such as OK or Yes) to be executed when the user hits the ENTER key. /// </summary> /// <param name="buttonOption"></param> private MsgBoxResult SetupDefaultButton(MsgBoxButtons buttonOption, MsgBoxResult defaultButton) { MsgBoxResult ret = defaultButton; // Lets define a useful default button (can be executed with ENTER) // if caller did not define a button or // if did not explicitly told the sub-system to not define a default button via MsgBoxResult.NoDefaultButton if (defaultButton == MsgBoxResult.None) { switch (buttonOption) { case MsgBoxButtons.Close: ret = MsgBoxResult.Close; break; case MsgBoxButtons.OK: case MsgBoxButtons.OKCancel: case MsgBoxButtons.OKClose: ret = MsgBoxResult.Ok; break; case MsgBoxButtons.YesNo: case MsgBoxButtons.YesNoCancel: ret = MsgBoxResult.Yes; break; } } return(ret); }
public static MsgBoxDialogResult Show(string text, string caption, MsgBoxButtons buttons, MsgBoxIcon icon) { DialogForm dialogForm = new DialogForm(text, caption, buttons); dialogForm.ShowDialog(); return(result); }
internal MsgBoxExForm(string message, string caption, MsgBoxButtons msgBoxButtons, MsgBoxIcon icon, MsgBoxDefaultButton defaultButton, MsgBoxCheckBox checkBox, string textColor, string formBackGroundColor, MsgBoxOrder topmost) : this(message, caption, msgBoxButtons, icon, defaultButton, checkBox, textColor, formBackGroundColor) { // Set the Z index of the form. SetTopMost = topmost; }
/// <summary> /// Class constructor /// </summary> /// <param name="caption"></param> /// <param name="messageBoxText"></param> /// <param name="innerMessage"></param> /// <param name="buttonOption"></param> /// <param name="image"></param> /// <param name="defaultButton"></param> /// <param name="helpLink"></param> /// <param name="helpLinkTitle"></param> /// <param name="navigateHelplinkMethod"></param> /// <param name="enableCopyFunction"></param> internal MsgBoxViewModel(string messageBoxText, string caption, string innerMessage, MsgBoxButtons buttonOption, MsgBoxImage image, MsgBoxResult defaultButton = MsgBoxResult.None, object helpLink = null, string helpLinkTitle = "", Func <object, bool> navigateHelplinkMethod = null, bool enableCopyFunction = false) { this.Title = caption; this.Message = messageBoxText; this.InnerMessageDetails = innerMessage; this.SetButtonVisibility(buttonOption); this.mIsDefaultButton = this.SetupDefaultButton(buttonOption, defaultButton); this.SetImageSource(image); this.mHelpLink = helpLink; this.mHelpLinkTitle = helpLinkTitle; this.mResult = MsgBoxResult.None; this.mDialogCloseResult = null; if (navigateHelplinkMethod != null) { this.mNavigateHyperlinkMethod = navigateHelplinkMethod; } this.EnableCopyFunction = enableCopyFunction; }
///<summary>This is a more efficient version of the MS MessageBox. It also automates the language translation. Returns true if result is OK or Yes.</summary> public static bool Show(System.Object sender, MsgBoxButtons buttons, string question) { if (buttons == MsgBoxButtons.OKCancel) { if (MessageBox.Show(Lan.g(sender.GetType().Name, question), "", MessageBoxButtons.OKCancel) == DialogResult.OK) { return(true); } else { return(false); } } else if (buttons == MsgBoxButtons.YesNo) { if (MessageBox.Show(Lan.g(sender.GetType().Name, question), "", MessageBoxButtons.YesNo) == DialogResult.Yes) { return(true); } else { return(false); } } return(false); }
public string PlayMsgBoxButton(MsgBoxButtons mbb) { switch (mbb) { case MsgBoxButtons.AbortRetryIgnore: return("[中止][重試][略過]"); case MsgBoxButtons.OK: return("[確定]"); case MsgBoxButtons.OKCancel: return("[確定][取消]"); case MsgBoxButtons.RetryCancel: return("[重試][取消]"); case MsgBoxButtons.YesNo: return("[是][否]"); case MsgBoxButtons.YesNoCancel: return("[是][否][取消]"); default: return("參數有誤!!"); } }
public DialogForm(string text, string caption, MsgBoxButtons buttons) { InitializeComponent(); this.StartPosition = FormStartPosition.CenterParent; SetText(text); SetCaption(caption); SetButton(buttons); }
public static MessageBox Show(string Title, string Message, MsgBoxButtons Buttons, MsgBoxIcon Icon, DialogClose oCallback) { MessageBox oBox = new MessageBox(Title, Message, Buttons, Icon, oCallback); oBox.ModalHost.ShowModal(oBox); return(oBox); }
public static MsgBoxResult Show(Exception exp, string caption, MsgBoxButtons buttonOption, MsgBoxImage image, MsgBoxResult btnDefault = MsgBoxResult.None, object helpLink = null, string helpLinkTitle = "", string helpLabel = "", Func <object, bool> navigateHelplinkMethod = null, bool enableCopyFunction = false) { string sMess = "Unknown error occured."; string messageBoxText = string.Empty; if (true) { try { messageBoxText = exp.Message; Exception innerEx = exp.InnerException; for (int i = 0; innerEx != null; i++, innerEx = innerEx.InnerException) { string spaces = string.Empty; for (int j = 0; j < i; j++) { spaces += " "; } messageBoxText += "\n" + spaces + "+->" + innerEx.Message; } sMess = exp.ToString(); } catch { } } // Construct the message box viewmodel ViewModel.MsgBoxViewModel viewModel = new ViewModel.MsgBoxViewModel(messageBoxText, caption, sMess, buttonOption, image, btnDefault, helpLink, helpLinkTitle, navigateHelplinkMethod, enableCopyFunction); viewModel.HyperlinkLabel = helpLabel; // Construct the message box view and add the viewmodel to it MsgBox.mMessageBox = new MsgBox(); MsgBox.mMessageBox.DataContext = viewModel; MsgBox.mMessageBox.ShowDialog(); return(viewModel.Result); }
/// <summary> /// Show the message box with caption. /// </summary> /// <param name="id">Message Box ID</param> /// <param name="message">Message.</param> /// <param name="caption">Caption.</param> /// <param name="buttons">Buttons.</param> /// <param name="customStyleID">ID custom style.</param> /// <param name="method">Called method with result</param> /// <param name="modal">if <c>true</c> then blocked other GUI elements</param> /// <param name="btnText0">Text for button Yes/Ok. "" - use default value</param> /// <param name="btnText1">Text for button No. "" - use default value</param> /// <param name="btnText2">Text for button Cancel. "" - use default value</param> public static void Show(int id, string message, string caption, MsgBoxButtons buttons, int customStyleID, DialogResultMethod method, bool modal = false, string btnText0 = "", string btnText1 = "", string btnText2 = "") { if (customStyleID < 0 || customStyleID >= prefab._customStyles.Count) { Debug.LogError("Custom style not found by ID"); return; } Show(id, message, caption, buttons, prefab._customStyles[customStyleID], method, modal, btnText0, btnText1, btnText2); }
/// <summary> /// Show the message box with caption and buttons. /// </summary> /// <param name="id">Message Box ID</param> /// <param name="message">Message.</param> /// <param name="caption">Caption.</param> /// <param name="buttons">Buttons.</param> /// <param name="style">Style of message box</param> /// <param name="method">Called method with result</param> /// <param name="modal">if <c>true</c> then blocked other GUI elements</param> /// <param name="btnText0">Text for button Yes/Ok. "" - use default value</param> /// <param name="btnText1">Text for button No. "" - use default value</param> /// <param name="btnText2">Text for button Cancel. "" - use default value</param> private static void Show(int id, string message, string caption, MsgBoxButtons buttons, MSGBoxStyle style, DialogResultMethod method, bool modal = false, string btnText0 = "", string btnText1 = "", string btnText2 = "") { Close(); _lastMsgBox = Instantiate(prefab); _lastMsgBox.BuildMessageBox(id, message, caption, buttons, style, method, modal, btnText0, btnText1, btnText2); if (EventSystem.current == null) { _lastMsgBox._eventer.SetActive(true); } }
public static MsgBox Show(string text, MsgBoxButtons buttons) { var canvas = GameObject.Find("Canvas"); if (canvas == null) { Debug.LogError("MsgBox: Canvas not found."); return(null); } var obj = Instantiate(Resources.Load("MsgBox")) as GameObject; var transform = obj.transform as RectTransform; var txtMessage = transform.FindChild("TxtMessage").GetComponent <Text>(); var buttonsTransform = transform.FindChild("Buttons").transform; var hasButtons = (buttons != MsgBoxButtons.None); if (!hasButtons) { foreach (Transform child in buttonsTransform) { child.gameObject.SetActive(false); } } else { foreach (var msgBoxButton in new[] { MsgBoxButtons.Okay, MsgBoxButtons.Yes, MsgBoxButtons.No }) { var buttonTransform = buttonsTransform.FindChild("Btn" + msgBoxButton); if (buttonTransform == null) { Debug.LogErrorFormat("MsgBox: Button '{0}' not found.", msgBoxButton); continue; } var button = buttonTransform.GetComponent <Button>(); if ((buttons & msgBoxButton) == 0) { button.gameObject.SetActive(false); } } } txtMessage.text = text; var width = Math.Max(200, txtMessage.preferredWidth + 20); var height = Math.Max(102, txtMessage.preferredHeight + 20 + 30 + (hasButtons ? 35 : 0)); transform.sizeDelta = new Vector2(width, height); transform.position = new Vector3(Screen.width / 2, Screen.height / 2); transform.SetParent(canvas.transform); return(obj.GetComponent <MsgBox>()); }
///<summary>Displays a message box with the text and reads the text aloud. The user can respond by clicking buttons or answering by voice.</summary> public static bool Show(string text, MsgBoxButtons buttons) { FormMsgBox FormMB = new FormMsgBox(text, buttons); FormMB.ShowDialog(); if (FormMB.DialogResult == DialogResult.OK) { return(true); } return(false); }
public MsgBoxResult Show(string text, string caption = null, MsgBoxButtons buttons = 0, MsgBoxIcon icon = 0, MsgBoxFlags flags = 0) { if (hWnd != IntPtr.Zero && CenterOwner) { IntPtr hInst = GetWindowLong(hWnd, GWL.HINSTANCE); IntPtr thrId = GetCurrentThreadId(); hook = SetWindowsHookEx(WH.CBT, HookPrc, hInst, thrId); } return((MsgBoxResult)MessageBox(hWnd, text, caption, (MB)buttons | (MB)icon | (MB)flags)); }
/// <summary> /// Show the message box with caption and buttons. /// </summary> /// <param name="id">Message Box ID</param> /// <param name="message">Message.</param> /// <param name="caption">Caption.</param> /// <param name="buttons">Buttons.</param> /// <param name="style">Style of message box</param> /// <param name="method">Called method with result</param> /// <param name="modal">if <c>true</c> then blocked other GUI elements</param> /// <param name="btnText0">Text for button Yes/Ok. "" - use default value</param> /// <param name="btnText1">Text for button No. "" - use default value</param> /// <param name="btnText2">Text for button Cancel. "" - use default value</param> public static void Show(int id, string message, string caption, MsgBoxButtons buttons, MsgBoxStyle style, DialogResultMethod method, bool modal = false, string btnText0 = "", string btnText1 = "", string btnText2 = "") { Close(); _lastMsgBox = (GameObject)Instantiate(Resources.Load("PXMSG/MSG")); MsgBox box = _lastMsgBox.GetComponent <MsgBox>(); box.BuildMessageBox(id, message, caption, buttons, style, method, modal, btnText0, btnText1, btnText2); if (EventSystem.current == null) { box.eventer.SetActive(true); } }
MsgBoxResult IMsgBoxService.Show(string messageBoxText, string caption, MsgBoxButtons buttonOption, MsgBoxResult btnDefault, object helpLink, string helpLinkTitle, string helpLinkLabel, Func <object, bool> navigateHelplinkMethod, bool showCopyMessage) { return(View.MsgBox.Show(messageBoxText, caption, buttonOption, btnDefault, helpLink, helpLinkTitle, helpLinkLabel, navigateHelplinkMethod, showCopyMessage)); }
public static MsgBoxResult Show(string messageBoxText, string caption, string details, MsgBoxButtons buttonOption, MsgBoxResult btnDefault = MsgBoxResult.None, object helpLink = null, string helpLinkTitle = "", string helpLabel = "", Func <object, bool> navigateHelplinkMethod = null, bool enableCopyFunction = false) { return(Show(messageBoxText, caption, details, buttonOption, MsgBoxImage.Default, btnDefault, helpLink, helpLinkTitle, helpLabel, navigateHelplinkMethod, enableCopyFunction)); }
public MessageBox(string Title, string Message, MsgBoxButtons Buttons, MsgBoxIcon Icon, DialogClose oCallback) { InitializeComponent(); ModalHost = new ModalControl(); _oCallback = oCallback; btOne.Click += OneClick; btTwo.Click += OneClick; btCross.Click += OneClick; //if (string.IsNullOrEmpty(Title)) // txtTitle.Text = "Error"; // else txtTitle.Text = Title; txtMessage.Text = Message; if (Buttons == MsgBoxButtons.YesNo) { btOne.Content = "Yes"; btOne.Tag = DialogExit.OK; btTwo.Content = "No"; btTwo.Tag = DialogExit.Cancel; } else { btOne.Visibility = Visibility.Collapsed; btTwo.Content = "OK"; btTwo.Tag = DialogExit.Cancel; } btCross.Tag = DialogExit.Cancel; _lblIcon.Text = Icon.ToString(); //string sImagePath = @"Resources\error_img.png"; //if (Icon == MsgBoxIcon.Warning) // sImagePath = "/images/warning.png"; //else if (Icon == MsgBoxIcon.Error) // sImagePath = "/images/error.png"; //BitmapImage oImage = new BitmapImage(); //oImage.UriSource = new Uri(sImagePath); ////oImage.SetSource(Application.GetResourceStream(new Uri(sImagePath)).Stream); //_imgIcon.Source = oImage; }
///<summary>No language translation.</summary> public static bool Show(MsgBoxButtons buttons, string question, string titleBarText) { switch (buttons) { case MsgBoxButtons.OKCancel: return(MessageBox.Show(question, titleBarText, MessageBoxButtons.OKCancel) == DialogResult.OK); case MsgBoxButtons.YesNo: return(MessageBox.Show(question, titleBarText, MessageBoxButtons.YesNo) == DialogResult.Yes); default: return(false); } }
///<summary>Automates the language translation of the entire string. Do NOT use if the text could be variable in any way.</summary> public static bool Show(object sender, MsgBoxButtons buttons, string question, string titleBarText) { switch (buttons) { case MsgBoxButtons.OKCancel: return(MessageBox.Show(Lan.g(sender.GetType().Name, question), Lan.g(sender.GetType().Name, titleBarText), MessageBoxButtons.OKCancel) == DialogResult.OK); case MsgBoxButtons.YesNo: return(MessageBox.Show(Lan.g(sender.GetType().Name, question), Lan.g(sender.GetType().Name, titleBarText), MessageBoxButtons.YesNo) == DialogResult.Yes); default: return(false); } }
MsgBoxResult IMsgBoxService.Show(Exception exp, string caption, MsgBoxButtons buttonOption, MsgBoxImage image, MsgBoxResult btnDefault = MsgBoxResult.None, object helpLink = null, string helpLinkTitle = "", string helpLabel = "", Func <object, bool> navigateHelplinkMethod = null, bool showCopyMessage = false) { return(View.MsgBox.Show(exp, caption, buttonOption, image, btnDefault, helpLink, helpLinkTitle, helpLabel, navigateHelplinkMethod, showCopyMessage)); }
/// <summary> /// Sends MsgBox to creature's client. /// </summary> /// <param name="creature"></param> /// <param name="title"></param> /// <param name="buttons"></param> /// <param name="align"></param> /// <param name="format"></param> /// <param name="args"></param> public static void MsgBox(Creature creature, string title, MsgBoxButtons buttons, MsgBoxAlign align, string format, params object[] args) { var packet = new Packet(Op.MsgBox, creature.EntityId); packet.PutString(format, args); // Can be sent with the title enum as byte as well. packet.PutString(title); packet.PutByte((byte)buttons); packet.PutByte((byte)align); creature.Client.Send(packet); }
///<summary>Displays a message box with the text and reads the text aloud. The user can respond by clicking buttons or answering by voice.</summary> public static bool Show(string text, MsgBoxButtons buttons) { VoiceMsgBox voiceBox = new VoiceMsgBox(); voiceBox._formMsgBox = new FormMsgBox(text, buttons); VoiceMsgBoxSpeech voiceBoxSpeech = new VoiceMsgBoxSpeech(voiceBox._formMsgBox); voiceBoxSpeech.SayText(); voiceBox._formMsgBox.ShowDialog(); voiceBoxSpeech.Dispose(); if (voiceBox._formMsgBox.DialogResult == DialogResult.OK) { return(true); } return(false); }
///<summary>This is a more efficient version of the MS MessageBox. It also automates the language translation. Returns true if result is OK or Yes.</summary> public static bool Show(System.Object sender,MsgBoxButtons buttons,string question) { if(buttons==MsgBoxButtons.OKCancel) { if(MessageBox.Show(Lan.g(sender.GetType().Name,question),"",MessageBoxButtons.OKCancel)==DialogResult.OK) { return true; } else { return false; } } else if(buttons==MsgBoxButtons.YesNo) { if(MessageBox.Show(Lan.g(sender.GetType().Name,question),"",MessageBoxButtons.YesNo)==DialogResult.Yes) { return true; } else { return false; } } return false; }
/// <summary> /// Class constructor from parameters. /// </summary> /// <param name="caption"></param> /// <param name="messageBoxText"></param> /// <param name="innerMessage"></param> /// <param name="buttonOption"></param> /// <param name="image"></param> /// <param name="defaultButton"></param> /// <param name="helpLink"></param> /// <param name="helpLinkTitle"></param> /// <param name="navigateHelplinkMethod"></param> /// <param name="enableCopyFunction"></param> /// <param name="defaultCloseResult">Determines the result if user closes a dialog with Esc, F4, or Window close button (X)</param> /// <param name="dialogCanCloseViaChrome">Determines whether user can close dialog via Esc, F4, or Window close button (X)</param> internal MsgBoxViewModel(string messageBoxText, string caption, string innerMessage, MsgBoxButtons buttonOption, MsgBoxImage image, MsgBoxResult defaultButton = MsgBoxResult.None, object helpLink = null, string helpLinkTitle = "", Func <object, bool> navigateHelplinkMethod = null, bool enableCopyFunction = false, MsgBoxResult defaultCloseResult = MsgBoxResult.None, bool dialogCanCloseViaChrome = true) { this.mButtonOption = buttonOption; this.Title = caption; this.Message = messageBoxText; this.InnerMessageDetails = innerMessage; // Enable Copy should be set before button options since button options should // be able to over rule the enableCopyFunction parameter this.EnableCopyFunction = enableCopyFunction; this.SetButtonVisibility(buttonOption); this.IsDefaultButton = this.SetupDefaultButton(buttonOption, defaultButton); this.TypeOfImage = image; this.mHelpLink = helpLink; this.HelpLinkTitle = helpLinkTitle; this.Result = MsgBoxResult.None; this.DefaultCloseResult = defaultCloseResult; this.DialogCanCloseViaChrome = dialogCanCloseViaChrome; this.mDialogCloseResult = null; if (navigateHelplinkMethod != null) { this.mNavigateHyperlinkMethod = navigateHelplinkMethod; } }
private static void InitButtons(MsgBoxButtons buttons) { switch (buttons) { case MsgBoxButtons.AbortRetryIgnore: _msgBox.InitAbortRetryIgnoreButtons(); break; case MsgBoxButtons.OK: _msgBox.InitOKButton(); break; case MsgBoxButtons.OKCancel: _msgBox.InitOKCancelButtons(); break; case MsgBoxButtons.RetryCancel: _msgBox.InitRetryCancelButtons(); break; case MsgBoxButtons.YesNo: _msgBox.InitYesNoButtons(); break; case MsgBoxButtons.YesNoCancel: _msgBox.InitYesNoCancelButtons(); break; } foreach (Button btn in _msgBox._buttonCollection) { btn.Padding = new Padding(3); btn.Height = 30; _msgBox._flpButtons.Controls.Add(btn); } }
/// <summary> /// Sends MsgBox to creature's client. /// </summary> /// <param name="creature"></param> /// <param name="title"></param> /// <param name="buttons"></param> /// <param name="align"></param> /// <param name="format"></param> /// <param name="args"></param> public static void MsgBox(Creature creature, MsgBoxTitle title, MsgBoxButtons buttons, MsgBoxAlign align, string format, params object[] args) { MsgBox(creature, title.ToString(), MsgBoxButtons.Close, MsgBoxAlign.Center, format, args); }
internal MsgBoxExForm(string message, string caption, MsgBoxButtons msgBoxButtons, MsgBoxIcon icon, MsgBoxDefaultButton defaultButton, MsgBoxCheckBox checkBox, string textColor) : this(message, caption, msgBoxButtons, icon, defaultButton, checkBox) { // Set the color of the Message text. TextColor = textColor; }