Example #1
0
 private void UpdateThemeBorderThickness(IResourceDictionary resources, ThemeViewModel theme)
 {
     if (theme.ThemeBorderThickness != null)
     {
         resources["ThemeBorderThickness"] = theme.ThemeBorderThickness.ToThickness();
     }
 }
        public void Attach(IResourceNode node, IResourceDictionary resources, Action <ThemeViewModel> preview = null)
        {
            var defaultThem = GetTheme(node);

            defaultThem.Name = "BaseLight";

            DefaultTheme = defaultThem;

            if (Themes == null)
            {
                CurrentTheme = defaultThem.Clone();
#pragma warning disable CS0618
                Themes = new ReactiveList <ThemeViewModel>();
                Themes.Add(CurrentTheme);
#pragma warning restore CS0618
            }
            else
            {
                CurrentTheme = Themes.FirstOrDefault();
            }

            _themeObservable = ObserveTheme(resources, CurrentTheme, preview);

            _editorObservable = Changed.Subscribe(x =>
            {
                if (x.PropertyName == nameof(CurrentTheme))
                {
                    _themeObservable?.Dispose();
                    if (CurrentTheme != null)
                    {
                        _themeObservable = ObserveTheme(resources, CurrentTheme, preview);
                    }
                }
            });
        }
Example #3
0
 public void UpdateTheme(IResourceDictionary resources, ThemeViewModel theme)
 {
     UpdateThemeAccent(resources, theme);
     UpdateThemeAccent2(resources, theme);
     UpdateThemeAccent3(resources, theme);
     UpdateThemeAccent4(resources, theme);
     UpdateThemeBackground(resources, theme);
     UpdateThemeBorderLow(resources, theme);
     UpdateThemeBorderMid(resources, theme);
     UpdateThemeBorderHigh(resources, theme);
     UpdateThemeControlLow(resources, theme);
     UpdateThemeControlMid(resources, theme);
     UpdateThemeControlHigh(resources, theme);
     UpdateThemeControlHighlightLow(resources, theme);
     UpdateThemeControlHighlightMid(resources, theme);
     UpdateThemeControlHighlightHigh(resources, theme);
     UpdateThemeForeground(resources, theme);
     UpdateThemeForegroundLow(resources, theme);
     UpdateHighlight(resources, theme);
     UpdateError(resources, theme);
     UpdateErrorLow(resources, theme);
     UpdateThemeBorderThickness(resources, theme);
     UpdateThemeDisabledOpacity(resources, theme);
     UpdateFontSizeSmall(resources, theme);
     UpdateFontSizeNormal(resources, theme);
     UpdateUpdateFontSizeLarge(resources, theme);
     UpdateUpdateScrollBarThickness(resources, theme);
 }
Example #4
0
 public void RemoveTheme(ThemeViewModel theme)
 {
     if (Themes != null)
     {
         Themes.Remove(theme);
         CurrentTheme = Themes.FirstOrDefault();
     }
 }
Example #5
0
 private void UpdateThemeBorderMid(IResourceDictionary resources, ThemeViewModel theme)
 {
     if (theme.ThemeBorderMidColor != null)
     {
         resources["ThemeBorderMidColor"] = theme.ThemeBorderMidColor.ToColor();
         resources["ThemeBorderMidBrush"] = theme.ThemeBorderMidColor.ToBrush();
     }
 }
Example #6
0
 private void UpdateThemeControlHighlightHigh(IResourceDictionary resources, ThemeViewModel theme)
 {
     if (theme.ThemeControlHighlightHighColor != null)
     {
         resources["ThemeControlHighlightHighColor"] = theme.ThemeControlHighlightHighColor.ToColor();
         resources["ThemeControlHighlightHighBrush"] = theme.ThemeControlHighlightHighColor.ToBrush();
     }
 }
