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 NGenogramShapeFactory factory = new NGenogramShapeFactory(); int row = 0, col = 0; double cellWidth = 240; double cellHeight = 150; for (int i = 0; i < factory.ShapeCount; i++, col++) { NShape shape = factory.CreateShape(i); shape.HorizontalPlacement = ENHorizontalPlacement.Center; shape.VerticalPlacement = ENVerticalPlacement.Center; NTextBlock textBlock = shape.GetFirstDescendant <NTextBlock>(); if (textBlock == null || i == (int)ENGenogramShape.Male || i == (int)ENGenogramShape.Female || i == (int)ENGenogramShape.Pet || i == (int)ENGenogramShape.UnknownGender) { textBlock = (NTextBlock)shape.TextBlock; } textBlock.Text = factory.GetShapeInfo(i).Name; activePage.Items.Add(shape); if (col >= 4) { row++; col = 0; } NPoint beginPoint = new NPoint(50 + col * cellWidth, 50 + row * cellHeight); if (shape.ShapeType == ENShapeType.Shape1D) { NPoint endPoint = beginPoint + new NPoint(cellWidth - 50, cellHeight - 50); shape.SetBeginPoint(beginPoint); shape.SetEndPoint(endPoint); } else { textBlock.SetFx(NTextBlock.PinYProperty, "$Parent.Height + Height + 10"); textBlock.ResizeMode = ENTextBlockResizeMode.TextSize; shape.SetBounds(beginPoint.X, beginPoint.Y, shape.Width, shape.Height); } } // size page to content activePage.Layout.ContentPadding = new NMargins(50); activePage.SizeToContent(); } finally { m_DrawingDocument.HistoryService.Resume(); } }