public override bool UpdateSlots() { var externalReferences = SharedRendererReferenceVisitor.GetExternalReferences(Editor.Asset.PropertyGraph.Definition, GetNodesContainingReferences()); // Check if our list of slots has changed var shouldRegenerate = outputSlotMap.Any(x => !externalReferences.ContainsKey(x.Key)) || externalReferences.Any(x => !outputSlotMap.ContainsKey(x.Key)); if (shouldRegenerate) { // If so, regenerate all of them (to easily handle insertion, index changes, etc. - in the future we could handle fine-update) foreach (var slot in OutputSlots.Cast <GraphicsCompositorSlotViewModel>().ToList()) { slot.Destroy(); } OutputSlots.Clear(); outputSlotMap.Clear(); foreach (var externalReference in externalReferences) { var name = SharedRendererOutputSlotViewModel.ComputeName(externalReference.Key); var slot = new SharedRendererOutputSlotViewModel(this, name, externalReference.Key); outputSlotMap.Add(externalReference.Key, slot); OutputSlots.Add(slot); } } return(shouldRegenerate); }
private void AddOutputSlot(IGraphicsCompositorSlotViewModel slot) { OutputSlots.Add(slot); foreach (var link in slot.Links) { graph.CreateEdge(link); } slot.Links.CollectionChanged += LinksCollectionChanged; }
private void RemoveOutputSlot(IGraphicsCompositorSlotViewModel slot) { foreach (var link in slot.Links) { graph.RemoveEdge(link); } slot.Links.CollectionChanged -= LinksCollectionChanged; OutputSlots.Remove(slot); }
public void AddConnection(BocsSlotBase slot) { if (slot == this) { return; } if (Node == slot.Node) { return; } slot.InputSlot = this; foreach (BocsSlotBase s in OutputSlots) { //if (s._slotType == BocsSlotType.) if (s == slot) { return; } } OutputSlots.Add(slot); }
private void OutputSlotsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Reset) { foreach (IGraphicsCompositorSlotViewModel slot in OutputSlots.ToList()) { RemoveOutputSlot(slot); } } if (e.NewItems != null) { foreach (IGraphicsCompositorSlotViewModel newSlot in e.NewItems) { AddOutputSlot(newSlot); } } if (e.OldItems != null) { foreach (IGraphicsCompositorSlotViewModel oldSlot in e.OldItems) { RemoveOutputSlot(oldSlot); } } }