Ejemplo n.º 1
0
        public MessageBoxViewModel(string message, MessageBoxButtons messageBoxButtons, MessageBoxIcons messageBoxIcons)
        {
            this.Message = message;

            this.IconKind = messageBoxIcons switch
            {
                MessageBoxIcons.Question => MaterialDesign::PackIconKind.HelpCircleOutline,
                MessageBoxIcons.Caution => MaterialDesign::PackIconKind.AlertOutline,
                _ => MaterialDesign::PackIconKind.AlertCircleOutline
            };

            this.IconColor = messageBoxIcons switch
            {
                MessageBoxIcons.Question => Utils.ConvertToBrush("#42a5f5"),
                MessageBoxIcons.Caution => Utils.ConvertToBrush("#ffa500"),
                _ => Utils.ConvertToBrush("#d4000"),
            };

            if (messageBoxButtons.HasFlag(MessageBoxButtons.Yes))
            {
                this.YesVisibility = Visibility.Visible;
            }
            else
            {
                this.YesVisibility = Visibility.Collapsed;
            }

            if (messageBoxButtons.HasFlag(MessageBoxButtons.No))
            {
                this.NoVisibility = Visibility.Visible;
            }
            else
            {
                this.NoVisibility = Visibility.Collapsed;
            }

            if (messageBoxButtons.HasFlag(MessageBoxButtons.OK))
            {
                this.OKVisibility = Visibility.Visible;
            }
            else
            {
                this.OKVisibility = Visibility.Collapsed;
            }

            if (messageBoxButtons.HasFlag(MessageBoxButtons.Cancel))
            {
                this.CancelVisibility = Visibility.Visible;
            }
            else
            {
                this.CancelVisibility = Visibility.Collapsed;
            }
        }
Ejemplo n.º 2
0
        protected virtual Command[] ToXwt(MessageBoxButtons buttons)
        {
            var result = new List <Command>();

            if (buttons.HasFlag(MessageBoxButtons.Ok))
            {
                result.Add(Ok);
            }
            if (buttons.HasFlag(MessageBoxButtons.Cancel))
            {
                result.Add(Cancel);
            }
            if (buttons.HasFlag(MessageBoxButtons.Yes))
            {
                result.Add(Yes);
            }
            if (buttons.HasFlag(MessageBoxButtons.No))
            {
                result.Add(No);
            }
            if (buttons.HasFlag(MessageBoxButtons.Abort))
            {
                result.Add(Abort);
            }
            if (buttons.HasFlag(MessageBoxButtons.Retry))
            {
                result.Add(Retry);
            }
            if (buttons.HasFlag(MessageBoxButtons.Ignore))
            {
                result.Add(Ignore);
            }

            return(result.ToArray());
        }
