Event sink services (or simply event sinks) are services, which provide centralized event handling. All NDiagramNode instances try to connect to an instance of the NDiagramEventSinkService (derived from NNodeEventSinkService - see Node Event Sink Service for more information).
Currently there are two instancable event sink services:
-
NDocumentEventSinkService - represents the event sink used by NDocument instances. It exposes additional, document specific events, related to connections, views, document modification etc.
-
NViewEventSinkService - represents the event sink used by NView instances. It exposes additional, view specific events, related to the view transformations, tools, selection etc.
The following code example shows how to intercept common document and view events.
C# |
Copy Code
|
---|---|
using Nevron.Dom; ... nDrawingDocument1.EventSinkService.NodeBoundsChanged += new Nevron.Dom.NodeEventHandler(EventSinkService_NodeBoundsChanged); nDrawingView1.EventSinkService.NodeSelected += new Nevron.Dom.NodeEventHandler(EventSinkService_NodeSelected); ... private void EventSinkService_NodeBoundsChanged(NNodeEventArgs args) { MessageBox.Show("Node: " + args.Node.ToString() + " bounds changed"); } private void EventSinkService_NodeSelected(NNodeEventArgs args) { MessageBox.Show("Node: " + args.Node.ToString() + " selected"); } |
Visual Basic |
Copy Code
|
---|---|
Imports Nevron.Dom ... AddHandler NDrawingDocument1.EventSinkService.NodeBoundsChanged, AddressOf EventSinkService_NodeBoundsChanged AddHandler NDrawingView1.EventSinkService.NodeSelected, AddressOf EventSinkService_NodeSelected ... Private Sub EventSinkService_NodeBoundsChanged(ByVal args As NNodeEventArgs) MessageBox.Show("Node: " + CType(args.Node, Object).ToString() + " bounds changed") End Sub Private Sub EventSinkService_NodeSelected(ByVal args As NNodeEventArgs) MessageBox.Show("Node: " + CType(args.Node, Object).ToString() + " selected") End Sub |