private Task <MessageBoxResult> ShowMessageBox(string message, string caption, MessageBoxButton button, MessageBoxImage icon)
        {
            message.AssertNotNull(nameof(message));
            caption.AssertNotNull(nameof(caption));

            var ownerWindow = _ownerWindowProvider.GetOwnerWindow();

            if (ownerWindow == null)
            {
                return(Task.FromResult(MessageBox.Show(message, caption, button, icon)));
            }

            return(Task.FromResult(MessageBox.Show(ownerWindow, message, caption, button, icon)));
        }
Exemple #2
0
        private Task <string> ShowDialog <TDialog>(IEnumerable <FileDialogFilter> filters, string initialPath = null, Action <TDialog> configureDialog = null)
            where TDialog : FileDialog, new()
        {
            filters.AssertNotNull(nameof(filters));

            var ownerWindow = _ownerWindowProvider.GetOwnerWindow();
            var dialog      = CreateDialog(filters, initialPath, configureDialog);

            if (dialog.ShowDialog(ownerWindow) == true)
            {
                return(Task.FromResult(dialog.FileName));
            }

            throw new OperationCanceledException();
        }