public void ChangeLanguage(Language language) { if (language != null) { string path = GetLanguagePath(language); if (!string.IsNullOrEmpty(path)) { Settings.Language = language.LanguageCode; ResourceMerger.UpdateResource(this); } else { Log.Error($"|Internationalization.ChangeLanguage|Language path can't be found <{path}>"); path = GetLanguagePath(AvailableLanguages.English); if (string.IsNullOrEmpty(path)) { Log.Error($"|Internationalization.ChangeLanguage|Default english language path can't be found <{path}>"); } } } else { Log.Error("|Internationalization.ChangeLanguage|Language can't be null"); } }
public void ChangeTheme(string themeName) { string themePath = GetThemePath(themeName); if (string.IsNullOrEmpty(themePath)) { themePath = GetThemePath("Dark"); if (string.IsNullOrEmpty(themePath)) { throw new Exception("Change theme failed"); } } UserSettingStorage.Instance.Theme = themeName; UserSettingStorage.Instance.Save(); ResourceMerger.UpdateResource(this); // Exception of FindResource can't be cathed if global exception handle is set var isBlur = Application.Current.TryFindResource("ThemeBlurEnabled"); if (isBlur is bool) { SetBlurForWindow(Application.Current.MainWindow, (bool)isBlur); } }
public void ChangeLanguage(Language language) { if (language == null) { throw new WoxI18nException("language can't be null"); } string path = GetLanguagePath(language); if (string.IsNullOrEmpty(path)) { path = GetLanguagePath(AvailableLanguages.English); if (string.IsNullOrEmpty(path)) { throw new Exception("Change Language failed"); } } Settings.Language = language.LanguageCode; ResourceMerger.UpdateResource(this); }
public void ChangeTheme(string themeName) { string themePath = GetThemePath(themeName); if (string.IsNullOrEmpty(themePath)) { themePath = GetThemePath("Dark"); if (string.IsNullOrEmpty(themePath)) { throw new Exception("Change theme failed"); } } Settings.Theme = themeName; ResourceMerger.UpdateResource(this); // Exception of FindResource can't be cathed if global exception handle is set var isBlur = Application.Current.TryFindResource("ThemeBlurEnabled"); if (isBlur is bool && Environment.OSVersion.Version >= new Version(6, 2)) { SetBlurForWindow(Application.Current.MainWindow, (bool)isBlur); } }