Skip to content

Commit 09af5ce

Browse files
committed
Chore: Updates
1 parent 3720946 commit 09af5ce

File tree

2 files changed

+94
-80
lines changed

2 files changed

+94
-80
lines changed

Source/NETworkManager/ViewModels/SettingsProfilesViewModel.cs

Lines changed: 58 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ public string Location
4848
/// </summary>
4949
public bool IsLocationManagedByPolicy => !string.IsNullOrWhiteSpace(PolicyManager.Current?.Profiles_FolderLocation);
5050

51+
/// <summary>
52+
/// Private field of <see cref="IsLocationChanged" /> property.
53+
/// </summary>
5154
private bool _isLocationChanged;
5255

5356
/// <summary>
@@ -66,6 +69,9 @@ public bool IsLocationChanged
6669
}
6770
}
6871

72+
/// <summary>
73+
/// Private field of <see cref="IsDefaultLocation" /> property.
74+
/// </summary>
6975
private bool _isDefaultLocation;
7076

7177
/// <summary>
@@ -84,8 +90,14 @@ public bool IsDefaultLocation
8490
}
8591
}
8692

93+
/// <summary>
94+
/// Private field of <see cref="ProfileFiles" /> property.
95+
/// </summary>
8796
private readonly ICollectionView _profileFiles;
8897

98+
/// <summary>
99+
/// Gets the collection view of profile files.
100+
/// </summary>
89101
public ICollectionView ProfileFiles
90102
{
91103
get => _profileFiles;
@@ -99,8 +111,15 @@ private init
99111
}
100112
}
101113

114+
/// <summary>
115+
/// Private field of <see cref="SelectedProfileFile" /> property.
116+
/// </summary>
117+
102118
private ProfileFileInfo _selectedProfileFile;
103119

120+
/// <summary>
121+
/// Gets or sets the currently selected profile file information.
122+
/// </summary>
104123
public ProfileFileInfo SelectedProfileFile
105124
{
106125
get => _selectedProfileFile;
@@ -114,8 +133,15 @@ public ProfileFileInfo SelectedProfileFile
114133
}
115134
}
116135

136+
/// <summary>
137+
/// Private field of <see cref="IsDailyBackupEnabled" /> property.
138+
/// </summary>
117139
private bool _isDailyBackupEnabled;
118140

141+
142+
/// <summary>
143+
/// Gets or sets a value indicating whether daily backups are enabled.
144+
/// </summary>
119145
public bool IsDailyBackupEnabled
120146
{
121147
get => _isDailyBackupEnabled;
@@ -132,8 +158,14 @@ public bool IsDailyBackupEnabled
132158
}
133159
}
134160

161+
/// <summary>
162+
/// Private field of <see cref="MaximumNumberOfBackups" /> property.
163+
/// </summary>
135164
private int _maximumNumberOfBackups;
136165

166+
/// <summary>
167+
/// Gets or sets the maximum number of backups to keep.
168+
/// </summary>
137169
public int MaximumNumberOfBackups
138170
{
139171
get => _maximumNumberOfBackups;
@@ -153,6 +185,9 @@ public int MaximumNumberOfBackups
153185

154186
#region Constructor, LoadSettings
155187

188+
/// <summary>
189+
/// Initializes a new instance of the <see cref="SettingsProfilesViewModel" /> class and loads the current profile files.
190+
/// </summary>
156191
public SettingsProfilesViewModel()
157192
{
158193
_isLoading = true;
@@ -168,6 +203,9 @@ public SettingsProfilesViewModel()
168203
_isLoading = false;
169204
}
170205

206+
/// <summary>
207+
/// Load view specific settings.
208+
/// </summary>
171209
private void LoadSettings()
172210
{
173211
Location = ProfileManager.GetProfilesFolderLocation();
@@ -179,14 +217,6 @@ private void LoadSettings()
179217
#endregion
180218

181219
#region ICommands & Actions
182-
183-
public ICommand OpenLocationCommand => new RelayCommand(_ => OpenLocationAction());
184-
185-
private static void OpenLocationAction()
186-
{
187-
Process.Start("explorer.exe", ProfileManager.GetProfilesFolderLocation());
188-
}
189-
190220
/// <summary>
191221
/// Gets the command that opens the location folder selection dialog.
192222
/// </summary>
@@ -209,14 +239,16 @@ private void BrowseLocationFolderAction()
209239
Location = dialog.SelectedPath;
210240
}
211241

242+
212243
/// <summary>
213-
/// Sets the location path based on the provided drag-and-drop input.
214-
/// </summary>
215-
/// <param name="path">The path to set as the location.</param>
216-
public void SetLocationPathFromDragDrop(string path)
244+
/// Gets the command that initiates the action to change the location.
245+
/// </summary>
246+
public ICommand OpenLocationCommand => new RelayCommand(_ => OpenLocationAction());
247+
248+
private static void OpenLocationAction()
217249
{
218-
Location = path;
219-
}
250+
Process.Start("explorer.exe", ProfileManager.GetProfilesFolderLocation());
251+
}
220252

