private void Draw()
{
// load buffer into a graphics object
System.Drawing.Graphics graphx = Graphics.FromImage(buffer);
// create objects
System.Drawing.Rectangle rect = new Rectangle(0,0,this.Width,this.Height);
System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(rect,System.Drawing.Color.Blue,System.Drawing.Color.Gray,System.Drawing.Drawing2D.LinearGradientMode.BackwardDiagonal);
// draw to buffer
graphx.FillRectangle(brush,rect);
// dispose of objects to prevent memory leak
brush.Dispose();
graphx.Dispose();
// tell the application to update the screen (which essential calls OnPaint)
Invalidate();
}