Exemple #1
0
        public override void DrawTextForAllNodes(Graphics oGraphics, Rectangle oTreemapRectangle, Nodes oNodes)
        {
            Debug.Assert(oGraphics != null);
            Debug.Assert(oNodes != null);
            this.AssertValid();
            FontForRectangle  fontForRectangle  = null;
            SolidBrush        solidBrush        = null;
            TextRenderingHint textRenderingHint = TextRenderingHint.SystemDefault;

            try
            {
                fontForRectangle  = new FontForRectangle(this.m_sFontFamily, this.m_fFontSizePt, oGraphics);
                textRenderingHint = base.SetTextRenderingHint(oGraphics, fontForRectangle.Font);
                solidBrush        = new SolidBrush(this.m_oTextColor);
                StringFormat oNonLeafStringFormat = this.CreateStringFormat(false);
                StringFormat oLeafStringFormat    = this.CreateStringFormat(true);
                int          textHeight           = TopTextDrawer.GetTextHeight(oGraphics, fontForRectangle.Font, this.m_iMinimumTextHeight);
                this.DrawTextForNodes(oNodes, oGraphics, fontForRectangle, textHeight, solidBrush, null, oNonLeafStringFormat, oLeafStringFormat, 0);
            }
            finally
            {
                if (solidBrush != null)
                {
                    solidBrush.Dispose();
                }
                if (fontForRectangle != null)
                {
                    fontForRectangle.Dispose();
                }
                oGraphics.TextRenderingHint = textRenderingHint;
            }
        }
Exemple #2
0
        public static int GetTextHeight(Graphics oGraphics, string sFontFamily, float fFontSizePt, int iMinimumTextHeight)
        {
            Debug.Assert(oGraphics != null);
            StringUtil.AssertNotEmpty(sFontFamily);
            Debug.Assert(fFontSizePt > 0f);
            Debug.Assert(iMinimumTextHeight >= 0);
            FontForRectangle fontForRectangle = null;
            int textHeight;

            try
            {
                fontForRectangle = new FontForRectangle(sFontFamily, fFontSizePt, oGraphics);
                textHeight       = TopTextDrawer.GetTextHeight(oGraphics, fontForRectangle.Font, iMinimumTextHeight);
            }
            finally
            {
                if (fontForRectangle != null)
                {
                    fontForRectangle.Dispose();
                }
            }
            return(textHeight);
        }