.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


comments powered by Disqus

Featured

  • Creating Reactive Applications in .NET

    In modern applications, data is being retrieved in asynchronous, real-time streams, as traditional pull requests where the clients asks for data from the server are becoming a thing of the past.

  • AI for GitHub Collaboration? Maybe Not So Much

    No doubt GitHub Copilot has been a boon for developers, but AI might not be the best tool for collaboration, according to developers weighing in on a recent social media post from the GitHub team.

  • Visual Studio 2022 Getting VS Code 'Command Palette' Equivalent

    As any Visual Studio Code user knows, the editor's command palette is a powerful tool for getting things done quickly, without having to navigate through menus and dialogs. Now, we learn how an equivalent is coming for Microsoft's flagship Visual Studio IDE, invoked by the same familiar Ctrl+Shift+P keyboard shortcut.

  • .NET 9 Preview 3: 'I've Been Waiting 9 Years for This API!'

    Microsoft's third preview of .NET 9 sees a lot of minor tweaks and fixes with no earth-shaking new functionality, but little things can be important to individual developers.

  • Data Anomaly Detection Using a Neural Autoencoder with C#

    Dr. James McCaffrey of Microsoft Research tackles the process of examining a set of source data to find data items that are different in some way from the majority of the source items.

Subscribe on YouTube