Наследование: System.Windows.Forms.Form
Пример #1
0
        private void okButton_Click(object sender, EventArgs e)
        {
            string message;

            if (this.m_validation != null && !this.m_validation(this.promptTextBox.Text, out message))
            {
                LocalizedMessageBox.Show(this, message, "", Localizer.Localize("Generic", "GENERIC_OK"), null, null, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
                base.DialogResult = DialogResult.None;
                return;
            }
            base.DialogResult = DialogResult.OK;
        }
Пример #2
0
        private static LocalizedMessageBox CreateMessageBox(string message, string title, string acceptText, string declineText, string cancelText, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
        {
            LocalizedMessageBox localizedMessageBox = new LocalizedMessageBox();

            localizedMessageBox.Text = title;
            localizedMessageBox.m_labelMessage.Text     = message;
            localizedMessageBox.m_buttonAccept.Visible  = (acceptText != null);
            localizedMessageBox.m_buttonAccept.Text     = acceptText;
            localizedMessageBox.m_buttonDecline.Visible = (declineText != null);
            localizedMessageBox.m_buttonDecline.Text    = declineText;
            localizedMessageBox.m_buttonCancel.Visible  = (cancelText != null);
            localizedMessageBox.m_buttonCancel.Text     = cancelText;
            localizedMessageBox.AcceptButton            = localizedMessageBox.m_buttonAccept;
            if (icon <= MessageBoxIcon.Hand)
            {
                if (icon != MessageBoxIcon.None)
                {
                    if (icon == MessageBoxIcon.Hand)
                    {
                        localizedMessageBox.m_labelIcon.Image = SystemIcons.Error.ToBitmap();
                    }
                }
                else
                {
                    localizedMessageBox.m_labelIcon.Image = null;
                }
            }
            else
            {
                if (icon != MessageBoxIcon.Question)
                {
                    if (icon != MessageBoxIcon.Exclamation)
                    {
                        if (icon == MessageBoxIcon.Asterisk)
                        {
                            localizedMessageBox.m_labelIcon.Image = SystemIcons.Information.ToBitmap();
                        }
                    }
                    else
                    {
                        localizedMessageBox.m_labelIcon.Image = SystemIcons.Warning.ToBitmap();
                    }
                }
                else
                {
                    localizedMessageBox.m_labelIcon.Image = SystemIcons.Question.ToBitmap();
                }
            }
            if (defaultButton != MessageBoxDefaultButton.Button1)
            {
                if (defaultButton != MessageBoxDefaultButton.Button2)
                {
                    if (defaultButton == MessageBoxDefaultButton.Button3)
                    {
                        localizedMessageBox.m_buttonAccept.TabIndex  = 1;
                        localizedMessageBox.m_buttonDecline.TabIndex = 2;
                        localizedMessageBox.m_buttonCancel.TabIndex  = 0;
                    }
                }
                else
                {
                    localizedMessageBox.m_buttonAccept.TabIndex  = 2;
                    localizedMessageBox.m_buttonDecline.TabIndex = 0;
                    localizedMessageBox.m_buttonCancel.TabIndex  = 1;
                }
            }
            localizedMessageBox.StartPosition = FormStartPosition.CenterParent;
            return(localizedMessageBox);
        }
Пример #3
0
 private static LocalizedMessageBox CreateMessageBox(string message, string title, string acceptText, string declineText, string cancelText, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
 {
     LocalizedMessageBox localizedMessageBox = new LocalizedMessageBox();
     localizedMessageBox.Text = title;
     localizedMessageBox.m_labelMessage.Text = message;
     localizedMessageBox.m_buttonAccept.Visible = (acceptText != null);
     localizedMessageBox.m_buttonAccept.Text = acceptText;
     localizedMessageBox.m_buttonDecline.Visible = (declineText != null);
     localizedMessageBox.m_buttonDecline.Text = declineText;
     localizedMessageBox.m_buttonCancel.Visible = (cancelText != null);
     localizedMessageBox.m_buttonCancel.Text = cancelText;
     localizedMessageBox.AcceptButton = localizedMessageBox.m_buttonAccept;
     if (icon <= MessageBoxIcon.Hand)
     {
         if (icon != MessageBoxIcon.None)
         {
             if (icon == MessageBoxIcon.Hand)
             {
                 localizedMessageBox.m_labelIcon.Image = SystemIcons.Error.ToBitmap();
             }
         }
         else
         {
             localizedMessageBox.m_labelIcon.Image = null;
         }
     }
     else
     {
         if (icon != MessageBoxIcon.Question)
         {
             if (icon != MessageBoxIcon.Exclamation)
             {
                 if (icon == MessageBoxIcon.Asterisk)
                 {
                     localizedMessageBox.m_labelIcon.Image = SystemIcons.Information.ToBitmap();
                 }
             }
             else
             {
                 localizedMessageBox.m_labelIcon.Image = SystemIcons.Warning.ToBitmap();
             }
         }
         else
         {
             localizedMessageBox.m_labelIcon.Image = SystemIcons.Question.ToBitmap();
         }
     }
     if (defaultButton != MessageBoxDefaultButton.Button1)
     {
         if (defaultButton != MessageBoxDefaultButton.Button2)
         {
             if (defaultButton == MessageBoxDefaultButton.Button3)
             {
                 localizedMessageBox.m_buttonAccept.TabIndex = 1;
                 localizedMessageBox.m_buttonDecline.TabIndex = 2;
                 localizedMessageBox.m_buttonCancel.TabIndex = 0;
             }
         }
         else
         {
             localizedMessageBox.m_buttonAccept.TabIndex = 2;
             localizedMessageBox.m_buttonDecline.TabIndex = 0;
             localizedMessageBox.m_buttonCancel.TabIndex = 1;
         }
     }
     localizedMessageBox.StartPosition = FormStartPosition.CenterParent;
     return localizedMessageBox;
 }
Пример #4
0
        public static DialogResult Show(IWin32Window owner, string message, string title, string acceptText, string declineText = null, string cancelText = null, MessageBoxIcon icon = MessageBoxIcon.None, MessageBoxDefaultButton defaultButton = MessageBoxDefaultButton.Button1)
        {
            LocalizedMessageBox localizedMessageBox = LocalizedMessageBox.CreateMessageBox(message, title, acceptText, declineText, cancelText, icon, defaultButton);

            return(localizedMessageBox.ShowDialog(owner));
        }