How to get the inclusions/subtree items deleted during the deletion of node

Hello,

How to get the list of inclusions items deleted while deleting a node.

Lets say I have two nodes(A and B) ; and a link(L) which connects both the nodes.
When i delete the node A, both node A and the connected link L are deleted.

By subscribing to the “SelectionDeleting” event and using the diagram.SelectedParts property i can get to know that the node A is deleted/selected for deletion. How would i know to that the link L will also be deleted.

Yes, this isn’t as convenient to use as it should be.

At SelectionDeleting time no one knows which Parts will be deleted; at SelectionDeleted time the Diagram.SelectedParts collection will be empty.

So I think you need to establish a DiagramModel.Changed event handler that looks for events whose ModelChangedEventArgs.Change == ModelChange.RemovedNode or ModelChange.RemovedLink.

Hello,

From my understanding “DiagramModel.Changed” event is fired for all the model related changes. So handling this event will be costlier in terms of performance. Please provide your insights on this if otherwise. Also, could you please suggest any other approach for the same.

An event handler that just does a couple simple comparisons is hardly slower than no event handler at all. Do you have any evidence otherwise?

At this moment I do not know of any alternative. My suggested approach is sometimes necessary for other reasons, as well.