protected override void InitDiagram() { base.InitDiagram(); NDrawing drawing = m_DrawingDocument.Content; NPage activePage = drawing.ActivePage; // hide the grid drawing.ScreenVisibility.ShowGrid = false; NBasicShapeFactory basicShapesFactory = new NBasicShapeFactory(); NShape shape1 = basicShapesFactory.CreateShape(ENBasicShape.Rectangle); shape1.SetBounds(10, 10, 381, 600); NTextBlock textBlock1 = new NTextBlock(); shape1.TextBlock = textBlock1; textBlock1.Content.Blocks.Clear(); AddFormattedTextToContent(textBlock1.Content); drawing.ActivePage.Items.Add(shape1); NShape shape2 = basicShapesFactory.CreateShape(ENBasicShape.Rectangle); shape2.SetBounds(401, 10, 381, 600); NTextBlock textBlock2 = new NTextBlock(); shape2.TextBlock = textBlock2; textBlock2.Content.Blocks.Clear(); AddFormattedTextWithImagesToContent(textBlock2.Content); drawing.ActivePage.Items.Add(shape2); }
protected override void InitDiagram() { base.InitDiagram(); NDrawing drawing = m_DrawingDocument.Content; NPage activePage = drawing.ActivePage; // hide the grid drawing.ScreenVisibility.ShowGrid = false; NBasicShapeFactory basicShapesFactory = new NBasicShapeFactory(); NShape shape1 = basicShapesFactory.CreateShape(ENBasicShape.Rectangle); shape1.SetBounds(10, 10, 600, 1000); NTextBlock textBlock = new NTextBlock(); shape1.TextBlock = textBlock; textBlock.Padding = new NMargins(20); textBlock.Content.Blocks.Clear(); textBlock.Content.HorizontalAlignment = ENAlign.Left; AddFormattedTextToContent(textBlock.Content); drawing.ActivePage.Items.Add(shape1); }
protected virtual void MoveTextBelowShape(NShape shape) { NTextBlock textBlock = shape.GetTextBlock(); textBlock.Padding = new NMargins(0, 5, 0, 0); textBlock.ResizeMode = ENTextBlockResizeMode.TextSize; textBlock.SetFx(NTextBlock.PinYProperty, new NShapeHeightFactorFx(1.0)); textBlock.LocPinY = 0; }
protected override void MoveTextBelowShape(NShape shape) { if (shape.ShapeType == ENShapeType.Shape1D) { NTextBlock textBlock = (NTextBlock)shape.TextBlock; textBlock.Padding = new NMargins(0, 5, 0, 0); textBlock.ResizeMode = ENTextBlockResizeMode.TextSize; textBlock.SetFx(NTextBlock.PinYProperty, new NShapeHeightFactorFx(1.0)); textBlock.LocPinY = -2; } else { base.MoveTextBelowShape(shape); } }
protected override void MoveTextBelowShape(NShape shape) { if (shape.ShapeType == ENShapeType.Shape2D) { base.MoveTextBelowShape(shape); return; } // if the shape is 1D put the text block on the left part of the shape and rotate it on 90 degrees. NTextBlock textBlock = shape.GetTextBlock(); textBlock.Padding = new NMargins(5, 0, 0, 0); textBlock.ResizeMode = ENTextBlockResizeMode.TextSize; textBlock.PinX = shape.BeginX; textBlock.SetFx(NTextBlock.PinYProperty, new NShapeHeightFactorFx(0)); textBlock.LocPinY = 0; textBlock.Angle = new NAngle(90); }
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(); } }