private void InitDocument(NDrawingDocument document) { // setup default NDrawingView1.Document. fill style, background style and shadow style Color color1 = Color.FromArgb(225, 232, 232); Color color2 = Color.FromArgb(32, 136, 178); NLightingImageFilter lightingFilter = new NLightingImageFilter(); lightingFilter.SpecularColor = Color.Black; lightingFilter.DiffuseColor = Color.White; lightingFilter.LightSourceType = LightSourceType.Positional; lightingFilter.Position = new NVector3DF(1, 1, 1); lightingFilter.BevelDepth = new NLength(8, NGraphicsUnit.Pixel); document.Style.FillStyle = new NColorFillStyle(color1); document.Style.FillStyle.ImageFiltersStyle.Filters.Add(lightingFilter); document.BackgroundStyle.FillStyle = new NGradientFillStyle(GradientStyle.DiagonalUp, GradientVariant.Variant1, Color.LightBlue, color2); document.Style.ShadowStyle.Type = ShadowType.GaussianBlur; document.Style.ShadowStyle.Offset = new NPointL(5, 5); document.ShadowsZOrder = ShadowsZOrder.BehindDocument; // create title NTextShape title = new NTextShape("Bubble Sort", GetGridCell(0, 1, 2, 1)); title.Style.TextStyle = new NTextStyle(); title.Style.TextStyle.FillStyle = (document.Style.FillStyle.Clone() as NFillStyle); title.Style.TextStyle.ShadowStyle = new NShadowStyle(); title.Style.TextStyle.ShadowStyle.Type = ShadowType.GaussianBlur; title.Style.TextStyle.FontStyle = new NFontStyle(new Font("Arial", 40, FontStyle.Bold)); title.Style.InteractivityStyle = CreateInteractivityStyle("Bubble Sort"); document.ActiveLayer.AddChild(title); // begin shape NShape shapeBegin = CreateFlowChartingShape(document, FlowChartingShapes.Termination, GetGridCell(0, 0), "BEGIN", ""); // get array item shape NShape shapeGetItem = CreateFlowChartingShape(document, FlowChartingShapes.Data, GetGridCell(1, 0), "Get array item [1...n]", ""); NRotatedBoundsLabel rotatedBoundsLabel = (NRotatedBoundsLabel)shapeGetItem.Labels.DefaultLabel; rotatedBoundsLabel.Margins = new Nevron.Diagram.NMargins(20, 20, 0, 0); // i = 1 shape NShape shapeI1 = CreateFlowChartingShape(document, FlowChartingShapes.Process, GetGridCell(2, 0), "i = 1", ""); // j = n shape NShape shapeJEN = CreateFlowChartingShape(document, FlowChartingShapes.Process, GetGridCell(3, 0), "j = n", ""); // less comparison shape NShape shapeLess = CreateFlowChartingShape(document, FlowChartingShapes.Decision, GetGridCell(4, 0), "item[i] < item[j - 1]?", ""); rotatedBoundsLabel = (NRotatedBoundsLabel)shapeLess.Labels.DefaultLabel; rotatedBoundsLabel.Margins = new Nevron.Diagram.NMargins(15, 15, 0, 0); // swap shape NShape shapeSwap = CreateFlowChartingShape(document, FlowChartingShapes.Process, GetGridCell(4, 1), "Swap item[i] and item[j-1]", ""); // j > i + 1? shape NShape shapeJQ = CreateFlowChartingShape(document, FlowChartingShapes.Decision, GetGridCell(5, 0), "j = (i + 1)?", ""); // dec j shape NShape shapeDecJ = CreateFlowChartingShape(document, FlowChartingShapes.Process, GetGridCell(5, 1), "j = j - 1", ""); // i > n - 1? shape NShape shapeIQ = CreateFlowChartingShape(document, FlowChartingShapes.Decision, GetGridCell(6, 0), "i = (n - 1)?", ""); // inc i shape NShape shapeIncI = CreateFlowChartingShape(document, FlowChartingShapes.Process, GetGridCell(6, 1), "i = i + 1", ""); // end shape NShape shapeEnd = CreateFlowChartingShape(document, FlowChartingShapes.Termination, GetGridCell(7, 0), "END", ""); // connect begin with get array item NLineShape connector1 = new NLineShape(); connector1.StyleSheetName = NDR.NameConnectorsStyleSheet; document.ActiveLayer.AddChild(connector1); connector1.FromShape = shapeBegin; connector1.ToShape = shapeGetItem; // connect get array item with i = 1 NLineShape connector2 = new NLineShape(); connector2.StyleSheetName = NDR.NameConnectorsStyleSheet; document.ActiveLayer.AddChild(connector2); connector2.FromShape = shapeGetItem; connector2.ToShape = shapeI1; // connect i = 1 and j = n NLineShape connector3 = new NLineShape(); connector3.StyleSheetName = NDR.NameConnectorsStyleSheet; connector3.CreateShapeElements(ShapeElementsMask.Ports); connector3.Ports.AddChild(new NLogicalLinePort(connector3.UniqueId, 50)); connector3.Ports.DefaultInwardPortUniqueId = (connector3.Ports.GetChildAt(0) as INDiagramElement).UniqueId; document.ActiveLayer.AddChild(connector3); connector3.FromShape = shapeI1; connector3.ToShape = shapeJEN; // connect j = n and item[i] < item[j-1]? NLineShape connector4 = new NLineShape(); connector4.StyleSheetName = NDR.NameConnectorsStyleSheet; connector4.CreateShapeElements(ShapeElementsMask.Ports); connector4.Ports.AddChild(new NLogicalLinePort(connector4.UniqueId, 50)); connector4.Ports.DefaultInwardPortUniqueId = (connector4.Ports.GetChildAt(0) as INDiagramElement).UniqueId; document.ActiveLayer.AddChild(connector4); connector4.FromShape = shapeJEN; connector4.ToShape = shapeLess; // connect item[i] < item[j-1]? and j = (i + 1)? NLineShape connector5 = new NLineShape(); connector5.StyleSheetName = NDR.NameConnectorsStyleSheet; connector5.Text = "No"; connector5.Style.TextStyle = new NTextStyle(); connector5.Style.TextStyle.StringFormatStyle.VertAlign = VertAlign.Top; connector5.CreateShapeElements(ShapeElementsMask.Ports); connector5.Ports.AddChild(new NLogicalLinePort(connector5.UniqueId, 50)); connector5.Ports.DefaultInwardPortUniqueId = (connector5.Ports.GetChildAt(0) as INDiagramElement).UniqueId; document.ActiveLayer.AddChild(connector5); connector5.FromShape = shapeLess; connector5.ToShape = shapeJQ; // connect j = (i + 1)? and i = (n - 1)? NLineShape connector6 = new NLineShape(); connector6.StyleSheetName = NDR.NameConnectorsStyleSheet; document.ActiveLayer.AddChild(connector6); connector6.FromShape = shapeJQ; connector6.ToShape = shapeIQ; // connect i = (n - 1) and END NLineShape connector7 = new NLineShape(); connector7.StyleSheetName = NDR.NameConnectorsStyleSheet; document.ActiveLayer.AddChild(connector7); connector7.FromShape = shapeIQ; connector7.ToShape = shapeEnd; // connect item[i] < item[j-1]? and Swap NLineShape connector8 = new NLineShape(); connector8.StyleSheetName = NDR.NameConnectorsStyleSheet; connector8.Text = "Yes"; connector8.Style.TextStyle = new NTextStyle(); connector8.Style.TextStyle.StringFormatStyle.VertAlign = VertAlign.Bottom; document.ActiveLayer.AddChild(connector8); connector8.FromShape = shapeLess; connector8.ToShape = shapeSwap; // connect j = (i + 1)? and j = (j - 1) NLineShape connector9 = new NLineShape(); connector9.StyleSheetName = NDR.NameConnectorsStyleSheet; document.ActiveLayer.AddChild(connector9); connector9.FromShape = shapeJQ; connector9.ToShape = shapeDecJ; // connect i = (n - 1)? and i = (i + 1) NLineShape connector10 = new NLineShape(); connector10.StyleSheetName = NDR.NameConnectorsStyleSheet; document.ActiveLayer.AddChild(connector10); connector10.FromShape = shapeIQ; connector10.ToShape = shapeIncI; // connect Swap to No connector NStep2Connector connector11 = new NStep2Connector(true); connector11.StyleSheetName = NDR.NameConnectorsStyleSheet; document.ActiveLayer.AddChild(connector11); connector11.FromShape = shapeSwap; connector11.ToShape = connector5; // connect i = i + 1 to connector3 NStep3Connector connector12 = new NStep3Connector(false, 50, 60, false); connector12.StyleSheetName = NDR.NameConnectorsStyleSheet; document.ActiveLayer.AddChild(connector12); connector12.StartPlug.Connect(shapeIncI.Ports.GetChildByName("Right", 0) as NPort); connector12.EndPlug.Connect(connector3.Ports.DefaultInwardPort); // connect j = j - 1 to connector4 NStep3Connector connector13 = new NStep3Connector(false, 50, 30, false); connector13.StyleSheetName = NDR.NameConnectorsStyleSheet; document.ActiveLayer.AddChild(connector13); connector13.StartPlug.Connect(shapeDecJ.Ports.GetChildByName("Right", 0) as NPort); connector13.EndPlug.Connect(connector4.Ports.DefaultInwardPort); }
/// <summary> /// Creates a new connector, which connects the specified shapes /// </summary> /// <param name="fromShape"></param> /// <param name="fromPortName"></param> /// <param name="toShape"></param> /// <param name="toPortName"></param> /// <param name="connectorType"></param> /// <param name="text"></param> /// <returns>new 1D shapes</returns> private NShape CreateConnector(NShape fromShape, string fromPortName, NShape toShape, string toPortName, ConnectorType connectorType, string text) { // check arguments if (fromShape == null) { throw new ArgumentNullException("fromShape"); } if (toShape == null) { throw new ArgumentNullException("toShape"); } NPort fromPort = (fromShape.Ports.GetChildByName(fromPortName, 0) as NPort); if (fromPort == null) { throw new ArgumentException("Was not able to find fromPortName in the ports collection of the fromShape", "fromPortName"); } NPort toPort = (toShape.Ports.GetChildByName(toPortName, 0) as NPort); if (toPort == null) { throw new ArgumentException("Was not able to find toPortName in the ports collection of the toShape", "toPortName"); } // create the connector NShape connector = null; switch (connectorType) { case ConnectorType.Line: connector = new NLineShape(); break; case ConnectorType.Bezier: connector = new NBezierCurveShape(); break; case ConnectorType.SingleArrow: connector = new NArrowShape(ArrowType.SingleArrow); break; case ConnectorType.DoubleArrow: connector = new NArrowShape(ArrowType.DoubleArrow); break; case ConnectorType.SideToTopBottom: connector = new NStep2Connector(false); break; case ConnectorType.TopBottomToSide: connector = new NStep2Connector(true); break; case ConnectorType.SideToSide: connector = new NStep3Connector(false, 50, 0, true); break; case ConnectorType.TopToBottom: connector = new NStep3Connector(true, 50, 0, true); break; case ConnectorType.DynamicHV: connector = new NRoutableConnector(RoutableConnectorType.DynamicHV); break; case ConnectorType.DynamicPolyline: connector = new NRoutableConnector(RoutableConnectorType.DynamicPolyline); break; case ConnectorType.DynamicCurve: connector = new NRoutableConnector(RoutableConnectorType.DynamicCurve); break; default: Debug.Assert(false, "New graph connector type?"); break; } // the connector must be added to the document prior to connecting it DrawingView.Document.ActiveLayer.AddChild(connector); // change the default label text connector.Text = text; // connectors by default inherit styles from the connectors stylesheet connector.StyleSheetName = NDR.NameConnectorsStyleSheet; // connect the connector to the specified ports connector.StartPlug.Connect(fromPort); connector.EndPlug.Connect(toPort); // modify the connector text style connector.Style.TextStyle = (connector.ComposeTextStyle().Clone() as NTextStyle); connector.Style.TextStyle.Offset = new NPointL(0, -7); return(connector); }
void InitDocument() { // set up visual formatting NDrawingView1.Document.Style.FillStyle = new NColorFillStyle(Color.Linen); // create the flowcharting shapes factory NFlowChartingShapesFactory factory = new NFlowChartingShapesFactory(NDrawingView1.Document); // modify the connectors style sheet NStyleSheet styleSheet = (NDrawingView1.Document.StyleSheets.GetChildByName(NDR.NameConnectorsStyleSheet, -1) as NStyleSheet); NTextStyle textStyle = new NTextStyle(); textStyle.BackplaneStyle.Visible = true; textStyle.BackplaneStyle.StandardFrameStyle.InnerBorderWidth = new NLength(0); styleSheet.Style.TextStyle = textStyle; styleSheet.Style.StrokeStyle = new NStrokeStyle(1, Color.Black); styleSheet.Style.StartArrowheadStyle.StrokeStyle = new NStrokeStyle(1, Color.Black); styleSheet.Style.EndArrowheadStyle.StrokeStyle = new NStrokeStyle(1, Color.Black); // create the begin shape NShape begin = factory.CreateShape((int)FlowChartingShapes.Termination); begin.Bounds = new NRectangleF(300, 300, 300, 300); begin.Text = "BEGIN"; NDrawingView1.Document.ActiveLayer.AddChild(begin); // create the step1 shape NShape step1 = factory.CreateShape((int)FlowChartingShapes.Process); step1.Bounds = new NRectangleF(300, 1200, 300, 300); step1.Text = "STEP1"; NDrawingView1.Document.ActiveLayer.AddChild(step1); // connect begin and step1 with bezier link NBezierCurveShape bezier = new NBezierCurveShape(); bezier.StyleSheetName = NDR.NameConnectorsStyleSheet; bezier.Text = "BEZIER"; bezier.SetPointAt(1, new NPointF(300, 900)); bezier.SetPointAt(2, new NPointF(600, 900)); NDrawingView1.Document.ActiveLayer.AddChild(bezier); bezier.FromShape = begin; bezier.ToShape = step1; // create question1 shape NShape question1 = factory.CreateShape((int)FlowChartingShapes.Decision); question1.Bounds = new NRectangleF(900, 1200, 300, 300); question1.Text = "QUESTION1"; NDrawingView1.Document.ActiveLayer.AddChild(question1); // connect step1 and question1 with line link NLineShape line = new NLineShape(); line.StyleSheetName = NDR.NameConnectorsStyleSheet; line.Text = "LINE"; NDrawingView1.Document.ActiveLayer.AddChild(line); line.FromShape = step1; line.ToShape = question1; // create the step2 shape NShape step2 = factory.CreateShape((int)FlowChartingShapes.Process); step2.Bounds = new NRectangleF(1500, 300, 300, 300); step2.Text = "STEP2"; NDrawingView1.Document.ActiveLayer.AddChild(step2); // connect step2 and question1 with HV link NStep2Connector hv1 = new NStep2Connector(false); hv1.StyleSheetName = NDR.NameConnectorsStyleSheet; hv1.Text = "HV1"; NDrawingView1.Document.ActiveLayer.AddChild(hv1); hv1.FromShape = step2; hv1.ToShape = question1; // connect question1 and step2 and with HV link NStep2Connector hv2 = new NStep2Connector(false); hv2.StyleSheetName = NDR.NameConnectorsStyleSheet; hv2.Text = "HV2"; NDrawingView1.Document.ActiveLayer.AddChild(hv2); hv2.FromShape = question1; hv2.ToShape = step2; // create a self loof as bezier on step2 NBezierCurveShape selfLoop = new NBezierCurveShape(); selfLoop.StyleSheetName = NDR.NameConnectorsStyleSheet; selfLoop.Text = "SELF LOOP"; NDrawingView1.Document.ActiveLayer.AddChild(selfLoop); selfLoop.FromShape = step2; selfLoop.ToShape = step2; selfLoop.Reflex(); // create step3 shape NShape step3 = factory.CreateShape((int)FlowChartingShapes.Process); step3.Bounds = new NRectangleF(2100, 1800, 300, 300); step3.Text = "STEP3"; NDrawingView1.Document.ActiveLayer.AddChild(step3); // connect question1 and step3 with an HVH link NStep3Connector hvh1 = new NStep3Connector(false, 50, 0, true); hvh1.StyleSheetName = NDR.NameConnectorsStyleSheet; hvh1.Text = "HVH1"; NDrawingView1.Document.ActiveLayer.AddChild(hvh1); hvh1.FromShape = question1; hvh1.ToShape = step3; // create end shape NShape end = factory.CreateShape((int)FlowChartingShapes.Termination); end.Bounds = new NRectangleF(900, 2100, 300, 300); end.Text = "END"; NDrawingView1.Document.ActiveLayer.AddChild(end); // connect step3 and end with VH link NStep2Connector vh1 = new NStep2Connector(true); vh1.StyleSheetName = NDR.NameConnectorsStyleSheet; vh1.Text = "VH1"; NDrawingView1.Document.ActiveLayer.AddChild(vh1); vh1.FromShape = step3; vh1.ToShape = end; // connect question1 and end with curve link (uses explicit ports) NRoutableConnector curve = new NRoutableConnector(RoutableConnectorType.DynamicCurve); curve.StyleSheetName = NDR.NameConnectorsStyleSheet; curve.Text = "CURVE"; NDrawingView1.Document.ActiveLayer.AddChild(curve); curve.StartPlug.Connect(question1.Ports.GetChildAt(3) as NPort); curve.EndPlug.Connect(end.Ports.GetChildAt(1) as NPort); curve.InsertPoint(1, new NPointF(1500, 1800)); // set a shadow to the document. Since styles are inheritable all objects will reuse this shadow NDrawingView1.Document.Style.ShadowStyle = new NShadowStyle( ShadowType.GaussianBlur, Color.Gray, new NPointL(5, 5), 1, new NLength(3)); // shadows must be displayed behind document content NDrawingView1.Document.ShadowsZOrder = ShadowsZOrder.BehindDocument; }
private void CreatePredefinedGraph() { // we will be using basic shapes for this example NBasicShapesFactory basicShapesFactory = new NBasicShapesFactory(); basicShapesFactory.DefaultSize = new NSizeF(80, 80); List <NPerson> persons = new List <NPerson>(); // create persons NPerson personEmil = new NPerson("Emil Moore", basicShapesFactory.CreateShape(BasicShapes.Circle)); NPerson personAndre = new NPerson("Andre Smith", basicShapesFactory.CreateShape(BasicShapes.Circle)); NPerson personRobert = new NPerson("Robert Johnson", basicShapesFactory.CreateShape(BasicShapes.Circle)); NPerson personBob = new NPerson("Bob Williams", basicShapesFactory.CreateShape(BasicShapes.Circle)); NPerson personPeter = new NPerson("Peter Brown", basicShapesFactory.CreateShape(BasicShapes.Circle)); NPerson personSilvia = new NPerson("Silvia Moore", basicShapesFactory.CreateShape(BasicShapes.Circle)); NPerson personEmily = new NPerson("Emily Smith", basicShapesFactory.CreateShape(BasicShapes.Circle)); NPerson personMonica = new NPerson("Monica Johnson", basicShapesFactory.CreateShape(BasicShapes.Circle)); NPerson personSamantha = new NPerson("Samantha Miller", basicShapesFactory.CreateShape(BasicShapes.Circle)); NPerson personIsabella = new NPerson("Isabella Davis", basicShapesFactory.CreateShape(BasicShapes.Circle)); persons.Add(personEmil); persons.Add(personAndre); persons.Add(personRobert); persons.Add(personBob); persons.Add(personPeter); persons.Add(personSilvia); persons.Add(personEmily); persons.Add(personMonica); persons.Add(personSamantha); persons.Add(personIsabella); // create family relashionships personEmil.m_Family = personSilvia; personAndre.m_Family = personEmily; personRobert.m_Family = personMonica; // create friend relationships personEmily.m_Friends.Add(personBob); personEmily.m_Friends.Add(personMonica); personAndre.m_Friends.Add(personPeter); personAndre.m_Friends.Add(personIsabella); personSilvia.m_Friends.Add(personBob); personSilvia.m_Friends.Add(personSamantha); personSilvia.m_Friends.Add(personIsabella); personEmily.m_Friends.Add(personIsabella); personEmily.m_Friends.Add(personPeter); personPeter.m_Friends.Add(personRobert); // create the person vertices for (int i = 0; i < persons.Count; i++) { NDrawingView1.Document.ActiveLayer.AddChild(persons[i].m_Shape); } // creeate the family relations for (int i = 0; i < persons.Count; i++) { NPerson currentPerson = persons[i]; if (currentPerson.m_Family != null) { NLineShape connector = new NLineShape(); NDrawingView1.Document.ActiveLayer.AddChild(connector); connector.FromShape = currentPerson.m_Shape; connector.ToShape = currentPerson.m_Family.m_Shape; connector.LayoutData.SpringStiffness = 2; connector.LayoutData.SpringLength = 100; connector.Style.StrokeStyle = new NStrokeStyle(2, Color.Coral); } } for (int i = 0; i < persons.Count; i++) { NPerson currentPerson = persons[i]; for (int j = 0; j < currentPerson.m_Friends.Count; j++) { NLineShape connector = new NLineShape(); NDrawingView1.Document.ActiveLayer.AddChild(connector); connector.FromShape = currentPerson.m_Shape; connector.ToShape = currentPerson.m_Friends[j].m_Shape; connector.LayoutData.SpringStiffness = 1; connector.LayoutData.SpringLength = 200; connector.Style.StrokeStyle = new NStrokeStyle(2, Color.Green); } } }
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; }