Example #7
0
 private void UpdateThemeForegroundLow(IResourceDictionary resources, ThemeViewModel theme)
 {
     if (theme.ThemeForegroundLowColor != null)
     {
         resources["ThemeForegroundLowColor"] = theme.ThemeForegroundLowColor.ToColor();
         resources["ThemeForegroundLowBrush"] = theme.ThemeForegroundLowColor.ToBrush();
     }
 }
Example #8
0
 private void UpdateHighlight(IResourceDictionary resources, ThemeViewModel theme)
 {
     if (theme.HighlightColor != null)
     {
         resources["HighlightColor"] = theme.HighlightColor.ToColor();
         resources["HighlightBrush"] = theme.HighlightColor.ToBrush();
     }
 }
Example #9
0
 private void UpdateErrorLow(IResourceDictionary resources, ThemeViewModel theme)
 {
     if (theme.ErrorLowColor != null)
     {
         resources["ErrorLowColor"] = theme.ErrorLowColor.ToColor();
         resources["ErrorLowBrush"] = theme.ErrorLowColor.ToBrush();
     }
 }
Example #10
0
 public void AddTheme(ThemeViewModel theme)
 {
     if (Themes != null)
     {
         Themes.Add(theme);
         CurrentTheme = theme;
     }
 }
Example #11
0
 private void UpdateThemeAccent4(IResourceDictionary resources, ThemeViewModel theme)
 {
     if (theme.ThemeAccentColor4 != null)
     {
         resources["ThemeAccentColor4"] = theme.ThemeAccentColor4.ToColor();
         resources["ThemeAccentBrush4"] = theme.ThemeAccentColor4.ToBrush();
     }
 }
 public void Reset(ThemeViewModel theme)
 {
     if (CurrentTheme != null)
     {
         int index = Themes.IndexOf(CurrentTheme);
         if (index >= 0)
         {
             Themes[index] = theme;
             CurrentTheme  = theme;
         }
     }
 }
Example #13
0
        public IDisposable ObserveTheme(IResourceDictionary resources, ThemeViewModel theme, Action <ThemeViewModel>?preview = null)
        {
            var disposable = new CompositeDisposable();

            Observe(theme, UpdateTheme);
            Observe(theme.ThemeAccentColor, UpdateThemeAccent);
            Observe(theme.ThemeAccentColor2, UpdateThemeAccent2);
            Observe(theme.ThemeAccentColor3, UpdateThemeAccent3);
            Observe(theme.ThemeAccentColor4, UpdateThemeAccent4);
            Observe(theme.ThemeBackgroundColor, UpdateThemeBackground);
            Observe(theme.ThemeBorderLowColor, UpdateThemeBorderLow);
            Observe(theme.ThemeBorderMidColor, UpdateThemeBorderMid);
            Observe(theme.ThemeBorderHighColor, UpdateThemeBorderHigh);
            Observe(theme.ThemeControlLowColor, UpdateThemeControlLow);
            Observe(theme.ThemeControlMidColor, UpdateThemeControlMid);
            Observe(theme.ThemeControlHighColor, UpdateThemeControlHigh);
            Observe(theme.ThemeControlHighlightLowColor, UpdateThemeControlHighlightLow);
            Observe(theme.ThemeControlHighlightMidColor, UpdateThemeControlHighlightMid);
            Observe(theme.ThemeControlHighlightHighColor, UpdateThemeControlHighlightHigh);
            Observe(theme.ThemeForegroundColor, UpdateThemeForeground);
            Observe(theme.ThemeForegroundLowColor, UpdateThemeForegroundLow);
            Observe(theme.HighlightColor, UpdateHighlight);
            Observe(theme.ErrorColor, UpdateError);
            Observe(theme.ErrorLowColor, UpdateErrorLow);
            Observe(theme.ThemeBorderThickness, UpdateThemeBorderThickness);

            if (resources != null)
            {
                UpdateTheme(resources, theme);
            }
            preview?.Invoke(theme);

            return(disposable);

            void Observe(IReactiveNotifyPropertyChanged <IReactiveObject>?value, Action <IResourceDictionary, ThemeViewModel> update)
            {
                if (value != null)
                {
                    disposable.Add(value.Changed.Subscribe(x =>
                    {
                        if (x.PropertyName != nameof(ThemeViewModel.Name))
                        {
                            if (resources != null)
                            {
                                update(resources, theme);
                            }
                            preview?.Invoke(theme);
                        }
                    }));
                }
            }
        }
