public static PressedButton ShowDialog(Form owner, CmbBasicSettings settings,
                                               CmbCheckboxSettings checkboxSettings,
                                               CmbHyperlinkSettings hyperlinkSettings)
        {
            using (var dialog = new CustomMessageBox(settings, checkboxSettings)) //, hyperlinkSettings))
            {
                if (owner != null && !owner.IsDisposed && !owner.Disposing)
                {
                    if (owner.Visible)
                    {
                        dialog.Owner = owner;
                        owner.Select();
                        dialog.ShowDialog(owner);
                    }
                    else
                    {
                        dialog.CenterToForm(owner);
                        dialog.ShowDialog();
                    }
                }
                else
                {
                    dialog.StartPosition = FormStartPosition.CenterScreen;
                    dialog.ShowDialog();
                }

                if (dialog.Result != PressedButton.None && checkboxSettings != null)
                {
                    checkboxSettings.Result = dialog.Checked;
                }

                return(dialog.Result);
            }
        }
        public static CustomMessageBox Show(Form owner, CmbBasicSettings settings, CmbCheckboxSettings checkboxSettings)
        {
            if (owner.IsDisposed || owner.Disposing || !owner.Visible)
            {
                owner = null;
            }

            var dialog = new CustomMessageBox(settings, checkboxSettings)
            {
                Owner = owner
            };                                                                               //, hyperlinkSettings))

            dialog.Show(owner);

            if (dialog.Result != PressedButton.None && checkboxSettings != null)
            {
                checkboxSettings.Result = dialog.Checked;
            }

            return(dialog);
        }
 public static PressedButton ShowDialog(Form owner, CmbBasicSettings settings,
                                        CmbCheckboxSettings checkboxSettings)
 {
     return(ShowDialog(owner, settings, checkboxSettings, null));
 }
        private CustomMessageBox(CmbBasicSettings settings, CmbCheckboxSettings checkboxSettings)
        {
            Opacity = 0;

            Result    = PressedButton.None;
            Font      = SystemFonts.MessageBoxFont;
            ForeColor = SystemColors.WindowText;

            InitializeComponent();

            StartPosition = settings.StartPosition;

            if (checkboxSettings != null)
            {
                _checkboxSettings = checkboxSettings;

                if (checkboxSettings.Text.IsNotEmpty())
                {
                    checkBox1.Text = checkboxSettings.Text;
                }
                checkBox1.Checked = checkboxSettings.InitialState;
                checkBox1.Visible = true;
            }
            else
            {
                checkBox1.Visible = false;
            }

            if (!string.IsNullOrEmpty(settings.SmallExplanation))
            {
                if (SystemFonts.MessageBoxFont.FontFamily.Name == "Segoe UI" &&
                    SystemFonts.MessageBoxFont.FontFamily.IsStyleAvailable(FontStyle.Regular))
                {
                    // use the special, windows-vista font style if we are running vista (using Segoe UI).
                    label1.ForeColor = Color.FromArgb(0, 51, 153); // [ColorTranslator.FromHtml("#003399")]
                    label1.Font      = new Font("Segoe UI", 12.0f, FontStyle.Regular, GraphicsUnit.Point);
                }
                else
                {
                    // might want to special case the old, MS Sans Serif font.
                    // use the regular font but bold it for XP, etc.
                    label1.Font = new Font(SystemFonts.MessageBoxFont.FontFamily.Name, 8.0f,
                                           FontStyle.Bold, GraphicsUnit.Point);
                }
            }

            Text        = settings.Title;
            label1.Text = settings.LargeHeading;
            label2.Text = string.IsNullOrEmpty(settings.SmallExplanation) ? string.Empty : settings.SmallExplanation;

            if (!string.IsNullOrEmpty(settings.LeftButton))
            {
                // if we have the button, we are fine
                buttonLeft.Text = settings.LeftButton;
            }
            else
            {
                // move settings to right button if we don't have the left button
                AcceptButton       = buttonMiddle;
                buttonLeft.Visible = false;
                panelLeft.Visible  = false;
            }

            if (!string.IsNullOrEmpty(settings.MiddleButton))
            {
                // if we have the button, we are fine
                buttonMiddle.Text = settings.MiddleButton;
            }
            else
            {
                // move settings to right button if we don't have the left button
                AcceptButton         = buttonRight;
                buttonMiddle.Visible = false;
                panelMiddle.Visible  = false;
            }

            // this button must always be present
            buttonRight.Text = settings.RightButton;

            if (settings.IconSet != null)
            {
                pictureBox1.Image = settings.IconSet.ToBitmap();
                settings.IconSet.PlayCorrespondingSystemSound();
            }

            TopMost = settings.AlwaysOnTop;

            _overrideIcon = settings.WindowIcon;
        }