protected override void InitDiagram() { NDrawing drawing = m_DrawingDocument.Content; NPage activePage = drawing.ActivePage; // 1. Create some shape factories NBasicShapeFactory basicShapesFactory = new NBasicShapeFactory(); NConnectorShapeFactory connectorShapesFactory = new NConnectorShapeFactory(); // 2. Create and add some shapes NShape shape1 = basicShapesFactory.CreateShape(ENBasicShape.Rectangle); shape1.SetBounds(new NRectangle(50, 50, 100, 100)); activePage.Items.Add(shape1); NShape shape2 = basicShapesFactory.CreateShape(ENBasicShape.Rectangle); shape2.SetBounds(new NRectangle(400, 50, 100, 100)); activePage.Items.Add(shape2); // 3. Connect the shapes NShape connector = connectorShapesFactory.CreateShape(ENConnectorShape.Line); activePage.Items.Add(connector); connector.GlueBeginToShape(shape1); connector.GlueEndToShape(shape2); // Add 2 outward ports to the connector NPort port1 = new NPort(0.3, 0.3, true); port1.GlueMode = ENPortGlueMode.Outward; connector.Ports.Add(port1); NPort port2 = new NPort(0.7, 0.7, true); port2.GlueMode = ENPortGlueMode.Outward; connector.Ports.Add(port2); // Attach label shapes to the outward ports of the connector NShape labelShape1 = CreateLabelShape("Label 1"); activePage.Items.Add(labelShape1); labelShape1.GlueMasterPortToPort(labelShape1.Ports[0], port1); NShape labelShape2 = CreateLabelShape("Label 2"); activePage.Items.Add(labelShape2); labelShape2.GlueMasterPortToPort(labelShape2.Ports[0], port2); }