protected override void OnPaint(PaintEventArgs e)
{
// Obtain the Graphics object
Graphics g = e.Graphics;
// Set the composit quality and smooting mode
// of the surface
g.CompositingQuality = CompositingQuality.HighQuality;
g.SmoothingMode = SmoothingMode.AntiAlias;
// Create a rectangle from point (20, 20) to (100, 100)
Rectangle rect = new Rectangle(20, 20, 100, 100);
// Create two Pen objects with Red and Green color
Pen redPen = new Pen(Color.Red, 3);
Pen blackPen = Pens.Black;
// Create a SolidBrush objects
SolidBrush greenBrush = new SolidBrush(Color.Green);
// Draw shapes and lines
g.DrawRectangle(redPen, rect);
g.FillEllipse(greenBrush, rect);
g.DrawLine(blackPen, 0, 250, this.Width, 250);
g.FillEllipse(Brushes.Blue, 70, 220, 30, 30);
g.FillEllipse(Brushes.SkyBlue, 100, 210, 40, 40);
g.FillEllipse(Brushes.Green, 140, 200, 50, 50);
g.FillEllipse(Brushes.Yellow, 190, 190, 60, 60);
g.FillEllipse(Brushes.Violet, 250, 180, 70, 70);
g.FillEllipse(Brushes.Red, 320, 170, 80, 80);
// Dispose objects
greenBrush.Dispose();
// blackPen.Dispose();
redPen.Dispose();
g.Dispose();
}