private NGroup CreateSubgroup(string name) { NGroup subgroup = new NGroup(); subgroup.Name = name; // Create 2 shapes NShape shape1 = CreateShape(name + "a"); shape1.Location = new NPointF(0, 0); subgroup.Shapes.AddChild(shape1); NShape shape2 = CreateShape(name + "b"); shape2.Location = new NPointF(110, 110); subgroup.Shapes.AddChild(shape2); // Create the decorators CreateDecorators(subgroup, subgroup.Name + " Subgroup"); // Update the model bounds so that the shapes are inside the specified padding subgroup.Padding = new Nevron.Diagram.NMargins(5, 5, 30, 5); subgroup.UpdateModelBounds(); return(subgroup); }
private NGroup CreateGroup(string name) { NGroup group = new NGroup(); group.Name = name; // Create 2 subgroups NGroup subGroup1 = CreateSubgroup(name + "1"); subGroup1.Location = new NPointF(20, 0); group.Shapes.AddChild(subGroup1); NGroup subGroup2 = CreateSubgroup(name + "2"); subGroup2.Location = new NPointF(260, 0); group.Shapes.AddChild(subGroup2); // Create the decorators CreateDecorators(group, group.Name + " Group"); // Update the model bounds so that the subgroups are inside the specified padding group.Padding = new Nevron.Diagram.NMargins(5, 5, 30, 5); group.UpdateModelBounds(); group.AutoUpdateModelBounds = true; return(group); }
private NGroup CreateElement(string text) { NGroup group = new NGroup(); document.ActiveLayer.AddChild(group); // Create the text shape NTextShape textShape = new NTextShape(text, 0, 0, 1, 1); group.Shapes.AddChild(textShape); textShape.SizeToText(new NMarginsF(10, 2, 10, 2)); // Create the line shape under the text NRectangleF rect = textShape.Bounds; NLineShape lineShape = new NLineShape(rect.X, rect.Bottom, rect.Right, rect.Bottom); group.Shapes.AddChild(lineShape); // Create the ports CreatePorts(group, lineShape); // Set the protections SetProtections(group); group.UpdateModelBounds(); return(group); }
private NGroup CreateStartElement(string text) { NGroup group = new NGroup(); document.ActiveLayer.AddChild(group); // Create the ellipse shape NShape ellipseShape = new NEllipseShape(0, 0, 1, 1); group.Shapes.AddChild(ellipseShape); ellipseShape.Text = text; ellipseShape.SizeToText(new NMarginsF(100, 18, 10, 18)); ellipseShape.Location = new NPointF(0, 0); // Create the check shape NBrainstormingShapesFactory brainstormingFactory = new NBrainstormingShapesFactory(document); NShape checkShape = brainstormingFactory.CreateShape(BrainstormingShapes.Check); checkShape.Bounds = new NRectangleF(26, 12, 24, 23); group.Shapes.AddChild(checkShape); // Create the ports CreatePorts(group, ellipseShape); // Set the protections SetProtections(group); group.UpdateModelBounds(); return(group); }
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 void OnVertexImported(NDataSourceImporter importer, NShape shape, INDataRecord dataRecord) { // Create a shape to host in the group based on the value of the "Type" column NShape innerShape = null; switch (dataRecord.GetColumnValue("Type").ToString()) { case "DB": innerShape = m_FilesAndFoldersFactory.CreateShape(FilesAndFoldersShapes.Binder); break; case "File": innerShape = m_FilesAndFoldersFactory.CreateShape(FilesAndFoldersShapes.SimpleFolder); break; case "Report": innerShape = m_FilesAndFoldersFactory.CreateShape(FilesAndFoldersShapes.BlankFile); break; } innerShape.Text = dataRecord.GetColumnValue("Id").ToString(); // Host the created shape in the group NGroup group = (NGroup)shape; group.Shapes.AddChild(innerShape); group.UpdateModelBounds(); }
protected NGroup CreateChildGroup() { Color color1 = Color.FromArgb(25, 0, 0xbb, 0xbb); Color color2 = Color.FromArgb(150, 0, 204, 0); NGroup group = new NGroup(); // create the group frame NRectangleF bounds = base.GetGridCell(0, 0, 1, 1); NRectangleShape frame = new NRectangleShape(bounds); frame.Protection = new NAbilities(AbilitiesMask.Select); frame.Style.FillStyle = new NColorFillStyle(color1); group.Shapes.AddChild(frame); // create the group shapes group.Shapes.AddChild(new NRectangleShape(base.GetGridCell(0, 0))); group.Shapes.AddChild(new NEllipseShape(base.GetGridCell(0, 1))); group.Shapes.AddChild(new NTextShape("Child group", base.GetGridCell(1, 0, 0, 1))); // update the group model bounds group.UpdateModelBounds(); // apply styles to the group group.Style.FillStyle = new NColorFillStyle(color2); group.Style.StrokeStyle = new NStrokeStyle(1, color2); group.Style.TextStyle = new NTextStyle(new Font("Arial", 10), color2); return(group); }
private void InitDocument() { Color color1 = Color.FromArgb(25, 0, 0xaa, 0xaa); Color color2 = Color.FromArgb(150, 0, 0, 204); NGroup group = new NGroup(); // create the group frame NRectangleF bounds = base.GetGridCell(0, 0, 2, 3); NRectangleShape frame = new NRectangleShape(bounds); frame.Protection = new NAbilities(AbilitiesMask.Select); frame.Style.FillStyle = new NColorFillStyle(color1); group.Shapes.AddChild(frame); // add some shape to the group group.Shapes.AddChild(new NRectangleShape(base.GetGridCell(0, 2))); group.Shapes.AddChild(new NEllipseShape(base.GetGridCell(0, 3))); group.Shapes.AddChild(new NTextShape("Parent group", GetGridCell(2, 0, 0, 3))); // add the child group in the group group.Shapes.AddChild(CreateChildGroup()); // update the group model bounds group.UpdateModelBounds(); // apply styles to the group group.Style.FillStyle = new NColorFillStyle(color2); group.Style.StrokeStyle = new NStrokeStyle(color2); group.Style.TextStyle = new NTextStyle(new Font("Arial", 10), color2); // add the parent group to the active layer document.ActiveLayer.AddChild(group); }
private void CreateGroup(int row, int col, AbilitiesMask protection) { // create a group NGroup group = new NGroup(); group.Protection = new NAbilities(protection); // add two rectangle shapes in it group.Shapes.AddChild(new NRectangleShape(new NRectangleF(0, 0, 1, 1))); group.Shapes.AddChild(new NRectangleShape(new NRectangleF(2, 2, 1, 1))); // update the group model bounds to fit the shapes group.UpdateModelBounds(); // transform the group to fit in the specified bounds group.Bounds = base.GetGridCell(row, col); // create the labels shape element group.CreateShapeElements(ShapeElementsMask.Labels); // create the default label NRotatedBoundsLabel label = new NRotatedBoundsLabel("", group.UniqueId, new Nevron.Diagram.NMargins(0)); group.Labels.AddChild(label); group.Labels.DefaultLabelUniqueId = label.UniqueId; // assign text to the group group.Text = "Protected from: " + protection.ToString(); // add the group to the active layer document.ActiveLayer.AddChild(group); }
private NGroup CreateGroup(string name) { NGroup group = new NGroup(); group.Name = name; document.ActiveLayer.AddChild(group); CreateTree(group); CreateGroupPorts(group); group.UpdateModelBounds(); return(group); }
protected NGroup CreateCartesianScaleGroup() { NGroup group = new NGroup(); // rect 1 uses cartesian scaling NRectangleShape rect1 = new NRectangleShape(0, 0, 75, 75); rect1.Rotate(CoordinateSystem.Scene, 45, rect1.PinPoint); rect1.ResizeInAggregate = ResizeInAggregate.CartesianScale; rect1.Text = "Cartesian Scale"; group.Shapes.AddChild(rect1); // rect 2 uses cartesian X scaling and Y reposition NRectangleShape rect2 = new NRectangleShape(150, 0, 75, 75); rect2.Rotate(CoordinateSystem.Scene, 45, rect2.PinPoint); rect2.ResizeInAggregate = ResizeInAggregate.CartesianScaleXRepositionY; rect2.Text = "Cartesian Scale X and Reposition Y"; group.Shapes.AddChild(rect2); // rect 3 uses cartesian Y scaling and X reposition NRectangleShape rect3 = new NRectangleShape(0, 150, 75, 75); rect3.Rotate(CoordinateSystem.Scene, 45, rect3.PinPoint); rect3.ResizeInAggregate = ResizeInAggregate.CartesianScaleYRepositionX; rect3.Text = "Cartesian Scale Y and Reposition X"; group.Shapes.AddChild(rect3); // rect 4 uses cartesian scale and reposition NRectangleShape rect4 = new NRectangleShape(150, 150, 75, 75); rect4.Rotate(CoordinateSystem.Scene, 45, rect4.PinPoint); rect4.ResizeInAggregate = ResizeInAggregate.CartesianScaleAndReposition; rect4.Text = "Cartesian Scale and Reposition"; group.Shapes.AddChild(rect4); // update the group model bounds group.UpdateModelBounds(); // in order to demonstrate the reposition, all shapes // are pinned to the bottom rigth corner of the group NPointF pin = new NPointF(group.Bounds.Right, group.Bounds.Bottom); foreach (NShape shape in group.Shapes) { shape.PinPoint = pin; } // add the group to the active layer document.ActiveLayer.AddChild(group); return(group); }
protected override void LoadExample() { // begin view init view.BeginInit(); view.DocumentPadding = new Nevron.Diagram.NMargins(20); view.Grid.Visible = false; // replace the default drag drop target tool with your own one // to extend the drop capabilities of the view NTool tool = view.Controller.Tools.GetToolByName(NDWFR.ToolDragDropTarget); int index = view.Controller.Tools.IndexOf(tool); view.Controller.Tools.Remove(tool); tool = new NMyDragDropTargetTool(); tool.Enabled = true; view.Controller.Tools.Insert(index, tool); // init document document.BeginInit(); // create and add your own data object adaptor // to extend the default set of supported data object formats document.DataObjectAdaptors.Add(new NMyDataObjectAdaptor()); // create a simple group for demonstration NGroup group = new NGroup(); group.Shapes.AddChild(new NRectangleShape(100, 100, 200, 200)); group.CreateShapeElements(ShapeElementsMask.Labels); NRotatedBoundsLabel label = new NRotatedBoundsLabel("Drop items from the tree view in me", group.UniqueId, new Nevron.Diagram.NMargins(0)); group.Labels.AddChild(label); group.Labels.DefaultLabelUniqueId = label.UniqueId; group.Text = "Drop items from the tree view in me"; group.UpdateModelBounds(); document.ActiveLayer.AddChild(group); document.EndInit(); // init form controls InitFormControls(); // end view init view.EndInit(); }
protected NGroup CreateReposionGroup() { NGroup group = new NGroup(); // rect 1 uses repositon only NRectangleShape rect1 = new NRectangleShape(0, 0, 75, 75); rect1.Rotate(CoordinateSystem.Scene, 45, rect1.PinPoint); rect1.ResizeInAggregate = ResizeInAggregate.RepositionOnly; rect1.Text = "Reposition only"; group.Shapes.AddChild(rect1); // rect 2 uses repositon X only NRectangleShape rect2 = new NRectangleShape(150, 0, 75, 75); rect2.Rotate(CoordinateSystem.Scene, 45, rect2.PinPoint); rect2.ResizeInAggregate = ResizeInAggregate.RepositionXOnly; rect2.Text = "Reposition X only"; group.Shapes.AddChild(rect2); // rect 3 uses repositon Y only NRectangleShape rect3 = new NRectangleShape(0, 150, 75, 75); rect3.Rotate(CoordinateSystem.Scene, 45, rect3.PinPoint); rect3.ResizeInAggregate = ResizeInAggregate.RepositionYOnly; rect3.Text = "Reposition Y only"; group.Shapes.AddChild(rect3); // update the group model bounds group.UpdateModelBounds(); // in order to demonstrate the reposition, all shapes // are pinned to the bottom rigth corner of the group NPointF pin = new NPointF(group.Bounds.Right, group.Bounds.Bottom); foreach (NShape shape in group.Shapes) { shape.PinPoint = pin; } // add the group to the active layer document.ActiveLayer.AddChild(group); return(group); }
private void InitDocument() { NBasicShapesFactory basicShapesFactory = new NBasicShapesFactory(); basicShapesFactory.DefaultSize = new NSizeF(100, 100); // create groups and apply a frame decorator to each one of them for (int i = 0; i < 4; i++) { NShape shape1 = basicShapesFactory.CreateShape(BasicShapes.Octagon); shape1.Bounds = new NRectangleF(0, 0, 80, 80); NShape shape2 = basicShapesFactory.CreateShape(BasicShapes.Ellipse); shape2.Bounds = new NRectangleF(100, 100, 80, 80); NGroup group = new NGroup(); group.Shapes.AddChild(shape1); group.Shapes.AddChild(shape2); group.Padding = new Nevron.Diagram.NMargins(30); group.UpdateModelBounds(); NFrameDecorator frameDecorator = new NFrameDecorator(); frameDecorator.StyleSheetName = "Decorators"; frameDecorator.ShapeHitTestable = true; frameDecorator.Header.Text = "Header"; group.CreateShapeElements(ShapeElementsMask.Decorators); group.Decorators.AddChild(frameDecorator); document.ActiveLayer.AddChild(group); } // layout them with a table layout NTableLayout layout = new NTableLayout(); layout.ConstrainMode = CellConstrainMode.Ordinal; layout.MaxOrdinal = 2; layout.HorizontalSpacing = 20; layout.VerticalSpacing = 20; layout.Layout(document.ActiveLayer.Children(null), new NDrawingLayoutContext(document)); // size document to content document.SizeToContent(NSizeF.Empty, document.AutoBoundsPadding); }
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 updateModelBoundsButton_Click(object sender, System.EventArgs e) { if (EventsHandlingPaused) { return; } NGroup group = view.Selection.AnchorNode as NGroup; if (group == null) { return; } PauseEventsHandling(); group.UpdateModelBounds(); document.SmartRefreshAllViews(); ResumeEventsHandling(); }
private void InitDocument() { // change the default document style document.Style.FillStyle = new NColorFillStyle(Color.FromArgb(50, 0, 0xaa, 0xaa)); document.Style.StrokeStyle = new NStrokeStyle(1, Color.FromArgb(0, 0xaa, 0xaa)); // create the group NGroup group = new NGroup(); // create ellipse1 NEllipseShape ellipse1 = new NEllipseShape(0, 0, 100, 100); ellipse1.Text = "1"; group.Shapes.AddChild(ellipse1); // create ellipse2 NEllipseShape ellipse2 = new NEllipseShape(150, 0, 100, 100); ellipse2.Text = "2"; group.Shapes.AddChild(ellipse2); // create ellipse3 NEllipseShape ellipse3 = new NEllipseShape(0, 150, 100, 100); ellipse3.Text = "3"; group.Shapes.AddChild(ellipse3); // update the model bounds of the group group.UpdateModelBounds(); // translate the group group.Translate(100, 100); // add the group to the active layer document.ActiveLayer.AddChild(group); }
private void CreateLegend() { NGroup legend = new NGroup(); NCompositeShape item = null; NRectangleShape ledendBackground = new NRectangleShape(0, 0, 1, 5); ledendBackground.Style.FillStyle = new NColorFillStyle(Color.White); legend.Shapes.AddChild(ledendBackground); item = CreateLegendItem(new NRectangleF(0.1f, 0.1f, 0.8f, 0.8f), "Metals", fsMetals); legend.Shapes.AddChild(item); item = CreateLegendItem(new NRectangleF(0.1f, 1.1f, 0.8f, 0.8f), "Metalloids", fsMatalloids); legend.Shapes.AddChild(item); item = CreateLegendItem(new NRectangleF(0.1f, 2.1f, 0.8f, 0.8f), "Non-metals", fsNonMetals); legend.Shapes.AddChild(item); item = CreateLegendItem(new NRectangleF(0.1f, 3.1f, 0.8f, 0.8f), "Transition Metals", feTransitionMetals); legend.Shapes.AddChild(item); item = CreateLegendItem(new NRectangleF(0.1f, 4.1f, 0.8f, 0.8f), "Gases", fsGases); legend.Shapes.AddChild(item); legend.UpdateModelBounds(); NRectangleF bounds = this.GetElementBounds(13, 7); bounds.Y = bounds.Y + bounds.Height * 0.1f; bounds.Width = bounds.Width * 5; bounds.Height = bounds.Height * 1.8f; legend.Bounds = bounds; document.ActiveLayer.AddChild(legend); }
NDrawingDocument CreateDocument(int bookId) { NDrawingDocument document = new NDrawingDocument(); // setup the document document.AutoBoundsPadding = new Nevron.Diagram.NMargins(0f, 7f, 7f, 7f); document.Style.FillStyle = new NColorFillStyle(Color.White); document.Style.TextStyle.FillStyle = new NColorFillStyle(Color.DarkGray); document.Style.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Left; document.Style.StrokeStyle = new NStrokeStyle(0, Color.White); NStandardFrameStyle frame = document.BackgroundStyle.FrameStyle as NStandardFrameStyle; frame.InnerBorderColor = Color.Gray; document.MeasurementUnit = NGraphicsUnit.Pixel; // set up the shape factories NBasicShapesFactory bookItemsFactory = new NBasicShapesFactory(document); bookItemsFactory.DefaultSize = new NSizeF(320, 200); NCustomToolsData.NBookEntry[] books = NCustomToolsData.CreateBooks(); NCustomToolsData.NBookEntry book = null; int length = books.Length; for (int i = 0; i < length; i++) { if (books[i].Id == bookId) { book = books[i]; break; } } if (bookId == -1 || book == null) { document.Style.StrokeStyle = new NStrokeStyle(1, Color.Red); document.ActiveLayer.AddChild(bookItemsFactory.CreateShape(BasicShapes.Pentagram)); document.SizeToContent(); return(document); } // create a table layout, which will align te thumbnail and the text lines // in two columns NTableLayout mainLayout = new NTableLayout(); mainLayout.Direction = LayoutDirection.LeftToRight; mainLayout.ConstrainMode = CellConstrainMode.Ordinal; mainLayout.MaxOrdinal = 2; mainLayout.VerticalContentPlacement = ContentPlacement.Near; // create a stack layout, which will align the text lines in rows NStackLayout textLayout = new NStackLayout(); textLayout.Direction = LayoutDirection.TopToBottom; textLayout.HorizontalContentPlacement = ContentPlacement.Near; textLayout.VerticalSpacing = 13; // create a stack layout, which will align the stars in 5 columns NStackLayout starsLayout = new NStackLayout(); starsLayout.Direction = LayoutDirection.LeftToRight; starsLayout.VerticalContentPlacement = ContentPlacement.Center; starsLayout.HorizontalSpacing = 1; NLayoutContext layoutContext = new NLayoutContext(); layoutContext.GraphAdapter = new NShapeGraphAdapter(); layoutContext.BodyAdapter = new NShapeBodyAdapter(document); layoutContext.BodyContainerAdapter = new NDrawingBodyContainerAdapter(document); // create the shapes for the book image and text lines NShape bookImageShape = bookItemsFactory.CreateShape(BasicShapes.Rectangle); bookImageShape.Width = 240f; bookImageShape.Height = 240f; NImageFillStyle fs1 = new NImageFillStyle(HttpContext.Current.Server.MapPath(@"~\Images\CustomTools\" + book.ImageFile)); fs1.TextureMappingStyle.MapLayout = MapLayout.Centered; NStyle.SetFillStyle(bookImageShape, fs1); NShape bookTitleShape = bookItemsFactory.CreateShape(BasicShapes.Rectangle); bookTitleShape.Text = book.Title; bookTitleShape.Width = 160f; bookTitleShape.Height = 32f; NShape bookAuthorShape = bookItemsFactory.CreateShape(BasicShapes.Rectangle); bookAuthorShape.Text = "by " + book.Author; bookAuthorShape.Width = 160f; bookAuthorShape.Height = 32f; NShape bookPriceShape = bookItemsFactory.CreateShape(BasicShapes.Rectangle); bookPriceShape.Text = "Price: $" + book.Price.ToString(); bookPriceShape.Width = 160f; bookPriceShape.Height = 32f; // create the star shapes NNodeList starShapes = new NNodeList(); for (int i = 0; i < 5; i++) { NShape star = bookItemsFactory.CreateShape(BasicShapes.Pentagram); star.Width = 10f; star.Height = 10f; if (i < book.Rating) { star.Style.FillStyle = new NColorFillStyle(Color.Orange); } else { star.Style.FillStyle = new NColorFillStyle(Color.LightGray); } starShapes.Add(star); } // prepare to layout NBatchGroup bgroup = new NBatchGroup(document); // create the stars group NGroup starsGroup = new NGroup(); // group the star shapes bgroup.Build(starShapes); bgroup.Group(null, false, out starsGroup); // collect the text shapes NNodeList textShapes = new NNodeList(); textShapes.Add(bookTitleShape); textShapes.Add(bookAuthorShape); textShapes.Add(bookPriceShape); textShapes.Add(starsGroup); // create the text group NGroup textGroup = new NGroup(); // group the text shapes bgroup.Build(textShapes); bgroup.Group(null, false, out textGroup); // collect the main layout shapes NNodeList mainElements = new NNodeList(); mainElements.Add(bookImageShape); mainElements.Add(textGroup); // create the main group NGroup mainGroup = new NGroup(); // group the main elements bgroup.Build(mainElements); bgroup.Group(null, false, out mainGroup); document.ActiveLayer.AddChild(mainGroup); // size all text shapes to text bookTitleShape.SizeToText(new NMarginsF(6f, 0f, 6f, 0f)); bookAuthorShape.SizeToText(new NMarginsF(6f, 0f, 6f, 0f)); bookPriceShape.SizeToText(new NMarginsF(6f, 0f, 6f, 0f)); // layout the star shapes starsLayout.Layout(starShapes, layoutContext); starsGroup.UpdateModelBounds(); // perform layout on the text textLayout.Layout(textShapes, layoutContext); textGroup.UpdateModelBounds(); // layout all elements mainLayout.Layout(mainElements, layoutContext); mainGroup.UpdateModelBounds(); // correct the text left padding bookTitleShape.Location = new NPointF(bookTitleShape.Location.X - 6f, bookTitleShape.Location.Y); bookAuthorShape.Location = new NPointF(bookAuthorShape.Location.X - 6f, bookAuthorShape.Location.Y); bookPriceShape.Location = new NPointF(bookPriceShape.Location.X - 6f, bookPriceShape.Location.Y); document.SizeToContent(); return(document); }
private void InitDocument() { NSimpleNetworkShapesFactory networkShapes = new NSimpleNetworkShapesFactory(); networkShapes.DefaultSize = new NSizeF(50, 50); int i; // create computers for (i = 0; i < 9; i++) { NShape computer = networkShapes.CreateShape(SimpleNetworkShapes.Computer); switch (i % 3) { case 0: computer.Location = new NPointF(10, 10); break; case 1: computer.Location = new NPointF(110, 10); break; case 2: computer.Location = new NPointF(75, 110); break; } document.ActiveLayer.AddChild(computer); } // link the computers for (i = 0; i < 3; i++) { NLineShape link = new NLineShape(); link.StyleSheetName = NDR.NameConnectorsStyleSheet; document.ActiveLayer.AddChild(link); if (i == 0) { link.FromShape = (NShape)document.ActiveLayer.GetChildAt(8); link.ToShape = (NShape)document.ActiveLayer.GetChildAt(0); } else { link.FromShape = (NShape)document.ActiveLayer.GetChildAt(i * 3 - 1); link.ToShape = (NShape)document.ActiveLayer.GetChildAt(i * 3); } } // create three groups NNodeList groupNodes1 = new NNodeList(); NBatchGroup batchGroup1 = new NBatchGroup(document); groupNodes1.Add(document.ActiveLayer.GetChildAt(0)); groupNodes1.Add(document.ActiveLayer.GetChildAt(1)); groupNodes1.Add(document.ActiveLayer.GetChildAt(2)); batchGroup1.Build(groupNodes1); NNodeList groupNodes2 = new NNodeList(); NBatchGroup batchGroup2 = new NBatchGroup(document); groupNodes2.Add(document.ActiveLayer.GetChildAt(3)); groupNodes2.Add(document.ActiveLayer.GetChildAt(4)); groupNodes2.Add(document.ActiveLayer.GetChildAt(5)); batchGroup2.Build(groupNodes2); NNodeList groupNodes3 = new NNodeList(); NBatchGroup batchGroup3 = new NBatchGroup(document); groupNodes3.Add(document.ActiveLayer.GetChildAt(6)); groupNodes3.Add(document.ActiveLayer.GetChildAt(7)); groupNodes3.Add(document.ActiveLayer.GetChildAt(8)); batchGroup3.Build(groupNodes3); NGroup[] groups = new NGroup[3]; batchGroup1.Group(document.ActiveLayer, false, out groups[0]); batchGroup2.Group(document.ActiveLayer, false, out groups[1]); batchGroup3.Group(document.ActiveLayer, false, out groups[2]); // add expand-collapse decorator and frame decorator to each group for (i = 0; i < groups.Length; i++) { NGroup group = groups[i]; // because groups are created after the link we want to ensure // that they are behind so that the links are not obscured group.SendToBack(); // create the decorators collection group.CreateShapeElements(ShapeElementsMask.Decorators); // create a frame decorator // we want the user to be able to select the shape when the frame is hit NFrameDecorator frameDecorator = new NFrameDecorator(); frameDecorator.ShapeHitTestable = true; frameDecorator.Header.Text = "Network " + i.ToString(); group.Decorators.AddChild(frameDecorator); // create an expand collapse decorator NExpandCollapseDecorator expandCollapseDecorator = new NExpandCollapseDecorator(); group.Decorators.AddChild(expandCollapseDecorator); // update the model bounds so that the computeres // are inside the specified padding group.Padding = new Nevron.Diagram.NMargins(5, 5, 30, 5); group.UpdateModelBounds(); group.AutoUpdateModelBounds = true; } // layout them with a table layout NLayoutContext context = new NLayoutContext(); context.GraphAdapter = new NShapeGraphAdapter(); context.BodyAdapter = new NShapeBodyAdapter(document); context.BodyContainerAdapter = new NDrawingBodyContainerAdapter(document); NTableLayout layout = new NTableLayout(); layout.ConstrainMode = CellConstrainMode.Ordinal; layout.MaxOrdinal = 2; layout.HorizontalSpacing = 50; layout.VerticalSpacing = 50; layout.Layout(document.ActiveLayer.Children(null), context); document.SizeToContent(NSizeF.Empty, document.AutoBoundsPadding); document.AutoBoundsMode = AutoBoundsMode.AutoSizeToContent; }
private void InitDocument() { // modify the connectors style sheet NStyleSheet styleSheet = (document.StyleSheets.GetChildByName(NDR.NameConnectorsStyleSheet, -1) as NStyleSheet); styleSheet.Style.StrokeStyle = new NStrokeStyle(1, Color.Black); styleSheet.Style.StartArrowheadStyle.Shape = ArrowheadShape.None; styleSheet.Style.EndArrowheadStyle.StrokeStyle = new NStrokeStyle(1, Color.Black); // create a stylesheet for the CPA shapes styleSheet = new NStyleSheet("CPA"); styleSheet.Style.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.FromArgb(68, 90, 108), Color.FromArgb(162, 173, 182)); document.StyleSheets.AddChild(styleSheet); // create a stylesheet for the CLIENT shapes styleSheet = new NStyleSheet("CLIENT"); styleSheet.Style.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.FromArgb(247, 150, 56), Color.FromArgb(251, 203, 156)); document.StyleSheets.AddChild(styleSheet); // create a stylesheet for the stripes styleSheet = new NStyleSheet("STRIPE"); styleSheet.Style.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.White, Color.FromArgb(221, 221, 221)); styleSheet.Style.StrokeStyle = new NStrokeStyle(0, Color.White); document.StyleSheets.AddChild(styleSheet); // create a stylesheet for the ABC texts styleSheet = new NStyleSheet("ABC"); styleSheet.Style.TextStyle = new NTextStyle(new Font("Ariel", 12), Color.FromArgb(150, 150, 150)); document.StyleSheets.AddChild(styleSheet); float abcWidth = 150; // configure the document base.DefaultGridCellSize = new NSizeF(100, 70); base.DefaultGridSpacing = new NSizeF(30, 30); base.DefaultGridOrigin = new NPointF(60, 30); document.Bounds = new NRectangleF(0, 0, 1000, (6 * base.DefaultGridCellSize.Height) + (7 * base.DefaultGridSpacing.Height)); document.ShadowsZOrder = ShadowsZOrder.BehindLayer; // create the stripes NRectanglePath rect = new NRectanglePath(0, 0, document.Width, document.Height / 3); rect.StyleSheetName = "STRIPE"; document.ActiveLayer.AddChild(rect); rect = new NRectanglePath(0, document.Height / 3, document.Width, document.Height / 3); rect.StyleSheetName = "STRIPE"; document.ActiveLayer.AddChild(rect); rect = new NRectanglePath(0, 2 * document.Height / 3, document.Width, document.Height / 3); rect.StyleSheetName = "STRIPE"; document.ActiveLayer.AddChild(rect); // create A,B,C texts NTextPrimitive text = new NTextPrimitive("A", document.Width - abcWidth, 0, abcWidth, document.Height / 3); text.Mode = BoxTextMode.Stretch; rect.StyleSheetName = "ABC"; document.ActiveLayer.AddChild(text); text = new NTextPrimitive("B", document.Width - abcWidth, document.Height / 3, abcWidth, document.Height / 3); text.Mode = BoxTextMode.Stretch; rect.StyleSheetName = "ABC"; document.ActiveLayer.AddChild(text); text = new NTextPrimitive("C", document.Width - abcWidth, 2 * document.Height / 3, abcWidth, document.Height / 3); text.Mode = BoxTextMode.Stretch; rect.StyleSheetName = "ABC"; document.ActiveLayer.AddChild(text); // add stripe texts text = new NTextPrimitive("Sing up client", document.Width - abcWidth, document.Height / 3 - 50, abcWidth, 50); document.ActiveLayer.AddChild(text); text = new NTextPrimitive("Monthly Accounting Services", document.Width - abcWidth, 2 * document.Height / 3 - 50, abcWidth, 50); document.ActiveLayer.AddChild(text); text = new NTextPrimitive("Additional Services", document.Width - abcWidth, 3 * document.Height / 3 - 50, abcWidth, 50); document.ActiveLayer.AddChild(text); // create a layer for the foreground shapes NLayer layer = new NLayer(); document.Layers.AddChild(layer); document.ActiveLayerUniqueId = layer.UniqueId; // all shapes in the foreground layer have a shadow layer.Style.ShadowStyle = new NShadowStyle( ShadowType.GaussianBlur, Color.Gray, new NPointL(5, 5), 1, new NLength(10)); // shapes in row 1 NShape newClient = base.CreateFlowChartingShape(FlowChartingShapes.Decision, base.GetGridCell(0, 0), "New Client", "CPA"); NShape register = base.CreateFlowChartingShape(FlowChartingShapes.Process, base.GetGridCell(0, 1), "Register", "CPA"); NShape clientAccountInfo = base.CreateFlowChartingShape(FlowChartingShapes.Data, base.GetGridCell(0, 2), "Client account info", "CPA"); NShape explainDataEntryProcedures = base.CreateFlowChartingShape(FlowChartingShapes.Process, base.GetGridCell(0, 3), "Explain data entry procedures", "CPA"); // shapes in row 2 NShape dataEntry = base.CreateFlowChartingShape(FlowChartingShapes.ManualInput, base.GetGridCell(2, 0), "Data Entry", "CLIENT"); NShape emailCompleted = base.CreateFlowChartingShape(FlowChartingShapes.Document, base.GetGridCell(2, 1), "E-mail Completed", "CLIENT"); NShape review = base.CreateFlowChartingShape(FlowChartingShapes.Process, base.GetGridCell(2, 2), "Review", "CPA"); NShape needsRevising = base.CreateFlowChartingShape(FlowChartingShapes.Decision, base.GetGridCell(2, 3), "Needs revising", "CPA"); NShape emailRevisions = base.CreateFlowChartingShape(FlowChartingShapes.Process, base.GetGridCell(2, 4), "E-mail revisions", "CPA"); NShape evaluateRevisions = base.CreateFlowChartingShape(FlowChartingShapes.Process, base.GetGridCell(2, 5), "Evaluate revisions", "CLIENT"); // shapes in row 3 NShape emailApprovedRevisions = base.CreateFlowChartingShape(FlowChartingShapes.Document, base.GetGridCell(3, 2), "E-mail Approved Revisions", "CLIENT"); NShape evaluateRevisions2 = base.CreateFlowChartingShape(FlowChartingShapes.Process, base.GetGridCell(3, 4), "Evaluate Revisions", "CLIENT"); NShape answerClientEmail = base.CreateFlowChartingShape(FlowChartingShapes.Process, base.GetGridCell(3, 5), "Answer Client E-mail", "CPA"); // shapes in row 4 NShape paywoll = base.CreateFlowChartingShape(FlowChartingShapes.Document, base.GetGridCell(5, 2), "Payroll", "CLIENT"); NShape taxes = base.CreateFlowChartingShape(FlowChartingShapes.Process, base.GetGridCell(5, 3), "Taxes", "CLIENT"); NShape controller = base.CreateFlowChartingShape(FlowChartingShapes.Process, base.GetGridCell(5, 4), "Controller", "CPA"); // some shapes need to have extra ports NRotatedBoundsPort port = new NRotatedBoundsPort(evaluateRevisions.UniqueId, new NContentAlignment(-25, 50)); port.Name = "BottomLeft"; evaluateRevisions.Ports.AddChild(port); port = new NRotatedBoundsPort(evaluateRevisions.UniqueId, new NContentAlignment(+25, 50)); port.Name = "BottomRight"; evaluateRevisions.Ports.AddChild(port); port = new NRotatedBoundsPort(answerClientEmail.UniqueId, new NContentAlignment(-25, -50)); port.Name = "TopLeft"; answerClientEmail.Ports.AddChild(port); port = new NRotatedBoundsPort(answerClientEmail.UniqueId, new NContentAlignment(+25, -50)); port.Name = "TopRight"; answerClientEmail.Ports.AddChild(port); // connect shapes in levels base.CreateConnector(newClient, "Center", register, "Center", ConnectorType.Line, "YES"); base.CreateConnector(register, "Center", clientAccountInfo, "Center", ConnectorType.Line, ""); base.CreateConnector(clientAccountInfo, "Center", explainDataEntryProcedures, "Center", ConnectorType.Line, ""); base.CreateConnector(dataEntry, "Center", emailCompleted, "Center", ConnectorType.Line, ""); base.CreateConnector(emailCompleted, "Center", review, "Center", ConnectorType.Line, ""); base.CreateConnector(review, "Center", needsRevising, "Center", ConnectorType.Line, ""); base.CreateConnector(needsRevising, "Center", emailRevisions, "Center", ConnectorType.Line, "YES"); base.CreateConnector(emailRevisions, "Center", evaluateRevisions, "Center", ConnectorType.Line, ""); base.CreateConnector(evaluateRevisions2, "Center", emailApprovedRevisions, "Center", ConnectorType.Line, ""); // connect accross levels NStep3Connector connector = (base.CreateConnector(newClient, "Center", dataEntry, "Center", ConnectorType.SideToSide, "NO") as NStep3Connector); connector.UseMiddleControlPointPercent = false; connector.MiddleControlPointOffset = -55; base.CreateConnector(explainDataEntryProcedures, "Center", dataEntry, "Center", ConnectorType.TopToBottom, ""); base.CreateConnector(emailApprovedRevisions, "Center", review, "Center", ConnectorType.Line, ""); base.CreateConnector(emailRevisions, "Center", evaluateRevisions2, "Center", ConnectorType.Line, ""); base.CreateConnector(evaluateRevisions, "BottomLeft", answerClientEmail, "TopLeft", ConnectorType.Line, ""); base.CreateConnector(answerClientEmail, "TopRight", evaluateRevisions, "BottomRight", ConnectorType.Line, ""); connector = (base.CreateConnector(needsRevising, "Center", paywoll, "Center", ConnectorType.TopToBottom, "") as NStep3Connector); connector.MiddleControlPointPercent = 66; connector = (base.CreateConnector(needsRevising, "Center", taxes, "Center", ConnectorType.TopToBottom, "") as NStep3Connector); connector.MiddleControlPointPercent = 66; connector = (base.CreateConnector(needsRevising, "Center", controller, "Center", ConnectorType.TopToBottom, "") as NStep3Connector); connector.MiddleControlPointPercent = 66; // create the legend as a group NGroup legend = new NGroup(); NRectangleShape legendBackground = new NRectangleShape(0, 0, 1, 3); legendBackground.Style.FillStyle = new NColorFillStyle(Color.White); legend.Shapes.AddChild(legendBackground); NRectangleF bounds = new NRectangleF(0, 1, 1, 1); bounds.Inflate(-0.2f, -0.2f); NRectangleShape cpaItem = new NRectangleShape(bounds); cpaItem.Text = "CPA"; cpaItem.StyleSheetName = "CPA"; legend.Shapes.AddChild(cpaItem); bounds = new NRectangleF(0, 2, 1, 1); bounds.Inflate(-0.2f, -0.2f); NRectangleShape clientItem = new NRectangleShape(bounds); clientItem.Text = "Client"; clientItem.StyleSheetName = "CLIENT"; legend.Shapes.AddChild(clientItem); legend.UpdateModelBounds(); legend.Bounds = base.GetGridCell(4, 0, 1, 1); document.ActiveLayer.AddChild(legend); }
private void CreateScene(NDrawingDocument document) { document.BackgroundStyle.FrameStyle.Visible = false; NFillStyle cpaFillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.FromArgb(102, 204, 255), Color.FromArgb(0, 128, 128)); NFillStyle clientFillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.FromArgb(255, 102, 0), Color.FromArgb(255, 204, 0)); NFillStyle stripeFillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.White, Color.FromArgb(221, 221, 221)); NTextStyle abcTextStyle = new NTextStyle(new Font("Arial", 12), Color.FromArgb(150, 150, 150)); float abcWidth = 150; NDrawingDocumentHelper helper = new NDrawingDocumentHelper(document); // configure the document helper.DefaultGridCellSize = new NSizeF(100, 70); helper.DefaultGridSpacing = new NSizeF(30, 30); helper.DefaultGridOrigin = new NPointF(60, 30); document.Bounds = new NRectangleF(0, 0, 1000, (6 * helper.DefaultGridCellSize.Height) + (7 * helper.DefaultGridSpacing.Height)); document.ShadowsZOrder = ShadowsZOrder.BehindLayer; // create the stripes NRectangleShape rect = new NRectangleShape(0, 0, document.Width, document.Height / 3); rect.Style.FillStyle = (NFillStyle)stripeFillStyle.Clone(); rect.Style.StrokeStyle = new NStrokeStyle(0, Color.White); document.ActiveLayer.AddChild(rect); rect = new NRectangleShape(0, document.Height / 3, document.Width, document.Height / 3); rect.Style.FillStyle = (NFillStyle)stripeFillStyle.Clone(); rect.Style.StrokeStyle = new NStrokeStyle(0, Color.White); document.ActiveLayer.AddChild(rect); rect = new NRectangleShape(0, 2 * document.Height / 3, document.Width, document.Height / 3); rect.Style.FillStyle = (NFillStyle)stripeFillStyle.Clone(); rect.Style.StrokeStyle = new NStrokeStyle(0, Color.White); document.ActiveLayer.AddChild(rect); // create A,B,C texts NTextShape text = new NTextShape("A", document.Width - abcWidth, 0, abcWidth, document.Height / 3); text.Mode = BoxTextMode.Stretch; text.Style.TextStyle = (abcTextStyle.Clone() as NTextStyle); document.ActiveLayer.AddChild(text); text = new NTextShape("B", document.Width - abcWidth, document.Height / 3, abcWidth, document.Height / 3); text.Mode = BoxTextMode.Stretch; text.Style.TextStyle = (abcTextStyle.Clone() as NTextStyle); document.ActiveLayer.AddChild(text); text = new NTextShape("C", document.Width - abcWidth, 2 * document.Height / 3, abcWidth, document.Height / 3); text.Mode = BoxTextMode.Stretch; text.Style.TextStyle = (abcTextStyle.Clone() as NTextStyle); document.ActiveLayer.AddChild(text); // add stripe texts text = new NTextShape("Sing up client", document.Width - abcWidth, document.Height / 3 - 50, abcWidth, 50); document.ActiveLayer.AddChild(text); text = new NTextShape("Monthly Accounting Services", document.Width - abcWidth, 2 * document.Height / 3 - 50, abcWidth, 50); document.ActiveLayer.AddChild(text); text = new NTextShape("Additional Services", document.Width - abcWidth, 3 * document.Height / 3 - 50, abcWidth, 50); document.ActiveLayer.AddChild(text); // create a layer for the forground shapes NLayer layer = new NLayer(); document.Layers.AddChild(layer); document.ActiveLayerUniqueId = layer.UniqueId; layer.Style.ShadowStyle = new NShadowStyle(ShadowType.GaussianBlur, Color.Gray, new Nevron.GraphicsCore.NPointL(5, 5), 1, new NLength(10)); // shapes in row 1 NShape newClient = helper.CreateBasicShape(BasicShapes.Diamond, helper.GetGridCell(0, 0), "New Client", cpaFillStyle); NShape register = helper.CreateBasicShape(BasicShapes.Rectangle, helper.GetGridCell(0, 1), "Register", cpaFillStyle); NShape clientAccountInfo = helper.CreateFlowChartingShape(FlowChartingShapes.Data, helper.GetGridCell(0, 2), "Client account info", cpaFillStyle); NShape explainDataEntryProcedures = helper.CreateBasicShape(BasicShapes.Rectangle, helper.GetGridCell(0, 3), "Explain data entry procedures", cpaFillStyle); // shapes in row 2 NShape dataEntry = helper.CreateFlowChartingShape(FlowChartingShapes.ManualInput, helper.GetGridCell(2, 0), "Data Entry", clientFillStyle); NShape emailCompleted = helper.CreateFlowChartingShape(FlowChartingShapes.Document, helper.GetGridCell(2, 1), "E-mail Completed", clientFillStyle); NShape review = helper.CreateBasicShape(BasicShapes.Rectangle, helper.GetGridCell(2, 2), "Review", cpaFillStyle); NShape needsRevising = helper.CreateBasicShape(BasicShapes.Diamond, helper.GetGridCell(2, 3), "Needs revising", cpaFillStyle); NShape emailRevisions = helper.CreateBasicShape(BasicShapes.Rectangle, helper.GetGridCell(2, 4), "E-mail revisions", cpaFillStyle); NShape evaluateRevisions = helper.CreateBasicShape(BasicShapes.Rectangle, helper.GetGridCell(2, 5), "Evaluate revisions", clientFillStyle); // shapes in row 3 NShape emailApprovedRevisions = helper.CreateFlowChartingShape(FlowChartingShapes.Document, helper.GetGridCell(3, 2), "E-mail Approved Revisions", clientFillStyle); NShape evaluateRevisions2 = helper.CreateBasicShape(BasicShapes.Rectangle, helper.GetGridCell(3, 4), "Evaluate Revisions", clientFillStyle); NShape answerClientEmail = helper.CreateBasicShape(BasicShapes.Rectangle, helper.GetGridCell(3, 5), "Answer Client E-mail", cpaFillStyle); // shapes in row 4 NShape paywoll = helper.CreateFlowChartingShape(FlowChartingShapes.Document, helper.GetGridCell(5, 2), "Payroll", clientFillStyle); NShape taxes = helper.CreateBasicShape(BasicShapes.Rectangle, helper.GetGridCell(5, 3), "Taxes", clientFillStyle); NShape controller = helper.CreateBasicShape(BasicShapes.Rectangle, helper.GetGridCell(5, 4), "Controller", cpaFillStyle); // create the optional ports of the shape evaluateRevisions.CreateShapeElements(ShapeElementsMask.Ports); // some shapes need to have extra ports NRotatedBoundsPort port = new NRotatedBoundsPort(evaluateRevisions.UniqueId, new NContentAlignment(-25, 50)); port.Name = "BottomLeft"; evaluateRevisions.Ports.AddChild(port); port = new NRotatedBoundsPort(evaluateRevisions.UniqueId, new NContentAlignment(+25, 50)); port.Name = "BottomRight"; evaluateRevisions.Ports.AddChild(port); // create the optional ports of the shape answerClientEmail.CreateShapeElements(ShapeElementsMask.Ports); port = new NRotatedBoundsPort(answerClientEmail.UniqueId, new NContentAlignment(-25, -50)); port.Name = "TopLeft"; answerClientEmail.Ports.AddChild(port); port = new NRotatedBoundsPort(answerClientEmail.UniqueId, new NContentAlignment(+25, -50)); port.Name = "TopRight"; answerClientEmail.Ports.AddChild(port); // connect shapes in levels helper.CreateConnector(newClient, "Center", register, "Center", ConnectorType.Line, "YES"); helper.CreateConnector(register, "Center", clientAccountInfo, "Center", ConnectorType.Line, ""); helper.CreateConnector(clientAccountInfo, "Center", explainDataEntryProcedures, "Center", ConnectorType.Line, ""); helper.CreateConnector(dataEntry, "Center", emailCompleted, "Center", ConnectorType.Line, ""); helper.CreateConnector(emailCompleted, "Center", review, "Center", ConnectorType.Line, ""); helper.CreateConnector(review, "Center", needsRevising, "Center", ConnectorType.Line, ""); helper.CreateConnector(needsRevising, "Center", emailRevisions, "Center", ConnectorType.Line, "YES"); helper.CreateConnector(emailRevisions, "Center", evaluateRevisions, "Center", ConnectorType.Line, ""); helper.CreateConnector(evaluateRevisions2, "Center", emailApprovedRevisions, "Center", ConnectorType.Line, ""); // connect accross levels NStep3Connector connector = (helper.CreateConnector(newClient, "Center", dataEntry, "Center", ConnectorType.SideToSide, "NO") as NStep3Connector); connector.UseMiddleControlPointPercent = false; connector.MiddleControlPointOffset = -50; helper.CreateConnector(explainDataEntryProcedures, "Center", dataEntry, "Center", ConnectorType.TopToBottom, ""); helper.CreateConnector(emailApprovedRevisions, "Center", review, "Center", ConnectorType.Line, ""); helper.CreateConnector(emailRevisions, "Center", evaluateRevisions2, "Center", ConnectorType.Line, ""); helper.CreateConnector(evaluateRevisions, "BottomLeft", answerClientEmail, "TopLeft", ConnectorType.Line, ""); helper.CreateConnector(answerClientEmail, "TopRight", evaluateRevisions, "BottomRight", ConnectorType.Line, ""); connector = (helper.CreateConnector(needsRevising, "Center", paywoll, "Center", ConnectorType.TopToBottom, "") as NStep3Connector); connector.MiddleControlPointPercent = 66; connector = (helper.CreateConnector(needsRevising, "Center", taxes, "Center", ConnectorType.TopToBottom, "") as NStep3Connector); connector.MiddleControlPointPercent = 66; connector = (helper.CreateConnector(needsRevising, "Center", controller, "Center", ConnectorType.TopToBottom, "") as NStep3Connector); connector.MiddleControlPointPercent = 66; // create the legend NGroup legend = new NGroup(); NRectangleShape ledendBackground = new NRectangleShape(0, 0, 1, 3); ledendBackground.Style.FillStyle = new NColorFillStyle(Color.White); legend.Shapes.AddChild(ledendBackground); NTextShape legendTitle = new NTextShape("Legend", 0, 0, 1, 1); legend.Shapes.AddChild(legendTitle); NRectangleF bounds = new NRectangleF(0, 1, 1, 1); bounds.Inflate(-0.2f, -0.2f); NShape shape = helper.CreateBasicShape(BasicShapes.Rectangle, bounds, "CPA", (NFillStyle)cpaFillStyle.Clone(), false); legend.Shapes.AddChild(shape); bounds = new NRectangleF(0, 2, 1, 1); bounds.Inflate(-0.2f, -0.2f); shape = helper.CreateBasicShape(BasicShapes.Rectangle, bounds, "Client", (NFillStyle)clientFillStyle.Clone(), false); legend.Shapes.AddChild(shape); legend.UpdateModelBounds(); legend.Bounds = helper.GetGridCell(4, 0, 1, 1); document.ActiveLayer.AddChild(legend); }
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); }