Пример #1
0
        /// <summary>
        /// Shows a confirmation dialog.
        /// </summary>
        /// <returns>True if the user clicked Yes.</returns>
        private bool ShowConfirmationDialog()
        {
            if (Program.RunInAutomatedTestMode)
            {
                return(true);
            }

            var buttonYes = new ThreeButtonDialog.TBDButton(
                string.IsNullOrEmpty(ConfirmationDialogYesButtonLabel) ? Messages.YES_BUTTON_CAPTION : ConfirmationDialogYesButtonLabel,
                DialogResult.Yes);

            var buttonNo = new ThreeButtonDialog.TBDButton(
                string.IsNullOrEmpty(ConfirmationDialogNoButtonLabel) ? Messages.NO_BUTTON_CAPTION : ConfirmationDialogNoButtonLabel,
                DialogResult.No,
                selected: ConfirmationDialogNoButtonSelected);

            using (var dialog = new WarningDialog(ConfirmationDialogText, buttonYes, buttonNo)
            {
                WindowTitle = ConfirmationDialogTitle
            })
            {
                if (!string.IsNullOrEmpty(ConfirmationDialogHelpId))
                {
                    dialog.HelpNameSetter = ConfirmationDialogHelpId;
                }

                return(dialog.ShowDialog(Parent ?? Program.MainWindow) == DialogResult.Yes);
            }
        }
Пример #2
0
        /// <summary>
        /// Shows a confirmation dialog.
        /// </summary>
        /// <returns>true if the user clicked Yes.</returns>
        protected bool ShowConfirmationDialog()
        {
            ThreeButtonDialog.TBDButton buttonYes = ThreeButtonDialog.ButtonYes;
            if (!string.IsNullOrEmpty(ConfirmationDialogYesButtonLabel))
            {
                buttonYes.label = ConfirmationDialogYesButtonLabel;
            }

            ThreeButtonDialog.TBDButton buttonNo = ThreeButtonDialog.ButtonNo;
            if (!string.IsNullOrEmpty(ConfirmationDialogNoButtonLabel))
            {
                buttonNo.label = ConfirmationDialogNoButtonLabel;
            }
            if (ConfirmationDialogNoButtonSelected)
            {
                buttonNo.selected = true;
            }

            return(MainWindow.Confirm(null, Parent, ConfirmationDialogTitle ?? Messages.XENCENTER,
                                      ConfirmationDialogHelpId, buttonYes, buttonNo, ConfirmationDialogText));
        }