.NET Tips and Tricks

Blog archive

Reviewing Nevron Diagram for .NET: Responding to Events

Now that I've created a diagram using Nevron's Diagram Designer and displayed it in a form so that a user can interact with it, I want to tie code to the diagram so that I can respond to the user's actions. The event that looks easiest to use is the Click event. Once in that event, I can use the view's Selection.Nodes collection to retrieve the currently selected Node.

Unfortunately, a Node has only two properties, which doesn't seem like much. However, Nevron's documentation made it clear that diagrams are made up of shapes: I'm willing to bet that I can convert this Node and get lots more properties. And I'm right: this code lets me retrieve values on a diagram object that I set back when I added the object to the diagram:

Dim ns As NShape
ns = CType(args.Node, NShape)
Dim ObjectInfo As String
ObjectInfo = ns.Tag

What I really wanted to use was the NodeSelecting event... but it wasn't firing. It turns out that I needed to turn on events for the NDrawingView object and wire up my event routine to the NDrawingView's EventSinkService with code like this:

Me.NDrawingView1.PreviewLayer.FireEvents = True
AddHandler Me.NDrawingView1.EventSinkService.NodeSelected, _
       AddressOf Me.NDrawingView1_NodeSelected

I can see that the tool is already going to be terrifically useful and I've really only scratched its surface. Even at this point, I can create a diagram that represents some process or model, load the diagram into a Windows Form, and let a user select objects in the diagram. Once a user selects an object in a diagram, I could use information from the object to retrieve (or update) a database. Alternatively, if a user enters text into an object, I can gather that information and use it in conjunction with data retrieved from other properties on the object (e.g. Name and Tag) to decide what to do next.

And this is before I've looked at giving the user the ability to add or remove items from the diagram.

Rather than continuing to use the help on Nevron's website, I decided it was time to let Visual Studio integrate the help for Nevron's suite. I pressed F1 to start the process and took the rest of the night off.

Why does Visual Studio Help take so long to start Help? I'm calling it quits for tonight.

Posted by Peter Vogel on 05/17/2010 at 1:16 PM

comments powered by Disqus


Subscribe on YouTube

Upcoming Events