// Apply Accent color and Theme // Note: Keep color and them in independent functions, otherwise the ChnageAppStyle // works for the last element. There must be a way to apply both at same time private void ApplyAccentColor(AccentColorData tgtAccentColor) { Tuple <AppTheme, Accent> appStyle = ThemeManager.DetectAppStyle(Application.Current); Accent accentColor = ThemeManager.GetAccent(tgtAccentColor.Name); ThemeManager.ChangeAppStyle(Application.Current, accentColor, appStyle.Item1); }
/// <summary> /// 修改样式 /// </summary> /// <param name="obj"></param> private void ChangeAccentColor(object obj) { if (obj != null && obj is AccentColorData) { m_CurrAppAccent = (obj as AccentColorData); var theme = ThemeManager.DetectAppStyle(Application.Current); var accent = ThemeManager.GetAccent(m_CurrAppAccent.Name); ThemeManager.ChangeAppStyle(Application.Current, accent, theme.Item1); } }
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); }
public WindowOptionViewModel(IRegionManager regionManager, IContainerExtension container, IVisualPlugins plugins) : base(regionManager) { AccentColors = AccentColorData.ColorList(); AppThemes = ApplicationThemeData.ColorList(); SelectedTheme = new ReactiveProperty <int>(0).AddTo(Disposable); SelectedTheme.Subscribe(ChangeTheme); //SelectedAccount = new ReactiveProperty<int>(0).AddTo(Disposable); //SelectedAccount.Subscribe(ChangeAccount); //FontSize = new ReactiveProperty<double>(14).AddTo(Disposable); //FontSize.Subscribe(ChangeFontSize); Swatches = new SwatchesProvider().Swatches; PaletteHelper paletteHelper = new PaletteHelper(); ITheme theme = paletteHelper.GetTheme(); }
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; }
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; }