Nevron Forum

Document EventSinkServices after loading a diagram

https://www.nevron.com/Forum/Topic4493.aspx

By Wilhelm Vortisch - Wednesday, November 17, 2010

Hi,

I have a problem with document EventSinkServices after loading a diagram with the "open" command of NDiagramCommandBarsManager.
In my application I have added the following command in the Form_Load function for getting the double click event:

nDrawingDocument1.EventSinkService.NodeDoubleClick += new NodeViewEventHandler(EventSinkService_NodeDoubleClicked);

If I add a shape to the default drawing document, it's all OK.
After I save these diagram to a ndb file and reloads it over the standard NDiagramCommandBarsManager command ("the open icon"), all EventSinkServices releated to the drawing document are "not active".

Where can I enable these EventSinkServices for a new drawing document?

Regards

Wilhelm
By Volvick Derose 1 - Wednesday, November 17, 2010

Hey, to solve this problem you need to add the event sink to the load diagram button as well. For instance, if you click on a button to load the diagram, then inside the onclick event of that button you need to include that code as well

nDrawingDocument1.EventSinkService.NodeDoubleClick += new NodeViewEventHandler(EventSinkService_NodeDoubleClicked);

that will fix the problem. I had the same problem, and that fixed it
By Wilhelm Vortisch - Monday, November 22, 2010

Hi Volvick,

thank you for the reply, my solution meanwhile:
If I use the predefined function of "New", "Open" and so in the NDiagramCommandBarsManager I have implemented a EventSinkService for the event DisplayedDocumentChanged of the NDrawingView.
Example:
nDrawingView1.EventSinkService.DisplayedDocumentChanged += new
Nevron.Diagram.DocumentEventHandler(EventSinkService_DisplayedDocumentChanged);

And the implementation:
private void EventSinkService_DisplayedDocumentChanged(NDocumentEventArgs args)
{
nDrawingDocument1 = nDrawingView1.Document;
nDrawingDocument1.BeginUpdate();
nDrawingDocument1.EventSinkService.NodeInserted += new ChildNodeEventHandler(EventSinkService_NodeInserted);
nDrawingDocument1.EventSinkService.NodeRemoving += new ChildNodeCancelEventHandler(EventSinkService_NodeRemoving);
nDrawingDocument1.EventSinkService.NodeDoubleClick += new NodeViewEventHandler(EventSinkService_NodeDoubleClicked);
nDrawingDocument1.EndUpdate();

}

The result of this implemenation is: after a "New" or "Open" of a document the EventSinkServices of the document are "reinstalled".

Regards

Wilhelm