private void CreateStroke() { // create an arrow head style which uses a custom shape NArrowheadStyle defaultStyle = new NArrowheadStyle( ArrowheadShape.Custom, "Double Opened Arrow", new NSizeL(13, 13), new NColorFillStyle(Color.OrangeRed), new NStrokeStyle(1, Color.Black)); // create a polyline which uses this arrowhead style NPointF[] points = new NPointF[] { new NPointF(290, 50), new NPointF(207, 199), new NPointF(40, 50), new NPointF(234, 95), new NPointF(94, 184) }; NPolylineShape polyline = new NPolylineShape(points); polyline.Style.StartArrowheadStyle = defaultStyle.Clone() as NArrowheadStyle; polyline.Style.EndArrowheadStyle = defaultStyle.Clone() as NArrowheadStyle; document.ActiveLayer.AddChild(polyline); }
private void CreateShapeWithLogicalLinePort() { NPointF[] points = new NPointF[] { new NPointF(151, 291), new NPointF(151, 316), new NPointF(123, 336), new NPointF(151, 350), new NPointF(158, 319), new NPointF(180, 312) }; // create a polyline shape with a logical line port NPolylineShape shape = new NPolylineShape(points); shape.Name = "Shape with a Logical Line Port"; shape.Bounds = base.GetGridCell(5, 1); // create the ports shape.CreateShapeElements(ShapeElementsMask.Ports); NLogicalLinePort port = new NLogicalLinePort(shape.UniqueId, 30); shape.Ports.RemoveAllChildren(); shape.Ports.AddChild(port); shape.Ports.DefaultInwardPortUniqueId = port.UniqueId; // connect it with the center shape document.ActiveLayer.AddChild(shape); ConnectShapes(centerShape, shape); // descibte it NTextShape text = new NTextShape("Shape with Logical Line Port", base.GetGridCell(5, 2, 0, 1)); document.ActiveLayer.AddChild(text); }
private void CreatePolylineShape(int row, int col) { NRectangleF cell = GetGridCell(row, col); Color color = GetPredefinedColor(3); int xdeviation = (int)cell.Width / 4; int ydeviation = (int)cell.Height / 4; NPointF[] points = new NPointF[] { new NPointF(cell.X + Random.Next(xdeviation), cell.Y + Random.Next(ydeviation)), new NPointF(cell.Right - Random.Next(xdeviation), cell.Y + Random.Next(ydeviation)), new NPointF(cell.Right - Random.Next(xdeviation), cell.Bottom - Random.Next(ydeviation)), new NPointF(cell.X + Random.Next(xdeviation), cell.Bottom - Random.Next(ydeviation)), new NPointF(cell.X + Random.Next((int)cell.Width), cell.Y + Random.Next((int)cell.Height)) }; // create polyline NPolylineShape polyline = new NPolylineShape(points); // set stroke style polyline.Style.StrokeStyle = new NStrokeStyle(2, color, LinePattern.DashDot); // set arrowheads style NArrowheadStyle arrowheadStyle = new NArrowheadStyle( ArrowheadShape.Fork, "", new NSizeL(12, 12), new NColorFillStyle(color), new NStrokeStyle(1, Color.Black)); polyline.Style.StartArrowheadStyle = arrowheadStyle; arrowheadStyle = new NArrowheadStyle( ArrowheadShape.Losangle, "", new NSizeL(12, 12), new NColorFillStyle(color), new NStrokeStyle(1, Color.Black)); polyline.Style.EndArrowheadStyle = arrowheadStyle; // add to the active layer document.ActiveLayer.AddChild(polyline); // add description cell = GetGridCell(row + 1, col); NTextShape text = new NTextShape("Polyline with dash-dot style and Fork and Losangle arrowheads", cell); document.ActiveLayer.AddChild(text); }
private void addRandomPolylineButton_Click(object sender, System.EventArgs e) { NRectangleF bounds = view.Viewport; int count = (int)pointsCountNumeric.Value; NPolylineShape path = new NPolylineShape(base.GetRandomPoints(bounds, count)); document.ActiveLayer.AddChild(path); path.Style = path.ComposeStyle().Clone() as NStyle; path.Style.StrokeStyle.Color = Color.DarkCyan; path.Style.StartArrowheadStyle.StrokeStyle.Color = Color.DarkCyan; path.Style.EndArrowheadStyle.StrokeStyle.Color = Color.DarkCyan; view.Selection.SingleSelect(path); view.SmartRefresh(); }
private void randomPolylineButton_Click(object sender, System.EventArgs e) { // create shape NPolylineShape shape = null; try { shape = new NPolylineShape(base.GetRandomPoints(view.Viewport, (int)pointsCountNumericUpDown.Value)); } catch { return; } // add to active layer document.ActiveLayer.AddChild(shape); document.SmartRefreshAllViews(); }
protected NGroup CreateScale1DGroup() { NGroup group = new NGroup(); // arrow NArrowShape arrow = new NArrowShape(ArrowType.SingleArrow, new NPointF(0, 0), new NPointF(75, 75), 10, 45, 30); arrow.ResizeInAggregate = ResizeInAggregate.Scale1D; arrow.Text = "Scale 1D"; group.Shapes.AddChild(arrow); // line NLineShape line = new NLineShape(new NPointF(150, 0), new NPointF(150 + 100, 100)); line.StyleSheetName = NDR.NameConnectorsStyleSheet; line.ResizeInAggregate = ResizeInAggregate.Scale1D; line.Text = "Scale 1D"; group.Shapes.AddChild(line); // polyline NPolylineShape polyline = new NPolylineShape(base.GetRandomPoints(new NRectangleF(0, 150, 100, 100), 3)); polyline.StyleSheetName = NDR.NameConnectorsStyleSheet; polyline.ResizeInAggregate = ResizeInAggregate.Scale1D; polyline.Text = "Scale 1D"; group.Shapes.AddChild(polyline); // rect NRectangleShape rect = new NRectangleShape(150, 150, 75, 75); rect.Rotate(CoordinateSystem.Scene, 45, rect.PinPoint); rect.ResizeInAggregate = ResizeInAggregate.Scale1D; rect.Text = "Scale 1D"; group.Shapes.AddChild(rect); // update the group model bounds group.UpdateModelBounds(); // add the group to the active layer document.ActiveLayer.AddChild(group); return(group); }
private void CreateSamplePolyline2() { NPointF[] points = new NPointF[] { new NPointF(212, 250), new NPointF(174, 250), new NPointF(174, 169), new NPointF(242, 169), new NPointF(242, 208), }; NPolylineShape hvPolyline = new NPolylineShape(points); document.ActiveLayer.AddChild(hvPolyline); hvPolyline.Style = hvPolyline.ComposeStyle().Clone() as NStyle; hvPolyline.Style.StrokeStyle.Color = Color.OrangeRed; hvPolyline.Style.StartArrowheadStyle.StrokeStyle.Color = Color.OrangeRed; hvPolyline.Style.EndArrowheadStyle.StrokeStyle.Color = Color.OrangeRed; hvPolyline.Style.BridgeStyle.Shape = BridgeShape.Sides2; }
private void CreateSamplePolyline1() { NPointF[] points = new NPointF[] { new NPointF(10, 210), new NPointF(75, 10), new NPointF(75, 10), new NPointF(75, 175), new NPointF(145, 175), new NPointF(145, 10), new NPointF(210, 75), new NPointF(210, 210), new NPointF(105, 210), new NPointF(105, 105), }; NPolylineShape line = new NPolylineShape(points); line.BridgeTargets = BridgeTargets.Self; document.ActiveLayer.AddChild(line); }
private void InitDocument() { // create a rectangle shape with a 2 bounds label NShape shape = new NRectangleShape(base.GetGridCell(0, 0)); shape.Style.FillStyle = new NColorFillStyle(Color.FromArgb(50, 0xcc, 0, 0)); shape.Labels.RemoveAllChildren(); NBoundsLabel boundsLabel = new NBoundsLabel("Label 1, Wrapped", shape.UniqueId, new Nevron.Diagram.NMargins(0, 0, 0, 50)); shape.Labels.AddChild(boundsLabel); shape.Labels.DefaultLabelUniqueId = boundsLabel.UniqueId; boundsLabel = new NBoundsLabel("Label 2, Stretched", shape.UniqueId, new Nevron.Diagram.NMargins(0, 0, 50, 0)); boundsLabel.Mode = BoxTextMode.Stretch; shape.Labels.AddChild(boundsLabel); document.ActiveLayer.AddChild(shape); // create a rectangle shape with a 2 rotated bounds labels shape = new NRectangleShape(base.GetGridCell(0, 1)); shape.Style.FillStyle = new NColorFillStyle(Color.FromArgb(50, 0, 0, 0xcc)); shape.Labels.RemoveAllChildren(); NRotatedBoundsLabel rotatedLabel = new NRotatedBoundsLabel("Rotated Label 1, Wrapped", shape.UniqueId, new Nevron.Diagram.NMargins(0, 0, 0, 50)); shape.Labels.AddChild(rotatedLabel); shape.Labels.DefaultLabelUniqueId = rotatedLabel.UniqueId; rotatedLabel = new NRotatedBoundsLabel("Rotated Label 2, Stretched", shape.UniqueId, new Nevron.Diagram.NMargins(0, 0, 50, 0)); rotatedLabel.Mode = BoxTextMode.Stretch; shape.Labels.AddChild(rotatedLabel); document.ActiveLayer.AddChild(shape); // create a polyline shape with two logical line labels NRectangleF cell = base.GetGridCell(1, 0, 0, 1); shape = new NPolylineShape(new NPointF[] { cell.Location, cell.RightBottom }); shape.Labels.RemoveAllChildren(); NLogicalLineLabel lineLabel = new NLogicalLineLabel("Line label - start", shape.UniqueId, 0, true, true); shape.Labels.AddChild(lineLabel); shape.Labels.DefaultLabelUniqueId = lineLabel.UniqueId; // alter the start label text style NTextStyle textStyle = document.Style.TextStyle.Clone() as NTextStyle; textStyle.StringFormatStyle.HorzAlign = HorzAlign.Left; textStyle.Offset = new NPointL(0, -7); NStyle.SetTextStyle(lineLabel, textStyle); // add the end label lineLabel = new NLogicalLineLabel("Line label - end", shape.UniqueId, 100, true, true); shape.Labels.AddChild(lineLabel); // alter the end label text style textStyle = document.Style.TextStyle.Clone() as NTextStyle; textStyle.StringFormatStyle.HorzAlign = HorzAlign.Right; textStyle.Offset = new NPointL(0, -7); NStyle.SetTextStyle(lineLabel, textStyle); document.ActiveLayer.AddChild(shape); }