From 464b3fc00422b81e3d56d3c2d18e45868ab5ca45 Mon Sep 17 00:00:00 2001 From: Yair Aichenbaum Date: Fri, 17 Apr 2020 00:02:57 -0400 Subject: [PATCH] Refactored detecting user locations --- Files.Launcher/Program.cs | 11 +--- Files/MultilingualResources/Files.es-ES.xlf | 2 +- Files/Strings/es-ES/Resources.resw | 3 + .../LayoutModes/GenericFileBrowser.xaml | 2 +- Files/UserControls/StatusBarControl.xaml | 6 +- Files/View Models/SettingsViewModel.cs | 56 +++++-------------- 6 files changed, 23 insertions(+), 57 deletions(-) diff --git a/Files.Launcher/Program.cs b/Files.Launcher/Program.cs index f84b2822730e..84d568e06f38 100644 --- a/Files.Launcher/Program.cs +++ b/Files.Launcher/Program.cs @@ -17,16 +17,7 @@ static void Main(string[] args) { if (arguments.Equals("StartupTasks")) { - // Detect User Paths - ApplicationData.Current.LocalSettings.Values["DesktopPath"] = Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Desktop", null); - ApplicationData.Current.LocalSettings.Values["DownloadsPath"] = Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "{374DE290-123F-4565-9164-39C4925E467B}", null); - ApplicationData.Current.LocalSettings.Values["DocumentsPath"] = Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Personal", null); - ApplicationData.Current.LocalSettings.Values["PicturesPath"] = Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "My Pictures", null); - ApplicationData.Current.LocalSettings.Values["MusicPath"] = Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "My Music", null); - ApplicationData.Current.LocalSettings.Values["VideosPath"] = Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "My Video", null); - ApplicationData.Current.LocalSettings.Values["OneDrivePath"] = Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\OneDrive", "UserFolder", null); - - // Check QuickLook Availability + // Check QuickLook Availability QuickLook.CheckQuickLookAvailability(localSettings); } else if (arguments.Equals("ToggleQuickLook")) diff --git a/Files/MultilingualResources/Files.es-ES.xlf b/Files/MultilingualResources/Files.es-ES.xlf index c8bd0d52cc54..6944dd4fc109 100644 --- a/Files/MultilingualResources/Files.es-ES.xlf +++ b/Files/MultilingualResources/Files.es-ES.xlf @@ -581,4 +581,4 @@ - + \ No newline at end of file diff --git a/Files/Strings/es-ES/Resources.resw b/Files/Strings/es-ES/Resources.resw index e6d2fb9faed0..4ac7ff0d9765 100644 --- a/Files/Strings/es-ES/Resources.resw +++ b/Files/Strings/es-ES/Resources.resw @@ -435,4 +435,7 @@ Ajustes + + Invertir Selección + \ No newline at end of file diff --git a/Files/UserControls/LayoutModes/GenericFileBrowser.xaml b/Files/UserControls/LayoutModes/GenericFileBrowser.xaml index 88f84a1d5d7a..8d8c3fe46932 100644 --- a/Files/UserControls/LayoutModes/GenericFileBrowser.xaml +++ b/Files/UserControls/LayoutModes/GenericFileBrowser.xaml @@ -309,11 +309,11 @@ DoubleTapped="{x:Bind local:App.CurrentInstance.InteractionOperations.List_ItemClick}" DragOver="List_DragOver" Drop="List_Drop" - LoadingRow="AllView_LoadingRow" FocusVisualPrimaryThickness="0" IsDoubleTapEnabled="True" IsRightTapEnabled="True" ItemsSource="{x:Bind AssociatedViewModel.FilesAndFolders, Mode=OneWay}" + LoadingRow="AllView_LoadingRow" PreparingCellForEdit="AllView_PreparingCellForEdit" PreviewKeyDown="AllView_PreviewKeyDown" RightTapped="{x:Bind local:App.CurrentInstance.InteractionOperations.AllView_RightTapped}" diff --git a/Files/UserControls/StatusBarControl.xaml b/Files/UserControls/StatusBarControl.xaml index b12d0039d5da..d197936db87c 100644 --- a/Files/UserControls/StatusBarControl.xaml +++ b/Files/UserControls/StatusBarControl.xaml @@ -37,21 +37,21 @@ - + diff --git a/Files/View Models/SettingsViewModel.cs b/Files/View Models/SettingsViewModel.cs index b045e5ea645e..559d158f64a1 100644 --- a/Files/View Models/SettingsViewModel.cs +++ b/Files/View Models/SettingsViewModel.cs @@ -440,6 +440,20 @@ public bool PinOneDriveToSideBar } } + public string DesktopPath = UserDataPaths.GetDefault().Desktop; + + public string DocumentsPath = UserDataPaths.GetDefault().Documents; + + public string DownloadsPath = UserDataPaths.GetDefault().Downloads; + + public string PicturesPath = UserDataPaths.GetDefault().Pictures; + + public string MusicPath = UserDataPaths.GetDefault().Music; + + public string VideosPath = UserDataPaths.GetDefault().Videos; + + public string OneDrivePath = Environment.GetEnvironmentVariable("OneDrive"); + private string _TempPath = (string)Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\Environment", "TEMP", null); public string TempPath { @@ -468,48 +482,6 @@ public string WinDirPath set => Set(ref _WinDirPath, value); } - public string DesktopPath - { - get => Get(UserDataPaths.GetDefault().Desktop); - set => Set(value); - } - - public string DocumentsPath - { - get => Get(UserDataPaths.GetDefault().Documents); - set => Set(value); - } - - public string DownloadsPath - { - get => Get(UserDataPaths.GetDefault().Downloads); - set => Set(value); - } - - public string PicturesPath - { - get => Get(UserDataPaths.GetDefault().Pictures); - set => Set(value); - } - - public string MusicPath - { - get => Get(UserDataPaths.GetDefault().Music); - set => Set(value); - } - - public string VideosPath - { - get => Get(UserDataPaths.GetDefault().Videos); - set => Set(value); - } - - public string OneDrivePath - { - get => Get(Environment.GetEnvironmentVariable("OneDrive")); - set => Set(value); - } - public bool AcrylicSidebar { get => Get(false);