Events when part selected

Hello. I have a selected part changed.

private void SelectedPartsChanged(object sender, EventArgs e)
NotifyCollectionChangedEventArgs l_event = e as NotifyCollectionChangedEventArgs;

If i add a element:
l_event.Action is Add

If i remove … l_event.Action is Remove.

If i no select element, l_event.Action is Reset

Ok, for the moment, but, if i change the selected element, we have two events:

Reset, and Add. And for a little moment, part.selected is null.

But if no select any element, only reset is called.

So, i need to know when the user select a node or the void ( no element).
The reset does not work (is change, the reset is launch)
selected part = null, does not work, a little moment when change a node is null.

How could do this?

Thanks in advance

Any idea?

Instead of overriding SelectedPartsChanged you should be overriding ClickSelectingTool.StandardMouseSelect.

In that method you can call:

Part currentPart = FindPartAt(diagram.LastMousePointInModel, true);

To determine whether you clicked on a Part or clicked on empty space, and take actions accordingly.

Thank you by the answer i’m probing it.