Exemplo n.º 1
0
        /// <summary>
        /// Shows the provided message in a simple dialog with a warning icon and the specified buttons.
        /// </summary>
        /// <param name="message">The message to display.</param>
        /// <param name="detail">Additional information to display.</param>
        /// <param name="buttons">The buttons to display.</param>
        public static DialogResult ShowWarningPrompt(string message, string detail, Buttons buttons = Buttons.YesNo)
        {
            var vm = new TaskDialogViewModel(message, detail);

            vm.SetIcon(Icon.Warning);
            vm.SetButtons(buttons);

            if (!vm.ShowTaskDialog())
            {
                var messageBoxViewModel = new MessageBoxViewModel(message + "\n\n" + detail);
                messageBoxViewModel.DialogTitle = "Warning";
                switch (buttons)
                {
                case Buttons.YesNo: return(messageBoxViewModel.ShowYesNoDialog());

                case Buttons.YesNoCancel: return(messageBoxViewModel.ShowYesNoCancelDialog());

                case Buttons.RetryCancel: return(messageBoxViewModel.ShowRetryCancelDialog());

                default: throw new NotImplementedException(buttons.ToString());
                }
            }

            return(vm.DialogResult);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Shows the provided message in a simple dialog.
        /// </summary>
        /// <param name="message">The message to display.</param>
        /// <param name="detail">Additional information to display.</param>
        public static void ShowMessage(string message, string detail)
        {
            var vm = new TaskDialogViewModel(message, detail);

            if (!vm.ShowTaskDialog())
            {
                MessageBoxViewModel.ShowMessage(message + "\n\n" + detail);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Shows the provided message in a simple dialog with an error icon.
        /// </summary>
        /// <param name="message">The message to display.</param>
        /// <param name="detail">Additional information to display.</param>
        public static void ShowErrorMessage(string message, string detail)
        {
            var vm = new TaskDialogViewModel(message, detail);

            vm.SetIcon(Icon.Error);

            if (!vm.ShowTaskDialog())
            {
                var messageBoxViewModel = new MessageBoxViewModel(message + "\n\n" + detail);
                messageBoxViewModel.DialogTitle = "Error";
                messageBoxViewModel.ShowDialog();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Executes the ok command.
        /// </summary>
        protected virtual void ExecuteOkCommand()
        {
            string errors = Validate();

            if (String.IsNullOrEmpty(errors))
            {
                Commit();
                DialogResult = DialogResult.Ok;
            }
            else
            {
                var viewModel = new MessageBoxViewModel(errors, _dialogService);
                viewModel.DialogTitle = "Corrections required";
                viewModel.ShowDialog();
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Shows the provided message in a simple dialog.
        /// </summary>
        /// <param name="message">The message to display.</param>
        public static void ShowMessage(string message)
        {
            var vm = new MessageBoxViewModel(message);

            vm.ShowDialog();
        }