How to cancel a diagram event?
The following events under diagram.model.eventsink has an option to cancel.
List of cancellable events
NodeCollectionChanged
The NodeCollectionChanged event is raised when the node collection contained in the model is changed (added/removed).
NodeCollectionChanging
The NodeCollectionChanging event is raised while modifying the model’s node collection.
ConnectionsChanged
This ConnectionsChanged event is raised when the connections between the nodes are modified.
ConnectionsChanging
The ConnectionsChanging event is raised while modifying connections between the nodes.
LabelsChanged
The LabelsChanged event is raised when labels are added.
PropertyChanging
The PropertyChanging event is raised while modifying the model’s property.
FlipChanging
The FlipChanging event is raised while the node is inverted using Flip property.
PinOffsetChanging
The PinOffsetChanging event is raised while modifying the offset of the pinpoint.
PinPointChanging
The PinPointChanging event is raised while changing the node’s pinpoint.
PortsChanged
The PortsChanged event is raised when the ports are added or changed.
RotationChanging
The RotationChanging event is raised when the node is rotating.
SizeChanging
The SizeChanging event is raised when the size of the node or connector is modified.
VertexChanging
The VertexChanging event is raised when the vertex of the node is changed.
ZorderChanging
The ZorderChanging event is raised when Zorder of the node is changed. When the node order is changed from front-to-back or from back-to-front, the ZorderChanging event is raised.
The following code example is used to cancel the events.
C#
diagram1.Model.EventSink.NodeCollectionChanged += EventSink_NodeCollectionChanged; void EventSink_NodeCollectionChanged(CollectionExEventArgs evtArgs) { if (evtArgs.ChangeType == CollectionExChangeType.Remove) //Events can be cancelled by setting the cancel property as true evtArgs.Cancel = true; }
VB
Private diagram1.Model.EventSink.NodeCollectionChanged += AddressOf EventSink_NodeCollectionChanged Private Sub EventSink_NodeCollectionChanged(ByVal evtArgs As CollectionExEventArgs) If evtArgs.ChangeType = CollectionExChangeType.Remove Then 'Events can be cancelled by setting the cancel property as true evtArgs.Cancel = True End If End Sub