From bd9ce2e507774170fbe261b80f296bfd41461129 Mon Sep 17 00:00:00 2001 From: I_aM_O Date: Sat, 26 Nov 2022 17:00:23 -0500 Subject: [PATCH] Improve file dialog behavior --- src/nxDumpFuse/Properties/launchSettings.json | 4 ++++ src/nxDumpFuse/Services/DialogService.cs | 14 ++++++++++---- src/nxDumpFuse/ViewModels/FuseViewModel.cs | 10 +++++++++- src/nxDumpFuse/nxDumpFuse.csproj | 12 ++++++------ 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/nxDumpFuse/Properties/launchSettings.json b/src/nxDumpFuse/Properties/launchSettings.json index 4f4dfef..a8a04d2 100644 --- a/src/nxDumpFuse/Properties/launchSettings.json +++ b/src/nxDumpFuse/Properties/launchSettings.json @@ -3,6 +3,10 @@ "nxDumpFuse": { "commandName": "Project", "commandLineArgs": "/l Trace" + }, + "WSL": { + "commandName": "WSL2", + "distributionName": "" } } } \ No newline at end of file diff --git a/src/nxDumpFuse/Services/DialogService.cs b/src/nxDumpFuse/Services/DialogService.cs index fba9235..df42bfe 100644 --- a/src/nxDumpFuse/Services/DialogService.cs +++ b/src/nxDumpFuse/Services/DialogService.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System.Collections.Generic; +using System.Threading.Tasks; using Avalonia.Controls; using nxDumpFuse.ViewModels.Interfaces; @@ -15,14 +16,18 @@ namespace nxDumpFuse.Services public async Task ShowOpenFileDialogAsync(string title, FileDialogFilter filter) { - var openFileDialog = new OpenFileDialog() + var openFileDialog = new OpenFileDialog { Title = title, AllowMultiple = false }; - openFileDialog.Filters.Add(filter); + openFileDialog.Filters!.Add(filter); var result = await openFileDialog.ShowAsync(_mainWindowProvider.GetMainWindow()); + if (result == null) + { + return string.Empty; + } return result.Length == 0 ? string.Empty : result[0]; } @@ -32,7 +37,8 @@ namespace nxDumpFuse.Services { Title = title }; - return await openFolderDialog.ShowAsync(_mainWindowProvider.GetMainWindow()); + var result = await openFolderDialog.ShowAsync(_mainWindowProvider.GetMainWindow()); + return result ?? string.Empty; } } } diff --git a/src/nxDumpFuse/ViewModels/FuseViewModel.cs b/src/nxDumpFuse/ViewModels/FuseViewModel.cs index 5bb38c2..aca3785 100644 --- a/src/nxDumpFuse/ViewModels/FuseViewModel.cs +++ b/src/nxDumpFuse/ViewModels/FuseViewModel.cs @@ -55,6 +55,7 @@ namespace nxDumpFuse.ViewModels public ReactiveCommand StopCommand { get; } private bool _isBusy; + public bool IsBusy { get => _isBusy; @@ -62,6 +63,7 @@ namespace nxDumpFuse.ViewModels } private string _inputFilePath = string.Empty; + public string InputFilePath { get => _inputFilePath; @@ -69,6 +71,7 @@ namespace nxDumpFuse.ViewModels } private string _outputDir = string.Empty; + public string OutputDir { get => _outputDir; @@ -76,6 +79,7 @@ namespace nxDumpFuse.ViewModels } private string _progressPartText = string.Empty; + public string ProgressPartText { get => _progressPartText; @@ -83,6 +87,7 @@ namespace nxDumpFuse.ViewModels } private double _progressPart; + public double ProgressPart { get => _progressPart; @@ -90,6 +95,7 @@ namespace nxDumpFuse.ViewModels } private double _progress; + public double Progress { get => _progress; @@ -97,6 +103,7 @@ namespace nxDumpFuse.ViewModels } private string _progressText = string.Empty; + public string ProgressText { get => _progressText; @@ -104,6 +111,7 @@ namespace nxDumpFuse.ViewModels } private ObservableCollection _logItems = new(); + public ObservableCollection LogItems { get => _logItems; @@ -143,7 +151,7 @@ namespace nxDumpFuse.ViewModels private async void SelectInputFile() { InputFilePath = await _dialogService.ShowOpenFileDialogAsync("Choose Input File", - new FileDialogFilter { Name = string.Empty, Extensions = new List() }); + new FileDialogFilter { Name = string.Empty, Extensions = new List { "*" } }); } private async void SelectOutputFolder() diff --git a/src/nxDumpFuse/nxDumpFuse.csproj b/src/nxDumpFuse/nxDumpFuse.csproj index 63c44d1..8526af7 100644 --- a/src/nxDumpFuse/nxDumpFuse.csproj +++ b/src/nxDumpFuse/nxDumpFuse.csproj @@ -6,7 +6,7 @@ true true win10-x64 - + true true @@ -22,12 +22,12 @@ - - - + + + - - + +