Ejemplo n.º 1
0
    public async Task <string> GetDirectoryAsync(string initialDirectory = null)
    {
        var dialog = new OpenFolderDialog {
            Directory = initialDirectory
        };
        var window = _mainWindowProvider.GetMainWindow();

        return(await dialog.ShowAsync(window));
    }
Ejemplo n.º 2
0
    public async ValueTask <string> ShowTextWindowAsync()
    {
        return(await _applicationDispatcher.InvokeAsync(async() =>
        {
            var window = new TextWindow();
            await window.ShowDialog(_mainWindowProvider.GetMainWindow());

            return window.ViewModel?.GetResult() ?? string.Empty;
        }));
    }
Ejemplo n.º 3
0
    public async ValueTask <string> ShowMultiLineTextInputWindowAsync()
    {
        return(await _applicationDispatcher.InvokeAsync(async() =>
        {
            var window = new MultiLineTextInputWindow();
            var serviceProvider = Bootstrapper.Instance.GetServiceProvider();

            var viewModel = serviceProvider.GetRequiredService <MultiLineTextInputWindowViewModel>();
            await viewModel.InitializeAsync();
            window.ViewModel = viewModel;

            await window.ShowDialog(_mainWindowProvider.GetMainWindow());
            return window.GetResult() ?? string.Empty;
        }));
    }
Ejemplo n.º 4
0
        private async Task <T> ShowDialogAsync <T>(DialogWindowBase <T> window)
        {
            var mainWindow = (MainWindow)_mainWindowProvider.GetMainWindow();

            window.WindowStartupLocation = WindowStartupLocation.CenterOwner;

            mainWindow.ShowOverlay();
            var result = await window.ShowDialog <T>(mainWindow);

            mainWindow.HideOverlay();

            return(result);
        }
Ejemplo n.º 5
0
        private async Task <T> ShowDialogAsync <T>(DialogWindowBase <T> window)
        {
            var mainWindow = (MainWindow)_mainWindowProvider.GetMainWindow();

            window.Owner = mainWindow;

            mainWindow.ShowOverlay();
            var result = await window.ShowDialog <T>(mainWindow);

            mainWindow.HideOverlay();

            return(result);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Opens the OpenFileDialog window from the ViewModel.
        /// </summary>
        /// <returns>
        /// A task returning a nullable string representing the file path.
        /// </returns>
        public async Task <string?> ShowOpenDialogAsync()
        {
            var dialog = new OpenFileDialog()
            {
                AllowMultiple = false,
                Filters       = new List <FileDialogFilter>
                {
                    new FileDialogFilter()
                    {
                        Name = "JSON", Extensions = { "json" }
                    }
                }
            };
            var result = await dialog.ShowAsync(_mainWindowProvider.GetMainWindow());

            if (result == null || result.Length == 0)
            {
                return(null);
            }

            return(result[0]);
        }
Ejemplo n.º 7
0
        private async Task <TResult> ShowDialogAsync <TResult>(DialogWindowBase <TResult> window)
            where TResult : DialogResultBase
        {
            var mainWindow = (MainWindow)_mainWindowProvider.GetMainWindow();

            mainWindow.ShowOverlay();
            var result = await window.ShowDialog <TResult>(mainWindow);

            mainWindow.HideOverlay();
            if (window is IDisposable disposable)
            {
                disposable.Dispose();
            }

            return(result);
        }
Ejemplo n.º 8
0
 private IWin32Window ChooseOwner([CanBeNull] IWin32Window owner)
 {
     return(owner ?? _mainWindowProvider.GetMainWindow());
 }