Skip to content

Commit

Permalink
optimize save config method
Browse files Browse the repository at this point in the history
  • Loading branch information
Scighost committed Jan 14, 2024
1 parent 07877c5 commit ef8ab71
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/Starward/AppConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public static int WindowSizeMode
set
{
windowSizeMode = value;
SaveConfiguration();
}
}

Expand All @@ -92,7 +91,6 @@ public static string? Language
set
{
language = value;
SaveConfiguration();
}
}

Expand All @@ -103,7 +101,6 @@ public static string UserDataFolder
set
{
userDataFolder = value;
SaveConfiguration();
}
}

Expand Down Expand Up @@ -165,7 +162,7 @@ private static void Initialize()



private static void SaveConfiguration()
public static void SaveConfiguration()
{
try
{
Expand Down
1 change: 1 addition & 0 deletions src/Starward/MyWindows/WelcomeWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public void ApplySetting()
AppConfig.UserDataFolder = UserDataFolder;
AppConfig.Language = TextLanguage;
AppConfig.WindowSizeMode = WindowSizeMode;
AppConfig.SaveConfiguration();
}


Expand Down
2 changes: 2 additions & 0 deletions src/Starward/Pages/Setting/AppearanceSettingPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ private void ComboBox_Language_SelectionChanged(object sender, SelectionChangedE
}
this.Bindings.Update();
WeakReferenceMessenger.Default.Send(new LanguageChangedMessage(lang!, CultureInfo.CurrentUICulture));
AppConfig.SaveConfiguration();
}
}
}
Expand Down Expand Up @@ -144,6 +145,7 @@ private void RadioButton_WindowSize_Click(object sender, RoutedEventArgs e)
AppConfig.WindowSizeMode = index;
MainWindow.Current.ChangeWindowSize();
WeakReferenceMessenger.Default.Send(new WindowSizeModeChangedMessage(index));
AppConfig.SaveConfiguration();
}
}
catch { }
Expand Down
1 change: 1 addition & 0 deletions src/Starward/Pages/Setting/FileSettingPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ private async Task ChangeDataFolderAsync()
{
AppConfig.UserDataFolder = null!;
AppConfig.ResetServiceProvider();
AppConfig.SaveConfiguration();
App.Current.CloseSystemTray();
App.Current.SwitchMainWindow(new WelcomeWindow());
}
Expand Down

0 comments on commit ef8ab71

Please sign in to comment.