private void Slots_CollectionChanged(object sender, TrackingCollectionChangedEventArgs e) { switch (e.Action) { case NotifyCollectionChangedAction.Add: { var slot = (Slot)e.Item; var slots = slot.Direction == SlotDirection.Input ? InputSlots : OutputSlots; var slotViewModel = new VisualScriptSlotViewModel(ViewModel, slot); slots.Add(slotViewModel); ViewModel.Slots.Add(slot, slotViewModel); break; } case NotifyCollectionChangedAction.Remove: { var slot = (Slot)e.Item; var slots = slot.Direction == SlotDirection.Input ? InputSlots : OutputSlots; var slotViewModel = ViewModel.Slots[slot]; slots.Remove(slotViewModel); ViewModel.Slots.Remove(slot); break; } default: throw new NotSupportedException(); } }
internal BlockNodeVertex(VisualScriptBlockViewModel viewModel) { ViewModel = viewModel; InputSlots = new ObservableCollection <object>(); OutputSlots = new ObservableCollection <object>(); // Add initial slots (if any) foreach (var slot in viewModel.Block.Slots) { var slots = slot.Direction == SlotDirection.Input ? InputSlots : OutputSlots; var slotViewModel = new VisualScriptSlotViewModel(viewModel, slot); slots.Add(slotViewModel); viewModel.Slots.Add(slot, slotViewModel); } // Setup listener to be aware of future changes viewModel.Block.Slots.CollectionChanged += Slots_CollectionChanged; }
public VisualScriptLinkViewModel(VisualScriptMethodEditorViewModel method, Link link, VisualScriptSlotViewModel sourceSlot, VisualScriptSlotViewModel targetSlot) : base(method.SafeArgument(nameof(method)).ServiceProvider) { this.Method = method; this.Editor = method.Editor; this.link = link; this.SourceSlot = sourceSlot; this.TargetSlot = targetSlot; }