SidebarLibrary.WinControls.OutlookBar.GetLabelSize C# (CSharp) Method

GetLabelSize() private method

private GetLabelSize ( Graphics g, OutlookBarBand band, int itemIndex ) : Size
g System.Drawing.Graphics
band OutlookBarBand
itemIndex int
return System.Drawing.Size
		Size GetLabelSize(Graphics g, OutlookBarBand band, int itemIndex)
		{

			Size textSize = new Size(0,0);
			if ( band.IconView == IconView.Large )
			{
				// Calculate text rectangle including word breaks if needed
				Rectangle rect = GetViewPortRect();
				Rectangle textRect = Rectangle.FromLTRB(rect.Left, rect.Top, rect.Width, rect.Top);

				// The TextUtil function is going to call GDI, but the Graphics object
				// is already being used by GDI+. Pass a null reference so that the TextUtil
				// function uses the Screen Device to calculate the text size
				if ( band.Items[itemIndex].Text != null )
				{
					textSize = TextUtil.GetTextSize(null, band.Items[itemIndex].Text,
						Font, ref textRect, DrawTextFormatFlags.DT_CALCRECT |
						DrawTextFormatFlags.DT_CENTER|DrawTextFormatFlags.DT_WORDBREAK);
				}
				return textSize;
			}
			else
			{
				// Same as above
				// Calculate text rectangle single line
				if ( band.Items[itemIndex].Text != null )
				{
					textSize = TextUtil.GetTextSize(null, band.Items[itemIndex].Text, Font);
				}
				return textSize;
			}
		}