示例#1
0
 ///#################################################################################
 /// <summary>
 /// 显示按钮选择对话框,可自定义图
 /// </summary>
 /// <param name="msg">要显示的文字</param>
 /// <param name="buttons">按钮种类</param>
 /// <param name="micon">图标种类</param>
 /// <returns>对话框返回值</returns>
 ///#################################################################################
 public static DialogResult Show(string msg, MessageBoxButtons buttons, PTMessageBoxIcon micon, bool bnewDialog)
 {
     if (bnewDialog)
     {
         frmMessage = new FrmMessageBox();
     }
     frmMessage.ShowMessageBox(msg, buttons, micon);
     return(frmMessage.ShowDialog());
 }
示例#2
0
        ///#################################################################################
        /// <summary>
        /// 文字、各种按钮、图形
        /// </summary>
        /// <param name="Message"></param>
        public void ShowMessageBox(string Text, MessageBoxButtons buttons, PTMessageBoxIcon icon)
        {
            //this.lbTitle.Text = "";
            this.Text             = "IP Space";
            this.lbNote.Text      = Text;
            this.lbNote.Left      = this.picNote.Left + picNote.Width + 10;
            this.lbNote.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.picNote.Visible  = true;
            switch (icon)
            {
            case PTMessageBoxIcon.Error:
            {
                this.picNote.Image = this.picError.Image;
                break;
            }

            case PTMessageBoxIcon.Question:
            {
                this.picNote.Image = this.picQuestion.Image;
                break;
            }

            case PTMessageBoxIcon.Right:
            {
                this.picNote.Image = this.picRight.Image;
                break;
            }

            case PTMessageBoxIcon.Warning:
            {
                this.picNote.Image = this.picInfo.Image;
                break;
            }
            }
            switch (buttons)
            {
            case MessageBoxButtons.OK:
            {
                this.btnYes.Visible    = false;
                this.btnNo.Visible     = false;
                this.btnCancel.Visible = false;
                this.btnOK.Visible     = true;
                this.btnOK.Left        = (this.Width - btnOK.Width) / 2;
                break;
            }

            case MessageBoxButtons.YesNo:
            {
                this.btnYes.Visible    = true;
                this.btnNo.Visible     = true;
                this.btnCancel.Visible = false;
                this.btnOK.Visible     = false;
                this.btnYes.Left       = this.Width / 2 - btnYes.Width - 20;
                this.btnNo.Left        = this.Width / 2 + 20;
                break;
            }

            case MessageBoxButtons.YesNoCancel:
            {
                this.btnYes.Visible    = true;
                this.btnNo.Visible     = true;
                this.btnCancel.Visible = true;
                this.btnOK.Visible     = false;
                this.btnNo.Left        = this.Width / 2 - btnNo.Width / 2;
                this.btnYes.Left       = this.btnNo.Left - btnYes.Width - 20;
                this.btnCancel.Left    = this.btnNo.Right + 20;
                break;
            }

            case MessageBoxButtons.OKCancel:
            {
                this.btnYes.Visible    = false;
                this.btnNo.Visible     = false;
                this.btnCancel.Visible = true;
                this.btnOK.Visible     = true;
                this.btnOK.Left        = this.Width / 2 - btnOK.Width - 20;
                this.btnCancel.Left    = this.Width / 2 + 20;
                break;
            }

            case MessageBoxButtons.RetryCancel:
            {
                this.btnRetry.Visible  = true;
                this.btnYes.Visible    = false;
                this.btnNo.Visible     = false;
                this.btnCancel.Visible = true;
                this.btnOK.Visible     = false;
                this.btnRetry.Left     = this.Width / 2 - btnRetry.Width - 20;
                this.btnCancel.Left    = this.Width / 2 + 20;
                break;
            }
            }
        }