Пример #1
0
 public static void SetTheme(ApplicationTheme theme)
 {
     if (ApplicationData.Current.LocalSettings.Values.ContainsKey(ThemeTypeKey))
     {
         ApplicationData.Current.LocalSettings.Values[ThemeTypeKey] = theme.ToString();
     }
     else
     {
         ApplicationData.Current.LocalSettings.Values.Add(ThemeTypeKey, theme.ToString());
     }
 }
Пример #2
0
        public static void UpdateAppTheme(ApplicationTheme theme)
        {
            ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;

            localSettings.Values.TryGetValue(_themeKey, out var previousTheme);

            if ((string)previousTheme == theme.ToString())
            {
                return;
            }

            localSettings.Values[_themeKey] = theme.ToString();
            App.UpdateAppTheme();
        }
Пример #3
0
        public static string ToThemeName(this ApplicationTheme theme)
        {
            switch (theme)
            {
            // This could probably all be done via Enum.ToString(),
            // but if, for some reason, it gets refactored, I want to ensure backwards
            // compatibility.
            case ApplicationTheme.Light:
                return("Light");

            case ApplicationTheme.Dark:
                return("Dark");

            default:
                return(theme.ToString());
            }
        }
Пример #4
0
        private static ElementTheme LoadThemeFromSettingsAsync(ApplicationTheme requestedTheme)
        {
            var settingsAdapter = new SettingsAdapter();
            var settingsFacade  = new SettingsFacade(settingsAdapter);

            ElementTheme cacheTheme = ElementTheme.Default;

            string themeName = settingsAdapter.GetValue(SETTINGS_KEY, string.Empty);

            if (!string.IsNullOrEmpty(themeName))
            {
                Enum.TryParse(themeName, out cacheTheme);
            }

            if (cacheTheme == ElementTheme.Default && settingsFacade.Theme.ToString() != requestedTheme.ToString())
            {
                ThemeManager.ChangeTheme(Enum.Parse <AppTheme>(requestedTheme.ToString()));
            }

            return(cacheTheme);
        }
Пример #5
0
 public void SetTheme(ApplicationTheme theme)
 {
     _settingsService.SetSetting("Theme", theme.ToString());
 }
Пример #6
0
        internal void UpdateSkin(ApplicationTheme theme)
        {
            ThemeManager.Current.ApplicationTheme = theme;
            var demoResources = new ResourceDictionary
            {
                Source = PackUriHelper.GetAbsoluteUri("HandyControlDemo", $"/Resources/Themes/Basic/Colors/{theme.ToString()}.xaml")
            };

            Resources.MergedDictionaries[0].MergedDictionaries.InsertOrReplace(1, demoResources);
        }