Пример #1
0
        private static Size MessageSize(string message, MessageBoxBlack _msgBox)
        {
            Graphics g      = _msgBox.CreateGraphics();
            int      width  = 450;
            int      height = 230;
            SizeF    size   = g.MeasureString(message, new System.Drawing.Font("Tahoma", 10));

            if (message.Length < 40)
            {
                if ((int)size.Width > 350)
                {
                    width = (int)size.Width;
                }
            }
            else if (message.Length < 100 && message.Length > 40)
            {
                string[] groups = (from Match m in Regex.Matches(message, ".{1,180}") select m.Value).ToArray();
                int      lines  = groups.Length + 1;
                width   = 560;
                height += (int)(size.Height + 5) * lines;
            }
            else
            {
                string[] groups = (from Match m in Regex.Matches(message, ".{1,180}") select m.Value).ToArray();
                int      lines  = groups.Length + 1;
                width   = 880;
                height += (int)(size.Height + 10) * lines;
            }
            return(new Size(width, height));
        }
Пример #2
0
        private static void InitIcon(MessageBoxBlack _msgBox, Icone icon)
        {
            switch (icon)
            {
            case Icone.Application:
                _msgBox.picIcon.Image = SystemIcons.Application.ToBitmap();
                break;

            case Icone.Exclamation:
                _msgBox.picIcon.Image = SystemIcons.Exclamation.ToBitmap();
                break;

            case Icone.Error:
                _msgBox.picIcon.Image = SystemIcons.Error.ToBitmap();
                break;

            case Icone.Info:
                _msgBox.picIcon.Image = SystemIcons.Information.ToBitmap();
                break;

            case Icone.Question:
                _msgBox.picIcon.Image = SystemIcons.Question.ToBitmap();
                break;

            case Icone.Shield:
                _msgBox.picIcon.Image = SystemIcons.Shield.ToBitmap();
                break;

            case Icone.Warning:
                _msgBox.picIcon.Image = SystemIcons.Warning.ToBitmap();
                break;
            }
        }
Пример #3
0
        public static DialogResult Show(string message, string title, Buttons buttons, Icone icon, AnimateStyle style)
        {
            MessageBoxBlack _msgBox = createMsgBox(message, title, buttons, icon, style);

            _msgBox.ShowDialog();

            return(_msgBox._buttonResult);
        }
Пример #4
0
        public static void Show(string message)
        {
            MessageBoxBlack _msgBox = createMsgBox(message, "Mensagem", Buttons.OK, Icone.Info, AnimateStyle.FadeIn);

            _msgBox.ShowDialog();

            MessageBeep(0);
        }
Пример #5
0
        public static void Advertencia(string message, string title = null)
        {
            MessageBoxBlack _msgBox = createMsgBox(message, title, Buttons.OK, Icone.Exclamation, AnimateStyle.FadeIn);

            _msgBox.ShowDialog();

            MessageBeep(0);
        }
Пример #6
0
        public static void Show(string message, string title)
        {
            MessageBoxBlack _msgBox = createMsgBox(message, title, Buttons.OK, Icone.Info, AnimateStyle.FadeIn);

            _msgBox.ShowDialog();

            MessageBeep(0);

            //_msgBox = new MessageBoxBlack();
            //_msgBox.lblMessage.Text = message;
            //_msgBox.lblTitle.Text = title;
            //_msgBox.Size = MessageBoxBlack.MessageSize(message);
            //_msgBox.ShowDialog();
        }
Пример #7
0
        private static MessageBoxBlack createMsgBox(string message, string title,
                                                    Buttons buttons, Icone icon, AnimateStyle style)
        {
            var _msgBox = new MessageBoxBlack();

            _msgBox.lblMessage.Text = message;
            _msgBox.lblTitle.Text   = title;
            _msgBox.Height          = 0;

            if (title == null)
            {
                title = "Mensagem";
            }

            MessageBoxBlack.InitButtons(_msgBox, buttons);
            MessageBoxBlack.InitIcon(_msgBox, icon);

            _msgBox._timer = new Timer();
            Size formSize = MessageBoxBlack.MessageSize(message, _msgBox);

            switch (style)
            {
            case AnimateStyle.SlideDown:
                _msgBox.Size            = new Size(formSize.Width, 0);
                _msgBox._timer.Interval = 1;
                _msgBox._timer.Tag      = new AnimateMsgBox(formSize, style);
                break;

            case AnimateStyle.FadeIn:
                _msgBox.Size            = formSize;
                _msgBox.Opacity         = 0;
                _msgBox._timer.Interval = 20;
                _msgBox._timer.Tag      = new AnimateMsgBox(formSize, style);
                break;

            case AnimateStyle.ZoomIn:
                _msgBox.Size            = new Size(formSize.Width + 100, formSize.Height + 100);
                _msgBox._timer.Tag      = new AnimateMsgBox(formSize, style);
                _msgBox._timer.Interval = 1;
                break;
            }

            _msgBox._timer.Tick += _msgBox.timer_Tick;
            _msgBox._timer.Start();
            return(_msgBox);
        }
Пример #8
0
        private static void InitButtons(MessageBoxBlack _msgBox, Buttons buttons)
        {
            switch (buttons)
            {
            case Buttons.AbortRetryIgnore:
                _msgBox.InitAbortRetryIgnoreButtons();
                break;

            case Buttons.OK:
                _msgBox.InitOKButton();
                break;

            case Buttons.OKCancel:
                _msgBox.InitOKCancelButtons();
                break;

            case Buttons.RetryCancel:
                _msgBox.InitRetryCancelButtons();
                break;

            case Buttons.YesNo:
                _msgBox.InitYesNoButtons();
                break;

            case Buttons.YesNoCancel:
                _msgBox.InitYesNoCancelButtons();
                break;
            }

            foreach (Button btn in _msgBox._buttonCollection)
            {
                btn.ForeColor = Color.FromArgb(170, 170, 170);
                btn.Font      = new System.Drawing.Font("Tahoma", 8);
                btn.Padding   = new Padding(3);
                btn.FlatStyle = FlatStyle.Flat;
                btn.Height    = 35;
                btn.Width     = 90;
                btn.FlatAppearance.BorderColor = Color.FromArgb(99, 99, 98);

                _msgBox.flpButtons.Controls.Add(btn);
            }
        }
Пример #9
0
        public static DialogResult Show(string message, string title, Buttons buttons, Icone icon)
        {
            MessageBoxBlack _msgBox = createMsgBox(message, title, buttons, icon, AnimateStyle.FadeIn);

            _msgBox.ShowDialog();

            //_msgBox = new MessageBoxBlack();
            //_msgBox.lblMessage.Text = message;
            //_msgBox.lblTitle.Text = title;

            //MessageBoxBlack.InitButtons(buttons);
            //MessageBoxBlack.InitIcon(icon);

            //_msgBox.Size = MessageBoxBlack.MessageSize(message);
            //_msgBox.ShowDialog();

            MessageBeep(0);

            return(_msgBox._buttonResult);
        }