public ThemeFileViewModel(ThemeFile themeFile) { this.themeFile = themeFile; properties.AddRange(themeFile.Properties.Select(x => new OwnedThemePropertyViewModel(x))); classes = themeFile.Classes.Select(x => new ThemeClassViewModel(x, this)).ToList(); classes.Sort((x, y) => string.Compare(x.Name, y.Name, StringComparison.OrdinalIgnoreCase)); var classMap = classes.ToDictionary(x => x.Class); foreach (var classViewModel in classes) { if (classViewModel.Class.BaseClass != null) { classViewModel.BaseClass = classMap[classViewModel.Class.BaseClass]; } } foreach (var @class in classes) { if (@class.Name.Equals("globals", StringComparison.OrdinalIgnoreCase)) { globals = @class; break; } } foreach (var @class in Classes) { @class.AddInheritedProperties(); } AddDefaultProperties(); }
public ThemeClassComparisonViewModel Compare( ThemeClassViewModel oldClass, ThemeClassViewModel newClass) { var cmpModel = new ThemeClassComparisonViewModel(oldClass, newClass); if (oldClass != null && newClass != null) { var items = MatchItems(oldClass.Parts, newClass.Parts, (l, r) => l.Id.CompareTo(r.Id)); foreach (var tuple in items) { var cmp = Compare(tuple.Item1, tuple.Item2); if (cmp != null) { cmpModel.Parts.Add(cmp); } } cmpModel.Properties = Compare(oldClass.Properties, newClass.Properties); if (cmpModel.Parts.Count == 0 && cmpModel.Properties.Count == 0) { return(null); } } return(cmpModel); }
public ThemeClassComparisonViewModel( ThemeClassViewModel oldClass, ThemeClassViewModel newClass) { OldClass = oldClass; NewClass = newClass; Comparison = ComparisonUtils.GetResult(oldClass != null, newClass != null); DisplayName = OldClass?.Name ?? NewClass?.Name; }
public ThemePartViewModel(ThemePart part, ThemeClassViewModel parent) { Part = part; Parent = parent; properties.AddRange(part.Properties.Select(x => new OwnedThemePropertyViewModel(x))); states = part.States.Select(x => new ThemeStateViewModel(x, this)).ToList(); states.Sort((x, y) => x.Id.CompareTo(y.Id)); }