221253
/// <summary>
222254
/// Gets the command that initiates the action to change the location.
@@ -238,13 +270,8 @@ private async Task ChangeLocationAction()
238270
if (!result)
239271
return;
240272

241-
// Save settings at the current location before changing it to prevent
242-
// unintended saves to the new location (e.g., triggered by background timer or the app close & restart).
243-
SettingsManager.Save();
244-
245273
// Set new location in SettingsInfo
246274
SettingsManager.Current.Profiles_FolderLocation = Location;
247-
SettingsManager.Save();
248275

249276
// Restart the application
250277
(Application.Current.MainWindow as MainWindow)?.RestartApplication();
@@ -270,14 +297,9 @@ private async Task RestoreDefaultLocationActionAsync()
270297
if (!result)
271298
return;
272299

273-
// Save settings at the current location before changing it to prevent
274-
// unintended saves to the new location (e.g., triggered by background timer or the app close & restart).
275-
SettingsManager.Save();
276-
277300
// Clear custom location to revert to default
278301
SettingsManager.Current.Profiles_FolderLocation = null;
279-
SettingsManager.Save();
280-
302+
281303
// Restart the application
282304
(Application.Current.MainWindow as MainWindow)?.RestartApplication();
283305
}
@@ -551,4 +573,15 @@ await DialogHelper.ShowMessageAsync(Application.Current.MainWindow,
551573
}
552574

553575
#endregion
576+
577+
#region Methods
578+
/// <summary>
579+
/// Sets the location path based on the provided drag-and-drop input.
580+
/// </summary>
581+
/// <param name="path">The path to set as the location.</param>
582+
public void SetLocationPathFromDragDrop(string path)
583+
{
584+
Location = path;
585+
}
586+
#endregion
554587
}

Source/NETworkManager/ViewModels/SettingsSettingsViewModel.cs

Lines changed: 36 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ public SettingsSettingsViewModel()
159159
}
160160

