protected override void InitDiagram() { base.InitDiagram(); m_DrawingDocument.HistoryService.Pause(); try { NDrawing drawing = m_DrawingDocument.Content; NPage activePage = drawing.ActivePage; // Hide grid and ports drawing.ScreenVisibility.ShowGrid = false; drawing.ScreenVisibility.ShowPorts = false; // Create all shapes NBrainstormingShapeFactory factory = new NBrainstormingShapeFactory(); factory.DefaultSize = new NSize(60, 60); for (int i = 0; i < factory.ShapeCount; i++) { NShape shape = factory.CreateShape(i); shape.HorizontalPlacement = ENHorizontalPlacement.Center; shape.VerticalPlacement = ENVerticalPlacement.Center; shape.HorizontalPlacement = ENHorizontalPlacement.Center; shape.VerticalPlacement = ENVerticalPlacement.Center; shape.Text = factory.GetShapeInfo(i).Name; MoveTextBelowShape(shape); activePage.Items.Add(shape); } // Arrange them NList <NShape> shapes = activePage.GetShapes(false); NLayoutContext layoutContext = new NLayoutContext(); layoutContext.BodyAdapter = new NShapeBodyAdapter(m_DrawingDocument); layoutContext.GraphAdapter = new NShapeGraphAdapter(); layoutContext.LayoutArea = activePage.GetContentEdge(); NTableFlowLayout tableLayout = new NTableFlowLayout(); tableLayout.HorizontalSpacing = 30; tableLayout.VerticalSpacing = 50; tableLayout.Direction = ENHVDirection.LeftToRight; tableLayout.MaxOrdinal = 5; tableLayout.Arrange(shapes.CastAll <object>(), layoutContext); // size page to content activePage.Layout.ContentPadding = new NMargins(40); activePage.SizeToContent(); } finally { m_DrawingDocument.HistoryService.Resume(); } }