private void DrawTabIcon( Graphics g, TabPage tabPage, int nIndex, ref Rectangle recBounds, ref RectangleF tabTextArea, bool hasErrors )
{
//----------------------------
// draw tab's icon
if (( ( tabPage.ImageIndex >= 0 ) && ( ImageList != null ) &&
(ImageList.Images[tabPage.ImageIndex] != null)) || (hasErrors))
{
int nLeftMargin = 2;
int nRightMargin = 2;
Image img = ( hasErrors )
? ep.Icon.ToBitmap()
: ImageList.Images[tabPage.ImageIndex];
var rimage = new Rectangle( recBounds.X + nLeftMargin, recBounds.Y + 1, img.Width, img.Height );
// adjust rectangles
float nAdj = nLeftMargin + img.Width + nRightMargin;
rimage.Y += ( recBounds.Height - img.Height )/2;
tabTextArea.X += nAdj;
tabTextArea.Width -= nAdj;
// draw icon
g.DrawImage( img, rimage );
}
}