/// <summary>
        /// When the user provides the content of message and the message title and also which type message and buttons to appear.
        /// </summary>
        /// <param name="form">The Form that messagebox will be showed from.</param>
        /// <param name="content">The Content of the message.</param>
        /// <param name="caption">The MesageBox title.</param>
        /// <param name="buttons">The Type of buttons to appear.</param>
        /// <param name="icon">The MessageBox type.</param>
        /// <returns>The MessageBox with the content and title and provided button(s) and type.</returns>
        public static DialogResult Show(MetroSetForm form, string content, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
        {
            MetroSetMessageBox msgBox = new MetroSetMessageBox();

            /*MetroSetMessageBox msgBox = new MetroSetMessageBox
             * {
             *  OwnerForm = form ?? throw new ArgumentNullException("MetroSetMessageBox requires a form, use 'this' as the first parameter in the place you use MetroSetMessageBox."),
             *  Content = content,
             *  Caption = caption,
             *  Buttons = buttons,
             *  Size = new Size(form.Width - 2, (form.Height / 3) - 1),
             *  Location = new Point(form.Location.X, (form.Height / 2) - 1)
             * };
             *
             * if (icon == MessageBoxIcon.Error || icon == MessageBoxIcon.Stop)
             * {
             *  BackgroundColor = Color.FromArgb(210, 50, 45);
             *  BorderColor = Color.FromArgb(210, 50, 45);
             *  ForegroundColor = Color.Black;
             * }
             *
             * else if (icon == MessageBoxIcon.Information)
             * {
             *  BackgroundColor = Color.FromArgb(60, 180, 218);
             *  BorderColor = Color.FromArgb(60, 180, 218);
             *  ForegroundColor = Color.White;
             * }
             *
             * else if (icon == MessageBoxIcon.Question)
             * {
             *  BackgroundColor = Color.FromArgb(70, 165, 70);
             *  BorderColor = Color.FromArgb(70, 165, 70);
             *  ForegroundColor = Color.Black;
             * }
             *
             * else if (icon == MessageBoxIcon.Exclamation || icon == MessageBoxIcon.Warning)
             * {
             *  BackgroundColor = Color.FromArgb(237, 156, 40);
             *  BorderColor = Color.FromArgb(237, 156, 40);
             *  ForegroundColor = Color.Black;
             * }
             *
             * else if (icon == MessageBoxIcon.None || icon == MessageBoxIcon.Asterisk || icon == MessageBoxIcon.Hand)
             * {
             *  BackgroundColor = Color.White;
             *  BorderColor = Color.FromArgb(65, 177, 225);
             *  ForegroundColor = Color.Black;
             * }*/

            return(msgBox.ShowDialog());
        }
        /// <summary>
        /// When the user provides the content of message and the message title and also which type message and buttons to appear.
        /// </summary>
        /// <param name="form">The Form that messagebox will be showed from.</param>
        /// <param name="content">The Content of the message.</param>
        /// <param name="caption">The MesageBox title.</param>
        /// <param name="buttons">The Type of buttons to appear.</param>
        /// <param name="icon">The MessageBox type.</param>
        /// <returns>The MessageBox with the content and title and provided button(s) and type.</returns>
        public static DialogResult Show(MetroSetForm form, string content, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
        {
            const string message = @"MetroSetMessageBox requires a form, use 'this' as the first parameter in the place you use MetroSetMessageBox.";
            var          msgBox  = new MetroSetMessageBox
            {
                OwnerForm = form ?? throw new ArgumentNullException(message),
                                  Content  = content,
                                  Caption  = caption,
                                  Buttons  = buttons,
                                  Size     = new Size(form.Width - 2, (form.Height / 3) - 1),
                                  Location = new Point(form.Location.X, (form.Height / 2) - 1)
            };

            if (icon == MessageBoxIcon.Error || icon == MessageBoxIcon.Stop)
            {
                BackgroundColor = Color.FromArgb(210, 50, 45);
                BorderColor     = Color.FromArgb(210, 50, 45);
                ForegroundColor = Color.White;
            }

            else if (icon == MessageBoxIcon.Information)
            {
                BackgroundColor = Color.FromArgb(60, 180, 218);
                BorderColor     = Color.FromArgb(60, 180, 218);
                ForegroundColor = Color.White;
            }

            else if (icon == MessageBoxIcon.Question)
            {
                BackgroundColor = Color.FromArgb(70, 165, 70);
                BorderColor     = Color.FromArgb(70, 165, 70);
                ForegroundColor = Color.White;
            }

            else if (icon == MessageBoxIcon.Exclamation || icon == MessageBoxIcon.Warning)
            {
                BackgroundColor = Color.FromArgb(237, 156, 40);
                BorderColor     = Color.FromArgb(237, 156, 40);
                ForegroundColor = Color.White;
            }

            else if (icon == MessageBoxIcon.None || icon == MessageBoxIcon.Asterisk || icon == MessageBoxIcon.Hand)
            {
                BackgroundColor = Color.White;
                BorderColor     = Color.FromArgb(65, 177, 225);
                ForegroundColor = Color.Black;
            }

            return(msgBox.ShowDialog());
        }
Beispiel #3
0
 /// <summary>
 /// When the user provides the content of message and the message title and also which type of buttons to appear.
 /// </summary>
 /// <param name="form">The Form that messagebox will be showed from.</param>
 /// <param name="content">The Content of the message.</param>
 /// <param name="caption">The MesageBox title.</param>
 /// <param name="buttons">The Type of buttons to appear.</param>
 /// <returns>The MessageBox with the content and title and provided button(s) type.</returns>
 public static DialogResult Show(MetroSetForm form, string content, string caption, MessageBoxButtons buttons)
 {
     return(Show(form, content, caption, buttons, MessageBoxIcon.None));
 }
Beispiel #4
0
 /// <summary>
 /// When the user just provides the content of message to appear.
 /// </summary>
 /// <param name="form">The Form that messagebox will be showed from.</param>
 /// <param name="content">The Content of the message.</param>
 /// <returns>The MessageBox with just the content and an ok button.</returns>
 public static DialogResult Show(MetroSetForm form, string content)
 {
     return(Show(form, content, form.Text, MessageBoxButtons.OK, MessageBoxIcon.None));
 }