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 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); }
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 CreateOrgChartShape(NPersonalInfo info) { NRectangleF bounds = info.Bounds; float bottomPortAlignment = info.BottomPortAlignment; Bitmap photo = new Bitmap(this.MapPathSecure(info.Picture)); // compose a new graph vertex from a frame and an image NRectanglePath frame = new NRectanglePath(bounds); NRectanglePath image = new NRectanglePath(new NPointF(bounds.X + 5, bounds.Y + 5), new NSizeF(photo.Size)); NImageFillStyle imgageFillStyle = new NImageFillStyle(photo, 0xff); NStyle.SetFillStyle(image, imgageFillStyle); NCompositeShape shape = new NCompositeShape(); shape.Primitives.AddChild(frame); shape.Primitives.AddChild(image); shape.UpdateModelBounds(); Document.ActiveLayer.AddChild(shape); // set the vertex fill style NColorFillStyle fillStyle = null; switch (info.Level) { case 0: fillStyle = new NColorFillStyle(Color.FromArgb(241, 100, 34)); break; case 1: fillStyle = new NColorFillStyle(Color.FromArgb(249, 167, 26)); break; case 2: fillStyle = new NColorFillStyle(Color.FromArgb(255, 247, 151)); break; } fillStyle.ImageFiltersStyle.Filters.Add(new NLightingImageFilter()); shape.Style.FillStyle = fillStyle; NInteractivityStyle interactivityStyle = new NInteractivityStyle(); interactivityStyle.Tooltip.Text = "Click to show " + info.Name + " personal information"; interactivityStyle.UrlLink.Url = "../Examples/WebControl/GettingStarted/NPersonalInfoPage.aspx?" + info.Id.ToString(); shape.Style.InteractivityStyle = interactivityStyle; // add a new label for the person name NRotatedBoundsLabel nameLabel = new NRotatedBoundsLabel(info.Name, shape.UniqueId, new Nevron.Diagram.NMargins(40, 1, 50, 1)); shape.Labels.AddChild(nameLabel); NStyle.SetTextStyle(nameLabel, nameLabel.ComposeTextStyle().Clone() as NTextStyle); nameLabel.Style.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Right; nameLabel.Style.TextStyle.StringFormatStyle.VertAlign = VertAlign.Top; // configure default label (used for the person position) NRotatedBoundsLabel positionLabel = shape.Labels.DefaultLabel as NRotatedBoundsLabel; NStyle.SetTextStyle(positionLabel, positionLabel.ComposeTextStyle().Clone() as NTextStyle); positionLabel.Style.TextStyle.FontStyle.InitFromFont(new Font("Arial", 10, FontStyle.Bold)); positionLabel.Style.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Right; positionLabel.Style.TextStyle.StringFormatStyle.VertAlign = VertAlign.Bottom; positionLabel.Margins = new Nevron.Diagram.NMargins(40, 5, 1, 50); positionLabel.Text = info.Position; // create the optional ports of the shape shape.CreateShapeElements(ShapeElementsMask.Ports); // add rotated bounds ports NPort leftPort = new NRotatedBoundsPort(shape.UniqueId, new NContentAlignment(ContentAlignment.MiddleLeft)); leftPort.Name = "Left"; shape.Ports.AddChild(leftPort); NPort rightPort = new NRotatedBoundsPort(shape.UniqueId, new NContentAlignment(ContentAlignment.MiddleRight)); rightPort.Name = "Right"; shape.Ports.AddChild(rightPort); NPort topPort = new NRotatedBoundsPort(shape.UniqueId, new NContentAlignment(ContentAlignment.TopCenter)); topPort.Name = "Top"; shape.Ports.AddChild(topPort); NRotatedBoundsPort bottomPort = new NRotatedBoundsPort(shape.UniqueId, new NContentAlignment(bottomPortAlignment, 50)); bottomPort.Name = "Bottom"; shape.Ports.AddChild(bottomPort); 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); }