public ManifestNode(IManifest modManifest, MtmTreeViewItem parent, IReferenceFinderService referenceFinderService) : base(parent, modManifest, referenceFinderService) { this.Manifest = modManifest; var groupedManifestEntries = this.Manifest.Entries.GroupBy(entry => entry.EntryType).OrderBy(entries => entries.Key); foreach (var groupedManifestEntry in groupedManifestEntries) { this.Children.Add(new ManifestEntryNode(this, groupedManifestEntry.Select(entry => entry).ToList(), groupedManifestEntry.Key, referenceFinderService)); } }
public ModNode(IMod mod, MtmTreeViewItem parent, IReferenceFinderService referenceFinderService) : base(parent, mod, referenceFinderService) { this.Mod = mod; if (this.Mod.Manifest != null) { this.Manifest = new ManifestNode(mod.Manifest, this, referenceFinderService); this.Children.Add(this.Manifest); } this.Mod.ResourceFiles.ToList() .ForEach(definition => this.Children.Add(new ResourceNode(this, definition, referenceFinderService))); }
public ModCollectionNode( IModCollection modCollection, MtmTreeViewItem parent, IReferenceFinderService referenceFinderService, bool preProcessRelationships = false) : base(parent, modCollection, referenceFinderService) { this.ModCollection = modCollection; this.ModCollection.Mods.OrderBy(mod => mod.Name).ToList().ForEach( mod => { var modNode = new ModNode(mod, this, referenceFinderService); this.Children.Add(modNode); modNode.PropertyChanged += (sender, args) => { this.OnPropertyChanged(nameof(this.TotalMods)); this.OnPropertyChanged(nameof(this.TotalModSize)); this.OnPropertyChanged(nameof(this.TotalModObjectCount)); this.OnPropertyChanged(nameof(this.TotalMechCount)); this.OnPropertyChanged(nameof(this.TotalVehicleCount)); this.OnPropertyChanged(nameof(this.TotalTurretCount)); this.OnPropertyChanged(nameof(this.TotalWeaponCount)); this.OnPropertyChanged(nameof(this.TotalUpgradeCount)); this.OnPropertyChanged(nameof(this.TotalCoolingCount)); }; }); // Hook up interdependent properties // When Pilots/Units are selected, notify lances // TODO: Formalize this into a modeled relationship so we can refactor properly // and reuse the concept. var lanceDependencyProperties = new List <ObjectType> { ObjectType.MechDef, ObjectType.TurretDef, ObjectType.VehicleDef, ObjectType.PilotDef }; var sourceObjects = this.AllChildren.Where( item => item.Object is IObjectDefinition obj && lanceDependencyProperties.Contains(obj.ObjectType)); var targetObjects = this.AllChildren.Where(item => item is LanceDefNode obj).Cast <LanceDefNode>() .SelectMany(node => node.LanceSlots); targetObjects.AsParallel().ForAll( // targetObjects.ToList().ForEach( target => { target.LoadEligibleUnitsAndPilots(); sourceObjects.AsParallel().ForAll( source => { var propertyName = nameof(LanceSlotModel.SelectedEligibleUnits); if (((IObjectDefinition)source.Object).ObjectType == ObjectType.PilotDef) { propertyName = nameof(LanceSlotModel.SelectedEligiblePilots); } source.PropertyChanged += (sender, args) => { if (args.PropertyName == nameof(IMtmTreeViewItem.IsChecked)) { target.OnPropertyChanged(propertyName); target.OnPropertyChanged(nameof(LanceSlotModel.ObjectStatus)); } }; }); }); this.IsExpanded = true; }