protected override void OnPaint(PaintEventArgs e) { /* ******************** * * * * * +------------------+ * * | /| /| /| | * * | /-| /-| /-| | * * | / | / | / | | * * +------------------+ * * * ************************** ************************** */ int left = 6; Size size; int drawableLength; using (IGraphics g = Plat.Inst.GetGraphics(this)) { g.BeginPaint(e.ClipRectangle); // fill background g.ForeColor = _TabLineColor; g.BackColor = BackColor; g.FillRectangle(0, 0, Width, Height); g.DrawLine(0, Height - 1, Width, Height - 1); // ensure capacity of x-coordinate array if (_TabRightCoords == null || _TabRightCoords.Length < _Items.Count) { _TabRightCoords = new int[_Items.Count + 8]; // add little extra } // draw each tabs for (int i = 0; i < _Items.Count; i++) { // make label text string text = (string)_Items[i].ToString(); size = g.MeasureText( text, _MaxTabTextWidth, out drawableLength ); // if the label is too long to draw, cut it and add ellipsis if (drawableLength < text.Length) { // measure width of text attached the ellipsis size = g.MeasureText( text, _MaxTabTextWidth - _ElipsisWidth, out drawableLength ); text = text.Substring(0, drawableLength) + "..."; size.Width += _ElipsisWidth; } // if right end of the tab exceeds limit, stop drawing if (Right - DropTipWidth <= left + size.Width + 8) { break; } // draw background of this tab int w = size.Width; int h = size.Height; if (_Items[i].Equals(_SelectedItem)) { // for selected tab, before drawing background // draw a line to erase border between content area g.ForeColor = _ActiveTabBackColor; g.DrawLine(left + 1, Height - 1, left + w + 7, Height - 1); g.BackColor = _ActiveTabBackColor; } else { g.BackColor = _TabBackColor; } g.FillRectangle(left + 1, Height - h - 3, w + 7, h + 2); g.FillRectangle(left + 2, Height - h - 4, w + 4, 1); // draw boundary g.ForeColor = _TabLineColor; g.DrawLine(left, Height - 1, left, Height - h - 2); // left g.DrawLine(left, Height - h - 2, left + 3, Height - h - 5); // left-top g.DrawLine(left + 3, Height - h - 5, left + w + 5, Height - h - 5); // top g.DrawLine(left + w + 5, Height - h - 5, left + w + 8, Height - h - 2); // top-right g.DrawLine(left + w + 8, Height - h - 2, left + w + 8, Height - 1); // right // draw text on the tab Point pos = new Point(left + 4, Height - size.Height - 2); g.DrawText(text, ref pos, _TabTextColor); // go to next tab _TabRightCoords[i] = left + w + 8; left += w + 8; } // draw line at left of triangle int half = _HalfHeight; int quarter = _QuarterHeight; int oneEighth = _OneEighthHeight; g.ForeColor = Color.Gray; g.DrawLine(Right - DropTipWidth, 0, Right - DropTipWidth, Height); // draw triangle g.ForeColor = Color.Black; for (int i = 0; i <= oneEighth + 1; i++) { g.DrawLine( Right - half + i, Height - quarter - oneEighth + i, Right - quarter - i + 1, Height - quarter - oneEighth + i ); } g.EndPaint(); } }