- // - // draw tab's icon if ((tabPage.ImageIndex >= 0) & (ImageList != null) & G.DrawLine(pen, recBounds.Left + 1, recBounds.Top-2, G.DrawLine(pen, recBounds.Left + 1, recBounds.Top-1, G.DrawLine(pen, recBounds.Left + 1, recBounds.Top, RecBounds.Right - 1, recBounds.Bottom+1) G.DrawLine(pen, recBounds.Left + 1, recBounds.Bottom+1, G.DrawLine(pen, recBounds.Left + 1, recBounds.Bottom, G.DrawPolygon(SystemPens.ControlDark, pt) - // - // draw border // g.DrawRectangle(SystemPens.ControlDark, recBounds) - // fill this tab with background colorīrush br = new SolidBrush(tabPage.BackColor) Pt = new Point(recBounds.Left, recBounds.Bottom - 3) Pt = new Point(recBounds.Left + 3, recBounds.Bottom) Pt = new Point(recBounds.Right - 3, recBounds.Bottom) Pt = new Point(recBounds.Right, recBounds.Bottom - 3) Pt = new Point(recBounds.Right, recBounds.Top) Pt = new Point(recBounds.Left, recBounds.Top) Pt = new Point(recBounds.Right, recBounds.Bottom) Pt = new Point(recBounds.Right, recBounds.Top + 3) Pt = new Point(recBounds.Right - 3, recBounds.Top) Pt = new Point(recBounds.Left + 3, recBounds.Top) Pt = new Point(recBounds.Left, recBounds.Top + 3) Pt = new Point(recBounds.Left, recBounds.Bottom) RectangleF tabTextArea = (RectangleF) this.GetTabRect(nIndex) īool bSelected = ( this.SelectedIndex = nIndex) Rectangle recBounds = this.GetTabRect(nIndex) Internal void DrawTab(Graphics g, TabPage tabPage, int nIndex) I have only implemented alignment to Top and Bottom because the alignment to Left and Right are more complicated (someone can try!) and there are other articles explaining this kind of behavior like. It also draws the text and the icon for the tab page. The DrawTab method uses polygons to draw the border. - // - // draw background to cover flat border areas if ( this.SelectedTab != null) draw tabs for ( int i = 0 i < this.TabCount i++) NWidth - nMargin, TabControlArea.Height) Rreg = new Rectangle(TabArea.Left, TabControlArea.Top, Rectangle rupdown2 = this.RectangleToClient(rupdown) Win32.GetWindowRect(scUpDown.Handle, ref rupdown) exclude updown control for painting if (Win32.IsWindowVisible(scUpDown.Handle)) - // - // clip region for drawing tabs Pen border = new Pen(SystemColors.ControlDark) - // fill client areaīrush br = new SolidBrush(SystemColors.Control) Rectangle TabArea = this.DisplayRectangle Rectangle TabControlArea = this.ClientRectangle Protected override void OnPaint(PaintEventArgs e)
0 Comments
Leave a Reply. |