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