From 468b1753aa4f378fb426b3047ce0bc2dca42c1f6 Mon Sep 17 00:00:00 2001 From: jesusalvino Date: Tue, 21 Mar 2023 01:04:03 -0500 Subject: [PATCH 01/14] UI changes --- .../Properties/Resources.Designer.cs | 36 +-- .../Properties/Resources.en-US.resx | 6 +- src/DynamoCoreWpf/Properties/Resources.resx | 6 +- .../Views/Core/CustomColorPicker.xaml | 2 +- .../Views/Core/GeometryScalingPopup.xaml.cs | 2 +- .../Views/Menu/PreferencesView.xaml | 246 +++++++++++------- 6 files changed, 183 insertions(+), 115 deletions(-) diff --git a/src/DynamoCoreWpf/Properties/Resources.Designer.cs b/src/DynamoCoreWpf/Properties/Resources.Designer.cs index 50af3a94e6d..31ea713a93e 100644 --- a/src/DynamoCoreWpf/Properties/Resources.Designer.cs +++ b/src/DynamoCoreWpf/Properties/Resources.Designer.cs @@ -1061,15 +1061,6 @@ public static string CustomColorPickerTitle { } } - /// - /// Looks up a localized string similar to Custom. - /// - public static string CustomColorsPopupTitle { - get { - return ResourceManager.GetString("CustomColorsPopupTitle", resourceCulture); - } - } - /// /// Looks up a localized string similar to A description that helps people understand what the node might be used for.. /// @@ -6809,6 +6800,24 @@ public static string PreferencesViewFontSizeLabel { } } + /// + /// Looks up a localized string similar to Backup Settings. + /// + public static string PreferencesViewGeneralSettingsBackup { + get { + return ResourceManager.GetString("PreferencesViewGeneralSettingsBackup", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Default Geometry Scaling. + /// + public static string PreferencesViewGeneralSettingsGeoScaling { + get { + return ResourceManager.GetString("PreferencesViewGeneralSettingsGeoScaling", resourceCulture); + } + } + /// /// Looks up a localized string similar to General. /// @@ -7034,15 +7043,6 @@ public static string PreferencesViewVisualSettingsDisplaySettings { } } - /// - /// Looks up a localized string similar to Default Geometry Scaling. - /// - public static string PreferencesViewVisualSettingsGeoScaling { - get { - return ResourceManager.GetString("PreferencesViewVisualSettingsGeoScaling", resourceCulture); - } - } - /// /// Looks up a localized string similar to Style Name. /// diff --git a/src/DynamoCoreWpf/Properties/Resources.en-US.resx b/src/DynamoCoreWpf/Properties/Resources.en-US.resx index 28c2707dfe9..f9439091191 100644 --- a/src/DynamoCoreWpf/Properties/Resources.en-US.resx +++ b/src/DynamoCoreWpf/Properties/Resources.en-US.resx @@ -2371,10 +2371,14 @@ You can try disabling loading packages from built-in package paths, or unload th Do you wish to uninstall {1}? Restart {2} to complete the uninstall and try downloading {0} again. - + Default Geometry Scaling Expander Header Name + + Backup Settings + Expander Header Name + Group Styles Expander Header Name diff --git a/src/DynamoCoreWpf/Properties/Resources.resx b/src/DynamoCoreWpf/Properties/Resources.resx index 92aaa7f6b78..58794b5bd6f 100644 --- a/src/DynamoCoreWpf/Properties/Resources.resx +++ b/src/DynamoCoreWpf/Properties/Resources.resx @@ -2590,10 +2590,14 @@ You can try disabling loading packages from built-in package paths, or unload th Do you wish to uninstall {1}? Restart {2} to complete the uninstall and try downloading {0} again. - + Default Geometry Scaling Expander Header Name + + Backup Settings + Expander Header Name + Group Styles Expander Header Name diff --git a/src/DynamoCoreWpf/Views/Core/CustomColorPicker.xaml b/src/DynamoCoreWpf/Views/Core/CustomColorPicker.xaml index f15e26b2805..da283bc40dd 100644 --- a/src/DynamoCoreWpf/Views/Core/CustomColorPicker.xaml +++ b/src/DynamoCoreWpf/Views/Core/CustomColorPicker.xaml @@ -314,7 +314,7 @@ FontFamily="{StaticResource ArtifaktElementRegular}" FontSize="20" Foreground="Black" - Text="{x:Static p:Resources.CustomColorsPopupTitle}" /> + Text="X" /> + + + + + + From 0650a6ddb2eea974b99726c5f29e4fbb343a7236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesus=20Alfredo=20Alvi=C3=B1o=20Lescano?= Date: Thu, 23 Mar 2023 15:41:53 -0500 Subject: [PATCH 02/14] Backup Location as setting and minor UI changes --- src/DynamoCore/Configuration/IPreferences.cs | 5 +++ src/DynamoCore/Configuration/PathManager.cs | 11 ++++++ .../Configuration/PreferenceSettings.cs | 15 ++++++++ src/DynamoCore/Models/DynamoModel.cs | 21 ++++++---- .../Properties/Resources.Designer.cs | 24 +++++++++++- .../Properties/Resources.en-US.resx | 4 ++ src/DynamoCoreWpf/Properties/Resources.resx | 4 ++ .../ViewModels/Menu/PreferencesViewModel.cs | 28 +++++++++++++- .../Views/Core/CustomColorPicker.xaml | 2 +- .../Views/Menu/PreferencesView.xaml | 19 ++++------ .../Views/Menu/PreferencesView.xaml.cs | 38 +++++++++++++++++-- 11 files changed, 145 insertions(+), 26 deletions(-) diff --git a/src/DynamoCore/Configuration/IPreferences.cs b/src/DynamoCore/Configuration/IPreferences.cs index 74ee4bc469e..20ceb9d216b 100644 --- a/src/DynamoCore/Configuration/IPreferences.cs +++ b/src/DynamoCore/Configuration/IPreferences.cs @@ -102,6 +102,11 @@ public interface IPreferences /// List RecentFiles { get; set; } + /// + /// Returns path of the Backup location + /// + string BackupLocation { get; set; } + /// /// Returns list of backup files /// diff --git a/src/DynamoCore/Configuration/PathManager.cs b/src/DynamoCore/Configuration/PathManager.cs index efc079d6090..a1f7ca17e44 100644 --- a/src/DynamoCore/Configuration/PathManager.cs +++ b/src/DynamoCore/Configuration/PathManager.cs @@ -460,6 +460,17 @@ internal void EnsureDirectoryExistence(List exceptions) exceptions.RemoveAll(x => x == null); // Remove all null entries. } + internal void UpdateBackupLocation(string backupLocation) + { + // check the pathmanager to see the backup folders vs the preferences pathManager. + string defaultBackupLocation = BackupDirectory; + string preferenceBackupLocation = backupLocation; + if (!defaultBackupLocation.Equals(preferenceBackupLocation) && !string.IsNullOrEmpty(preferenceBackupLocation)) + { + //PreferenceSettings.BackupLocation = currentBackupFolder; + } + } + /// /// Returns the backup file path for a workspace /// diff --git a/src/DynamoCore/Configuration/PreferenceSettings.cs b/src/DynamoCore/Configuration/PreferenceSettings.cs index b723a111540..4546d6d3895 100644 --- a/src/DynamoCore/Configuration/PreferenceSettings.cs +++ b/src/DynamoCore/Configuration/PreferenceSettings.cs @@ -57,6 +57,7 @@ public class PreferenceSettings : NotificationObject, IPreferences, IRenderPreci private bool isEnablePersistExtensionsEnabled; private bool isStaticSplashScreenEnabled; private bool isCreatedFromValidFile = true; + private string backupLocation; #region Constants /// @@ -357,6 +358,19 @@ public int MaxNumRecentFiles /// public List RecentFiles { get; set; } + /// + /// Backup files path + /// + public string BackupLocation + { + get { return backupLocation; } + set + { + backupLocation = value; + RaisePropertyChanged(nameof(BackupLocation)); + } + } + /// /// A list of backup file paths. /// @@ -801,6 +815,7 @@ public PreferenceSettings() BackupInterval = DefaultBackupInterval; BackupFilesCount = 1; BackupFiles = new List(); + BackupLocation = ""; LibraryZoomScale = 100; PythonScriptZoomScale = 100; diff --git a/src/DynamoCore/Models/DynamoModel.cs b/src/DynamoCore/Models/DynamoModel.cs index b5c68726e84..a21df765484 100644 --- a/src/DynamoCore/Models/DynamoModel.cs +++ b/src/DynamoCore/Models/DynamoModel.cs @@ -630,7 +630,7 @@ protected DynamoModel(IStartConfiguration config) CERLocation = cerConfig.CRStartConfig.CERLocation; } - ClipBoard = new ObservableCollection(); + ClipBoard = new ObservableCollection(); pathManager = new PathManager(new PathManagerParams { @@ -670,6 +670,7 @@ protected DynamoModel(IStartConfiguration config) geometryFactoryPath = config.GeometryFactoryPath; OnRequestUpdateLoadBarStatus(new SplashScreenLoadEventArgs(Resources.SplashScreenInitPreferencesSettings, 30)); + IPreferences preferences = CreateOrLoadPreferences(config.Preferences); if (preferences is PreferenceSettings settings) { @@ -796,7 +797,7 @@ protected DynamoModel(IStartConfiguration config) PreferenceSettings.AddDefaultTrustedLocations(); } - InitializePreferences(PreferenceSettings); + InitializePreferences(); // At this point, pathManager.PackageDirectories only has 1 element which is the directory // in AppData. If list of PackageFolders is empty, add the folder in AppData to the list since there @@ -1668,17 +1669,21 @@ private IPreferences CreateOrLoadPreferences(IPreferences preferences) return new PreferenceSettings(); } - private static void InitializePreferences(IPreferences preferences) + private void InitializePreferences() { - ProtoCore.Mirror.MirrorData.PrecisionFormat = DynamoUnits.Display.PrecisionFormat = preferences.NumberFormat; - - var settings = preferences as PreferenceSettings; - if (settings != null) + if (PreferenceSettings != null) { - settings.InitializeNamespacesToExcludeFromLibrary(); + ProtoCore.Mirror.MirrorData.PrecisionFormat = DynamoUnits.Display.PrecisionFormat = PreferenceSettings.NumberFormat; + PreferenceSettings.InitializeNamespacesToExcludeFromLibrary(); + UpdateBackupLocation(PreferenceSettings.BackupLocation); } } + public void UpdateBackupLocation(string selectedBackupLocation) + { + pathManager.UpdateBackupLocation(selectedBackupLocation); + } + /// /// Responds to property update notifications on the preferences, /// and synchronizes with the Units Manager. diff --git a/src/DynamoCoreWpf/Properties/Resources.Designer.cs b/src/DynamoCoreWpf/Properties/Resources.Designer.cs index 31ea713a93e..1c4f53f5858 100644 --- a/src/DynamoCoreWpf/Properties/Resources.Designer.cs +++ b/src/DynamoCoreWpf/Properties/Resources.Designer.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version:4.0.30319.42000 @@ -1060,7 +1060,18 @@ public static string CustomColorPickerTitle { return ResourceManager.GetString("CustomColorPickerTitle", resourceCulture); } } - + + /// + /// Looks up a localized string similar to Custom. + /// + public static string CustomColorsPopupTitle + { + get + { + return ResourceManager.GetString("CustomColorsPopupTitle", resourceCulture); + } + } + /// /// Looks up a localized string similar to A description that helps people understand what the node might be used for.. /// @@ -6634,6 +6645,15 @@ public static string PreferencesSettingCustomPythomTemplate { } } + /// + /// Looks up a localized string similar to Default Backup Location. + /// + public static string PreferencesSettingDefaultBackupLocation { + get { + return ResourceManager.GetString("PreferencesSettingDefaultBackupLocation", resourceCulture); + } + } + /// /// Looks up a localized string similar to Use Hardware Acceleration. /// diff --git a/src/DynamoCoreWpf/Properties/Resources.en-US.resx b/src/DynamoCoreWpf/Properties/Resources.en-US.resx index f9439091191..7c916df574e 100644 --- a/src/DynamoCoreWpf/Properties/Resources.en-US.resx +++ b/src/DynamoCoreWpf/Properties/Resources.en-US.resx @@ -3364,6 +3364,10 @@ You can manage this in Preferences -> Security. Auto-Backup Interval Setting menu | Auto-Backup Interval + + Default Backup Location + Default Backup Location + Maximum Number of Recent Files Setting menu | Maximum Number of Recent Files diff --git a/src/DynamoCoreWpf/Properties/Resources.resx b/src/DynamoCoreWpf/Properties/Resources.resx index 58794b5bd6f..b40ea0a5d3d 100644 --- a/src/DynamoCoreWpf/Properties/Resources.resx +++ b/src/DynamoCoreWpf/Properties/Resources.resx @@ -3351,6 +3351,10 @@ You can manage this in Preferences -> Security. Auto-Backup Interval Setting menu | Auto-Backup Interval + + Default Backup Location + Default Backup Location + Maximum Number of Recent Files Setting menu | Maximum Number of Recent Files diff --git a/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs b/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs index 2ec1773e013..47e847072b7 100644 --- a/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs @@ -224,6 +224,22 @@ public int BackupIntervalInMinutes } } + /// + /// Backup files path + /// + public string BackupLocation + { + get + { + return preferenceSettings.BackupLocation; + } + set + { + preferenceSettings.BackupLocation = value; + RaisePropertyChanged(nameof(BackupLocation)); + } + } + /// /// Maximum number of recent files on startup page. /// @@ -1151,6 +1167,7 @@ public PreferencesViewModel(DynamoViewModel dynamoViewModel) Res.DynamoViewSettingMenuNumber00000 }; SelectedNumberFormat = preferenceSettings.NumberFormat; + BackupLocation = preferenceSettings.BackupLocation; runSettingsIsChecked = preferenceSettings.DefaultRunType; RunPreviewIsChecked = preferenceSettings.ShowRunPreview; @@ -1212,7 +1229,7 @@ public virtual void OnRequestShowFileDialog(object sender, PythonTemplatePathEve public DelegateCommand AddPythonPathCommand { get; private set; } public DelegateCommand DeletePythonPathCommand { get; private set; } - public DelegateCommand UpdatePythonPathCommand { get; private set; } + public DelegateCommand UpdatePythonPathCommand { get; private set; } private void InitializeCommands() { @@ -1221,6 +1238,12 @@ private void InitializeCommands() UpdatePythonPathCommand = new DelegateCommand(p => UpdatePathAt()); } + public void UpdateBackupLocation(string backupLocation) + { + BackupLocation = backupLocation; + dynamoViewModel.Model.UpdateBackupLocation(backupLocation); + } + // Add python template path private void AddPath() { @@ -1415,6 +1438,9 @@ private void Model_PropertyChanged(object sender, PropertyChangedEventArgs e) case nameof(BackupIntervalInMinutes): description = Res.ResourceManager.GetString(nameof(Res.PreferencesSettingBackupInterval), System.Globalization.CultureInfo.InvariantCulture); goto default; + case nameof(BackupLocation): + description = Res.ResourceManager.GetString(nameof(Res.PreferencesSettingDefaultBackupLocation), System.Globalization.CultureInfo.InvariantCulture); + goto default; case nameof(MaxNumRecentFiles): description = Res.ResourceManager.GetString(nameof(Res.PreferencesSettingMaxRecentFiles), System.Globalization.CultureInfo.InvariantCulture); UpdateRecentFiles(); diff --git a/src/DynamoCoreWpf/Views/Core/CustomColorPicker.xaml b/src/DynamoCoreWpf/Views/Core/CustomColorPicker.xaml index da283bc40dd..f15e26b2805 100644 --- a/src/DynamoCoreWpf/Views/Core/CustomColorPicker.xaml +++ b/src/DynamoCoreWpf/Views/Core/CustomColorPicker.xaml @@ -314,7 +314,7 @@ FontFamily="{StaticResource ArtifaktElementRegular}" FontSize="20" Foreground="Black" - Text="X" /> + Text="{x:Static p:Resources.CustomColorsPopupTitle}" /> diff --git a/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml.cs b/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml.cs index 42185b9ebea..2c24c1408b8 100644 --- a/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml.cs +++ b/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml.cs @@ -497,7 +497,7 @@ private void SelectBackupLocation(object sender, RoutedEventArgs e) { var dialog = new DynamoFolderBrowserDialog { - Title = "New Backup Location",//Res.ExportSettingsDialogTitle, + Title = Res.PreferencesSettingsBackupLocationDialogTitle, Owner = this }; @@ -615,7 +615,7 @@ private void UpdateZoomScaleValueLabel(Slider slider, Label label) double percentage = slider.Value - 25; //The margin value for the label goes from - 480 to 310, resulting in 790 pixels from the starting point to the end. - //We also standardized the values ​​of the percentage(from 0 to 275). + //We also standardized the values ​​of the percentage(from 0 to 275). //The value is decreased to 480 because the margin begins at - 480 //This is the relation between the margin in pixels and the value of the percentage double marginValue = (790 * percentage / 275) - 480; From 16c3e071d07793c9536f2e9c9ec103fbbd42b475 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesus=20Alfredo=20Alvi=C3=B1o=20Lescano?= Date: Fri, 24 Mar 2023 12:42:23 -0500 Subject: [PATCH 04/14] Dealing with invalid Bakup location path and UI titles --- src/DynamoCore/Configuration/PathManager.cs | 9 +++++++-- src/DynamoCore/Models/DynamoModel.cs | 8 ++++++-- .../Properties/Resources.Designer.cs | 18 ++++++++++++++++++ .../Properties/Resources.en-US.resx | 6 ++++++ src/DynamoCoreWpf/Properties/Resources.resx | 6 ++++++ .../ViewModels/Menu/PreferencesViewModel.cs | 15 ++++++++++++--- .../Views/Menu/PreferencesView.xaml.cs | 18 +++++++++++------- 7 files changed, 66 insertions(+), 14 deletions(-) diff --git a/src/DynamoCore/Configuration/PathManager.cs b/src/DynamoCore/Configuration/PathManager.cs index 92103b16adb..25c233a7858 100644 --- a/src/DynamoCore/Configuration/PathManager.cs +++ b/src/DynamoCore/Configuration/PathManager.cs @@ -460,14 +460,19 @@ internal void EnsureDirectoryExistence(List exceptions) exceptions.RemoveAll(x => x == null); // Remove all null entries. } - internal void UpdateBackupLocation(string backupLocation) + internal bool UpdateBackupLocation(string newBackupLocation) { + var isValidFolder = PathHelper.CreateFolderIfNotExist(newBackupLocation); + if (isValidFolder != null) + return false; + string defaultBackupLocation = BackupDirectory; - string preferenceBackupLocation = backupLocation; + string preferenceBackupLocation = newBackupLocation; if (!defaultBackupLocation.Equals(preferenceBackupLocation) && !string.IsNullOrEmpty(preferenceBackupLocation)) { backupDirectory = preferenceBackupLocation; } + return true; } /// diff --git a/src/DynamoCore/Models/DynamoModel.cs b/src/DynamoCore/Models/DynamoModel.cs index a21df765484..d4201342005 100644 --- a/src/DynamoCore/Models/DynamoModel.cs +++ b/src/DynamoCore/Models/DynamoModel.cs @@ -1675,13 +1675,17 @@ private void InitializePreferences() { ProtoCore.Mirror.MirrorData.PrecisionFormat = DynamoUnits.Display.PrecisionFormat = PreferenceSettings.NumberFormat; PreferenceSettings.InitializeNamespacesToExcludeFromLibrary(); + if (string.IsNullOrEmpty(PreferenceSettings.BackupLocation)) + { + PreferenceSettings.BackupLocation = pathManager.BackupDirectory; + } UpdateBackupLocation(PreferenceSettings.BackupLocation); } } - public void UpdateBackupLocation(string selectedBackupLocation) + public bool UpdateBackupLocation(string selectedBackupLocation) { - pathManager.UpdateBackupLocation(selectedBackupLocation); + return pathManager.UpdateBackupLocation(selectedBackupLocation); } /// diff --git a/src/DynamoCoreWpf/Properties/Resources.Designer.cs b/src/DynamoCoreWpf/Properties/Resources.Designer.cs index a5e9873e64e..283cbce26d3 100644 --- a/src/DynamoCoreWpf/Properties/Resources.Designer.cs +++ b/src/DynamoCoreWpf/Properties/Resources.Designer.cs @@ -6672,6 +6672,24 @@ public static string PreferencesSettingMaxRecentFiles { } } + /// + /// Looks up a localized string similar to Invalid Backup location. + /// + public static string PreferencesSettingsBackupFailedMessage { + get { + return ResourceManager.GetString("PreferencesSettingsBackupFailedMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Backup location Failed. + /// + public static string PreferencesSettingsBackupFailedTitle { + get { + return ResourceManager.GetString("PreferencesSettingsBackupFailedTitle", resourceCulture); + } + } + /// /// Looks up a localized string similar to Select Folder to Backup. /// diff --git a/src/DynamoCoreWpf/Properties/Resources.en-US.resx b/src/DynamoCoreWpf/Properties/Resources.en-US.resx index 5bfb339cba8..fd0a2e67435 100644 --- a/src/DynamoCoreWpf/Properties/Resources.en-US.resx +++ b/src/DynamoCoreWpf/Properties/Resources.en-US.resx @@ -3374,6 +3374,12 @@ You can manage this in Preferences -> Security. Select Folder to Backup + + Backup location Failed + + + Invalid Backup location + Maximum Number of Recent Files Setting menu | Maximum Number of Recent Files diff --git a/src/DynamoCoreWpf/Properties/Resources.resx b/src/DynamoCoreWpf/Properties/Resources.resx index 7292147a72b..f9e41f28ab5 100644 --- a/src/DynamoCoreWpf/Properties/Resources.resx +++ b/src/DynamoCoreWpf/Properties/Resources.resx @@ -3361,6 +3361,12 @@ You can manage this in Preferences -> Security. Select Folder to Backup + + Backup location Failed + + + Invalid Backup location + Maximum Number of Recent Files Setting menu | Maximum Number of Recent Files diff --git a/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs b/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs index 47e847072b7..700c1046ee5 100644 --- a/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs @@ -1238,10 +1238,19 @@ private void InitializeCommands() UpdatePythonPathCommand = new DelegateCommand(p => UpdatePathAt()); } - public void UpdateBackupLocation(string backupLocation) + public bool UpdateBackupLocation(string newBackupLocation) { - BackupLocation = backupLocation; - dynamoViewModel.Model.UpdateBackupLocation(backupLocation); + var previousBackupLocation = BackupLocation; + BackupLocation = newBackupLocation; + + if (dynamoViewModel.Model.UpdateBackupLocation(newBackupLocation)) + { + return true; + } else + { + BackupLocation = previousBackupLocation; + return false; + } } // Add python template path diff --git a/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml.cs b/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml.cs index 2c24c1408b8..2d6cc2d86f2 100644 --- a/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml.cs +++ b/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml.cs @@ -506,20 +506,24 @@ private void SelectBackupLocation(object sender, RoutedEventArgs e) if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { - string selectedBackupLocation = dialog.SelectedPath; - - viewModel.UpdateBackupLocation(selectedBackupLocation); - try { - //Analytics.TrackEvent(Actions.Export, Categories.Preferences); + string selectedBackupLocation = dialog.SelectedPath; + if (!viewModel.UpdateBackupLocation(selectedBackupLocation)) + { + Wpf.Utilities.MessageBoxService.Show( + this, + Res.PreferencesSettingsBackupFailedMessage, + Res.PreferencesSettingsBackupFailedTitle, + MessageBoxButton.OK, MessageBoxImage.Exclamation); + } } catch (Exception ex) { Wpf.Utilities.MessageBoxService.Show( this, ex.Message, - Res.ExportSettingsFailedMessage, + Res.PreferencesSettingsBackupFailedTitle, MessageBoxButton.OK, MessageBoxImage.Exclamation); } } @@ -615,7 +619,7 @@ private void UpdateZoomScaleValueLabel(Slider slider, Label label) double percentage = slider.Value - 25; //The margin value for the label goes from - 480 to 310, resulting in 790 pixels from the starting point to the end. - //We also standardized the values ​​of the percentage(from 0 to 275). + //We also standardized the values ​​of the percentage(from 0 to 275). //The value is decreased to 480 because the margin begins at - 480 //This is the relation between the margin in pixels and the value of the percentage double marginValue = (790 * percentage / 275) - 480; From a6c8ea65a2e781d0a0734090e1881b2a6cc3280f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesus=20Alfredo=20Alvi=C3=B1o=20Lescano?= Date: Fri, 24 Mar 2023 18:29:55 -0500 Subject: [PATCH 05/14] Add the Reset Backup Location button --- src/DynamoCore/Configuration/PathManager.cs | 18 ++++++----- src/DynamoCore/Models/DynamoModel.cs | 15 ++++++++-- src/DynamoCoreWpf/DynamoCoreWpf.csproj | 2 ++ .../Properties/Resources.Designer.cs | 13 ++++++-- .../Properties/Resources.en-US.resx | 3 ++ src/DynamoCoreWpf/Properties/Resources.resx | 3 ++ src/DynamoCoreWpf/UI/Images/reset-default.png | Bin 0 -> 399 bytes src/DynamoCoreWpf/UI/Images/reset-hover.png | Bin 0 -> 402 bytes .../UI/Themes/Modern/DynamoModern.xaml | 27 +++++++++++++++-- .../ViewModels/Menu/PreferencesViewModel.cs | 28 +++++++++++++++++- .../Views/Menu/PreferencesView.xaml | 14 +++++++++ .../Views/Menu/PreferencesView.xaml.cs | 10 ++++--- 12 files changed, 113 insertions(+), 20 deletions(-) create mode 100644 src/DynamoCoreWpf/UI/Images/reset-default.png create mode 100644 src/DynamoCoreWpf/UI/Images/reset-hover.png diff --git a/src/DynamoCore/Configuration/PathManager.cs b/src/DynamoCore/Configuration/PathManager.cs index 25c233a7858..b883587499c 100644 --- a/src/DynamoCore/Configuration/PathManager.cs +++ b/src/DynamoCore/Configuration/PathManager.cs @@ -79,6 +79,7 @@ class PathManager : IPathManager private readonly string logDirectory; private readonly string samplesDirectory; private string backupDirectory; + private string defaultBackupDirectory; private readonly string preferenceFilePath; private string pythonTemplateFilePath; @@ -232,6 +233,11 @@ public string BackupDirectory get { return backupDirectory; } } + public string DefaultBackupDirectory + { + get { return defaultBackupDirectory; } + } + public string PreferenceFilePath { get { return preferenceFilePath; } @@ -405,6 +411,7 @@ internal PathManager(PathManagerParams pathManagerParams) preferenceFilePath = Path.Combine(userDataDir, PreferenceSettingsFileName); pythonTemplateFilePath = Path.Combine(userDataDir, PythonTemplateFileName); backupDirectory = Path.Combine(userDataDirNoVersion, BackupDirectoryName); + defaultBackupDirectory = backupDirectory; // Common directories. commonDataDir = GetCommonDataFolder(); @@ -462,16 +469,11 @@ internal void EnsureDirectoryExistence(List exceptions) internal bool UpdateBackupLocation(string newBackupLocation) { - var isValidFolder = PathHelper.CreateFolderIfNotExist(newBackupLocation); - if (isValidFolder != null) + bool isValidFolder = PathHelper.CreateFolderIfNotExist(newBackupLocation) == null; + if (!isValidFolder) return false; - string defaultBackupLocation = BackupDirectory; - string preferenceBackupLocation = newBackupLocation; - if (!defaultBackupLocation.Equals(preferenceBackupLocation) && !string.IsNullOrEmpty(preferenceBackupLocation)) - { - backupDirectory = preferenceBackupLocation; - } + backupDirectory = newBackupLocation; return true; } diff --git a/src/DynamoCore/Models/DynamoModel.cs b/src/DynamoCore/Models/DynamoModel.cs index d4201342005..0628d4025d6 100644 --- a/src/DynamoCore/Models/DynamoModel.cs +++ b/src/DynamoCore/Models/DynamoModel.cs @@ -1675,19 +1675,30 @@ private void InitializePreferences() { ProtoCore.Mirror.MirrorData.PrecisionFormat = DynamoUnits.Display.PrecisionFormat = PreferenceSettings.NumberFormat; PreferenceSettings.InitializeNamespacesToExcludeFromLibrary(); + if (string.IsNullOrEmpty(PreferenceSettings.BackupLocation)) { - PreferenceSettings.BackupLocation = pathManager.BackupDirectory; + PreferenceSettings.BackupLocation = pathManager.DefaultBackupDirectory; } UpdateBackupLocation(PreferenceSettings.BackupLocation); } } public bool UpdateBackupLocation(string selectedBackupLocation) - { + { return pathManager.UpdateBackupLocation(selectedBackupLocation); } + public bool IsDefaultBackupLocation() + { + return PreferenceSettings.BackupLocation.Replace(@"\\", @"\").Equals(pathManager.DefaultBackupDirectory.Replace(@"\\", @"\")); + } + + public string DefaultBackupLocation() + { + return pathManager.DefaultBackupDirectory; + } + /// /// Responds to property update notifications on the preferences, /// and synchronizes with the Units Manager. diff --git a/src/DynamoCoreWpf/DynamoCoreWpf.csproj b/src/DynamoCoreWpf/DynamoCoreWpf.csproj index 0032451cff1..59a4e26ac9a 100644 --- a/src/DynamoCoreWpf/DynamoCoreWpf.csproj +++ b/src/DynamoCoreWpf/DynamoCoreWpf.csproj @@ -1625,6 +1625,8 @@ + + diff --git a/src/DynamoCoreWpf/Properties/Resources.Designer.cs b/src/DynamoCoreWpf/Properties/Resources.Designer.cs index 283cbce26d3..18353120083 100644 --- a/src/DynamoCoreWpf/Properties/Resources.Designer.cs +++ b/src/DynamoCoreWpf/Properties/Resources.Designer.cs @@ -2876,9 +2876,9 @@ public static string FilePathConverterNoFileSelected { return ResourceManager.GetString("FilePathConverterNoFileSelected", resourceCulture); } } - + /// - /// Looks up a localized string similar to Trust this file’s location in the future.. + /// Looks up a localized string similar to Trust this file’s location in the future.. /// public static string FileTrustWarningCheckBoxText { get { @@ -6672,6 +6672,15 @@ public static string PreferencesSettingMaxRecentFiles { } } + /// + /// Looks up a localized string similar to Reset Backup Location. + /// + public static string PreferencesSettingResetBackupLocationTooltip { + get { + return ResourceManager.GetString("PreferencesSettingResetBackupLocationTooltip", resourceCulture); + } + } + /// /// Looks up a localized string similar to Invalid Backup location. /// diff --git a/src/DynamoCoreWpf/Properties/Resources.en-US.resx b/src/DynamoCoreWpf/Properties/Resources.en-US.resx index fd0a2e67435..bfc392cabb7 100644 --- a/src/DynamoCoreWpf/Properties/Resources.en-US.resx +++ b/src/DynamoCoreWpf/Properties/Resources.en-US.resx @@ -3371,6 +3371,9 @@ You can manage this in Preferences -> Security. Edit Backup Location + + Reset Backup Location + Select Folder to Backup diff --git a/src/DynamoCoreWpf/Properties/Resources.resx b/src/DynamoCoreWpf/Properties/Resources.resx index f9e41f28ab5..8d60512bc48 100644 --- a/src/DynamoCoreWpf/Properties/Resources.resx +++ b/src/DynamoCoreWpf/Properties/Resources.resx @@ -3358,6 +3358,9 @@ You can manage this in Preferences -> Security. Edit Backup Location + + Reset Backup Location + Select Folder to Backup diff --git a/src/DynamoCoreWpf/UI/Images/reset-default.png b/src/DynamoCoreWpf/UI/Images/reset-default.png new file mode 100644 index 0000000000000000000000000000000000000000..ac25b8e62eaef357f657a05d014616b77cd26b8e GIT binary patch literal 399 zcmV;A0dW3_P)fK-rlu-ie>K`0?d1OoB~*^$?4v?Gmd z&CGlAW^B$ZRun}jggD?D!aaD$IloNP^qOT^M>X68RaJFZmgU6kMg-4s9Dj3SS5b6% zz|m@jzf=r=)MN8J?@=qx%5@OBzB!H)BuTPIVL(!4%ESGImu0!wBmofUfu?D^VHkeY z%mU1<=}6={fX*n2lx#A8m!@fC>9_*Mas24}{#_fvS91y*h!zG}U+5mHSY6jgDU)Hw z&%4i|mZFo;vUUdOtQVL730gnFl~nu;nx|tH1HlELCxG%*3A>%omv8E;4zBB-O zgFq17<#VTlu;L?e3muRW(m`B-(?RSGoDQ4{k`7D<$&CXbwge=&As}xO)>`AWtcoW21U@ zz;s-r&||IxFp!oUByy4MJ3$a^42+856aJyK;Hy3@6Nm-|z&HC}$Dd)^Z;MQ_uY1;! zFXy=k4a?C%=-~uVwyJgUMt+|piM)`C6;MBtnJowCDT<;UJ+7n{Md7=yOFQ)yL*Ms@ wG)-G}k6}PN+A;jal(%jHNfM-Qz$i`mUm5tBl;vV1%m4rY07*qoM6N<$f>-yVkpKVy literal 0 HcmV?d00001 diff --git a/src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml b/src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml index 0e73540a481..a7052948ab0 100644 --- a/src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml +++ b/src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml @@ -3202,6 +3202,27 @@ + +