Skip to content

Commit 7ed0538

Browse files
committed
Feature: UI
1 parent 4b3010b commit 7ed0538

File tree

4 files changed

+54
-12
lines changed

4 files changed

+54
-12
lines changed

Source/NETworkManager.Localization/Resources/Strings.Designer.cs

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Source/NETworkManager.Localization/Resources/Strings.resx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3975,6 +3975,14 @@ If you click Cancel, the profile file will remain unencrypted.</value>
39753975
<data name="RestoreDefaultLocationSettingsMessage" xml:space="preserve">
39763976
<value>The default path is restored and the application is restarted afterwards.
39773977

3978+
You can copy the “settings.json” file from "{0}" to "{1}" to migrate your previous settings, if necessary. The application must be closed for this to prevent the settings from being overwritten.</value>
3979+
</data>
3980+
<data name="ChangeLocationQuestion" xml:space="preserve">
3981+
<value>Change location?</value>
3982+
</data>
3983+
<data name="ChangeLocationSettingsMessage" xml:space="preserve">
3984+
<value>The location is changed and the application is restarted afterwards.
3985+
39783986
You can copy the “settings.json” file from "{0}" to "{1}" to migrate your previous settings, if necessary. The application must be closed for this to prevent the settings from being overwritten.</value>
39793987
</data>
39803988
</root>

Source/NETworkManager/ViewModels/SettingsSettingsViewModel.cs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,22 +205,29 @@ public void SetLocationPathFromDragDrop(string path)
205205
Location = path;
206206
}
207207

208-
public ICommand ChangeLocationCommand => new RelayCommand(_ => ChangeLocationAction());
208+
public ICommand ChangeLocationCommand => new RelayCommand(_ => ChangeLocationAction().ConfigureAwait(false));
209209

210210
private async Task ChangeLocationAction()
211211
{
212-
/*
213-
var result = await DialogHelper.ShowConfirmationMessageAsync(Application.Current.MainWindow,
214-
Strings.ChangeSettingsLocationQuestion,
215-
Strings.SettingsLocationWillBeChangedAndApplicationWillBeRestartedMessage,
216-
ChildWindowIcon.Question,
217-
Strings.Apply);
212+
var result = await DialogHelper.ShowConfirmationMessageAsync(Application.Current.MainWindow,
213+
Strings.ChangeLocationQuestion,
214+
string.Format(Strings.ChangeLocationSettingsMessage, SettingsManager.GetSettingsFolderLocation(), Location),
215+
ChildWindowIcon.Question,
216+
Strings.Change);
217+
218+
if (!result)
219+
return;
220+
221+
// Save settings at the current location before changing it to prevent
222+
// unintended saves to the new location (e.g., triggered by background timer or the app close & restart).
223+
SettingsManager.Save();
218224

225+
// Set new location
226+
LocalSettingsManager.Current.SettingsFolderLocation = Location;
219227
LocalSettingsManager.Save();
220228

221229
// Restart the application
222230
(Application.Current.MainWindow as MainWindow)?.RestartApplication();
223-
*/
224231
}
225232

226233
public ICommand RestoreDefaultLocationCommand => new RelayCommand(_ => RestoreDefaultLocationActionAsync().ConfigureAwait(false));
@@ -229,15 +236,19 @@ private async Task RestoreDefaultLocationActionAsync()
229236
{
230237
var result = await DialogHelper.ShowConfirmationMessageAsync(Application.Current.MainWindow,
231238
Strings.RestoreDefaultLocationQuestion,
232-
string.Format(Strings.RestoreDefaultLocationSettingsMessage, SettingsManager.GetSettingsFolderLocation(),SettingsManager.GetDefaultSettingsFolderLocation()),
239+
string.Format(Strings.RestoreDefaultLocationSettingsMessage, SettingsManager.GetSettingsFolderLocation(), SettingsManager.GetDefaultSettingsFolderLocation()),
233240
ChildWindowIcon.Question,
234241
Strings.Restore);
235242

236243
if (!result)
237244
return;
238245

239-
LocalSettingsManager.Current.SettingsFolderLocation = null;
246+
// Save settings at the current location before changing it to prevent
247+
// unintended saves to the new location (e.g., triggered by background timer or the app close & restart).
248+
SettingsManager.Save();
240249

250+
// Clear custom location to revert to default
251+
LocalSettingsManager.Current.SettingsFolderLocation = null;
241252
LocalSettingsManager.Save();
242253

243254
// Restart the application

Source/NETworkManager/Views/SettingsSettingsView.xaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@
6868
</Style>
6969
</StackPanel.Style>
7070
<Button Style="{StaticResource ImageWithTextButton}"
71-
HorizontalAlignment="Left" Margin="0,0,10,0" >
71+
Command="{Binding ChangeLocationCommand}"
72+
Visibility="{Binding IsLocationChanged, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}"
73+
HorizontalAlignment="Left"
74+
Margin="0,0,10,0" >
7275
<Button.Content>
7376
<Grid>
7477
<Grid.ColumnDefinitions>
@@ -81,7 +84,7 @@
8184
</Rectangle.OpacityMask>
8285
</Rectangle>
8386
<TextBlock Grid.Column="1" Grid.Row="0"
84-
Text="{x:Static localization:Strings.Apply}"
87+
Text="{x:Static localization:Strings.Change}"
8588
Style="{StaticResource ButtonWithImageTextBlock}" />
8689
</Grid>
8790
</Button.Content>

0 commit comments

Comments
 (0)