ATMLCommonLibrary.controls.awb.AWBTabControl.DrawTabIcon C# (CSharp) Method

DrawTabIcon() private method

private DrawTabIcon ( Graphics g, TabPage tabPage, int nIndex, Rectangle &recBounds, RectangleF &tabTextArea, bool hasErrors ) : void
g System.Drawing.Graphics
tabPage System.Windows.Forms.TabPage
nIndex int
recBounds System.Drawing.Rectangle
tabTextArea System.Drawing.RectangleF
hasErrors bool
return void
        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 );
            }
        }