Skip to content

Commit

Permalink
fix: 修复了一个变换版本后回循环使用上一次用户设置导致保存失效的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Shizuku-Nanami committed Oct 18, 2024
1 parent ea88a80 commit 0afc758
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
7 changes: 4 additions & 3 deletions SYSTools/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,10 @@ private void NavigateTo(Type navPageType, NavigationTransitionInfo transitionInf

private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
// 随时升级配置文件并保存到最新版本
Properties.Settings.Default.Upgrade();
Properties.Settings.Default.Save();
if (!System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.PerUserRoamingAndLocal).HasFile)
Properties.Settings.Default.Upgrade();
Properties.Settings.Default.Save();
LoadUserSettings();
// 加载用户配置
LoadUserSettings();
}
Expand Down
7 changes: 3 additions & 4 deletions SYSTools/Pages/Configuration.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ public Configuration()
{
InitializeComponent();
LoadUserSettings();
GlobalSettings.Instance.BackgroundImageBlurRadius = Properties
.Settings
.Default
.BackgroundImageBlurRadius;
DataContext = this;
}

Expand Down Expand Up @@ -74,9 +70,12 @@ private void LoadBackgroundImage(string imagePath)
private void LoadUserSettings()
{
string savedImagePath = Properties.Settings.Default.BackgroundImagePath;
double savedBlurRadius = Properties.Settings.Default.BackgroundImageBlurRadius;
if (!string.IsNullOrWhiteSpace(savedImagePath) && File.Exists(savedImagePath))
{
LoadBackgroundImage(savedImagePath);
GlobalSettings.Instance.BackgroundImageBlurRadius = savedBlurRadius;
GlobalSettings.Instance.BackgroundImagePath = savedImagePath;
}
}
}
Expand Down

0 comments on commit 0afc758

Please sign in to comment.