Fix color scheme change issue & Code cleanup

This commit is contained in:
Jack251970 2025-03-14 13:39:04 +08:00
parent caa5a4825d
commit 8484c2b87a

View file

@ -113,7 +113,15 @@ public partial class SettingsPaneThemeViewModel : BaseModel
get => Settings.ColorScheme;
set
{
UpdateColorScheme();
ThemeManagerForColorSchemeSwitch.Current.ApplicationTheme = value switch
{
Infrastructure.UserSettings.ColorSchemes.Light => ApplicationTheme.Light,
Infrastructure.UserSettings.ColorSchemes.Dark => ApplicationTheme.Dark,
Infrastructure.UserSettings.ColorSchemes.System => null,
_ => ThemeManagerForColorSchemeSwitch.Current.ApplicationTheme
};
ThemeManager.Instance.RefreshFrame();
Settings.ColorScheme = value;
}
@ -220,9 +228,8 @@ public partial class SettingsPaneThemeViewModel : BaseModel
public BackdropTypes BackdropType
{
get => Enum.IsDefined(typeof(BackdropTypes), Settings.BackdropType)
? (BackdropTypes)Settings.BackdropType
? Settings.BackdropType
: BackdropTypes.None;
set
{
if (!Enum.IsDefined(typeof(BackdropTypes), value))
@ -241,9 +248,6 @@ public partial class SettingsPaneThemeViewModel : BaseModel
}
}
public bool UseSound
{
get => Settings.UseSound;
@ -468,29 +472,17 @@ public partial class SettingsPaneThemeViewModel : BaseModel
public string ThemeImage => Constant.QueryTextBoxIconImagePath;
public SettingsPaneThemeViewModel(Settings settings)
{
Settings = settings;
}
[RelayCommand]
private void OpenThemesFolder()
{
App.API.OpenDirectory(Path.Combine(DataLocation.DataDirectory(), Constant.Themes));
}
private void UpdateColorScheme()
{
ThemeManagerForColorSchemeSwitch.Current.ApplicationTheme = Settings.ColorScheme switch
{
Infrastructure.UserSettings.ColorSchemes.Light => ApplicationTheme.Light,
Infrastructure.UserSettings.ColorSchemes.Dark => ApplicationTheme.Dark,
Infrastructure.UserSettings.ColorSchemes.System => null,
_ => ThemeManagerForColorSchemeSwitch.Current.ApplicationTheme
};
ThemeManager.Instance.RefreshFrame();
}
public SettingsPaneThemeViewModel(Settings settings)
{
Settings = settings;
}
[RelayCommand]
public void Reset()
{