private void UpdateSelected() { if (SelectedEntry == null) { return; } try { var def = ThemeManager.Inst.Cache.GetDefaultOrFallback(); var defset = new AlephThemeSet(def, def, new AlephTheme[0]); var parser = new ThemeParser(); parser.LoadFromString(SelectedEntry.Source, SelectedEntry.SourceFilename); parser.Parse(); var theme = parser.Generate(); var set = new AlephThemeSet(def, theme, new AlephTheme[0]); SelectedEntry.Name = theme.Name; SelectedEntry.ParsedSet = set; SelectedEntry.ParsedTheme = theme; foreach (var dv in DefaultValues) { dv.Value = set.GetStrRepr(dv.Key); dv.Changed = set.GetStrRepr(dv.Key) != defset.GetStrRepr(dv.Key); } } catch (Exception e) { ErrorText = e.ToString(); } }
public ThemeEditorViewmodel(ThemeEditor owner) { Owner = owner; var dt = ThemeManager.Inst.Cache.GetDefault(); foreach (var at in ThemeManager.Inst.Cache.GetAllAvailable()) { var newEntry = new ThemeEditorEntry { SourceFilename = at.SourceFilename, Name = at.Name, Source = at.Source, OriginalSource = at.Source, ParsedTheme = at, ParsedSet = new AlephThemeSet(dt, at, new AlephTheme[0]), }; Entries.Add(newEntry); if (at == ThemeManager.Inst.CurrentBaseTheme) { _selectedEntry = newEntry; } } var def = new AlephThemeSet(dt, dt, new AlephTheme[0]); foreach (var prop in AlephTheme.THEME_PROPERTIES) { DefaultValues.Add(new ThemeEditorDV { Key = prop.Item1, Default = dt.GetXmlStr(prop.Item1.ToLower()), TypeStr = prop.Item2.ToString(), Value = SelectedEntry?.ParsedSet?.GetStrRepr(prop.Item1), Changed = SelectedEntry?.ParsedSet?.GetStrRepr(prop.Item1) != def?.GetStrRepr(prop.Item1) }); } }