public override void DrawTextForSelectedNode(Graphics oGraphics, Node oSelectedNode) { Debug.Assert(oGraphics != null); Debug.Assert(oSelectedNode != null); this.AssertValid(); IFontMapper fontMapper = null; Brush brush = null; TextRenderingHint textRenderingHint = TextRenderingHint.SystemDefault; try { fontMapper = this.CreateFontMapper(oGraphics); brush = new SolidBrush(this.m_oSelectedFontColor); Font font; string s; if (fontMapper.NodeToFont(oSelectedNode, oSelectedNode.Level, oGraphics, out font, out s)) { textRenderingHint = base.SetTextRenderingHint(oGraphics, font); StringFormat format = this.CreateStringFormat(); oGraphics.DrawString(s, font, brush, oSelectedNode.Rectangle, format); } } finally { if (fontMapper != null) { fontMapper.Dispose(); } if (brush != null) { brush.Dispose(); } oGraphics.TextRenderingHint = textRenderingHint; } }
protected void DrawTextForNodes(Nodes oNodes, Graphics oGraphics, IFontMapper oFontMapper, StringFormat oStringFormat, TransparentBrushMapper oTransparentBrushMapper, int iNodeLevel) { Debug.Assert(oNodes != null); Debug.Assert(oGraphics != null); Debug.Assert(oFontMapper != null); Debug.Assert(oStringFormat != null); Debug.Assert(oTransparentBrushMapper != null); Debug.Assert(iNodeLevel >= 0); foreach (Node current in oNodes) { RectangleF rectangle = current.Rectangle; if (!rectangle.IsEmpty) { Font font; string s; if (base.TextShouldBeDrawnForNode(current, iNodeLevel) && oFontMapper.NodeToFont(current, iNodeLevel, oGraphics, out font, out s)) { base.SetTextRenderingHint(oGraphics, font); Brush brush = oTransparentBrushMapper.LevelToTransparentBrush(iNodeLevel); oGraphics.DrawString(s, font, brush, rectangle, oStringFormat); } this.DrawTextForNodes(current.Nodes, oGraphics, oFontMapper, oStringFormat, oTransparentBrushMapper, iNodeLevel + 1); } } }
public override void DrawTextForSelectedNode(Graphics oGraphics, Node oSelectedNode) { Debug.Assert(oGraphics != null); Debug.Assert(oSelectedNode != null); AssertValid(); IFontMapper fontMapper = null; Brush brush = null; TextRenderingHint textRenderingHint = TextRenderingHint.SystemDefault; try { fontMapper = CreateFontMapper(oGraphics); brush = new SolidBrush(m_oSelectedFontColor); if (fontMapper.NodeToFont(oSelectedNode, oSelectedNode.Level, oGraphics, out Font oFont, out string sTextToDraw)) { textRenderingHint = SetTextRenderingHint(oGraphics, oFont); StringFormat format = CreateStringFormat(); oGraphics.DrawString(sTextToDraw, oFont, brush, oSelectedNode.Rectangle, format); } } finally { fontMapper?.Dispose(); brush?.Dispose(); oGraphics.TextRenderingHint = textRenderingHint; } }
protected void DrawTextForNodes(Nodes oNodes, Graphics oGraphics, IFontMapper oFontMapper, StringFormat oStringFormat, TransparentBrushMapper oTransparentBrushMapper, int iNodeLevel) { Debug.Assert(oNodes != null); Debug.Assert(oGraphics != null); Debug.Assert(oFontMapper != null); Debug.Assert(oStringFormat != null); Debug.Assert(oTransparentBrushMapper != null); Debug.Assert(iNodeLevel >= 0); foreach (Node oNode in oNodes) { RectangleF rectangle = oNode.Rectangle; if (!rectangle.IsEmpty) { if (TextShouldBeDrawnForNode(oNode, iNodeLevel) && oFontMapper.NodeToFont(oNode, iNodeLevel, oGraphics, out Font oFont, out string sTextToDraw)) { SetTextRenderingHint(oGraphics, oFont); Brush brush = oTransparentBrushMapper.LevelToTransparentBrush(iNodeLevel); oGraphics.DrawString(sTextToDraw, oFont, brush, rectangle, oStringFormat); } DrawTextForNodes(oNode.Nodes, oGraphics, oFontMapper, oStringFormat, oTransparentBrushMapper, iNodeLevel + 1); } } }