public TECSystem(TECSystem source, Dictionary <Guid, Guid> guidDictionary = null, ObservableListDictionary <ITECObject> characteristicReference = null, Tuple <TemplateSynchronizer <TECEquipment>, TemplateSynchronizer <TECSubScope> > synchronizers = null) : this() { if (guidDictionary == null) { guidDictionary = new Dictionary <Guid, Guid>(); } guidDictionary[_guid] = source.Guid; foreach (TECEquipment equipment in source.Equipment) { var toAdd = new TECEquipment(equipment, guidDictionary, characteristicReference, ssSynchronizer: synchronizers?.Item2); if (synchronizers != null && synchronizers.Item1.Contains(equipment)) { synchronizers.Item1.LinkNew(synchronizers.Item1.GetTemplate(equipment), toAdd); } if (characteristicReference != null) { characteristicReference.AddItem(equipment, toAdd); } Equipment.Add(toAdd); } foreach (TECController controller in source._controllers) { var toAdd = controller.CopyController(guidDictionary); if (characteristicReference != null) { characteristicReference.AddItem(controller, toAdd); } _controllers.Add(toAdd); } foreach (TECPanel panel in source.Panels) { var toAdd = new TECPanel(panel, guidDictionary); if (characteristicReference != null) { characteristicReference.AddItem(panel, toAdd); } Panels.Add(toAdd); } foreach (TECMisc misc in source.MiscCosts) { var toAdd = new TECMisc(misc); MiscCosts.Add(toAdd); } foreach (TECScopeBranch branch in source.ScopeBranches) { var toAdd = new TECScopeBranch(branch); ScopeBranches.Add(toAdd); } foreach (TECProposalItem item in source.ProposalItems) { var toAdd = new TECProposalItem(item, guidDictionary); ProposalItems.Add(toAdd); } this.copyPropertiesFromLocated(source); ModelLinkingHelper.LinkSystem(this, guidDictionary); }
public TECSystem AddInstance() { Dictionary <Guid, Guid> guidDictionary = new Dictionary <Guid, Guid>(); var newSystem = new TECSystem(); newSystem.CopyPropertiesFromScope(this); if (this.Location != null) { newSystem.Location = this.Location; } foreach (TECEquipment equipment in Equipment) { var toAdd = new TECEquipment(equipment, guidDictionary, TypicalInstanceDictionary); TypicalInstanceDictionary.AddItem(equipment, toAdd); newSystem.Equipment.Add(toAdd); } foreach (TECController controller in Controllers) { var toAdd = controller.CopyController(guidDictionary); TypicalInstanceDictionary.AddItem(controller, toAdd); newSystem.AddController(toAdd); } foreach (TECPanel panel in Panels) { var toAdd = new TECPanel(panel, guidDictionary); TypicalInstanceDictionary.AddItem(panel, toAdd); newSystem.Panels.Add(toAdd); } foreach (TECMisc misc in MiscCosts) { var toAdd = new TECMisc(misc); TypicalInstanceDictionary.AddItem(misc, toAdd); newSystem.MiscCosts.Add(toAdd); } foreach (TECScopeBranch branch in ScopeBranches) { var toAdd = new TECScopeBranch(branch); TypicalInstanceDictionary.AddItem(branch, toAdd); newSystem.ScopeBranches.Add(toAdd); } //Proposal items are not currently synced to instances //foreach(TECProposalItem propItem in ProposalItems) //{ // var toAdd = new TECProposalItem(propItem); // TypicalInstanceDictionary.AddItem(propItem, toAdd); // newSystem.ProposalItems.Add(toAdd); //} ModelLinkingHelper.LinkSystem(newSystem, guidDictionary); Instances.Add(newSystem); return(newSystem); }
public TECTypical(TECTypical source, Dictionary <Guid, Guid> guidDictionary = null, ObservableListDictionary <ITECObject> characteristicReference = null) : this() { if (guidDictionary != null) { guidDictionary[_guid] = source.Guid; } foreach (TECEquipment equipment in source.Equipment) { var toAdd = new TECEquipment(equipment, guidDictionary, characteristicReference); if (characteristicReference != null) { characteristicReference.AddItem(equipment, toAdd); } Equipment.Add(toAdd); } foreach (TECController controller in source.Controllers) { var toAdd = controller.CopyController(guidDictionary); if (characteristicReference != null) { characteristicReference.AddItem(controller, toAdd); } AddController(toAdd); } foreach (TECPanel panel in source.Panels) { var toAdd = new TECPanel(panel, guidDictionary); if (characteristicReference != null) { characteristicReference.AddItem(panel, toAdd); } Panels.Add(toAdd); } foreach (TECMisc misc in source.MiscCosts) { var toAdd = new TECMisc(misc); MiscCosts.Add(toAdd); } foreach (TECScopeBranch branch in source.ScopeBranches) { var toAdd = new TECScopeBranch(branch); ScopeBranches.Add(toAdd); } copyPropertiesFromLocated(source); }
//Copy Constructor public TECEquipment(TECEquipment equipmentSource, Dictionary <Guid, Guid> guidDictionary = null, ObservableListDictionary <ITECObject> characteristicReference = null, TemplateSynchronizer <TECSubScope> ssSynchronizer = null) : this() { if (guidDictionary != null) { guidDictionary[_guid] = equipmentSource.Guid; } foreach (TECSubScope subScope in equipmentSource.SubScope) { var toAdd = new TECSubScope(subScope, guidDictionary, characteristicReference); if (ssSynchronizer != null && ssSynchronizer.Contains(subScope)) { ssSynchronizer.LinkNew(ssSynchronizer.GetTemplate(subScope), toAdd); } characteristicReference?.AddItem(subScope, toAdd); SubScope.Add(toAdd); } copyPropertiesFromScope(equipmentSource); }
protected void handleEquipmentRemoval(TECEquipment equip) { List <TECProposalItem> toRemove = new List <TECProposalItem>(); foreach (var item in this.ProposalItems) { if (item.DisplayScope == equip) { if (item.ContainingScope.Count == 0) { toRemove.Add(item); } else { item.DisplayScope = item.ContainingScope.First(); item.ContainingScope.Remove(item.DisplayScope); } } } toRemove.ForEach(x => this.ProposalItems.Remove(x)); }
public TECTypical(TECSystem system, TECScopeManager manager) : this() { Dictionary <Guid, Guid> guidDictionary = new Dictionary <Guid, Guid>(); guidDictionary[_guid] = system.Guid; foreach (TECEquipment equipment in system.Equipment) { var toAdd = new TECEquipment(equipment, guidDictionary); Equipment.Add(toAdd); } foreach (TECController controller in system.Controllers) { var toAdd = controller.CopyController(guidDictionary); AddController(toAdd); } foreach (TECPanel panel in system.Panels) { var toAdd = new TECPanel(panel, guidDictionary); Panels.Add(toAdd); } foreach (TECMisc misc in system.MiscCosts) { var toAdd = new TECMisc(misc); MiscCosts.Add(toAdd); } foreach (TECScopeBranch branch in system.ScopeBranches) { var toAdd = new TECScopeBranch(branch); ScopeBranches.Add(toAdd); } foreach (TECProposalItem item in system.ProposalItems) { var toAdd = new TECProposalItem(item, guidDictionary); ProposalItems.Add(toAdd); } copyPropertiesFromLocated(system); ModelLinkingHelper.LinkSystem(this, guidDictionary); }
public TECTemplates(Guid guid) : base(guid) { Catalogs.ScopeChildRemoved += scopeChildRemoved; SubScopeSynchronizer = new TemplateSynchronizer <TECSubScope>((item => { return(new TECSubScope(item)); }), (item => { }), syncSubScope, this.Templates); SubScopeSynchronizer.TECChanged += synchronizerChanged; EquipmentSynchronizer = new TemplateSynchronizer <TECEquipment>( //Copy (item => { TECEquipment newItem = new TECEquipment(); newItem.CopyPropertiesFromScope(item); foreach (TECSubScope subScope in item.SubScope) { newItem.SubScope.Add(SubScopeSynchronizer.NewItem(subScope)); } return(newItem); }), //Remove (item => { foreach (TECSubScope subScope in item.SubScope) { if (SubScopeSynchronizer.GetTemplate(subScope) != null) { SubScopeSynchronizer.RemoveItem(subScope); } } }), //Sync syncEquipment, this.Templates); EquipmentSynchronizer.TECChanged += synchronizerChanged; }
private void syncEquipment(TemplateSynchronizer <TECEquipment> synchronizer, TECEquipment template, TECEquipment changed, TECChangedEventArgs args) { if (!(args.Sender is TECEquipment)) { return; } TECEquipment item = args.Sender as TECEquipment; TECSubScope value = args.Value as TECSubScope; List <TECEquipment> references = synchronizer.GetFullDictionary()[template]; if (value != null && args.Change == Change.Add) { TECSubScope newTemplate = value; if (item == template) { SubScopeSynchronizer.NewGroup(newTemplate); } else { TECSubScope parentTemplate = SubScopeSynchronizer.GetTemplate(newTemplate); if (parentTemplate != null) { SubScopeSynchronizer.RemoveItem(newTemplate); newTemplate = SubScopeSynchronizer.NewItem(parentTemplate); } else { newTemplate = new TECSubScope(value); } template.SubScope.Add(newTemplate); SubScopeSynchronizer.NewGroup(newTemplate); SubScopeSynchronizer.LinkExisting(newTemplate, value); } foreach (TECEquipment reference in references.Where(obj => obj != item)) { reference.SubScope.Add(SubScopeSynchronizer.NewItem(newTemplate)); } } else if (value != null && args.Change == Change.Remove) { TECSubScope subScopeTemplate = value; if (item != template) { subScopeTemplate = SubScopeSynchronizer.GetTemplate(value); } template.SubScope.Remove(subScopeTemplate); List <TECSubScope> subScopeReferences = SubScopeSynchronizer.GetFullDictionary()[subScopeTemplate]; foreach (TECEquipment reference in references) { List <TECSubScope> toRemove = new List <TECSubScope>(); foreach (TECSubScope referenceSubScope in reference.SubScope) { if (subScopeReferences.Contains(referenceSubScope)) { toRemove.Add(referenceSubScope); } } foreach (TECSubScope thing in toRemove) { reference.SubScope.Remove(thing); } } SubScopeSynchronizer.RemoveGroup(subScopeTemplate); if (SubScopeSynchronizer.GetTemplate(subScopeTemplate) != null) { SubScopeSynchronizer.RemoveItem(subScopeTemplate); } } else { if (item != template) { template.CopyChildrenFromScope(item); } foreach (TECEquipment reference in references.Where(obj => obj != item)) { reference.CopyChildrenFromScope(item); } } }
public object DropData() { TECEquipment outEquip = new TECEquipment(this); return(outEquip); }
public TECProposalItem(TECEquipment displayScope) : this(Guid.NewGuid(), displayScope) { }
public TECProposalItem(Guid guid, TECEquipment dislpayScope) : base(guid) { this.DisplayScope = dislpayScope; ContainingScope.CollectionChanged += containingScopeCollectionChanged; new ChangeWatcher(dislpayScope).Changed += scopeChanged; }