private void portOffsetYNumeric_ValueChanged(object sender, System.EventArgs e) { if (EventsHandlingPaused) { return; } // get the selected shape NShape shape = view.Selection.AnchorNode as NShape; if (shape == null || shape.Ports == null || shape.Ports.DefaultInwardPort == null) { return; } PauseEventsHandling(); // change the port Y offset NPort port = shape.Ports.DefaultInwardPort as NPort; port.Offset = new NSizeF(port.Offset.Width, (float)portOffsetYNumeric.Value); ResumeEventsHandling(); document.SmartRefreshAllViews(); }
protected virtual void InitDiagram() { NShape shape = new NShape(); // ... // left NPort left = new NPort(0, 0.5d, true); left.SetDirection(ENBoxDirection.Left); shape.Ports.Add(left); // top NPort top = new NPort(0.5d, 0.0f, true); top.SetDirection(ENBoxDirection.Up); shape.Ports.Add(top); // right NPort right = new NPort(1.0d, 0.5d, true); right.SetDirection(ENBoxDirection.Right); shape.Ports.Add(right); // bottom NPort bottom = new NPort(0.5d, 1.0f, true); bottom.SetDirection(ENBoxDirection.Down); shape.Ports.Add(bottom); }
private void UpdatePortGeneralPropertiesControls(NPort port) { // can only disconnect the port if it is connected to any plugs disconnectPortButton.Enabled = (port.Plugs.Count != 0); // update port offset NSizeF offset = port.Offset; portOffsetXNumeric.Value = (decimal)offset.Width; portOffsetYNumeric.Value = (decimal)offset.Height; // populate the combo with available anchors INDiagramElementContainer searchRoot = port.GetRootForReferenceProperty("AnchorUniqueId"); NFilter filter = port.GetFilterForReferenceProperty("AnchorUniqueId"); NNodeList anchors = searchRoot.Descendants(null, -1); anchors.Insert(0, searchRoot); anchors = anchors.Filter(filter); anchorIdComboBox.Items.Clear(); anchorIdComboBox.Items.AddRange((object[])(anchors.ToArray(typeof(object)))); // select the currently chosen anchor for (int i = 0; i < anchorIdComboBox.Items.Count; i++) { Guid elemendGuid = (anchorIdComboBox.Items[i].Tag as INDiagramElement).UniqueId; if (elemendGuid.Equals(port.AnchorUniqueId)) { anchorIdComboBox.SelectedIndex = i; break; } } }
private void anchorIdComboBox_SelectedIndexChanged(object sender, System.EventArgs e) { if (EventsHandlingPaused) { return; } // get the selected shape NShape shape = view.Selection.AnchorNode as NShape; if (shape == null || shape.Ports == null || shape.Ports.DefaultInwardPort == null) { return; } PauseEventsHandling(); // anchor the default port to the selected element NPort port = shape.Ports.DefaultInwardPort as NPort; if (anchorIdComboBox.SelectedIndex == -1) { port.AnchorUniqueId = Guid.Empty; } else { port.AnchorUniqueId = (anchorIdComboBox.SelectedItem as NDiagramElement).UniqueId; } ResumeEventsHandling(); document.SmartRefreshAllViews(); }
/// <summary> /// Gets the port with the given name or creates one if a port with the given name /// does not exist in the specified shape. /// </summary> /// <param name="shape"></param> /// <param name="member"></param> /// <returns></returns> private NPort GetOrCreatePort(NShape shape, string member) { NPort port = shape.GetPortByName(member); if (port != null) { return(port); } // The port does not exist, so create it NLabel label = (NLabel)shape.Widget.GetFirstDescendant(new NLabelByTextFilter(member)); if (label == null) { return(null); } NPairBox pairBox = (NPairBox)label.GetFirstAncestor(NPairBox.NPairBoxSchema); NStackPanel stack = (NStackPanel)pairBox.ParentNode; double yRelative = (pairBox.GetAggregationInfo().Index + 0.5) / stack.Count; port = new NPort(0.5, yRelative, true); port.SetDirection(ENBoxDirection.Right); shape.Ports.Add(port); return(port); }
/// <summary> /// Creates a one to many connector from the member1 of shape1 to /// member2 of shape2. /// </summary> /// <param name="shape1"></param> /// <param name="member1"></param> /// <param name="shape2"></param> /// <param name="member2"></param> private void Connect(NShape shape1, string member1, NShape shape2, string member2) { NRoutableConnector connector = new NRoutableConnector(); connector.UserClass = ConnectorOneToManyClassName; m_DrawingDocument.Content.ActivePage.Items.Add(connector); // Get or create the ports NPort port1 = GetOrCreatePort(shape1, member1); NPort port2 = GetOrCreatePort(shape2, member2); if (port1 == null) { throw new ArgumentException("A member with name '" + member1 + "' not found in shape '" + shape1.Name + "'", "member"); } if (port1 == null) { throw new ArgumentException("A member with name '" + member2 + "' not found in shape '" + shape2.Name + "'", "member"); } // Connect the ports connector.GlueBeginToPort(port1); connector.GlueEndToPort(port2); }
private void ConnectCoffeeCups(NPort port1, NPort port2) { NLineShape line = new NLineShape(); document.ActiveLayer.AddChild(line); line.StartPlug.Connect(port1); line.EndPlug.Connect(port2); }
private void Connect(NPort beginPort, NPort endPort) { NRoutableConnector connector = new NRoutableConnector(); connector.RerouteMode = ENRoutableConnectorRerouteMode.Always; m_DrawingDocument.Content.ActivePage.Items.AddChild(connector); connector.GlueBeginToPort(beginPort); connector.GlueEndToPort(endPort); }
private NRoutableConnector ConnectElements(NGroup from, NGroup to) { NRoutableConnector line = new NRoutableConnector(); document.ActiveLayer.AddChild(line); NPort fromPort = (NPort)from.Ports.GetChildByName("RightPort"); NPort toPort = (NPort)to.Ports.GetChildByName("LeftPort"); line.StartPlug.Connect(fromPort); line.EndPlug.Connect(toPort); return(line); }
/// <summary> /// Creates a new connector, which connects the specified shapes /// </summary> /// <param name="fromShape"></param> /// <param name="fromPortName"></param> /// <param name="toShape"></param> /// <param name="toPortName"></param> /// <param name="connectorType"></param> /// <param name="text"></param> /// <returns>new 1D shapes</returns> private NShape CreateConnector(NShape fromShape, string fromPortName, NShape toShape, string toPortName, ENConnectorShape connectorType, string text) { // check arguments if (fromShape == null) { throw new ArgumentNullException("fromShape"); } if (toShape == null) { throw new ArgumentNullException("toShape"); } // create the connector NShape connector = new NConnectorShapeFactory().CreateShape(connectorType); // set text and user class connector.Text = text; connector.UserClass = NDR.StyleSheetNameConnectors; // connect begin NPort fromPort = fromShape.Ports.GetPortByName(fromPortName); if (fromPort != null) { connector.GlueBeginToPort(fromPort); } else { connector.GlueBeginToShape(fromShape); } // connect end NPort toPort = toShape.Ports.GetPortByName(toPortName); if (toPort != null) { connector.GlueEndToPort(toPort); } else { connector.GlueEndToShape(toShape); } // add to active page m_DrawingDocument.Content.ActivePage.Items.Add(connector); return(connector); }
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); }
private void ConnectShapes(NShape shape1, NShape shape2, NShape winner, int depth) { NPort port = (NPort)winner.Ports.GetChildByName("Left"); NRoutableConnector connector = new NRoutableConnector(); document.ActiveLayer.AddChild(connector); connector.FromShape = shape2; connector.EndPlug.Connect(port); SetAnimationsStyle(connector, depth); connector = new NRoutableConnector(); document.ActiveLayer.AddChild(connector); connector.FromShape = shape1; connector.EndPlug.Connect(port); SetAnimationsStyle(connector, depth); }
public override int GetHashCode() { int hash = 1; if (NRconnectTime != 0L) { hash ^= NRconnectTime.GetHashCode(); } if (NRconneCount != 0L) { hash ^= NRconneCount.GetHashCode(); } if (NPort != 0L) { hash ^= NPort.GetHashCode(); } if (StrDBName.Length != 0) { hash ^= StrDBName.GetHashCode(); } if (StrDnsIp.Length != 0) { hash ^= StrDnsIp.GetHashCode(); } if (StrDBUser.Length != 0) { hash ^= StrDBUser.GetHashCode(); } if (StrDBPwd.Length != 0) { hash ^= StrDBPwd.GetHashCode(); } if (NServerID != 0L) { hash ^= NServerID.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
void Interaction_GluingShapes(NGlueShapesEventArgs args) { // safely get the ports collection NPortCollection ports = (NPortCollection)args.Shape2D.GetChild(NShape.PortsChild, false); if (ports == null && ports.Count == 0) { return; } // get the anchor point in page coordinates NPoint anchorInPage = args.ConnectBegin ? args.Shape1D.GetEndPointInPage() : args.Shape1D.GetBeginPointInPage(); // get the nearest port NPort neartestPort = ports[0]; double neartestDistance = NGeometry2D.PointsDistance(anchorInPage, neartestPort.GetLocationInPage()); for (int i = 1; i < ports.Count; i++) { NPort curPort = ports[i]; double curDistance = NGeometry2D.PointsDistance(anchorInPage, curPort.GetLocationInPage()); if (curDistance < neartestDistance) { neartestDistance = curDistance; neartestPort = curPort; } } // connect begin or end if (args.ConnectBegin) { args.Shape1D.GlueBeginToPort(neartestPort); } else { args.Shape1D.GlueEndToPort(neartestPort); } // cancel the event so that the diagram does not perform default connection args.Cancel = true; }
/// <summary> /// Creates a custom shape that is a replica of the Visio Trapedzoid shape. With NOV diagram you can replicate the smart behavior of any Visio smart shape. /// </summary> /// <returns></returns> protected NShape CreateTrapedzoidShape() { NShape shape = new NShape(); shape.Init2DShape(); // add controls NControl control = new NControl(); control.SetFx(NControl.XProperty, new NShapeWidthFactorFx(0.3)); control.Y = 0.0d; control.SetFx(NControl.XBehaviorProperty, string.Format("IF(X<Width/2,{0},{1})", ((int)ENCoordinateBehavior.OffsetFromMin), ((int)ENCoordinateBehavior.OffsetFromMax))); control.YBehavior = ENCoordinateBehavior.Locked; control.Tooltip = "Modify strip width"; shape.Controls.Add(control); // add a geometry NGeometry geometry1 = shape.Geometry; { NMoveTo plotFigure = geometry1.MoveTo("MIN(Controls.0.X,Width-Controls.0.X)", 0.0d); geometry1.LineTo("Width-Geometry.0.X", 0.0d); geometry1.LineTo("Width", "Height"); geometry1.LineTo(0.0d, "Height"); geometry1.LineTo("Geometry.0.X", "Geometry.0.Y"); plotFigure.CloseFigure = true; } // add ports for (int i = 0; i < 4; i++) { NPort port = new NPort(); shape.Ports.Add(port); switch (i) { case 0: // top port.Relative = true; port.X = 0.5; port.Y = 0.0d; port.SetDirection(ENBoxDirection.Up); break; case 1: // right port.SetFx(NPort.XProperty, "(Geometry.1.X + Geometry.2.X) / 2"); port.SetFx(NPort.YProperty, new NShapeHeightFactorFx(0.5)); port.SetDirection(ENBoxDirection.Right); break; case 2: // bottom port.Relative = true; port.X = 0.5; port.Y = 1.0d; port.SetDirection(ENBoxDirection.Down); break; case 3: // left port.SetFx(NPort.XProperty, "(Geometry.0.X + Geometry.3.X) / 2"); port.SetFx(NPort.YProperty, new NShapeHeightFactorFx(0.5)); port.SetDirection(ENBoxDirection.Left); break; } } return(shape); }
/// <summary> /// Creates a connector between the ports of the specified shapes /// </summary> /// <param name="fromShape"></param> /// <param name="fromPortName"></param> /// <param name="toShape"></param> /// <param name="toPortName"></param> /// <param name="connectorType"></param> /// <param name="text"></param> /// <returns></returns> public NShape CreateConnector(NShape fromShape, string fromPortName, NShape toShape, string toPortName, ConnectorType connectorType, string text) { // check input if (fromShape == null) { throw new ArgumentNullException("fromShape"); } if (toShape == null) { throw new ArgumentNullException("toShape"); } NPort fromPort = (fromShape.Ports.GetChildByName(fromPortName, 0) as NPort); if (fromPort == null) { throw new ArgumentException("Was not able to find fromPortName in the ports collection of the fromShape", "fromPortName"); } NPort toPort = (toShape.Ports.GetChildByName(toPortName, 0) as NPort); if (toPort == null) { throw new ArgumentException("Was not able to find toPortName in the ports collection of the toShape", "toPortName"); } // create the connector NShape connector = null; switch (connectorType) { case ConnectorType.Line: connector = new NLineShape(); break; case ConnectorType.Bezier: connector = new NBezierCurveShape(); break; case ConnectorType.SingleArrow: connector = new NArrowShape(ArrowType.SingleArrow); break; case ConnectorType.DoubleArrow: connector = new NArrowShape(ArrowType.DoubleArrow); break; case ConnectorType.SideToTopBottom: connector = new NStep2Connector(false); break; case ConnectorType.TopBottomToSide: connector = new NStep2Connector(true); break; case ConnectorType.SideToSide: connector = new NStep3Connector(false, 50, 0, true); break; case ConnectorType.TopToBottom: connector = new NStep3Connector(true, 50, 0, true); break; case ConnectorType.DynamicHV: connector = new NRoutableConnector(RoutableConnectorType.DynamicHV); break; case ConnectorType.DynamicPolyline: connector = new NRoutableConnector(RoutableConnectorType.DynamicPolyline); break; case ConnectorType.DynamicCurve: connector = new NRoutableConnector(RoutableConnectorType.DynamicCurve); break; default: Debug.Assert(false, "New graph connector type?"); break; } // the connector must be added to the document prior to connecting it document.ActiveLayer.AddChild(connector); connector.StartPlug.Connect(fromPort); connector.EndPlug.Connect(toPort); connector.Style.TextStyle = (connector.ComposeTextStyle().Clone() as NTextStyle); connector.Style.TextStyle.Offset = new Nevron.GraphicsCore.NPointL(0, -7); connector.Text = text; return(connector); }
private void UpdateControlsState() { // only single selection is processed if (view.Selection.Nodes.Count != 1) { DisablePortControls(); return; } // check to see if the selected node is a shape and its defualt port is valid NShape shape = (view.Selection.AnchorNode as NShape); if (shape == null || shape.Ports == null || shape.Ports.DefaultInwardPort == null) { DisablePortControls(); return; } // enable the common operations and properties groups portOperationsGroup.Enabled = true; portPropertiesGroup.Enabled = true; // get the shape default port NPort defaultPort = shape.Ports.DefaultInwardPort; // update the general port properties UpdatePortGeneralPropertiesControls(defaultPort); // update dynamic port specific if (defaultPort is NDynamicPort) { dynamicPortGroup.Visible = true; NDynamicPort port = defaultPort as NDynamicPort; dynamicPortGlueModeCombo.SelectedItem = port.GlueMode; } else { dynamicPortGroup.Visible = false; } // update bounds port specific if (defaultPort is NBoundsPort || defaultPort is NRotatedBoundsPort) { boundsPortGroup.Visible = true; if (defaultPort is NBoundsPort) { alignmentComboBox.SelectedItem = (defaultPort as NBoundsPort).Alignment; } else { alignmentComboBox.SelectedItem = (defaultPort as NRotatedBoundsPort).Alignment; } } else { boundsPortGroup.Visible = false; } // update point port specific if (defaultPort is NPointPort) { pointPortGroup.Visible = true; portIndexModeComboBox.SelectedItem = (defaultPort as NPointPort).PointIndexMode; customPointIndexNumeric.Value = (defaultPort as NPointPort).CustomPointIndex; } else { pointPortGroup.Visible = false; } // update logical line port specific if (defaultPort is NLogicalLinePort) { logicalLinePortGroup.Visible = true; percentPositionNumeric.Value = (decimal)(defaultPort as NLogicalLinePort).Percent; } else { logicalLinePortGroup.Visible = false; } }
private NShape CreateAndShape() { NShape shape = new NShape(); shape.Init2DShape(); NSize normalSize = new NSize(1, 1); NGraphicsPath path = new NGraphicsPath(); // create input lines double x1 = 0; double y1 = normalSize.Height / 3; path.StartFigure(x1, y1); path.LineTo(normalSize.Width / 4, y1); double y2 = normalSize.Height * 2 / 3; double x2 = 0; path.StartFigure(x2, y2); path.LineTo(normalSize.Width / 4, y2); // create body path.StartFigure(normalSize.Width / 4, 0); path.LineTo(normalSize.Width / 4, 1); NPoint ellipseCenter = new NPoint(normalSize.Width / 4, 0.5); path.AddEllipseSegment(NRectangle.FromCenterAndSize(ellipseCenter, normalSize.Width, normalSize.Height), NMath.PIHalf, -NMath.PI); path.CloseFigure(); // create output double y3 = normalSize.Height / 2; double x3 = normalSize.Width; path.StartFigure(normalSize.Width * 3 / 4, y3); path.LineTo(x3, y3); shape.Geometry.AddRelative(new NDrawPath(new NRectangle(0, 0, 1, 1), path)); // create ports NPort input1 = new NPort(); input1.X = x1; input1.Y = y1; input1.Relative = true; input1.SetDirection(ENBoxDirection.Left); input1.FlowMode = ENPortFlowMode.Input; shape.Ports.Add(input1); NPort input2 = new NPort(); input2.X = x2; input2.Y = y2; input2.Relative = true; input2.SetDirection(ENBoxDirection.Left); input2.FlowMode = ENPortFlowMode.Input; shape.Ports.Add(input2); NPort output1 = new NPort(); output1.X = x3; output1.Y = y3; output1.Relative = true; output1.SetDirection(ENBoxDirection.Right); output1.FlowMode = ENPortFlowMode.Output; shape.Ports.Add(output1); // by default this shape does not accept shape-to-shape connections shape.DefaultShapeGlue = ENDefaultShapeGlue.None; // set text shape.Text = "AND"; return(shape); }
private NShape CreateTrapezoidShape(double width, double height, double pinX, double pinY) { NShape shape = new NShape(); shape.Init2DShape(); shape.Width = width; shape.Height = height; shape.PinX = pinX; shape.PinY = pinY; // add controls NControl control = new NControl(); control.SetFx(NControl.XProperty, new NShapeWidthFactorFx(0.3)); control.Y = 0.0d; control.XBehavior = ENCoordinateBehavior.OffsetFromMax; control.YBehavior = ENCoordinateBehavior.Locked; control.Tooltip = "Modify strip width"; shape.Controls.Add(control); // add a geometry NGeometry geometry1 = new NGeometry(); { NMoveTo plotFigure = geometry1.MoveTo("MIN(Controls.0.X,Width-Controls.0.X)", 0.0d); geometry1.LineTo("Width-Geometry.0.X", 0.0d); geometry1.LineTo(new NShapeWidthFactorFx(1), new NShapeHeightFactorFx(1)); geometry1.LineTo(0.0d, "Height"); geometry1.LineTo("Geometry.0.X", "Geometry.0.Y"); plotFigure.CloseFigure = true; } shape.Geometry = geometry1; // add ports // top NPort port = new NPort(); port.SetFx(NPort.XProperty, new NShapeWidthFactorFx(0.5)); port.Y = 0.0d; port.GlueMode = ENPortGlueMode.Outward; port.DirX = 0.0d; port.DirY = -1; shape.Ports.Add(port); // right port = new NPort(); port.SetFx(NPort.XProperty, new NShapeWidthFactorFx(1)); port.SetFx(NPort.YProperty, new NShapeHeightFactorFx(0.5)); port.GlueMode = ENPortGlueMode.InwardAndOutward; port.DirX = 1; port.DirY = 0.0d; shape.Ports.Add(port); // bottom port = new NPort(); port.SetFx(NPort.XProperty, "Controls.0.X"); port.SetFx(NPort.YProperty, new NShapeHeightFactorFx(1)); port.DirX = 0.0d; port.DirY = 1; shape.Ports.Add(port); // left port = new NPort(); port.X = 0.0d; port.SetFx(NPort.YProperty, new NShapeHeightFactorFx(0.5)); port.DirX = -1; port.DirY = 0.0d; shape.Ports.Add(port); // shape.FillStyle = new NColorFillStyle(Color.Gray); shape.Geometry.Stroke = new NStroke(1, NColor.Black); shape.Geometry.Stroke.LineJoin = ENLineJoin.Miter; /* NShadow shadow = new NShadow(NColor.Green, 50, 50); * shadow.ScalePinPoint = new NPoint(0.5, 0.5); * shadow.Scale = 1.0; * shadow.UseFillAndStrokeAlpha = false; * shadow.ApplyToFilling = true; * shadow.ApplyToOutline = true; * shape.Shadow = shadow;*/ NStackPanel stack = new NStackPanel(); NButton button = new NButton("Hello Joro"); //button.Click += new Function<NEventArgs>(button_Click); stack.Add(button); NLabel label = new NLabel("Hello World"); stack.Add(label); //shape.Widget = stack; //shape.Widget = new NLabel("Hello World"); return(shape); }
/// <summary> /// Creates a new connector, which connects the specified shapes /// </summary> /// <param name="fromShape"></param> /// <param name="fromPortName"></param> /// <param name="toShape"></param> /// <param name="toPortName"></param> /// <param name="connectorType"></param> /// <param name="text"></param> /// <returns>new 1D shapes</returns> protected NShape CreateConnector(NShape fromShape, string fromPortName, NShape toShape, string toPortName, ConnectorType connectorType, string text) { // check arguments if (fromShape == null) { throw new ArgumentNullException("fromShape"); } if (toShape == null) { throw new ArgumentNullException("toShape"); } NPort fromPort = (fromShape.Ports.GetChildByName(fromPortName, 0) as NPort); if (fromPort == null) { throw new ArgumentException("Was not able to find fromPortName in the ports collection of the fromShape", "fromPortName"); } NPort toPort = (toShape.Ports.GetChildByName(toPortName, 0) as NPort); if (toPort == null) { throw new ArgumentException("Was not able to find toPortName in the ports collection of the toShape", "toPortName"); } // create the connector NShape connector = null; switch (connectorType) { case ConnectorType.Line: connector = new NLineShape(); break; case ConnectorType.Bezier: connector = new NBezierCurveShape(); break; case ConnectorType.SingleArrow: connector = new NArrowShape(ArrowType.SingleArrow); break; case ConnectorType.DoubleArrow: connector = new NArrowShape(ArrowType.DoubleArrow); break; case ConnectorType.SideToTopBottom: connector = new NStep2Connector(false); break; case ConnectorType.TopBottomToSide: connector = new NStep2Connector(true); break; case ConnectorType.SideToSide: connector = new NStep3Connector(false, 50, 0, true); break; case ConnectorType.TopToBottom: connector = new NStep3Connector(true, 50, 0, true); break; case ConnectorType.DynamicHV: connector = new NRoutableConnector(RoutableConnectorType.DynamicHV); break; case ConnectorType.DynamicPolyline: connector = new NRoutableConnector(RoutableConnectorType.DynamicPolyline); break; case ConnectorType.DynamicCurve: connector = new NRoutableConnector(RoutableConnectorType.DynamicCurve); break; default: Debug.Assert(false, "New graph connector type?"); break; } // the connector must be added to the document prior to connecting it DrawingView.Document.ActiveLayer.AddChild(connector); // change the default label text connector.Text = text; // connectors by default inherit styles from the connectors stylesheet connector.StyleSheetName = NDR.NameConnectorsStyleSheet; // connect the connector to the specified ports connector.StartPlug.Connect(fromPort); connector.EndPlug.Connect(toPort); // modify the connector text style connector.Style.TextStyle = (connector.ComposeTextStyle().Clone() as NTextStyle); connector.Style.TextStyle.Offset = new NPointL(0, -7); return(connector); }