Beispiel #1
0
        public PromptModel(string message, string title, PromptMessageButtons buttons)
        {
            if (string.IsNullOrEmpty(title))
            {
                title = "Prompt";
            }

            if (string.IsNullOrEmpty(message))
            {
                throw new ArgumentNullException("Message parameter must be provided!");
            }

            this.Title      = title;
            this.Message    = message;
            this.ButtonType = buttons;
        }
Beispiel #2
0
        /// <summary>
        /// Animates this prompt in with the specified options
        /// </summary>
        public DialogResult Show(string message, string title, PromptMessageButtons buttons)
        {
            this.ParentControl.BringToFront();
            this.Title.Text   = title;
            this.Message.Text = message;

            switch (buttons)
            {
            case PromptMessageButtons.Ok:
                this.Btn2.Text      = DialogResult.OK.ToString();
                this.Btn2.Visible   = true;
                this.Btn2.BackColor = DialogButtonStyles.PositiveBackColor;

                this.Btn1.Visible = false;
                this.Btn3.Visible = false;
                break;

            case PromptMessageButtons.OkCancel:
                this.Btn1.Text      = DialogResult.OK.ToString();
                this.Btn1.Visible   = true;
                this.Btn1.BackColor = DialogButtonStyles.PositiveBackColor;

                this.Btn3.Text      = DialogResult.Cancel.ToString();
                this.Btn3.Visible   = true;
                this.Btn3.BackColor = DialogButtonStyles.NeutralBackColor;

                this.Btn2.Visible = false;
                break;

            case PromptMessageButtons.YesNoCancel:
                this.Btn1.Text      = DialogResult.Yes.ToString();
                this.Btn1.Visible   = true;
                this.Btn1.BackColor = DialogButtonStyles.PositiveBackColor;

                this.Btn2.Text      = DialogResult.Cancel.ToString();
                this.Btn2.Visible   = true;
                this.Btn2.BackColor = DialogButtonStyles.NeutralBackColor;

                this.Btn3.Text      = DialogResult.No.ToString();
                this.Btn3.Visible   = true;
                this.Btn3.BackColor = DialogButtonStyles.NegativeBackColor;
                break;

            case PromptMessageButtons.YesNo:
                this.Btn1.Text      = DialogResult.Yes.ToString();
                this.Btn1.Visible   = true;
                this.Btn1.BackColor = DialogButtonStyles.PositiveBackColor;

                this.Btn3.Text      = DialogResult.No.ToString();
                this.Btn3.Visible   = true;
                this.Btn3.BackColor = DialogButtonStyles.NegativeBackColor;

                this.Btn2.Visible = false;
                break;

            default:
                break;
            }

            int _scale = 45;
            int _y     = this.PromptPanel.Location.Y - _scale;

            this.PromptPanel.Location = new Point(this.PromptPanel.Location.X, _y);

            // ensure the UI thread updates the UI components
            Action <double> invoker = new Action <double>((value) =>
            {
                this.PromptPanel.Location = new Point(this.PromptPanel.Location.X, _y + (int)(_scale * value));
            });

            DoubleAnimation doubleAnimation = new DoubleAnimation(0.0, 1.0, new QuadraticEaseFunction(EaseMode.EaseOut), 300, 120);

            doubleAnimation.TimelineTick += (o, a) =>
            {
                double _current = doubleAnimation.Current;
                this.BeginInvoke(invoker, _current);
            };

            doubleAnimation.Begin();
            this.AnimateOpacity(300, 0.0, 0.6);

            return(base.ShowDialog());
        }
Beispiel #3
0
 /// <summary>
 /// Animates this prompt in with the specified options
 /// </summary>
 public DialogResult Show(string message, PromptMessageButtons buttons)
 {
     return(this.Show(message, "", buttons));
 }