Пример #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;
            }
        }
Пример #2
0
        public override void DrawTextForSelectedNode(Graphics oGraphics, Node oSelectedNode)
        {
            Debug.Assert(oGraphics != null);
            Debug.Assert(oSelectedNode != null);
            AssertValid();
            FontForRectangle  fontForRectangle  = null;
            SolidBrush        solidBrush        = null;
            SolidBrush        solidBrush2       = null;
            TextRenderingHint textRenderingHint = TextRenderingHint.SystemDefault;

            try
            {
                fontForRectangle  = new FontForRectangle(m_sFontFamily, m_fFontSizePt, oGraphics);
                textRenderingHint = SetTextRenderingHint(oGraphics, fontForRectangle.Font);
                solidBrush        = new SolidBrush(m_oSelectedFontColor);
                solidBrush2       = new SolidBrush(m_oSelectedBackColor);
                StringFormat oNonLeafStringFormat = CreateStringFormat(bLeafNode: false);
                StringFormat oLeafStringFormat    = CreateStringFormat(bLeafNode: true);
                int          textHeight           = GetTextHeight(oGraphics, fontForRectangle.Font, m_iMinimumTextHeight);
                DrawTextForNode(oGraphics, oSelectedNode, fontForRectangle, textHeight, solidBrush, solidBrush2, oNonLeafStringFormat, oLeafStringFormat);
            }
            finally
            {
                solidBrush?.Dispose();
                solidBrush2?.Dispose();
                fontForRectangle?.Dispose();
                oGraphics.TextRenderingHint = textRenderingHint;
            }
        }
Пример #3
0
 protected void Dispose(bool bDisposing)
 {
     if (!this.m_bDisposed && bDisposing)
     {
         if (this.m_oFontForRectangles != null)
         {
             IEnumerator enumerator = this.m_oFontForRectangles.GetEnumerator();
             try
             {
                 while (enumerator.MoveNext())
                 {
                     FontForRectangle fontForRectangle = (FontForRectangle)enumerator.Current;
                     fontForRectangle.Dispose();
                 }
             }
             finally
             {
                 IDisposable disposable = enumerator as IDisposable;
                 if (disposable != null)
                 {
                     disposable.Dispose();
                 }
             }
         }
         this.m_oFontForRectangles = null;
     }
     this.m_bDisposed = true;
 }
Пример #4
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;

            try
            {
                fontForRectangle = new FontForRectangle(sFontFamily, fFontSizePt, oGraphics);
                return(GetTextHeight(oGraphics, fontForRectangle.Font, iMinimumTextHeight));
            }
            finally
            {
                fontForRectangle?.Dispose();
            }
        }