Example #1
0
 private static void ModalState(MetroMessageBoxControl control)
 {
     do
     {
         ;
     }while (control.Visible);
 }
Example #2
0
        public static DialogResult Show(
            IWin32Window owner,
            string message,
            string title,
            MessageBoxButtons buttons,
            MessageBoxIcon icon,
            MessageBoxDefaultButton defaultbutton,
            int height)
        {
            DialogResult dialogResult = DialogResult.None;

            if (owner != null)
            {
                Form form = !(owner is Form) ? ((ContainerControl)owner).ParentForm : (Form)owner;
                switch (icon)
                {
                case MessageBoxIcon.Hand:
                    SystemSounds.Hand.Play();
                    break;

                case MessageBoxIcon.Question:
                    SystemSounds.Beep.Play();
                    break;

                case MessageBoxIcon.Exclamation:
                    SystemSounds.Exclamation.Play();
                    break;

                default:
                    SystemSounds.Asterisk.Play();
                    break;
                }

                MetroMessageBoxControl messageBoxControl = new MetroMessageBoxControl();
                messageBoxControl.BackColor                = form.BackColor;
                messageBoxControl.Properties.Buttons       = buttons;
                messageBoxControl.Properties.DefaultButton = defaultbutton;
                messageBoxControl.Properties.Icon          = icon;
                messageBoxControl.Properties.Message       = message;
                messageBoxControl.Properties.Title         = title;
                messageBoxControl.Padding       = new Padding(0, 0, 0, 0);
                messageBoxControl.ControlBox    = false;
                messageBoxControl.ShowInTaskbar = false;
                messageBoxControl.TopMost       = true;
                messageBoxControl.Size          = new Size(form.Size.Width, height);
                messageBoxControl.Location      = new Point(form.Location.X,
                                                            form.Location.Y + (form.Height - messageBoxControl.Height) / 2);
                messageBoxControl.ArrangeApperance();
                Convert.ToInt32(Math.Floor(messageBoxControl.Size.Height * 0.28));
                int num = (int)messageBoxControl.ShowDialog();
                messageBoxControl.BringToFront();
                messageBoxControl.SetDefaultButton();
                Action <MetroMessageBoxControl> action = ModalState;
                IAsyncResult asyncResult = action.BeginInvoke(messageBoxControl, null, action);
                bool         flag        = false;
                try
                {
                    while (!asyncResult.IsCompleted)
                    {
                        Thread.Sleep(1);
                        Application.DoEvents();
                    }
                }
                catch
                {
                    flag = true;
                    if (!asyncResult.IsCompleted)
                    {
                        try
                        {
                        }
                        catch
                        {
                        }
                    }
                }

                if (!flag)
                {
                    dialogResult = messageBoxControl.Result;
                    messageBoxControl.Dispose();
                }
            }

            return(dialogResult);
        }
Example #3
0
 public MetroMessageBoxProperties(MetroMessageBoxControl owner) => Owner = owner;