From 90fac19c116b5d006df58969de3f26e57262f0c1 Mon Sep 17 00:00:00 2001 From: DavG25 <31524206+DavG25@users.noreply.github.com> Date: Wed, 21 Sep 2022 15:43:14 +0800 Subject: [PATCH] Fix inconsistent theme colors (#30) * Increment version number * Fix theme not syncing together when changed * Fix buttons not changing theme * Fix font missing Co-authored-by: sabihoshi --- GenshinLyreMidiPlayer.WPF/App.xaml | 4 ++-- .../GenshinLyreMidiPlayer.WPF.csproj | 2 +- .../ViewModels/MainWindowViewModel.cs | 14 +++++++++----- .../ViewModels/SettingsPageViewModel.cs | 11 ++++++++++- .../Views/LyrePlayerView.xaml | 15 ++++++++------- .../Views/PlaylistView.xaml | 15 ++++++++------- .../Views/SettingsPageView.xaml | 17 ++++++++--------- 7 files changed, 46 insertions(+), 32 deletions(-) diff --git a/GenshinLyreMidiPlayer.WPF/App.xaml b/GenshinLyreMidiPlayer.WPF/App.xaml index 164e8ce..d5803ba 100644 --- a/GenshinLyreMidiPlayer.WPF/App.xaml +++ b/GenshinLyreMidiPlayer.WPF/App.xaml @@ -44,8 +44,8 @@ - - diff --git a/GenshinLyreMidiPlayer.WPF/GenshinLyreMidiPlayer.WPF.csproj b/GenshinLyreMidiPlayer.WPF/GenshinLyreMidiPlayer.WPF.csproj index adc3e1b..d091a3c 100644 --- a/GenshinLyreMidiPlayer.WPF/GenshinLyreMidiPlayer.WPF.csproj +++ b/GenshinLyreMidiPlayer.WPF/GenshinLyreMidiPlayer.WPF.csproj @@ -6,7 +6,7 @@ true GenshinLyreMidiPlayer.WPF.App app.manifest - 4.0.2 + 4.0.4 item_windsong_lyre.ico enable https://github.com/sabihoshi/GenshinLyreMidiPlayer diff --git a/GenshinLyreMidiPlayer.WPF/ViewModels/MainWindowViewModel.cs b/GenshinLyreMidiPlayer.WPF/ViewModels/MainWindowViewModel.cs index 89de7d4..37e432b 100644 --- a/GenshinLyreMidiPlayer.WPF/ViewModels/MainWindowViewModel.cs +++ b/GenshinLyreMidiPlayer.WPF/ViewModels/MainWindowViewModel.cs @@ -60,10 +60,14 @@ public void Navigate(INavigation sender, RoutedNavigationEventArgs args) public void ToggleTheme() { - ThemeManager.Current.ApplicationTheme - = _theme.GetTheme() is ThemeType.Dark - ? ApplicationTheme.Light - : ApplicationTheme.Dark; + ThemeManager.Current.ApplicationTheme = _theme.GetTheme() switch + { + ThemeType.Unknown => ApplicationTheme.Dark, + ThemeType.Dark => ApplicationTheme.Light, + ThemeType.Light => ApplicationTheme.Dark, + ThemeType.HighContrast => ApplicationTheme.Dark, + _ => ApplicationTheme.Dark + }; SettingsView.OnThemeChanged(); } @@ -87,7 +91,7 @@ public void SearchSong(AutoSuggestBox sender, TextChangedEventArgs e) protected override async void OnViewLoaded() { Navigation = ((MainWindowView) View).RootNavigation; - _theme.SetTheme(_theme.GetSystemTheme()); + SettingsView.OnThemeChanged(); if (!await SettingsView.TryGetLocationAsync()) _ = SettingsView.LocationMissing(); if (SettingsView.AutoCheckUpdates) diff --git a/GenshinLyreMidiPlayer.WPF/ViewModels/SettingsPageViewModel.cs b/GenshinLyreMidiPlayer.WPF/ViewModels/SettingsPageViewModel.cs index 5e3d913..7993045 100644 --- a/GenshinLyreMidiPlayer.WPF/ViewModels/SettingsPageViewModel.cs +++ b/GenshinLyreMidiPlayer.WPF/ViewModels/SettingsPageViewModel.cs @@ -319,11 +319,20 @@ await Task.Delay(start, PlayTimerToken.Token) [UsedImplicitly] public void OnThemeChanged() { + ThemeManager.Current.ApplicationTheme ??= _theme.GetSystemTheme() switch + { + ThemeType.Unknown => ApplicationTheme.Light, + ThemeType.Dark => ApplicationTheme.Dark, + ThemeType.Light => ApplicationTheme.Light, + ThemeType.HighContrast => ApplicationTheme.Dark, + _ => ApplicationTheme.Light + }; + _theme.SetTheme(ThemeManager.Current.ApplicationTheme switch { ApplicationTheme.Light => ThemeType.Light, ApplicationTheme.Dark => ThemeType.Dark, - _ => _theme.GetSystemTheme() + _ => ThemeType.Light }); Settings.Modify(s => s.AppTheme = (int?) ThemeManager.Current.ApplicationTheme ?? -1); diff --git a/GenshinLyreMidiPlayer.WPF/Views/LyrePlayerView.xaml b/GenshinLyreMidiPlayer.WPF/Views/LyrePlayerView.xaml index 9cdb7a1..a8445a3 100644 --- a/GenshinLyreMidiPlayer.WPF/Views/LyrePlayerView.xaml +++ b/GenshinLyreMidiPlayer.WPF/Views/LyrePlayerView.xaml @@ -25,7 +25,7 @@ @@ -36,24 +36,25 @@ HorizontalAlignment="Center"> @@ -120,7 +121,7 @@ SelectedItem="{Binding SelectedMidiInput}" DisplayMemberPath="DeviceName" /> diff --git a/GenshinLyreMidiPlayer.WPF/Views/PlaylistView.xaml b/GenshinLyreMidiPlayer.WPF/Views/PlaylistView.xaml index de05fc4..17fad14 100644 --- a/GenshinLyreMidiPlayer.WPF/Views/PlaylistView.xaml +++ b/GenshinLyreMidiPlayer.WPF/Views/PlaylistView.xaml @@ -16,7 +16,7 @@ xmlns:viewModels="clr-namespace:GenshinLyreMidiPlayer.WPF.ViewModels" xmlns:midi="clr-namespace:GenshinLyreMidiPlayer.Data.Midi;assembly=GenshinLyreMidiPlayer.Data" - d:DataContext="{d:DesignInstance viewModels:PlaylistViewModel}"> + d:DataContext="{d:DesignInstance Type=viewModels:PlaylistViewModel}"> @@ -39,11 +39,11 @@ - + Glyph="" FontFamily="Segoe MDL2 Assets" /> - + Current song: @@ -124,10 +124,11 @@ Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center"> diff --git a/GenshinLyreMidiPlayer.WPF/Views/SettingsPageView.xaml b/GenshinLyreMidiPlayer.WPF/Views/SettingsPageView.xaml index 5af9ee1..49ae38a 100644 --- a/GenshinLyreMidiPlayer.WPF/Views/SettingsPageView.xaml +++ b/GenshinLyreMidiPlayer.WPF/Views/SettingsPageView.xaml @@ -103,7 +103,7 @@ @@ -112,16 +112,15 @@ - - You are running version - v - + + You are running version + v +