Not albe to add the controls as mentioned in the How To section


https://www.nevron.com/Forum/Topic9629.aspx
Print Topic | Close Window

By lopamudra vemulapalli - 8 Years Ago
Hello,

I am exploring the tool to use it in our development. I am trying out to see if I can add around 8 ports to rectangle and connect it to other rectangles after adding 8 ports using Diagram.
I tried to add controls using the following example:
http://support.nevron.com/KB/a8/create-a-simple-diagram-in-winform-application.aspx?KBSearchID=28419

but I was not able to add the controls nDrawingView and nDrawingDocument to a form. I am using Nevron Open Vision 2016.1 version.

Please help me resolve this.

Thanks
By Nevron Support - 8 Years Ago
Hi,

The example you are looking at is for our old diagramming product - Nevron Diagram for .NET, but you are using the Diagram of Nevron Open Vision. That is why the code is not working. In order to get started with our new diagramming component - NOV Diagram, you should first initialize the NOV framework in the entry point of your applications (i.e. the "Program.cs" file of a C# WinForms application) as shown in the following documentation topic:

Hosting NOV in Windows Forms

Then you can either drag and drop a NOV drawing view from the toolbox to your form or you can programatically create it in you form's constructor or load event handler. Here's an example of the code to put in the form:


using System.Windows.Forms;
using Nevron.Nov.Diagram;
using Nevron.Nov.Diagram.Shapes;
using Nevron.Nov.UI;
using Nevron.Nov.Windows.Forms;

namespace NNovWinFormsSample
{
    public partial class frmDiagram : Form
    {
        public frmDiagram()
        {
            InitializeComponent();

            // Create a diagram UI (a drawing view with a ribbon)
            NWidget diagramUI = CreateDiagramUI();

            // Create a NOV widget host and place the diagram UI in it
            NNovWidgetHost<NWidget> novHost = new NNovWidgetHost<NWidget>(diagramUI);
            novHost.Dock = DockStyle.Fill;
            Controls.Add(novHost);
        }

        private NWidget CreateDiagramUI()
        {
            // Create a drawing view
            NDrawingView drawingView = new NDrawingView();
            NPage page = drawingView.Content.ActivePage;

            // Create and add a rectangle shape to the active page
            NBasicShapesFactory factory = new NBasicShapesFactory();
            NShape shape = factory.CreateShape(ENBasicShapes.Rectangle);
            shape.SetBounds(20, 20, 150, 100);
            page.Items.Add(shape);

            // Create a ribbon around the drawing view
            NDiagramRibbonBuilder builder = new NDiagramRibbonBuilder();
            return builder.CreateUI(drawingView);
        }
    }
}

By lopamudra vemulapalli - 8 Years Ago
Hello,

Thanks for the reply. I was able to execute the program with given instructions. Can you also please let me know how can i add additional port on each side of rectangle (Center port is not required)?

Thanks,
Lopa
By Nevron Support - 8 Years Ago
The following documentation topic gives more information about ports and demonstrates how to add ports to a shape:

NOV Diagram Ports