Exemplo n.º 1
0
        protected QMessageBox(string Text, string Title, QMessageBoxButtons Buttons, QMessageBoxIcon Icon, QMessageBoxButton DefaultButton) : base(Title, (Buttons == QMessageBoxButtons.OK) ? ButtonCreateType.OKOnly : ButtonCreateType.OKAndCancel)
        {
            this.SPACING = 8;

            this.ClientSize = new Size(400, 300);

            icon = Icon;

            int textWidth = TextRenderer.MeasureText(Text, Styles.Font).Width;
            int iconWidth = (icon == QMessageBoxIcon.None) ? 0 : getIcon().Width + 5;

            int width;

            int baseWidth = textWidth + iconWidth;

            if (baseWidth < 300)
                width = Math.Max(150, baseWidth + 50);
            else if (baseWidth > 400)
                width = 400 + SPACING + iconWidth;
            else
                width = 350;

            lblMain = new QLabel(Text);
            this.Controls.Add(lblMain);
            lblMain.Location = new Point(SPACING + iconWidth, SPACING);
            lblMain.SetWidth(width - lblMain.Left - 2 * SPACING);

            iconTop = Math.Max(lblMain.Top, lblMain.Top + lblMain.Height / 2 - getIcon().Height);

            qmbButtons = Buttons;

            switch (qmbButtons)
            {
                case QMessageBoxButtons.OK:
                    btn1 = btnOK;
                    break;
                case QMessageBoxButtons.OKCancel:
                    btn1 = btnCancel;
                    btn2 = btnOK;
                    break;
                case QMessageBoxButtons.YesNo:
                    btn1 = btnCancel;
                    btn1.Text = Localization.NO;
                    btn2 = btnOK;
                    btn2.Text = Localization.YES;
                    break;
            }
            PlaceButtons(width, lblMain.Bottom + SPACING);
            this.ClientSize = new Size(width, btn1.Bottom + SPACING);

            Lib.DoEvents();
            Lib.Beep();

            defaultButton = DefaultButton;

            Clock.DoOnMainThread(doFocus);
        }
Exemplo n.º 2
0
 public static DialogResult Show(IWin32Window Owner, string Text, string Title, QMessageBoxButtons Buttons, QMessageBoxIcon Icon, QMessageBoxButton DefaultButton)
 {
     QMessageBox box = new QMessageBox(Text, Title, Buttons, Icon, DefaultButton);
     box.ShowDialog(Owner);
     return box.DialogResult;
 }
Exemplo n.º 3
0
        public QCheckedMessageBox(IWin32Window Owner, string Text, string Title, QMessageBoxButtons Buttons, QMessageBoxIcon Icon, QMessageBoxButton DefaultButton, string CheckboxText, bool Checked)
            : base(Text, Title, Buttons, Icon, DefaultButton)
        {
            chkCheckbox          = new QCheckBox(CheckboxText, this.BackColor);
            chkCheckbox.Location = new Point(MARGIN, btnOK.Bottom + SPACING);
            chkCheckbox.Checked  = Checked;
            this.Controls.Add(chkCheckbox);
            this.ClientSize = new Size(Math.Max(this.ClientRectangle.Width, chkCheckbox.Right + MARGIN), chkCheckbox.Bottom + MARGIN);

            this.ShowDialog(Owner);
        }