Example #14
0
 public void ResetTheme(ThemeViewModel theme)
 {
     if (Themes != null && CurrentTheme != null)
     {
         int index = Themes.IndexOf(CurrentTheme);
         if (index >= 0)
         {
             string name = CurrentTheme.Name;
             Themes[index]     = theme;
             CurrentTheme      = theme;
             CurrentTheme.Name = name;
         }
     }
 }
 private void UpdateThemeAccent3(IResourceDictionary resources, ThemeViewModel theme)
 {
     resources["ThemeAccentColor3"] = theme.ThemeAccentColor3.ToColor();
     resources["ThemeAccentBrush3"] = theme.ThemeAccentColor3.ToBrush();
 }
 private void UpdateThemeControlLow(IResourceDictionary resources, ThemeViewModel theme)
 {
     resources["ThemeControlLowColor"] = theme.ThemeControlLowColor.ToColor();
     resources["ThemeControlLowBrush"] = theme.ThemeControlLowColor.ToBrush();
 }
Example #17
0
 private void UpdateUpdateScrollBarThickness(IResourceDictionary resources, ThemeViewModel theme)
 {
     resources["ScrollBarThickness"] = theme.ScrollBarThickness;
 }
Example #18
0
 private void UpdateUpdateFontSizeLarge(IResourceDictionary resources, ThemeViewModel theme)
 {
     resources["FontSizeLarge"] = theme.FontSizeLarge;
 }
Example #19
0
 private void UpdateFontSizeNormal(IResourceDictionary resources, ThemeViewModel theme)
 {
     resources["FontSizeNormal"] = theme.FontSizeNormal;
 }
Example #20
0
 private void UpdateThemeDisabledOpacity(IResourceDictionary resources, ThemeViewModel theme)
 {
     resources["ThemeDisabledOpacity"] = theme.ThemeDisabledOpacity;
 }
 private void UpdateThemeControlHighlightMid(IResourceDictionary resources, ThemeViewModel theme)
 {
     resources["ThemeControlHighlightMidColor"] = theme.ThemeControlHighlightMidColor.ToColor();
     resources["ThemeControlHighlightMidBrush"] = theme.ThemeControlHighlightMidColor.ToBrush();
 }
 private void UpdateThemeForeground(IResourceDictionary resources, ThemeViewModel theme)
 {
     resources["ThemeForegroundColor"] = theme.ThemeForegroundColor.ToColor();
     resources["ThemeForegroundBrush"] = theme.ThemeForegroundColor.ToBrush();
 }
 private void UpdateError(IResourceDictionary resources, ThemeViewModel theme)
 {
     resources["ErrorColor"] = theme.ErrorColor.ToColor();
     resources["ErrorBrush"] = theme.ErrorColor.ToBrush();
 }
 public void Add(ThemeViewModel theme)
 {
     Themes.Add(theme);
     CurrentTheme = theme;
 }
Example #25
0
        public void ExportAsFile(string path, ThemeViewModel theme)
        {
            var xaml = theme.ToXaml();

            File.WriteAllText(path, xaml);
        }
 private void UpdateThemeBorderHigh(IResourceDictionary resources, ThemeViewModel theme)
 {
     resources["ThemeBorderHighColor"] = theme.ThemeBorderHighColor.ToColor();
     resources["ThemeBorderHighBrush"] = theme.ThemeBorderHighColor.ToBrush();
 }