fix dark theme again
This commit is contained in:
parent
70cef4a361
commit
5234ee06e0
2 changed files with 13 additions and 11 deletions
|
@ -19,17 +19,6 @@ namespace EnvyUpdate
|
|||
{
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
// Remove placeholder light theme and apply system app theme
|
||||
Wpf.Ui.Appearance.Accent.ApplySystemAccent();
|
||||
Application.Current.Resources.MergedDictionaries.RemoveAt(0);
|
||||
ThemesDictionary themedict = new ThemesDictionary();
|
||||
if (Util.IsDarkTheme())
|
||||
themedict.Theme = Wpf.Ui.Appearance.ThemeType.Dark;
|
||||
else
|
||||
themedict.Theme = Wpf.Ui.Appearance.ThemeType.Light;
|
||||
Application.Current.Resources.MergedDictionaries.Add(themedict);
|
||||
// TODO: Watch for theme changes and dynamically update
|
||||
|
||||
// Listen to notification activation
|
||||
ToastNotificationManagerCompat.OnActivated += ToastNotificationManagerCompat_OnActivated;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Microsoft.Toolkit.Uwp.Notifications;
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
@ -54,6 +55,10 @@ namespace EnvyUpdate
|
|||
Environment.Exit(1);
|
||||
}
|
||||
|
||||
// Check dark theme
|
||||
AdjustTheme();
|
||||
SystemEvents.UserPreferenceChanged += AdjustTheme;
|
||||
|
||||
// Delete installed legacy versions, required for people upgrading from very old versions.
|
||||
if (Directory.Exists(GlobalVars.appdata))
|
||||
{
|
||||
|
@ -114,5 +119,13 @@ namespace EnvyUpdate
|
|||
RootNavigation.Navigate(0);
|
||||
}
|
||||
}
|
||||
|
||||
private void AdjustTheme(object sender = null, UserPreferenceChangedEventArgs e = null)
|
||||
{
|
||||
if (Util.IsDarkTheme())
|
||||
Wpf.Ui.Appearance.Theme.Apply(Wpf.Ui.Appearance.ThemeType.Dark, Wpf.Ui.Appearance.BackgroundType.Mica);
|
||||
else
|
||||
Wpf.Ui.Appearance.Theme.Apply(Wpf.Ui.Appearance.ThemeType.Light, Wpf.Ui.Appearance.BackgroundType.Mica);
|
||||
}
|
||||
}
|
||||
}
|
Reference in a new issue