private void ApplyAppTheme(AppThemeData tgtThemeData)
        {
            Tuple <AppTheme, Accent> appStyle = ThemeManager.DetectAppStyle(Application.Current);
            AppTheme theme = ThemeManager.GetAppTheme(tgtThemeData.Name);

            ThemeManager.ChangeAppStyle(Application.Current, appStyle.Item2, theme);
        }
示例#2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            ExceptionHandler.Init();

            Thread.CurrentThread.CurrentCulture   = new CultureInfo("ru-RU");
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("ru-RU");
            FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement),
                                                               new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

            Properties.Settings df    = Shell.Properties.Settings.Default;
            AppThemeData        theme = new AppThemeData()
            {
                Name = df.UserTheme
            };

            theme.ChangeTheme();
            AppThemeData accent = new AppThemeData()
            {
                Name = df.UserAccent
            };

            accent.ChangeAccent();

            base.OnStartup(e);
#if (DEBUG)
            //RunInDebugMode();
            RunInReleaseMode();
#else
            RunInReleaseMode();
#endif
            //ShutdownMode = ShutdownMode.OnMainWindowClose;
        }
示例#3
0
 /// <summary>
 /// 修改风格
 /// </summary>
 /// <param name="obj"></param>
 private void ChangeAppTheme(object obj)
 {
     if (obj != null && obj is AppThemeData)
     {
         m_CurrAppTheme = (obj as AppThemeData);
         var theme    = ThemeManager.DetectAppStyle(Application.Current);
         var appTheme = ThemeManager.GetAppTheme(m_CurrAppTheme.Name);
         ThemeManager.ChangeAppStyle(Application.Current, theme.Item2, appTheme);
     }
 }
示例#4
0
        public PreviewData(AccentColorData accentColor, AppThemeData appTheme)
        {
            AccentColorData = accentColor;
            AppThemeData    = appTheme;
            foreach (var themeSetting in AccentColorData.ThemeSettings)
            {
                themeSetting.ValueChanged += themeSetting_ValueChanged;
            }

            foreach (var themeSetting in AppThemeData.ThemeSettings)
            {
                themeSetting.ValueChanged += themeSetting_ValueChanged;
            }
        }
        private void LoadColrAndThemeFromSettings()
        {
            // get from config object the settings fro Coloer and Theme
            string colorSetting = _userConfigService.GetConfigItemValue(Color_Config_Key);
            string themeSetting = _userConfigService.GetConfigItemValue(Theme_Config_Key);

            // If found, convert to accent color and theme data
            if (colorSetting != String.Empty && themeSetting != String.Empty)
            {
                // Look AccentColor and theme in the available list, save it
                _selectedAccentColorData = _accentColorDataList.FirstOrDefault(a => a.Name == colorSetting);
                // Look Theme Data in the available list, and apply it
                _SelectedAppThemeData = _appThemeDataList.FirstOrDefault(t => t.Name == themeSetting);
            }
        }
        public void InitializeColorAndTheme()
        {
            // if not color and theme has been defined yet, use application current color,
            // otherwise apply the one from the settings
            if (_selectedAccentColorData == null || _SelectedAppThemeData == null)
            {
                // Detect application current Accent Color and Theme
                Tuple <AppTheme, Accent> appStyle = ThemeManager.DetectAppStyle(Application.Current);
                Tuple <AppTheme, Accent> theme    = ThemeManager.DetectAppStyle(Application.Current);

                // Look AccentColor and theme in the available list, save it
                _selectedAccentColorData = _accentColorDataList.FirstOrDefault(a => a.Name == appStyle.Item2.Name);
                // Look Theme Data in the available list, and apply it
                _SelectedAppThemeData = _appThemeDataList.FirstOrDefault(t => t.Name == theme.Item1.Name);
            }

            // Apply color and theme
            ApplyAccentColor(_selectedAccentColorData);
            ApplyAppTheme(_SelectedAppThemeData);
        }
示例#7
0
        public void Refresh()
        {
            var accentColorResources = AccentColorData.GetResourceDictionary();
            var appThemeResources    = AppThemeData.GetResourceDictionary();

            FrameworkElement.Resources.MergedDictionaries.Add(accentColorResources);
            FrameworkElement.Resources.MergedDictionaries.Add(appThemeResources);

            if (_lastColorResourceDictionary != null)
            {
                FrameworkElement.Resources.MergedDictionaries.Remove(_lastColorResourceDictionary);
            }

            if (_lastBaseResourceDictionary != null)
            {
                FrameworkElement.Resources.MergedDictionaries.Remove(_lastBaseResourceDictionary);
            }

            _lastBaseResourceDictionary  = appThemeResources;
            _lastColorResourceDictionary = accentColorResources;
        }
示例#8
0
        private void LoadTheme(AccentColorData accentColor, AppThemeData appTheme, bool editAccentColor)
        {
            CurrentTitle = editAccentColor
                ? Application.Current.Resources["AccentColorString"].ToString()
                : Application.Current.Resources["AppTheme"].ToString();

            var themeToEdit = editAccentColor ? (DataThemeBase)accentColor : appTheme;

            CurrentElement = themeToEdit;
            CurrentView    = new ThemePage();
            var previewData = new PreviewData(accentColor, appTheme)
            {
                FrameworkElement = PreviewControl
            };

            PreviewData    = previewData;
            PreviewControl = new LivePreview();
            previewData.FrameworkElement = PreviewControl;
            previewData.Refresh();
            CanGoBack = true;
        }