コード例 #1
0
 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");
     }
 }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
ファイル: Internationalization.cs プロジェクト: lovewitty/Wox
        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);
        }
コード例 #4
0
        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);
            }
        }