public void Show(string caption, string content, MyMessageBoxButton button, MyMessageBoxIcon icon, DialogHandlerCallback callback, System.Object refer = null, bool flag = false) { Init(); TitleText.text = caption; ContentText.text = content; buttonType = button; iconType = icon; SetButton(button); SetIcon(icon); ShowToggle.gameObject.SetActive(flag); passRefer = refer; msgHandler = callback; }
void SetIcon(MyMessageBoxIcon icon) { switch (icon) { case MyMessageBoxIcon.Asterisk: IconImage.sprite = IconArray[0]; break; case MyMessageBoxIcon.Error: IconImage.sprite = IconArray[1]; break; case MyMessageBoxIcon.Exclamation: IconImage.sprite = IconArray[2]; break; case MyMessageBoxIcon.Information: IconImage.sprite = IconArray[3]; break; case MyMessageBoxIcon.None: IconImage.gameObject.SetActive(false); break; case MyMessageBoxIcon.Question: IconImage.sprite = IconArray[4]; break; case MyMessageBoxIcon.Stop: IconImage.sprite = IconArray[5]; break; case MyMessageBoxIcon.Warning: IconImage.sprite = IconArray[6]; break; } }
/// <summary> /// 弹出消息框 /// </summary> /// <param name="text">消息内容</param> /// <param name="title">标题</param> /// <param name="MessageBoxButton">按钮类型(默认OK)</param> /// <param name="MessageBoxIcon">消息图标(默认不显示)</param> public void Show(string text, string title, MyMessageBoxButton MessageBoxButton, MyMessageBoxIcon MessageBoxIcon) { this.Text = title; this.label1.Text = text; switch (MessageBoxButton) { case MyMessageBoxButton.OK: button1.Visible = true; button1.Location = button2.Location; button2.Visible = false; break; case MyMessageBoxButton.Cancel: button1.Visible = false; button2.Visible = true; break; case MyMessageBoxButton.OKCancel: button1.Visible = true; button2.Visible = true; break; } switch (MessageBoxIcon) { case MyMessageBoxIcon.None: pictureBox1.Visible = false; break; case MyMessageBoxIcon.Error: pictureBox1.Visible = true; pictureBox1.Image = Image.FromFile(path[0]); break; case MyMessageBoxIcon.Warning: pictureBox1.Visible = true; pictureBox1.Image = Image.FromFile(path[1]); break; case MyMessageBoxIcon.Asterisk: pictureBox1.Visible = true; pictureBox1.Image = Image.FromFile(path[2]); break; case MyMessageBoxIcon.Question: pictureBox1.Visible = true; pictureBox1.Image = Image.FromFile(path[3]); break; } this.ShowDialog(); }
private void displayMessage( string message, string title, string details, MyMessageBoxButtons buttons, MyMessageBoxIcon icon, MyMessageBoxDefaultButton defaultButton ) { MyMessageBox mmb = new MyMessageBox( message, title, details, buttons, icon, defaultButton ); messageDialogResult = mmb.ShowDialog(); messageEvent.Set(); }
public MyMessageBox(string message, string caption, string details, MyMessageBoxButtons buttons, MyMessageBoxIcon icon, MyMessageBoxDefaultButton defaultButton) : this() { this.message.Text = message; this.Text = caption; detailsBox.Text = details.Replace("\n", "\r\n"); this.details.Visible = !details.Equals(string.Empty); switch (buttons) { case MyMessageBoxButtons.OK: ok.Visible = true; break; case MyMessageBoxButtons.OKCancel: ok.Visible = cancel.Visible = true; break; case MyMessageBoxButtons.YesNo: yes.Visible = no.Visible = true; break; } switch (icon) { case MyMessageBoxIcon.Information: messageIcon.Image = Win32Window.IconToAlphaBitmap(SystemIcons.Information); break; case MyMessageBoxIcon.Question: messageIcon.Image = Win32Window.IconToAlphaBitmap(SystemIcons.Question); break; case MyMessageBoxIcon.Error: messageIcon.Image = Win32Window.IconToAlphaBitmap(SystemIcons.Error); break; case MyMessageBoxIcon.Warning: messageIcon.Image = Win32Window.IconToAlphaBitmap(SystemIcons.Warning); break; } this.defaultButton = defaultButton; }
public MyMessageBox(string message, string caption, string details, MyMessageBoxButtons buttons, MyMessageBoxIcon icon) : this(message, caption, details, buttons, icon, MyMessageBoxDefaultButton.Button1) { }
/// <summary> /// Constructs a MyMessageBox object. /// </summary> /// <param name="message">The message to display.</param> /// <param name="caption">The string displayed in the title bar.</param> /// <param name="details">The string displayed in the details view.</param> /// <param name="buttons">The buttons to display on the dialog.</param> /// <param name="icon">The icon to display on the dialog.</param> /// <param name="defaultButton">The default button.</param> public MyMessageBox(string message, string caption, string details, MyMessageBoxButtons buttons, MyMessageBoxIcon icon, MyMessageBoxDefaultButton defaultButton) : this() { this.message.Text = message; this.Text = caption; detailsBox.Text = details.Replace("\n", "\r\n"); this.details.Visible = !details.Equals(string.Empty); switch (buttons) { case MyMessageBoxButtons.OK: ok.Visible = true; break; case MyMessageBoxButtons.OKCancel: ok.Visible = cancel.Visible = true; break; case MyMessageBoxButtons.YesNo: yes.Visible = no.Visible = true; break; } switch (icon) { case MyMessageBoxIcon.Information: messageIcon.Image = Win32Window.IconToAlphaBitmap(SystemIcons.Information); break; case MyMessageBoxIcon.Question: messageIcon.Image = Win32Window.IconToAlphaBitmap(SystemIcons.Question); break; case MyMessageBoxIcon.Error: messageIcon.Image = Win32Window.IconToAlphaBitmap(SystemIcons.Error); break; case MyMessageBoxIcon.Warning: messageIcon.Image = Win32Window.IconToAlphaBitmap(SystemIcons.Warning); break; } this.defaultButton = defaultButton; }
/// <summary> /// Constructs a MyMessageBox object. /// </summary> /// <param name="message">The message to display.</param> /// <param name="caption">The string displayed in the title bar.</param> /// <param name="details">The string displayed in the details view.</param> /// <param name="buttons">The buttons to display on the dialog.</param> /// <param name="icon">The icon to display on the dialog.</param> public MyMessageBox(string message, string caption, string details, MyMessageBoxButtons buttons, MyMessageBoxIcon icon) : this(message, caption, details, buttons, icon, MyMessageBoxDefaultButton.Button1) { }