Пример #1
0
        void ShowDialog(Window parent, MessageIcon icon, string title, string content, MessageChoice choices, string help, bool enableDontAsk, MessageChoice defaultChoice)
        {
            if (IsSet(choices, MessageChoice.Yes | MessageChoice.OK) || (choices == MessageChoice.Help))
                throw new ArgumentException();

            view = CreateWindow(parent);

            Icon = icon;
            Title = title;
            Content = content;
            Choices = new List<ICommand>();
            EnableDontAskAgain = enableDontAsk;
            Result = MessageChoice.None;

            if (!string.IsNullOrEmpty(help))
                HelpMessage = help;

            if (IsSet(choices, MessageChoice.Yes))
                Choices.Add(new ChoiceCommand(CloseCommand, defaultChoice == MessageChoice.Yes, false, "Yes", MessageChoice.Yes));

            if (IsSet(choices, MessageChoice.No))
                Choices.Add(new ChoiceCommand(CloseCommand, defaultChoice == MessageChoice.No, !IsSet(choices, MessageChoice.Cancel), "No", MessageChoice.No));

            if (IsSet(choices, MessageChoice.OK))
                Choices.Add(new ChoiceCommand(CloseCommand, choices == MessageChoice.OK || defaultChoice == MessageChoice.OK, !IsSet(choices, MessageChoice.Cancel), "OK", MessageChoice.OK));

            if (IsSet(choices, MessageChoice.Cancel))
                Choices.Add(new ChoiceCommand(CloseCommand, choices == MessageChoice.Cancel || defaultChoice == MessageChoice.Cancel, true, "Cancel", MessageChoice.Cancel));

            if (IsSet(choices, MessageChoice.Help))
                Choices.Add(new ChoiceCommand(HelpCommand, choices == MessageChoice.Help || defaultChoice == MessageChoice.Help, false, "Help", MessageChoice.Help));

            view.ShowDialog();
        }
Пример #2
0
        Dialog CreateWindow(Window parent)
        {
            var dialog = new Dialog { DataContext = this };

            if (parent == null)
            {
                dialog.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            }
            else
            {
                dialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            }

            return dialog;
        }