Ejemplo n.º 1
0
 internal void MeasureMinimumWidth(Graphics graphics, ref int minimumWidth)
 {
     if (MeasureWidth != null)
     {
         MeasureWidthEventArgs e = new MeasureWidthEventArgs(graphics);
         MeasureWidth(this, e);
         minimumWidth = Math.Max(minimumWidth, e.ItemWidth);
     }
     if (text.Length > 0)
     {
         // Prevent GDI exception (forum-12284) when text is very long
         if (text.Length > short.MaxValue)
         {
             text = text.Substring(0, short.MaxValue - 1);
         }
         int width = 2 + (int)graphics.MeasureString(text, font, new PointF(0, 0), textFormat).Width;
         minimumWidth = Math.Max(minimumWidth, width);
     }
 }
Ejemplo n.º 2
0
		internal void MeasureMinimumWidth(Graphics graphics, ref int minimumWidth)
		{
			if (MeasureWidth != null) {
				MeasureWidthEventArgs e = new MeasureWidthEventArgs(graphics);
				MeasureWidth(this, e);
				minimumWidth = Math.Max(minimumWidth, e.ItemWidth);
			}
			if (text.Length > 0) {
				// Prevent GDI exception (forum-12284) when text is very long
				if (text.Length > short.MaxValue) {
					text = text.Substring(0, short.MaxValue - 1);
				}
				int width = 2 + (int)graphics.MeasureString(text, font, new PointF(0, 0), textFormat).Width;
				minimumWidth = Math.Max(minimumWidth, width);
			}
		}