If you want to create a curved tab style control similar to the control on the right, then you can use the path functionallity of the graphics class to produce the rectangle with rounded corners at the top.
A linear gradiant brush finishes off the nice rendering effect.
[csharp]
Rectangle rc = new Rectangle(0, 0, this.Width, _CaptionHeight+1);
LinearGradientBrush b = new LinearGradientBrush(rc,
_CaptionLeftColor, _CaptionRightColor,
LinearGradientMode.Vertical);
// Now draw the caption areas with the rounded corners at the top
GraphicsPath path = new GraphicsPath();
path.AddLine(_CurveRadius, 0, this.Width -
(_CurveRadius * 2), 0);
path.AddArc(this.Width - (_CurveRadius * 2) - 1, 0,
(_CurveRadius * 2), (_CurveRadius * 2), 270, 90);
path.AddLine(this.Width-1, _CurveRadius,this.Width-1, _CaptionHeight);
path.AddLine(this.Width, _CaptionHeight+1, 0, _CaptionHeight+1);
path.AddLine(0, _CaptionHeight, 0, _CurveRadius);
path.AddArc(0, 0, (_CurveRadius * 2),
(_CurveRadius * 2), 180, 90);
// Remove jaggies
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
// Smooooth fill
e.Graphics.FillPath(b, path);
e.Graphics.DrawPath(new Pen(_PanelOutlineColor), path);
[/csharp]
Recent Comments