Example #1
0
        public void Attach(IResourceDictionary resources, Action <ThemeViewModel>?preview = null)
        {
            if (Themes == null)
            {
                CurrentTheme = DefaultTheme?.Clone();
                Themes       = new ObservableCollection <ThemeViewModel>();
                if (CurrentTheme != null)
                {
                    Themes.Add(CurrentTheme);
                }
            }
            else
            {
                CurrentTheme = Themes.FirstOrDefault();
            }

            if (CurrentTheme != null)
            {
                _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 #2
0
        public void ResetTheme()
        {
            var clone = DefaultTheme?.Clone();

            if (clone != null)
            {
                ResetTheme();
            }
        }
Example #3
0
        public void AddTheme()
        {
            if (Themes != null)
            {
                var theme = Themes.Count == 0 || CurrentTheme == null?DefaultTheme?.Clone() : CurrentTheme?.Clone();

                if (theme != null)
                {
                    if (Themes.Count > 0 && Themes.Count(x => x.Name == theme.Name) > 0)
                    {
                        theme.Name += "-copy";
                    }
                    AddTheme(theme);
                }
            }
        }