private void dynamicPortGlueModeCombo_SelectedIndexChanged(object sender, EventArgs e) { if (EventsHandlingPaused) { return; } // get the selected shape NShape shape = view.Selection.AnchorNode as NShape; if (shape == null || shape.Ports == null) { return; } // get a dynamic port NDynamicPort port = shape.Ports.DefaultInwardPort as NDynamicPort; if (port == null) { return; } PauseEventsHandling(); // change the port glue mode port.GlueMode = (DynamicPortGlueMode)dynamicPortGlueModeCombo.SelectedItem; ResumeEventsHandling(); document.SmartRefreshAllViews(); }
private void CreateCenterShape() { // create the center shape to which all other shapes connect NRectangleF cell = base.GetGridCell(3, 0); cell.Inflate(-5, -5); NEllipseShape shape = new NEllipseShape(cell); shape.Name = "Center shape"; shape.Style.FillStyle = new NColorFillStyle(Color.FromArgb(50, 0, 0xbb, 0)); shape.Style.StrokeStyle = new NStrokeStyle(1, Color.FromArgb(0, 0xbb, 0)); shape.CreateShapeElements(ShapeElementsMask.Ports); NDynamicPort port = new NDynamicPort(shape.UniqueId, ContentAlignment.MiddleCenter, DynamicPortGlueMode.GlueToContour); shape.Ports.AddChild(port); shape.Ports.DefaultInwardPortUniqueId = port.UniqueId; // add it to the active layer and store for reuse document.ActiveLayer.AddChild(shape); centerShape = shape; }
private NCompositeShape CreateVerticalPipe() { NDynamicPort port; NCompositeShape shape = new NCompositeShape(); NRectanglePath rect = new NRectanglePath(SIZE, 0, SIZE, 3 * SIZE); NStyle.SetStrokeStyle(rect, new NStrokeStyle(0, Color.White)); shape.Primitives.AddChild(rect); shape.Primitives.AddChild(new NLinePath(SIZE, 0, SIZE, 3 * SIZE)); shape.Primitives.AddChild(new NLinePath(2 * SIZE, 0, 2 * SIZE, 3 * SIZE)); shape.UpdateModelBounds(); if (shape.Ports == null) { shape.CreateShapeElements(ShapeElementsMask.Ports); } port = new NDynamicPort(shape.UniqueId, TOP, DynamicPortGlueMode.GlueToContour); port.Type = PortType.InwardAndOutward; shape.Ports.AddChild(port); port = new NDynamicPort(shape.UniqueId, BOTTOM, DynamicPortGlueMode.GlueToContour); port.Type = PortType.InwardAndOutward; shape.Ports.AddChild(port); SetProtections(shape); return(shape); }
private NShape createPort(string name, PortType type) { int width = 10; int height = 10; NShape port; port = new NPolygonShape(new NPointF[] { new NPointF(0, 0), new NPointF((int)(width * 1.5), 0), new NPointF((int)(width * 1.5 + 10), (int)(height / 2)), new NPointF((int)(width * 1.5), (int)(height)), new NPointF(0, (int)(height)) }); port.Name = name; port.CreateShapeElements(ShapeElementsMask.Ports); NDynamicPort portInner; if (type == PortType.IN) { portInner = new NDynamicPort(new NContentAlignment(-50, 0), DynamicPortGlueMode.GlueToContour); } else { portInner = new NDynamicPort(new NContentAlignment(50, 0), DynamicPortGlueMode.GlueToContour); } portInner.Name = name; port.Ports.AddChild(portInner); return(port); }
private void CreateShapePorts(NShape shape) { shape.CreateShapeElements(ShapeElementsMask.Ports); // create a dynamic port anchored to the center of the shape NDynamicPort port = new NDynamicPort(new NContentAlignment(ContentAlignment.MiddleCenter), DynamicPortGlueMode.GlueToContour); port.Name = "port"; shape.Ports.AddChild(port); }
private NCompositeShape CreateCrossPipe() { NDynamicPort port; NCompositeShape shape = new NCompositeShape(); NPolygonPath polygon = new NPolygonPath(new NPointF[] { new NPointF(0, SIZE), new NPointF(SIZE, SIZE), new NPointF(SIZE, 0), new NPointF(2 * SIZE, 0), new NPointF(2 * SIZE, SIZE), new NPointF(3 * SIZE, SIZE), new NPointF(3 * SIZE, 2 * SIZE), new NPointF(2 * SIZE, 2 * SIZE), new NPointF(2 * SIZE, 3 * SIZE), new NPointF(SIZE, 3 * SIZE), new NPointF(SIZE, 2 * SIZE), new NPointF(0, 2 * SIZE) }); NStyle.SetStrokeStyle(polygon, new NStrokeStyle(0, Color.White)); shape.Primitives.AddChild(polygon); shape.Primitives.AddChild(new NLinePath(0, SIZE, SIZE, SIZE)); shape.Primitives.AddChild(new NLinePath(SIZE, SIZE, SIZE, 0)); shape.Primitives.AddChild(new NLinePath(2 * SIZE, 0, 2 * SIZE, SIZE)); shape.Primitives.AddChild(new NLinePath(2 * SIZE, SIZE, 3 * SIZE, SIZE)); shape.Primitives.AddChild(new NLinePath(3 * SIZE, 2 * SIZE, 2 * SIZE, 2 * SIZE)); shape.Primitives.AddChild(new NLinePath(2 * SIZE, 2 * SIZE, 2 * SIZE, 3 * SIZE)); shape.Primitives.AddChild(new NLinePath(SIZE, 3 * SIZE, SIZE, 2 * SIZE)); shape.Primitives.AddChild(new NLinePath(SIZE, 2 * SIZE, 0, 2 * SIZE)); shape.UpdateModelBounds(); if (shape.Ports == null) { shape.CreateShapeElements(ShapeElementsMask.Ports); } port = new NDynamicPort(shape.UniqueId, LEFT, DynamicPortGlueMode.GlueToContour); port.Type = PortType.InwardAndOutward; shape.Ports.AddChild(port); port = new NDynamicPort(shape.UniqueId, TOP, DynamicPortGlueMode.GlueToContour); port.Type = PortType.InwardAndOutward; shape.Ports.AddChild(port); port = new NDynamicPort(shape.UniqueId, RIGHT, DynamicPortGlueMode.GlueToContour); port.Type = PortType.InwardAndOutward; shape.Ports.AddChild(port); port = new NDynamicPort(shape.UniqueId, BOTTOM, DynamicPortGlueMode.GlueToContour); port.Type = PortType.InwardAndOutward; shape.Ports.AddChild(port); SetProtections(shape); return(shape); }
private NShape CreateShape(string name) { NShape shape = new NRectangleShape(0, 0, 100, 100); shape.Name = name; shape.Text = name + " Node"; // Create a center port shape.CreateShapeElements(ShapeElementsMask.Ports); NDynamicPort port = new NDynamicPort(new NContentAlignment(0, 0), DynamicPortGlueMode.GlueToContour); shape.Ports.AddChild(port); return(shape); }
private void CreatePorts(NGroup group, NShape anchorShape) { group.CreateShapeElements(ShapeElementsMask.Ports); NDynamicPort leftPort = new NDynamicPort(new NContentAlignment(ContentAlignment.MiddleLeft), DynamicPortGlueMode.GlueToLocation); leftPort.AnchorUniqueId = anchorShape.UniqueId; leftPort.Name = "LeftPort"; group.Ports.AddChild(leftPort); group.CreateShapeElements(ShapeElementsMask.Ports); NDynamicPort rightPort = new NDynamicPort(new NContentAlignment(ContentAlignment.MiddleRight), DynamicPortGlueMode.GlueToLocation); rightPort.AnchorUniqueId = anchorShape.UniqueId; rightPort.Name = "RightPort"; group.Ports.AddChild(rightPort); }
private void OnNodesConnecting(NConnectionCancelEventArgs args) { NDynamicPort port1 = (NDynamicPort)document.GetElementFromUniqueId(args.UniqueId1); NDynamicPort port2 = (NDynamicPort)document.GetElementFromUniqueId(args.UniqueId2); int side1 = GetSideIndex(port1); int side2 = GetSideIndex(port2); bool sidesFail = side1 % 2 != side2 % 2; bool alreadyConnected = port1.ConnectedPoints != null || port2.ConnectedPoints != null; if (sidesFail || alreadyConnected) { // The ports cannot be connected, so cancel the connection and apply a bounce back force NPoint offset = new NPoint(0, 0); bool even = side1 % 2 == 0; if (sidesFail) { if (even) { offset.X = (1 - side1) * SIZE; } else { offset.Y = (2 - side1) * SIZE; } } else { if (!even) { offset.X = (2 - side1) * SIZE; } else { offset.Y = (1 - side1) * SIZE; } } port1.Shape.Location = new NPointF(port1.Shape.Location.X + offset.X, port1.Shape.Location.Y + offset.Y); args.Cancel = true; } }
private int GetSideIndex(NDynamicPort port) { if (port.Alignment == LEFT) { return(0); } else if (port.Alignment == TOP) { return(1); } else if (port.Alignment == RIGHT) { return(2); } else if (port.Alignment == BOTTOM) { return(3); } else { throw new Exception("Invalid port side"); } }
public NExpandableShape() { // add a rectangle shape as base NRectangleShape rect = new NRectangleShape(new NRectangleF(0, 0, 75, 75)); rect.DestroyShapeElements(ShapeElementsMask.All); rect.Protection = new NAbilities(AbilitiesMask.Select | AbilitiesMask.InplaceEdit); Shapes.AddChild(rect); // add an expand collapse shape NExpandCollapseCheck check = new NExpandCollapseCheck(); check.Bounds = new NRectangleF(80, 0, 12, 12); check.Protection = new NAbilities(AbilitiesMask.Select | AbilitiesMask.InplaceEdit); check.ResizeInAggregate = ResizeInAggregate.RepositionOnly; Shapes.AddChild(check); // update the model bounds with the rectangle bounds UpdateModelBounds(rect.Transform.TransformBounds(rect.ModelBounds)); // initially it is expanded m_bExpanded = true; // by default the group has one dynamic port anchored to the rectangle CreateShapeElements(ShapeElementsMask.Ports); NDynamicPort port = new NDynamicPort(rect.UniqueId, ContentAlignment.MiddleCenter, DynamicPortGlueMode.GlueToContour); Ports.AddChild(port); Ports.DefaultInwardPortUniqueId = port.UniqueId; // by default the group has one rotated bounds port anchored to the rectangle CreateShapeElements(ShapeElementsMask.Labels); NRotatedBoundsLabel label = new NRotatedBoundsLabel("", rect.UniqueId, new Nevron.Diagram.NMargins(10)); Labels.AddChild(label); Labels.DefaultLabelUniqueId = label.UniqueId; }
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; } }
protected NGroup CreateNetwork(NPointF location, string labelText) { NGroup group = new NGroup(); document.ActiveLayer.AddChild(group); // create computer1 NCompositeShape computer1 = CreateComputer(); computer1.Location = new NPointF(0, 0); group.Shapes.AddChild(computer1); // create computer2 NCompositeShape computer2 = CreateComputer(); computer2.Location = new NPointF(200, 0); group.Shapes.AddChild(computer2); // create computer3 NCompositeShape computer3 = CreateComputer(); computer3.Location = new NPointF(100, 180); group.Shapes.AddChild(computer3); // connect the computers in the network ConnectComputers(computer1, computer2, group); ConnectComputers(computer2, computer3, group); ConnectComputers(computer3, computer1, group); // update the group model bounds group.UpdateModelBounds(); // insert a frame NRectangleShape frame = new NRectangleShape(group.ModelBounds); frame.Protection = new NAbilities(AbilitiesMask.Select | AbilitiesMask.InplaceEdit); group.Shapes.InsertChild(0, frame); // change group fill style group.Style.FillStyle = new NGradientFillStyle(GradientStyle.FromCenter, GradientVariant.Variant2, Color.Gainsboro, Color.White); // reposition and resize the group group.Location = location; group.Width = 155; group.Height = 155; // add a dynamic port to the group group.CreateShapeElements(ShapeElementsMask.Ports); NDynamicPort port = new NDynamicPort(group.UniqueId, ContentAlignment.MiddleCenter, DynamicPortGlueMode.GlueToContour); group.Ports.AddChild(port); group.Ports.DefaultInwardPortUniqueId = port.UniqueId; // modify the margins and text of the default label group.CreateShapeElements(ShapeElementsMask.Labels); NRotatedBoundsLabel label = new NRotatedBoundsLabel(labelText, group.UniqueId, new Nevron.Diagram.NMargins(0, 0, -10, 100)); group.Labels.AddChild(label); group.Labels.DefaultLabelUniqueId = label.UniqueId; return(group); }
protected NCompositeShape CreateCoffeeCupShape(NPointF location, float scale) { NCompositeShape shape = new NCompositeShape(); // create the cup as a polygon path NPolygonPath cup = new NPolygonPath(new NPointF[] { new NPointF(45, 268), new NPointF(63, 331), new NPointF(121, 331), new NPointF(140, 268) }); shape.Primitives.AddChild(cup); // create the cup hangle as a closed curve path NClosedCurvePath handle = new NClosedCurvePath(new NPointF[] { new NPointF(175, 295), new NPointF(171, 278), new NPointF(140, 283), new NPointF(170, 290), new NPointF(128, 323) }, 1); NStyle.SetFillStyle(handle, new NColorFillStyle(Color.LightSalmon)); shape.Primitives.AddChild(handle); // create the steam as a custom filled path GraphicsPath path = new GraphicsPath(); path.AddBeziers(new PointF[] { new PointF(92, 258), new PointF(53, 163), new PointF(145, 160), new PointF(86, 50), new PointF(138, 194), new PointF(45, 145), new PointF(92, 258) }); path.CloseAllFigures(); NCustomPath steam = new NCustomPath(path, PathType.ClosedFigure); NStyle.SetFillStyle(steam, new NColorFillStyle(Color.FromArgb(50, 122, 122, 122))); shape.Primitives.AddChild(steam); // update the shape model bounds to fit the primitives it contains shape.UpdateModelBounds(); // create the shape ports shape.CreateShapeElements(ShapeElementsMask.Ports); // create dynamic port anchored to the cup center NDynamicPort dynamicPort = new NDynamicPort(cup.UniqueId, ContentAlignment.MiddleCenter, DynamicPortGlueMode.GlueToContour); shape.Ports.AddChild(dynamicPort); // create rotated bounds port anchored to the middle right side of the handle NRotatedBoundsPort rotatedBoundsPort = new NRotatedBoundsPort(handle.UniqueId, ContentAlignment.MiddleRight); shape.Ports.AddChild(rotatedBoundsPort); // apply style to the shape shape.Style.FillStyle = new NColorFillStyle(Color.LightCoral); // position it and scale the shape shape.Location = location; shape.Width = shape.Width * scale; shape.Height = shape.Height * scale; return(shape); }
protected NCompositeShape CreateComputer() { NCompositeShape computer = new NCompositeShape(); // create the frame NEllipsePath frame = new NEllipsePath(-28, -28, 140, 140); NStyle.SetFillStyle(frame, new NColorFillStyle(Color.WhiteSmoke)); computer.Primitives.AddChild(frame); // create display 1 computer.Primitives.AddChild(new NRectanglePath(0, 0, 57, 47)); // create display 2 computer.Primitives.AddChild(new NRectanglePath(6, 4, 47, 39)); // create the keyboard computer.Primitives.AddChild(new NRectanglePath(-21, 53, 60, 14)); // create the tower case computer.Primitives.AddChild(new NRectanglePath(65, 0, 32, 66)); // create floppy 1 computer.Primitives.AddChild(new NRectanglePath(70, 5, 20, 3.75f)); // create floppy 2 computer.Primitives.AddChild(new NRectanglePath(70, 15, 20, 3.75f)); // create floppy 3 computer.Primitives.AddChild(new NRectanglePath(70, 25, 20, 3.75f)); // create the mouse tail computer.Primitives.AddChild(new NBezierCurvePath(new NPointF(38, 82), new NPointF(61, 74), new NPointF(27, 57), new NPointF(63, 54))); // create the mouse NEllipsePath mouse = new NEllipsePath(26, 79, 11, 19); mouse.Rotate(CoordinateSystem.Scene, 42, new NPointF(36.5f, 88.5f)); computer.Primitives.AddChild(mouse); // update the model bounds to fit the primitives computer.UpdateModelBounds(); // the default fill style is dold computer.Style.FillStyle = new NColorFillStyle(Color.Gold); // create the computer ports computer.CreateShapeElements(ShapeElementsMask.Ports); // create a dynamic port anchored to the center of the frame NDynamicPort port = new NDynamicPort(frame.UniqueId, ContentAlignment.MiddleCenter, DynamicPortGlueMode.GlueToContour); port.Name = "port"; // make the new port the one and default port of the computer computer.Ports.RemoveAllChildren(); computer.Ports.AddChild(port); computer.Ports.DefaultInwardPortUniqueId = port.UniqueId; return(computer); }
private NCompositeShape CreateEndPipe(string type) { NDynamicPort port; NCompositeShape shape = new NCompositeShape(); NPolygonPath polygon; NContentAlignment ca; switch (type) { case "W": polygon = new NPolygonPath(new NPointF[] { new NPointF(3 * SIZE, SIZE), new NPointF(2 * SIZE, 1.5f * SIZE), new NPointF(3 * SIZE, 2 * SIZE) }); ca = RIGHT; break; case "N": polygon = new NPolygonPath(new NPointF[] { new NPointF(SIZE, 3 * SIZE), new NPointF(1.5f * SIZE, 2 * SIZE), new NPointF(2 * SIZE, 3 * SIZE) }); ca = BOTTOM; break; case "E": polygon = new NPolygonPath(new NPointF[] { new NPointF(0, SIZE), new NPointF(SIZE, 1.5f * SIZE), new NPointF(0, 2 * SIZE) }); ca = LEFT; break; case "S": polygon = new NPolygonPath(new NPointF[] { new NPointF(SIZE, 0), new NPointF(1.5f * SIZE, SIZE), new NPointF(2 * SIZE, 0) }); ca = TOP; break; default: throw new ArgumentException("Unsupported elbow pipe type"); } NStyle.SetStrokeStyle(polygon, new NStrokeStyle(0, Color.White)); shape.Primitives.AddChild(polygon); shape.Primitives.AddChild(new NLinePath(polygon.Points[0], polygon.Points[1])); shape.Primitives.AddChild(new NLinePath(polygon.Points[1], polygon.Points[2])); shape.UpdateModelBounds(new NRectangleF(0, 0, 3 * SIZE, 3 * SIZE)); if (shape.Ports == null) { shape.CreateShapeElements(ShapeElementsMask.Ports); } port = new NDynamicPort(shape.UniqueId, ca, DynamicPortGlueMode.GlueToContour); port.Type = PortType.InwardAndOutward; shape.Ports.AddChild(port); SetProtections(shape); return(shape); }
private UDNGroup CreateInstance(string name, List <Port> ports, string id) { int instanceWidth = 50; int instanceHeight = 50; int InputMaxSize = 10; int InputCnt = 0; int OutputMaxSize = 10; int OutputCnt = 0; int offsetWidth = 9; int offsetHeight = 30; int widthPadding = 10; int heightPadding = 10; int textWidth = 30; int textHeight = 15; double textOffset = 1.5; int curInPtCnt = 0; int curOutPtCnt = 0; UDNGroup group = new UDNGroup(); group.Name = name; group.UDFullName = name; group.UDPorts = ports; // find max input/output port size for (int i = 0; i < ports.Count; i++) { if (ports[i].Type == PortType.IN) { InputCnt += 1; if (InputMaxSize < ports[i].Name.Length) { InputMaxSize = ports[i].Name.Length; } } else { OutputCnt += 1; if (OutputMaxSize < ports[i].Name.Length) { OutputMaxSize = ports[i].Name.Length; } } } instanceWidth = (InputMaxSize * offsetWidth) + (OutputMaxSize * offsetWidth) + widthPadding; instanceHeight = (InputCnt > OutputCnt ? InputCnt : OutputCnt) * offsetHeight + heightPadding; textWidth = instanceWidth; // Add Instance NRectangleShape node = new NRectangleShape(0, 0, (int)instanceWidth, (int)instanceHeight); NAbilities protection = node.Protection; protection.InplaceEdit = true; node.Protection = protection; node.Name = name; group.Shapes.AddChild(node); NTextShape nodeName = new NTextShape(name, 0, -15, textWidth, textHeight); nodeName.Style.TextStyle = new NTextStyle(); nodeName.Style.TextStyle.FontStyle = new NFontStyle(new Font("Arial", 9)); protection = nodeName.Protection; protection.InplaceEdit = true; nodeName.Protection = protection; group.Shapes.AddChild(nodeName); // Add Port for (int i = 0; i < ports.Count; i++) { NShape port = createPort(ports[i].Name, ports[i].Type); protection = port.Protection; protection.InplaceEdit = true; port.Protection = protection; group.Shapes.AddChild(port); if (ports[i].Type == PortType.IN) { curInPtCnt += 1; port.Location = new NPointF(-port.Bounds.Width / 2, (node.Bounds.Height / (InputCnt + 1)) * curInPtCnt); NTextShape portName = new NTextShape(ports[i].Name, port.Bounds.Width / 2, (node.Bounds.Height / (InputCnt + 1)) * curInPtCnt, ports[i].Name.Length * 9, (int)(port.Bounds.Height * textOffset)); portName.Style.TextStyle = new NTextStyle(); portName.Style.TextStyle.FontStyle = new NFontStyle(new Font("Arial", 9)); portName.Style.TextStyle.StringFormatStyle.HorzAlign = Nevron.HorzAlign.Left; protection = portName.Protection; protection.InplaceEdit = true; portName.Protection = protection; group.Shapes.AddChild(portName); } else { curOutPtCnt += 1; port.Location = new NPointF((-port.Bounds.Width / 2) + node.Bounds.Width, (node.Bounds.Height / (OutputCnt + 1)) * curOutPtCnt); NTextShape portName = new NTextShape(ports[i].Name, node.Bounds.Width - (port.Bounds.Width / 2) - (ports[i].Name.Length * 9), (node.Bounds.Height / (OutputCnt + 1)) * curOutPtCnt, ports[i].Name.Length * 9, (int)(port.Bounds.Height * textOffset)); portName.Style.TextStyle = new NTextStyle(); portName.Style.TextStyle.FontStyle = new NFontStyle(new Font("Arial", 9)); portName.Style.TextStyle.StringFormatStyle.HorzAlign = Nevron.HorzAlign.Right; protection = portName.Protection; protection.InplaceEdit = true; portName.Protection = protection; group.Shapes.AddChild(portName); } port.CreateShapeElements(ShapeElementsMask.Ports); NDynamicPort portInner; if (ports[i].Type == PortType.IN) { portInner = new NDynamicPort(new NContentAlignment(-50, 0), DynamicPortGlueMode.GlueToContour); portInner.Name = ports[i].Name; } else { portInner = new NDynamicPort(new NContentAlignment(50, 0), DynamicPortGlueMode.GlueToContour); portInner.Name = ports[i].Name; } port.Ports.AddChild(portInner); } group.UpdateModelBounds(); return(group); }
private UDNGroup CreateGlobalPort(string name, PortType type) { int width = 10; int height = 15; UDNGroup group = new UDNGroup(); group.Name = name; NShape port = new NPolygonShape(new NPointF[] { new NPointF(0, 0), new NPointF((int)(width * 1.5), 0), new NPointF((int)(width * 1.5 + 10), (int)(height / 2)), new NPointF((int)(width * 1.5), (int)(height)), new NPointF(0, (int)(height)) }); group.Shapes.AddChild(port); port.Name = name; port.CreateShapeElements(ShapeElementsMask.Ports); NDynamicPort portInner; if (type == PortType.IN) { portInner = new NDynamicPort(new NContentAlignment(50, 0), DynamicPortGlueMode.GlueToContour); } else { portInner = new NDynamicPort(new NContentAlignment(-50, 0), DynamicPortGlueMode.GlueToContour); } portInner.Name = name; port.Ports.AddChild(portInner); NTextShape nodeName; if (type == PortType.IN) { nodeName = new NTextShape(name, -(name.Length * 8), 0, name.Length * 8, height); } else { nodeName = new NTextShape(name, port.Bounds.Width, 0, name.Length * 8, height); } nodeName.Style.TextStyle = new NTextStyle(); nodeName.Style.TextStyle.FontStyle = new NFontStyle(new Font("Arial", 9)); if (type == PortType.IN) { nodeName.Style.TextStyle.StringFormatStyle.HorzAlign = Nevron.HorzAlign.Right; } else { nodeName.Style.TextStyle.StringFormatStyle.HorzAlign = Nevron.HorzAlign.Left; } group.Shapes.AddChild(nodeName); group.UpdateModelBounds(); return(group); }