Ejemplo n.º 3
0
        public MessageBoxScreen(string title, string message, MessageBoxButtons buttons)
            : base(title)
        {
            Message      = new TextBlock(message);
            Message.Font = ScreenManager.Trebuchet24;
            StackPanel.Items.Insert(1, Message);

            _meYes.OnSelected    += meYes_OnSelected;
            _meNo.OnSelected     += meNo_OnSelected;
            _meCancel.OnSelected += meCancel_OnSelected;
            _meOk.OnSelected     += meOk_OnSelected;

            _meYes.Font    = ScreenManager.Trebuchet24;
            _meNo.Font     = ScreenManager.Trebuchet24;
            _meOk.Font     = ScreenManager.Trebuchet24;
            _meCancel.Font = ScreenManager.Trebuchet24;

            if (buttons.HasFlag(MessageBoxButtons.Yes))
            {
                MenuItems.AddItems(_meYes);
            }

            if (buttons.HasFlag(MessageBoxButtons.No))
            {
                MenuItems.AddItems(_meNo);
            }

            if (buttons.HasFlag(MessageBoxButtons.Ok))
            {
                MenuItems.AddItems(_meOk);
            }

            if (buttons.HasFlag(MessageBoxButtons.Cancel))
            {
                MenuItems.AddItems(_meCancel);
            }

            MenuPosition = Vector2.One * 0.5f -
                           0.5f * new Vector2(StackPanel.Width, StackPanel.Height) /
                           new Vector2(XnaDartsGame.Viewport.Width, XnaDartsGame.Viewport.Height);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="caption">The caption</param>
        /// <param name="description">The description</param>
        /// <param name="buttonSelection">The default button selection</param>
        public MessageBoxViewModel(string caption, string description, MessageBoxButtons buttonSelection = MessageBoxButtons.OK | MessageBoxButtons.Cancel)
            : base(typeof(MessageBoxViewModel))
        {
            _toggleButtons  = new List <MessageBoxButton>();
            _confirmButtons = new List <MessageBoxButton>();
            _optionButtons  = new List <MessageBoxButton>();

            ButtonClickedCommand = new RelayCommand((o) => ButtonClicked(o as MessageBoxButton), (o) => CanButtonBeClicked(o as MessageBoxButton));

            if (buttonSelection.HasFlag(MessageBoxButtons.OK))
            {
                ConfirmButtons.Add(new MessageBoxButton("OK"));
            }
            if (buttonSelection.HasFlag(MessageBoxButtons.Later))
            {
                ConfirmButtons.Add(new MessageBoxButton("Not now"));
            }
            if (buttonSelection.HasFlag(MessageBoxButtons.Cancel))
            {
                ConfirmButtons.Add(new MessageBoxButton("Cancel"));
            }

            if (ConfirmButtons.Any())
            {
                if (!ConfirmButtons.Any(button => button.IsDefault))
                {
                    ConfirmButtons.First().IsDefault = true;
                }
                if (!ConfirmButtons.Any(button => button.IsCancel))
                {
                    ConfirmButtons.Last().IsCancel = true;
                }
            }

            Caption     = caption;
            Description = description;
        }
Ejemplo n.º 5
0
        protected virtual void InitButtons(MessageBoxButtons buttons, ColorContexts colorContext)
        {
            DefaultButton btn = null;

            if (buttons.HasFlag(MessageBoxButtons.Continue))
            {
                btn        = new DefaultButton("continuebutton", "&Continue", colorContext, (char)0, true);
                btn.Click += (sender, eContinue) => OnContinue();
                ButtonContainer.AddChild(btn);
                btn.Focus();
            }

            if (buttons.HasFlag(MessageBoxButtons.Repeat))
            {
                btn        = new DefaultButton("repeatbutton", "&Repeat", colorContext, (char)0, true);
                btn.Click += (sender, eRepeat) => OnRepeat();
                ButtonContainer.AddChild(btn);
            }

            if (buttons.HasFlag(MessageBoxButtons.Yes))
            {
                btn        = new DefaultButton("yesbutton", "&Yes", colorContext, (char)0, true);
                btn.Click += (sender, eYes) => OnYes();
                ButtonContainer.AddChild(btn);
                btn.Focus();
            }

            if (buttons.HasFlag(MessageBoxButtons.No))
            {
                btn        = new DefaultButton("nobutton", "&No", colorContext, (char)0, true);
                btn.Click += (sender, eNo) => OnNo();
                ButtonContainer.AddChild(btn);
            }

            if (buttons.HasFlag(MessageBoxButtons.OK))
            {
                btn        = new DefaultButton("okbutton", "&OK", colorContext, (char)0, true);
                btn.Click += (sender, eOK) => OnOK();
                ButtonContainer.AddChild(btn);
                btn.Focus();
            }

            if (buttons.HasFlag(MessageBoxButtons.Cancel))
            {
                btn        = new DefaultButton("cancelbutton", "&Cancel", colorContext, (char)0, true);
                btn.Click += (sender, eCancel) => OnCancel();
                ButtonContainer.AddChild(btn);
            }
        }
Ejemplo n.º 6
0
        protected virtual void InitButtons(MessageBoxButtons buttons)
        {
            // panel
            DefaultButton btn = null;

            if (buttons.HasFlag(MessageBoxButtons.Continue))
            {
                btn        = ButtonContainer.AddChild(new DefaultButton("continuebutton", "&Continue"));
                btn.Click += (sender, eContinue) => OnContinue();
            }

            if (buttons.HasFlag(MessageBoxButtons.Repeat))
            {
                btn        = ButtonContainer.AddChild(new DefaultButton("repeatbutton", "&Repeat"));
                btn.Click += (sender, eRepeat) => OnRepeat();
            }

            if (buttons.HasFlag(MessageBoxButtons.Yes))
            {
                btn        = ButtonContainer.AddChild(new DefaultButton("yesbutton", "&Yes"));
                btn.Click += (sender, eYes) => OnYes();
            }

            if (buttons.HasFlag(MessageBoxButtons.No))
            {
                btn        = ButtonContainer.AddChild(new DefaultButton("nobutton", "&No"));;
                btn.Click += (sender, eNo) => OnNo();
            }

            if (buttons.HasFlag(MessageBoxButtons.OK))
            {
                btn        = ButtonContainer.AddChild(new DefaultButton("okbutton", "&OK"));
                btn.Click += (sender, eOK) => OnOK();
            }

            if (buttons.HasFlag(MessageBoxButtons.Cancel))
            {
                btn        = ButtonContainer.AddChild(new DefaultButton("cancelbutton", "&Cancel"));
                btn.Click += (sender, eCancel) => OnCancel();
            }

            ButtonContainer.Children.First.Focus();
        }