diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs index 77b9ab3cf..d7bae5e80 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs @@ -15,8 +15,6 @@ using Flow.Launcher.ViewModel; using ModernWpf; using ThemeManager = Flow.Launcher.Core.Resource.ThemeManager; using ThemeManagerForColorSchemeSwitch = ModernWpf.ThemeManager; -using static Flow.Launcher.Core.Resource.Theme; -using System.Windows.Interop; namespace Flow.Launcher.SettingPages.ViewModels; @@ -38,8 +36,11 @@ public partial class SettingsPaneThemeViewModel : BaseModel ThemeManager.Instance.ChangeTheme(value.FileNameWithoutExtension); if (ThemeManager.Instance.BlurEnabled && Settings.UseDropShadowEffect == false) + { DropShadowEffect = true; OnPropertyChanged(nameof(IsDropShadowEnabled)); + } + ThemeManager.Instance.RefreshFrame(); //ThemeManager.Instance.SetBlurForWindow(); } @@ -107,6 +108,24 @@ public partial class SettingsPaneThemeViewModel : BaseModel public class ColorSchemeData : DropdownDataGeneric { } public List ColorSchemes { get; } = DropdownDataGeneric.GetValues("ColorScheme"); + public string ColorScheme + { + get => Settings.ColorScheme; + set + { + ThemeManagerForColorSchemeSwitch.Current.ApplicationTheme = value switch + { + Constant.Light => ApplicationTheme.Light, + Constant.Dark => ApplicationTheme.Dark, + Constant.System => null, + _ => ThemeManagerForColorSchemeSwitch.Current.ApplicationTheme + }; + + ThemeManager.Instance.RefreshFrame(); + + Settings.ColorScheme = value; + } + } public List TimeFormatList { get; } = new() { @@ -209,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)) @@ -230,9 +248,6 @@ public partial class SettingsPaneThemeViewModel : BaseModel } } - - - public bool UseSound { get => Settings.UseSound; @@ -457,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)); } - public void UpdateColorScheme() - { - ThemeManagerForColorSchemeSwitch.Current.ApplicationTheme = Settings.ColorScheme switch - { - Constant.Light => ApplicationTheme.Light, - Constant.Dark => ApplicationTheme.Dark, - Constant.System => null, - _ => ThemeManagerForColorSchemeSwitch.Current.ApplicationTheme - }; - ThemeManager.Instance.RefreshFrame(); - } - - public SettingsPaneThemeViewModel(Settings settings) - { - Settings = settings; - } - [RelayCommand] public void Reset() { diff --git a/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml b/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml index ec068cb5c..d45556e1d 100644 --- a/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml +++ b/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml @@ -688,9 +688,8 @@ DisplayMemberPath="Display" FontSize="14" ItemsSource="{Binding ColorSchemes}" - SelectedValue="{Binding Settings.ColorScheme}" - SelectedValuePath="Value" - SelectionChanged="Selector_OnSelectionChanged" /> + SelectedValue="{Binding ColorScheme, Mode=TwoWay}" + SelectedValuePath="Value" /> diff --git a/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml.cs b/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml.cs index 7f32728c2..18d3a31a2 100644 --- a/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml.cs +++ b/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml.cs @@ -1,7 +1,4 @@ using System; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Media; using System.Windows.Navigation; using Flow.Launcher.SettingPages.ViewModels; using Page = ModernWpf.Controls.Page; @@ -25,9 +22,4 @@ public partial class SettingsPaneTheme : Page base.OnNavigatedTo(e); } - - private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArgs e) - { - _viewModel.UpdateColorScheme(); - } }