internal void DrawTab(Graphics g, TabPage tabPage, int nIndex) { Rectangle recBounds = this.GetTabRect(nIndex); RectangleF tabTextArea = (RectangleF)this.GetTabRect(nIndex); bool bSelected = (this.SelectedIndex == nIndex); Point[] pt = new Point[7]; if (this.Alignment == TabAlignment.Top) { pt[0] = new Point(recBounds.Left, recBounds.Bottom); pt[1] = new Point(recBounds.Left, recBounds.Top + 3); pt[2] = new Point(recBounds.Left + 3, recBounds.Top); pt[3] = new Point(recBounds.Right - 3, recBounds.Top); pt[4] = new Point(recBounds.Right, recBounds.Top + 3); pt[5] = new Point(recBounds.Right, recBounds.Bottom); pt[6] = new Point(recBounds.Left, recBounds.Bottom); } else { pt[0] = new Point(recBounds.Left, recBounds.Top); pt[1] = new Point(recBounds.Right, recBounds.Top); pt[2] = new Point(recBounds.Right, recBounds.Bottom - 3); pt[3] = new Point(recBounds.Right - 3, recBounds.Bottom); pt[4] = new Point(recBounds.Left + 3, recBounds.Bottom); pt[5] = new Point(recBounds.Left, recBounds.Bottom - 3); pt[6] = new Point(recBounds.Left, recBounds.Top); } //---------------------------- // fill this tab with background color //TODO: criar uma propriedade para armazenar a cor da tab selecionada Brush br; if (bSelected) { br = new SolidBrush(Color.Gold); if (tabPage.GetType().FullName == typeof(TabMonitor).FullName) { if (((TabMonitor)tabPage).Controlado) { br = new SolidBrush(Color.MidnightBlue); } else { br = new SolidBrush(Color.Gold); } } else { br = new SolidBrush(Color.Gold); } } else { if (tabPage.GetType() == typeof(TabMonitor)) { if (((TabMonitor)tabPage).Controlado) { br = new SolidBrush(Color.MidnightBlue); } else { br = new SolidBrush(tabPage.BackColor); } } else { br = new SolidBrush(tabPage.BackColor); } } g.FillPolygon(br, pt); br.Dispose(); //---------------------------- //---------------------------- // draw border //g.DrawRectangle(SystemPens.ControlDark, recBounds); g.DrawPolygon(SystemPens.ControlDark, pt); //if (bSelected) //{ // //---------------------------- // // clear bottom lines // Pen pen = new Pen(tabPage.BackColor); // switch (this.Alignment) // { // case TabAlignment.Top: // g.DrawLine(pen, recBounds.Left + 1, recBounds.Bottom, recBounds.Right - 1, recBounds.Bottom); // g.DrawLine(pen, recBounds.Left + 1, recBounds.Bottom+1, recBounds.Right - 1, recBounds.Bottom+1); // break; // case TabAlignment.Bottom: // g.DrawLine(pen, recBounds.Left + 1, recBounds.Top, recBounds.Right - 1, recBounds.Top); // g.DrawLine(pen, recBounds.Left + 1, recBounds.Top-1, recBounds.Right - 1, recBounds.Top-1); // g.DrawLine(pen, recBounds.Left + 1, recBounds.Top-2, recBounds.Right - 1, recBounds.Top-2); // break; // } // pen.Dispose(); // //---------------------------- //} //---------------------------- //---------------------------- // draw tab's icon if ((tabPage.ImageIndex >= 0) && (ImageList != null) && (ImageList.Images[tabPage.ImageIndex] != null)) { int nLeftMargin = 8; int nRightMargin = 2; Image img = ImageList.Images[tabPage.ImageIndex]; Rectangle rimage = new Rectangle(recBounds.X + nLeftMargin, recBounds.Y + 1, img.Width, img.Height); // adjust rectangles float nAdj = (float)(nLeftMargin + img.Width + nRightMargin); rimage.Y += (recBounds.Height - img.Height) / 2; tabTextArea.X += nAdj; tabTextArea.Width -= nAdj; // draw icon g.DrawImage(img, rimage); } //---------------------------- //---------------------------- // draw string StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Center; if (bSelected) { if (tabPage.GetType().FullName == typeof(TabMonitor).FullName) { if (((TabMonitor)tabPage).Controlado) { br = new SolidBrush(Color.White); } else { br = new SolidBrush(Color.Black); } } else { if (tabPage.GetType() == typeof(TabMonitor)) { if (((TabMonitor)tabPage).Controlado) { br = new SolidBrush(Color.White); } else { br = new SolidBrush(Color.Black); } } else { br = new SolidBrush(Color.Black); } } } else { br = new SolidBrush(tabPage.ForeColor); } g.DrawString(tabPage.Text, Font, br, tabTextArea, stringFormat); //---------------------------- }