.NET Tips and Tricks

Blog archive

Nevron Diagram for .NET: Drawing and Loading a Diagram

I was being dumb about drawing a diagram for Nevron's Diagram for .NET. I went back to my Start menu and looked under Nevron .NET Vision 2010.1 for VS2008 | Nevron Diagram | WinForm. There I found (eureka!) Nevron's Diagram Designer. I opened it and found what looks like a very complete object drawing tool. I used it to create a simple diagram (see Figure 1)


[Click on image for larger view.]
Figure 1. Nevron's Diagram for .NET package includes the Diagram Designer, which allows you to create a diagram without code.

Now that I've created a diagram, I want to load it into my form for the user to interact with it. It took a little while to recognize that Nevron makes a distinction between "persistent documents" (documents saved to your hard disk) and "drawing documents" (documents in memory). My saved diagram is a persistent document that I need to convert to a drawing document. The tool to do that, it turns out, is the PersistencyManager. I also had to recognize that I wanted to load the resulting drawing document into the NDiagramView control on my form (I had assumed that I would be putting it in the NDiagramDocument).

A search for "diagram designer" on the Nevron site put it all together for me and gave me these four lines of code to display my diagram (see Figure 2):

Dim pm As New NPersistencyManager
Dim ddoc As NDrawingDocument
ddoc = pm.LoadDrawingFromFile( _
"C:\Course\512\PHVSampleDiagram.ndb")
Me.NDrawingView1.Document = ddoc

[Click on image for larger view.]
Figure 2. Working with Nevron's PersistencyManager object you can load diagrams created with the Nevron Diagram Designer into a window on your form.

What's cool about the diagram now displayed in my Visual Basic form is that the user can interact with it. If I don't lock the diagram, for instance, the user can drag the shapes around, double click the shapes to enter text into them -- basically, do all the things that you'd expect the user to do with a drawing tool (one suspects that Nevron's Diagram Designer is simply built with the same components that I'm using here). If I added more of the Diagram for .NET controls to my form I could define my own shapes and let users use them to create controls in my form.

I set some more properties to get the display I wanted. I also (finally) picked up my license key to get rid of the demo notice that my diagrams were displaying. I'm now ready to move onto the next part of my test: Tying code to my user's interaction with the diagram.

Posted by Peter Vogel on 05/16/2010


comments powered by Disqus

Featured

  • GitHub Previews Agentic AI in VS Code Copilot

    GitHub announced a raft of improvements to its Copilot AI in the Visual Studio Code editor, including a new "agent mode" in preview that lets developers use the AI technology to write code faster and more accurately.

  • Copilot Engineering in the Cloud with Azure and GitHub

    Who better to lead a full-day deep dive into this tech than two experts from GitHub, which introduced the original "AI pair programmer" and spawned the ubiquitous Copilot moniker?

  • Uno Platform Wants Microsoft to Improve .NET WebAssembly in Two Ways

    Uno Platform, a third-party dev tooling specialist that caters to .NET developers, published a report on the state of WebAssembly, addressing some shortcomings in the .NET implementation it would like to see Microsoft address.

  • Random Neighborhoods Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the random neighborhoods regression technique, where the goal is to predict a single numeric value. Compared to other ML regression techniques, advantages are that it can handle both large and small datasets, and the results are highly interpretable.

  • As Some Orgs Restrict DeepSeek AI Usage, Microsoft Offers Models and Dev Guidance

    While some organizations are restricting employee usage of the new open source DeepSeek AI from a Chinese company due to data collection concerns, Microsoft has taken a different approach.

Subscribe on YouTube

Upcoming Training Events