From 4ef0b67a82954f37b97ec9b183c2cf0331e90fdd Mon Sep 17 00:00:00 2001 From: Timothy Baldridge Date: Thu, 18 Mar 2021 22:14:07 -0600 Subject: [PATCH] Fix weird bug with CommonFileDialogFilters --- Wabbajack.App.Test/FilePickerTests.cs | 10 +++++----- Wabbajack/Util/FilePickerVM.cs | 3 ++- Wabbajack/View Models/Compilers/MO2CompilerVM.cs | 2 +- Wabbajack/View Models/Installers/InstallerVM.cs | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Wabbajack.App.Test/FilePickerTests.cs b/Wabbajack.App.Test/FilePickerTests.cs index 3dfdd991..26cafc25 100644 --- a/Wabbajack.App.Test/FilePickerTests.cs +++ b/Wabbajack.App.Test/FilePickerTests.cs @@ -291,11 +291,11 @@ namespace Wabbajack.Test public async Task FileWithFilters_Passes() { var vm = new FilePickerVM(); - await using (CreateSetFile(vm)) + await using (var file = CreateSetFile(vm)) { vm.PathType = FilePickerVM.PathTypeOptions.File; vm.ExistCheckOption = FilePickerVM.CheckOptions.Off; - vm.Filters.Add(new Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogFilter("test", $"*.{vm.TargetPath.Extension}")); + vm.Filters.Add(new Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogFilter("test", $"*{vm.TargetPath.Extension}")); await Task.Delay(250); Assert.False(vm.Exists); Assert.True(vm.ErrorState.Succeeded); @@ -312,7 +312,7 @@ namespace Wabbajack.Test { vm.PathType = FilePickerVM.PathTypeOptions.File; vm.ExistCheckOption = FilePickerVM.CheckOptions.Off; - vm.Filters.Add(new Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogFilter("test", $"*.{vm.TargetPath.Extension}z")); + vm.Filters.Add(new Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogFilter("test", $"*{vm.TargetPath.Extension}z")); await Task.Delay(250); Assert.False(vm.Exists); Assert.False(vm.ErrorState.Succeeded); @@ -328,7 +328,7 @@ namespace Wabbajack.Test vm.PathType = FilePickerVM.PathTypeOptions.File; vm.ExistCheckOption = FilePickerVM.CheckOptions.Off; vm.TargetPath = (AbsolutePath)"SomePath.png"; - vm.Filters.Add(new Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogFilter("test", $"*.{vm.TargetPath.Extension}")); + vm.Filters.Add(new Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogFilter("test", $"*{vm.TargetPath.Extension}")); await Task.Delay(250); Assert.False(vm.Exists); Assert.True(vm.ErrorState.Succeeded, vm.ErrorState.Reason); @@ -345,7 +345,7 @@ namespace Wabbajack.Test ExistCheckOption = FilePickerVM.CheckOptions.Off, FilterCheckOption = FilePickerVM.CheckOptions.IfPathNotEmpty }; - vm.Filters.Add(new Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogFilter("test", $"*.{vm.TargetPath.Extension}")); + vm.Filters.Add(new Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogFilter("test", $"*{vm.TargetPath.Extension}")); await Task.Delay(250); Assert.False(vm.Exists); Assert.True(vm.ErrorState.Succeeded); diff --git a/Wabbajack/Util/FilePickerVM.cs b/Wabbajack/Util/FilePickerVM.cs index 81491344..9b753322 100644 --- a/Wabbajack/Util/FilePickerVM.cs +++ b/Wabbajack/Util/FilePickerVM.cs @@ -65,7 +65,7 @@ namespace Wabbajack private readonly ObservableAsPropertyHelper _errorTooltip; public string ErrorTooltip => _errorTooltip.Value; - public SourceList Filters { get; } = new SourceList(); + public SourceList Filters { get; } = new(); public const string PathDoesNotExistText = "Path does not exist"; public const string DoesNotPassFiltersText = "Path does not pass designated filters"; @@ -158,6 +158,7 @@ namespace Wabbajack Filters.Connect().QueryWhenChanged(), resultSelector: (target, type, checkOption, query) => { + Console.WriteLine("fff"); switch (type) { case PathTypeOptions.Either: diff --git a/Wabbajack/View Models/Compilers/MO2CompilerVM.cs b/Wabbajack/View Models/Compilers/MO2CompilerVM.cs index 19279473..63b140e4 100644 --- a/Wabbajack/View Models/Compilers/MO2CompilerVM.cs +++ b/Wabbajack/View Models/Compilers/MO2CompilerVM.cs @@ -50,7 +50,7 @@ namespace Wabbajack PathType = FilePickerVM.PathTypeOptions.File, PromptTitle = "Select a Modlist" }; - ModListLocation.Filters.Add(new CommonFileDialogFilter("MO2 Profile (modlist.txt) or Native Settings (native_compiler_settings.json)", ".txt,.json")); + ModListLocation.Filters.Add(new CommonFileDialogFilter("MO2 Profile (modlist.txt) or Native Settings (native_compiler_settings.json)", "*.txt,*.json")); DownloadLocation = new FilePickerVM() { diff --git a/Wabbajack/View Models/Installers/InstallerVM.cs b/Wabbajack/View Models/Installers/InstallerVM.cs index d92c0521..e1344fee 100644 --- a/Wabbajack/View Models/Installers/InstallerVM.cs +++ b/Wabbajack/View Models/Installers/InstallerVM.cs @@ -113,7 +113,7 @@ namespace Wabbajack PathType = FilePickerVM.PathTypeOptions.File, PromptTitle = "Select a ModList to install" }; - ModListLocation.Filters.Add(new CommonFileDialogFilter("Wabbajack Modlist", ".wabbajack")); + ModListLocation.Filters.Add(new CommonFileDialogFilter("Wabbajack Modlist", "*.wabbajack")); // Swap to proper sub VM based on selected type _installer = this.WhenAny(x => x.TargetManager)