161161
/// <summary>
162-
/// Loads the application settings from the current settings folder location.
163-
/// </summary>
162+
/// Load view specific settings.
163+
/// </summary>
164164
private void LoadSettings()
165165
{
166166
Location = SettingsManager.GetSettingsFolderLocation();
@@ -172,36 +172,6 @@ private void LoadSettings()
172172
#endregion
173173

174174
#region ICommands & Actions
175-
176-
/// <summary>
177-
/// Gets the command that opens a location when executed.
178-
/// </summary>
179-
public ICommand OpenLocationCommand => new RelayCommand(_ => OpenLocationAction());
180-
181-
/// <summary>
182-
/// Opens the settings folder location in Windows Explorer.
183-
/// </summary>
184-
private static void OpenLocationAction()
185-
{
186-
Process.Start("explorer.exe", SettingsManager.GetSettingsFolderLocation());
187-
}
188-
189-
/// <summary>
190-
/// Gets the command that resets the application settings to their default values.
191-
/// </summary>
192-
public ICommand ResetSettingsCommand => new RelayCommand(_ => ResetSettingsAction());
193-
194-
/// <summary>
195-
/// Resets the application settings to their default values.
196-
/// </summary>
197-
private void ResetSettingsAction()
198-
{
199-
ResetSettings().ConfigureAwait(false);
200-
}
201-
202-
#endregion
203-
204-
#region Methods
205175
/// <summary>
206176
/// Gets the command that opens the location folder selection dialog.
207177
/// </summary>
@@ -210,10 +180,7 @@ private void ResetSettingsAction()
210180
/// <summary>
211181
/// Opens a dialog that allows the user to select a folder location and updates the Location property with the
212182
/// selected path if the user confirms the selection.
213-
/// </summary>
214-
/// <remarks>If the Location property is set to a valid directory path, it is pre-selected in the dialog.
215-
/// This method does not return a value and is intended for use in a user interface context where folder selection
216-
/// is required.</remarks>
183+
/// </summary>
217184
private void BrowseLocationFolderAction()
218185
{
219186
using var dialog = new System.Windows.Forms.FolderBrowserDialog();
@@ -228,12 +195,16 @@ private void BrowseLocationFolderAction()
228195
}
229196

230197
/// <summary>
231-
/// Sets the location path based on the provided drag-and-drop input.
232-
/// </summary>
233-
/// <param name="path">The path to set as the location. This value cannot be null or empty.</param>
234-
public void SetLocationPathFromDragDrop(string path)
198+
/// Gets the command that opens a location when executed.
199+
/// </summary>
200+
public ICommand OpenLocationCommand => new RelayCommand(_ => OpenLocationAction());
201+
202+
/// <summary>
203+
/// Opens the settings folder location in Windows Explorer.
204+
/// </summary>
205+
private static void OpenLocationAction()
235206
{
236-
Location = path;
207+
Process.Start("explorer.exe", SettingsManager.GetSettingsFolderLocation());
237208
}
238209

239210
/// <summary>
@@ -242,12 +213,8 @@ public void SetLocationPathFromDragDrop(string path)
242213
public ICommand ChangeLocationCommand => new RelayCommand(_ => ChangeLocationAction().ConfigureAwait(false));
243214

244215
/// <summary>
245-
/// Prompts the user to confirm and then changes the location of the application's settings folder.
216+
/// Prompts the user to confirm and then changes the location of the profiles folder.
246217
/// </summary>
247-
/// <remarks>This method displays a confirmation dialog to the user before changing the settings folder
248-
/// location. If the user confirms, it saves the current settings, updates the settings folder location, and
249-
/// restarts the application to apply the changes. No action is taken if the user cancels the confirmation
250-
/// dialog.</remarks>
251218
/// <returns>A task that represents the asynchronous operation.</returns>
252219
private async Task ChangeLocationAction()
253220
{
@@ -309,19 +276,21 @@ private async Task RestoreDefaultLocationActionAsync()
309276
}
310277

311278
/// <summary>
312-
/// Resets the application settings to their default values and restarts the application after user confirmation.
279+
/// Gets the command that resets the application settings to their default values.
280+
/// </summary>
281+
public ICommand ResetSettingsCommand => new RelayCommand(_ => ResetSettingsAction().ConfigureAwait(false));
282+
283+
/// <summary>
284+
/// Resets the application settings to their default values.
313285
/// </summary>
314-
/// <remarks>Displays a confirmation dialog to the user before proceeding. If the user confirms, the
315-
/// settings are reinitialized to their defaults and the application is restarted. No action is taken if the user
316-
/// cancels the confirmation dialog.</remarks>
317286
/// <returns>A task that represents the asynchronous operation.</returns>
318-
private async Task ResetSettings()
287+
private async Task ResetSettingsAction()
319288
{
320289
var result = await DialogHelper.ShowConfirmationMessageAsync(Application.Current.MainWindow,
321-
Strings.ResetSettingsQuestion,
322-
Strings.SettingsAreResetAndApplicationWillBeRestartedMessage,
323-
ChildWindowIcon.Question,
324-
Strings.Reset);
290+
Strings.ResetSettingsQuestion,
291+
Strings.SettingsAreResetAndApplicationWillBeRestartedMessage,
292+
ChildWindowIcon.Question,
293+
Strings.Reset);
325294

326295
if (!result)
327296
return;
@@ -332,5 +301,17 @@ private async Task ResetSettings()
332301
// Restart the application
333302
(Application.Current.MainWindow as MainWindow)?.RestartApplication();
334303
}
304+
305+
#endregion
306+
307+
#region Methods
308+
/// <summary>
309+
/// Sets the location path based on the provided drag-and-drop input.
310+
/// </summary>
311+
/// <param name="path">The path to set as the location.</param>
312+
public void SetLocationPathFromDragDrop(string path)
313+
{
314+
Location = path;
315+
}
335316
#endregion
336317
}

0 commit comments

Comments
 (0)