示例#1
0
        private void InputTextBox_Load(object sender, EventArgs e)
        {
            this.Text     = caption;
            lblTitle.Text = title;
            tbText.Text   = TextValue;

            if (buttons == null || buttons.Length == 0)
            {
                buttons         = new CustomMessageBoxButton[] { new CustomMessageBoxButton(CustomButtonResult.OK), new CustomMessageBoxButton(CustomButtonResult.Cancel) };
                defaultButtonNo = 1;
            }

            for (int i = 0; i < buttons.Length; i++)
            {
                AddMessageBoxButton(buttons[i], i > 0, i == defaultButtonNo - 1);
            }

            cbVerification.Visible = !string.IsNullOrEmpty(VerificationText);
            if (cbVerification.Visible)
            {
                cbVerification.Text = VerificationText;
            }

            int customWidth = 80 * bottomPanel.Controls.Cast <Control>().Count(w => w is Button) - 6 + 20 + (cbVerification.Visible ? cbVerification.Width + 10 : 0);

            if (this.ClientSize.Width < customWidth)
            {
                this.Width = customWidth + this.Width - this.ClientSize.Width;
            }

            CustomResult = CustomButtonResult.None;
        }
示例#2
0
 private void ButtonClick(object sender, EventArgs e)
 {
     if (isStandart)
     {
         this.DialogResult = (DialogResult)(sender as Button).Tag;
     }
     else
     {
         CustomResult = (CustomButtonResult)(sender as Button).Tag;
         Close();
     }
 }
示例#3
0
 private void ButtonClick(object sender, EventArgs e)
 {
     CustomResult = (CustomButtonResult)(sender as Button).Tag;
     Close();
 }
示例#4
0
        private void CustomMessageBox_Load(object sender, EventArgs e)
        {
            if (icon != null)
            {
                lblIcon.Image = icon;
            }

            this.Text        = caption;
            lblTitle.Visible = !string.IsNullOrEmpty(title);
            if (lblTitle.Visible)
            {
                lblTitle.Text = title;
            }
            lblContent.Text = text;

            if (buttons == null || buttons.Length == 0)
            {
                buttons = new CustomMessageBoxButton[] { new CustomMessageBoxButton(CustomButtonResult.OK) }
            }
            ;

            for (int i = 0; i < buttons.Length; i++)
            {
                AddMessageBoxButton(buttons[i], i > 0, i == defaultButtonNo - 1);
            }

            cbVerification.Visible = !string.IsNullOrEmpty(VerificationText);
            if (cbVerification.Visible)
            {
                cbVerification.Text = VerificationText;
            }


            lblTitle.Left = lblContent.Left = (icon != null) ? 48 : 10;

            int customHeight = lblContent.Height + (lblTitle.Visible ? lblTitle.Height + 10 : 0) + 20 + bottomPanel.Height;

            if (this.ClientSize.Height < customHeight)
            {
                this.Height = customHeight + this.Height - this.ClientSize.Height;
            }

            int customWidth = 80 * bottomPanel.Controls.Cast <Control>().Count(w => w is Button) - 6 + 20 + (cbVerification.Visible ? cbVerification.Width + 10 : 0);

            if (lblTitle.Visible)
            {
                if (customWidth < lblTitle.Left + lblTitle.Width + 10)
                {
                    customWidth = lblTitle.Left + lblTitle.Width + 10;
                }
            }
            if (customWidth < lblContent.Left + lblContent.Width + 10)
            {
                customWidth = lblContent.Left + lblContent.Width + 10;
            }

            if (this.ClientSize.Width < customWidth)
            {
                this.Width = customWidth + this.Width - this.ClientSize.Width;
            }

            int customPos = (mainPanel.Height - 20 - (lblTitle.Visible ? lblTitle.Height  : 0) - lblContent.Height) / 2;

            lblContent.Top = 10 + (lblTitle.Visible ? lblTitle.Height : 0) + customPos;

            if (icon != null)
            {
                lblIcon.Height = lblTitle.Visible ? lblTitle.Height + 30 : mainPanel.Height;
            }

            CustomResult = CustomButtonResult.None;
        }
示例#5
0
 public CustomMessageBoxButton(CustomButtonResult result, string text = null)
 {
     this.Result = result;
     this.Text   = !string.IsNullOrEmpty(text) ? text : result.ToString();
 }