From 093d6d0c317657e72dabf5c4232f8e2d682f96e5 Mon Sep 17 00:00:00 2001 From: Marco Gavelli Date: Sun, 26 Sep 2021 15:06:44 +0200 Subject: [PATCH 1/2] Fix edit tags & edit terminals button --- .../ExperimentalViewModel.cs | 20 ++++++++++++++++--- .../PreferencesViewModel.cs | 18 +++++++++++++++-- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/Files/ViewModels/SettingsViewModels/ExperimentalViewModel.cs b/Files/ViewModels/SettingsViewModels/ExperimentalViewModel.cs index 29d597a335c8..40fe3a22a1d6 100644 --- a/Files/ViewModels/SettingsViewModels/ExperimentalViewModel.cs +++ b/Files/ViewModels/SettingsViewModels/ExperimentalViewModel.cs @@ -1,6 +1,8 @@ -using Microsoft.Toolkit.Mvvm.ComponentModel; +using Files.Helpers; +using Microsoft.Toolkit.Mvvm.ComponentModel; using Microsoft.Toolkit.Mvvm.Input; using System; +using Windows.Foundation.Collections; using Windows.Storage; using Windows.System; @@ -29,8 +31,20 @@ public bool AreFileTagsEnabled private async void LaunchFileTagsConfigFile() { - await Launcher.LaunchFileAsync( - await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appdata:///local/settings/filetags.json"))); + var configFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appdata:///local/settings/filetags.json")); + if (!await Launcher.LaunchFileAsync(configFile)) + { + var connection = await AppServiceConnectionHelper.Instance; + if (connection != null) + { + await connection.SendMessageAsync(new ValueSet() + { + { "Arguments", "InvokeVerb" }, + { "FilePath", configFile.Path }, + { "Verb", "open" } + }); + } + } } } } \ No newline at end of file diff --git a/Files/ViewModels/SettingsViewModels/PreferencesViewModel.cs b/Files/ViewModels/SettingsViewModels/PreferencesViewModel.cs index 6c9aa41f0f43..8532a5c32f5c 100644 --- a/Files/ViewModels/SettingsViewModels/PreferencesViewModel.cs +++ b/Files/ViewModels/SettingsViewModels/PreferencesViewModel.cs @@ -1,11 +1,13 @@ using Files.DataModels; using Files.Enums; +using Files.Helpers; using Microsoft.Toolkit.Mvvm.ComponentModel; using Microsoft.Toolkit.Mvvm.Input; using Microsoft.Toolkit.Uwp; using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using Windows.Foundation.Collections; using Windows.Storage; using Windows.System; @@ -127,8 +129,20 @@ public bool OpenFoldersNewTab private async void LaunchTerminalsConfigFile() { - await Launcher.LaunchFileAsync( - await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appdata:///local/settings/terminal.json"))); + var configFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appdata:///local/settings/terminal.json")); + if (!await Launcher.LaunchFileAsync(configFile)) + { + var connection = await AppServiceConnectionHelper.Instance; + if (connection != null) + { + await connection.SendMessageAsync(new ValueSet() + { + { "Arguments", "InvokeVerb" }, + { "FilePath", configFile.Path }, + { "Verb", "open" } + }); + } + } } } } \ No newline at end of file From 755441d93b93a9bba163e7e7ef4b02b30b22f2cb Mon Sep 17 00:00:00 2001 From: Marco Gavelli Date: Mon, 27 Sep 2021 20:54:29 +0200 Subject: [PATCH 2/2] Switched to AsyncRelayCommand --- Files/ViewModels/SettingsViewModels/ExperimentalViewModel.cs | 5 +++-- Files/ViewModels/SettingsViewModels/PreferencesViewModel.cs | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Files/ViewModels/SettingsViewModels/ExperimentalViewModel.cs b/Files/ViewModels/SettingsViewModels/ExperimentalViewModel.cs index 40fe3a22a1d6..f6ebcb56ffd2 100644 --- a/Files/ViewModels/SettingsViewModels/ExperimentalViewModel.cs +++ b/Files/ViewModels/SettingsViewModels/ExperimentalViewModel.cs @@ -2,6 +2,7 @@ using Microsoft.Toolkit.Mvvm.ComponentModel; using Microsoft.Toolkit.Mvvm.Input; using System; +using System.Threading.Tasks; using Windows.Foundation.Collections; using Windows.Storage; using Windows.System; @@ -27,9 +28,9 @@ public bool AreFileTagsEnabled } } - public RelayCommand EditFileTagsCommand => new RelayCommand(() => LaunchFileTagsConfigFile()); + public IRelayCommand EditFileTagsCommand => new AsyncRelayCommand(() => LaunchFileTagsConfigFile()); - private async void LaunchFileTagsConfigFile() + private async Task LaunchFileTagsConfigFile() { var configFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appdata:///local/settings/filetags.json")); if (!await Launcher.LaunchFileAsync(configFile)) diff --git a/Files/ViewModels/SettingsViewModels/PreferencesViewModel.cs b/Files/ViewModels/SettingsViewModels/PreferencesViewModel.cs index 8532a5c32f5c..962c5daa1f70 100644 --- a/Files/ViewModels/SettingsViewModels/PreferencesViewModel.cs +++ b/Files/ViewModels/SettingsViewModels/PreferencesViewModel.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Threading.Tasks; using Windows.Foundation.Collections; using Windows.Storage; using Windows.System; @@ -95,7 +96,7 @@ public Terminal SelectedTerminal } } - public RelayCommand EditTerminalApplicationsCommand => new RelayCommand(() => LaunchTerminalsConfigFile()); + public IRelayCommand EditTerminalApplicationsCommand => new AsyncRelayCommand(() => LaunchTerminalsConfigFile()); public bool ShowConfirmDeleteDialog { @@ -127,7 +128,7 @@ public bool OpenFoldersNewTab } } - private async void LaunchTerminalsConfigFile() + private async Task LaunchTerminalsConfigFile() { var configFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appdata:///local/settings/terminal.json")); if (!await Launcher.LaunchFileAsync(configFile))