tgjones / gemini

Gemini is an IDE framework similar in concept to the Visual Studio Shell. It uses AvalonDock and has an MVVM architecture based on Caliburn Micro.
Other
1.1k stars 298 forks source link

How to compare ThemeManager.CurrentTheme.Name #336

Closed diluculo closed 2 years ago

diluculo commented 2 years ago

In my project, I'd like to do something when the theme is changed. For this, I did a simple comparison of CurrentTheme.Name. But, the problem is that it is not "Dark" but "어둡게"(dark in Korean) when Korean is selected. Please give me a hint how to know which theme is selected.

My code is:

_themeManager.CurrentThemeChanged += OnThemeChanged;

private void OnThemeChanged(object sender, EventArgs e)
{
   var themeManager = sender as ThemeManager;
   if (themeManager == null) return;

   if (themeManager.CurrentTheme.Name == "Dark")
   { ... }
   else if (themeManager.CurrentTheme.Name == "Blue")
   { ... }
   else
   { ... }
}
EchterAgo commented 2 years ago

You can use themeManager.CurrentTheme is DarkTheme or check themeManager.CurrentTheme.GetType().Name == "DarkTheme".

diluculo commented 2 years ago

@EchterAgo Thanks a million. Both are working.