public void CreatePolygon() { // create polygon NRectangleF cell = this.DocumentHelper.GetGridCell(0, 2); 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)) }; NPolygonShape polygon = new NPolygonShape(points); // set fill and stroke styles polygon.Style.FillStyle = new NGradientFillStyle(GradientStyle.FromCenter, GradientVariant.Variant1, Color.Green, Color.Yellow); polygon.Style.StrokeStyle = new NStrokeStyle(1, Color.Black, LinePattern.DashDot); // add to active layer Document.ActiveLayer.AddChild(polygon); // add description cell = this.DocumentHelper.GetGridCell(1, 2); NTextShape text = new NTextShape("Polygon with gradient fill style and dash-dot stroke style", cell); Document.ActiveLayer.AddChild(text); }
private void CreateGroup(int row, int col, Color color) { string transactionName = color.ToString().Replace("Color [", string.Empty).Replace("]", string.Empty) + " group"; // start transaction document.StartTransaction(transactionName); // create the shapes in the group NPolygonShape polygon = new NPolygonShape(base.GetRandomPoints(base.GetGridCell(row, col), 6)); NClosedCurveShape curve = new NClosedCurveShape(base.GetRandomPoints(base.GetGridCell(row, col + 1), 6), 1); NTextShape text = new NTextShape(transactionName, base.GetGridCell(row, col, 0, 1)); // create the group NGroup group = new NGroup(); group.Shapes.AddChild(polygon); group.Shapes.AddChild(curve); group.Shapes.AddChild(text); group.UpdateModelBounds(); // apply styles to it group.Style.FillStyle = new NColorFillStyle(Color.FromArgb(50, color)); group.Style.StrokeStyle = new NStrokeStyle(1, color); group.Style.TextStyle = new NTextStyle(new Font("Arial", 10), color); group.Style.TextStyle.StringFormatStyle.VertAlign = VertAlign.Bottom; // add the group to the active layer document.ActiveLayer.AddChild(group); // commit the transaction document.HistoryService.Commit(); }
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); }
void CreateLabeledPolyOutline(NPointF[] points, NPolygonShape polyShape, NNodeList labels, string title) { NNodeList nodes = new NNodeList(); nodes.Add(polyShape); if (labels != null) { nodes.AddRange(labels); } int length = points.Length - 1; int vIndex = 0, hIndex = 0, index = 0; for (int i = 0; i < length; i++) { nodes.Add(ConnectPointsLabeled(points[i], points[i + 1], ref hIndex, ref vIndex, ref index)); } nodes.Add(ConnectPointsLabeled(points[points.Length - 1], points[0], ref hIndex, ref vIndex, ref index)); NGroup g; NBatchGroup batchGroup = new NBatchGroup(document); batchGroup.Build(nodes); batchGroup.Group(document.ActiveLayer, true, out g); g.Name = title + " Group"; }
void CreateBalcony2(NPointF offset) { NPointF[] points = ApplyOffset(Balcony2.points, offset); NPolygonShape p = new NPolygonShape(points); p.Text = "Bedroom Balcony"; p.Style.TextStyle = txMain.Clone() as NTextStyle; document.ActiveLayer.AddChild(p); CreateLabeledPolyOutline(points, p, null, "Bedroom Balcony"); }
void CreateGuestRoom(NPointF offset) { NPointF[] points = ApplyOffset(GuestRoom.points, offset); NPolygonShape p = new NPolygonShape(points); p.Text = "Guest Room, H=270"; p.Style.TextStyle = txMain.Clone() as NTextStyle; document.ActiveLayer.AddChild(p); CreateLabeledPolyOutline(points, p, null, "Guest Room"); }
void CreateInnerHallway(NPointF offset) { NPointF[] points = ApplyOffset(InnerHallway.points, offset); NPolygonShape p = new NPolygonShape(points); p.Text = "Inn.Hallway, H=270"; p.Style.TextStyle = txMain.Clone() as NTextStyle; document.ActiveLayer.AddChild(p); CreateLabeledPolyOutline(points, p, null, "Inner Hallway"); }
void CreateKitchen(NPointF offset) { NPointF[] points = ApplyOffset(Kitchen.points, offset); NPolygonShape p = new NPolygonShape(points); p.Text = "Kitchen, H=265"; p.Style.TextStyle = txMain.Clone() as NTextStyle; document.ActiveLayer.AddChild(p); CreateLabeledPolyOutline(points, p, null, "Kitchen"); }
void CreateHallway(NPointF offset) { NPointF[] points = ApplyOffset(Hallway.points, offset); NPolygonShape p = new NPolygonShape(points); p.Text = "Hallway, H=270"; p.Style.TextStyle = txMain.Clone() as NTextStyle; p.Style.TextStyle.Offset = new NPointL(-60, 0); document.ActiveLayer.AddChild(p); NNodeList labels = new NNodeList(); labels.Add(AddLabel(ApplyOffset(Hallway.section1Center, offset), "H=240", false)); CreateLabeledPolyOutline(points, p, labels, "Hallway"); }
void CreateLivingRoom(NPointF offset) { NPointF[] points = ApplyOffset(LivingRoom.points, offset); NPolygonShape p = new NPolygonShape(points); p.Text = "Living Room, H=265"; p.Style.TextStyle = txMain; document.ActiveLayer.AddChild(p); NNodeList labels = new NNodeList(); labels.Add(AddLabel(LivingRoom.section1Center, "H=240", false)); labels.Add(AddLabel(LivingRoom.section2Center, "H=240", true)); CreateLabeledPolyOutline(points, p, labels, "Living Room"); }
private void randomPolygonButton_Click(object sender, System.EventArgs e) { // create shape NPolygonShape shape = null; try { shape = new NPolygonShape(base.GetRandomPoints(view.Viewport, (int)pointsCountNumericUpDown.Value)); } catch { return; } // add to active layer document.ActiveLayer.AddChild(shape); document.SmartRefreshAllViews(); }
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); }