コード例 #1
0
        private MsgBox(string title, string description, MsgBoxReason buttons) : this(description, buttons)
        {
            lblTitle.Text = title;

            //Reposition the text label so that the title label wont overlap
            while (lblTitle.Location.Y + lblTitle.Height >= lblText.Location.Y)
            {
                lblText.Location = new Point(lblText.Location.X, lblText.Location.Y + 20);
            }

            //Resize the form so that the entire text shows
            while (pnlMainGradient.Height < (lblText.Location.Y + lblText.Height))
            {
                this.Height += 35;
            }
        }
コード例 #2
0
        private MsgBox(string description, MsgBoxReason buttons)
        {
            InitializeComponent();

            if (buttons == MsgBoxReason.YesNo)
            {
                btnYes.Visible = true;
                btnNo.Visible  = true;
            }
            else
            {
                btnOk.Visible = true;
            }


            this.description = description;

            this.Opacity = 0;
            tmrFadeIn.Start();
            lblText.MaximumSize  = new Size((pnlMainGradient.Width - lblText.Location.X) - 10, 0);
            lblTitle.MaximumSize = new Size((pnlMainGradient.Width - lblTitle.Location.X) - 10, 0);


            lblText.Text = description;



            //Resize the form so that the entire text shows
            while (pnlMainGradient.Height < (lblText.Location.Y + lblText.Height))
            {
                this.Height += 35;
            }


            Form1 mainForm = (Form1)Application.OpenForms["Form1"];

            if (mainForm != null)
            {
                //Place the message box in the middle of the main form
                this.StartPosition = FormStartPosition.Manual;
                this.Location      = new Point(mainForm.Location.X + ((mainForm.Width / 2) - this.Width / 2), mainForm.Location.Y + ((mainForm.Height / 2) - (this.Height / 2)));
            }
            else
            {
                this.StartPosition = FormStartPosition.CenterScreen;
            }
        }
コード例 #3
0
 public static DialogResult Show(string text, string title, MsgBoxReason buttons)
 {
     newMessageBox = new MsgBox(text, title, buttons);
     newMessageBox.ShowDialog();
     return(result);
 }