Beispiel #1
0
 public int GetHeight(Win32DCSafeHandle hdc, FontCache fontCache)
 {
     if (!this.m_calculatedHeight)
     {
         this.m_calculatedHeight = true;
         for (int i = 0; i < this.m_logicalRuns.Count; i++)
         {
             TextRun textRun = this.m_logicalRuns[i];
             int     ascent  = textRun.GetAscent(hdc, fontCache);
             if (ascent > this.m_ascent)
             {
                 this.m_ascent = ascent;
             }
             int descent = textRun.GetDescent(hdc, fontCache);
             if (descent > this.m_descent)
             {
                 this.m_descent = descent;
             }
         }
         if (this.m_prefix != null)
         {
             for (int j = 0; j < this.m_prefix.Count; j++)
             {
                 TextRun textRun2 = this.m_prefix[j];
                 int     ascent2  = textRun2.GetAscent(hdc, fontCache);
                 if (ascent2 > this.m_ascent)
                 {
                     this.m_ascent = ascent2;
                 }
                 int descent2 = textRun2.GetDescent(hdc, fontCache);
                 if (descent2 > this.m_descent)
                 {
                     this.m_descent = descent2;
                 }
             }
         }
     }
     return(this.m_ascent + this.m_descent);
 }
Beispiel #2
0
 private void CalculateDimensions(Win32DCSafeHandle hdc, FontCache fontCache, bool useVisualRunsIfAvailable)
 {
     if (!this.m_calculatedDimensions)
     {
         bool           flag = useVisualRunsIfAvailable && this.m_visualRuns != null;
         List <TextRun> list = flag ? this.m_visualRuns : this.m_logicalRuns;
         this.m_width       = 0;
         this.m_prefixWidth = 0;
         int count = list.Count;
         int num   = 0;
         for (int i = 0; i < count; i++)
         {
             TextRun textRun = list[i];
             int     width   = textRun.GetWidth(hdc, fontCache);
             this.m_width += width;
             if (!flag)
             {
                 num = Math.Max(textRun.GetWidth(hdc, fontCache, true) - width, num);
             }
             else if (i == count - 1)
             {
                 num = textRun.GetWidth(hdc, fontCache, true) - width;
             }
             if (!this.m_calculatedHeight)
             {
                 int ascent = textRun.GetAscent(hdc, fontCache);
                 if (ascent > this.m_ascent)
                 {
                     this.m_ascent = ascent;
                 }
                 int descent = textRun.GetDescent(hdc, fontCache);
                 if (descent > this.m_descent)
                 {
                     this.m_descent = descent;
                 }
             }
         }
         this.m_width += num;
         if (this.m_prefix != null)
         {
             for (int j = 0; j < this.m_prefix.Count; j++)
             {
                 TextRun textRun2 = this.m_prefix[j];
                 if (!this.m_calculatedHeight)
                 {
                     int ascent2 = textRun2.GetAscent(hdc, fontCache);
                     if (ascent2 > this.m_ascent)
                     {
                         this.m_ascent = ascent2;
                     }
                     int descent2 = textRun2.GetDescent(hdc, fontCache);
                     if (descent2 > this.m_descent)
                     {
                         this.m_descent = descent2;
                     }
                 }
                 this.m_prefixWidth += textRun2.GetWidth(hdc, fontCache);
             }
         }
         this.m_calculatedDimensions = true;
         this.m_calculatedHeight     = true;
     }
 }