Rectangle GetLabelRect(int index)
{
Rectangle viewPortRect = GetViewPortRect();
OutlookBarBand band = bands[currentBandIndex];
Debug.Assert(band != null);
Size imageSize = Size.Empty;
Rectangle itemRect = Rectangle.Empty;
Size labelSize = Size.Empty;
Point pt = new Point(0,0);
using ( Graphics g = Graphics.FromHwnd(Handle) )
{
itemRect = GetItemRect(g, band, index, Rectangle.Empty);
labelSize = GetLabelSize(g, band, index);
}
if ( band.IconView == IconView.Small )
{
if ( band.SmallImageList != null )
{
imageSize = band.SmallImageList.ImageSize;
// Don't include the offset between the icon and the label
// so that we don't leave a miss hit gap
pt.X = itemRect.Left + imageSize.Width;
pt.Y = itemRect.Top + (itemRect.Height - labelSize.Height)/2;
}
return new Rectangle(pt.X, pt.Y , labelSize.Width + X_SMALLICON_LABEL_OFFSET+2 , labelSize.Height);
}
else
{
if ( band.LargeImageList != null )
{
imageSize = band.LargeImageList.ImageSize;
pt.X = itemRect.Left + (viewPortRect.Width - labelSize.Width) / 2;
// Don't include the offset between the icon and the label
// so that we don't leave a miss hit gap
pt.Y = itemRect.Top + imageSize.Height;
}
return new Rectangle(pt.X, pt.Y, labelSize.Width, labelSize.Height+ Y_LARGEICON_LABEL_OFFSET+2);
}
}