/// <summary> Method is called whenever this form is resized. </summary>
/// <param name="e"></param>
/// <remarks> This redraws the background of this form </remarks>
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
// Get rid of any current background image
if (BackgroundImage != null)
{
BackgroundImage.Dispose();
BackgroundImage = null;
}
if (ClientSize.Width > 0)
{
// Create the items needed to draw the background
Bitmap image = new Bitmap(ClientSize.Width, ClientSize.Height);
Graphics gr = Graphics.FromImage(image);
Rectangle rect = new Rectangle(new Point(0, 0), ClientSize);
// Create the brush
LinearGradientBrush brush = new LinearGradientBrush(rect, SystemColors.Control, ControlPaint.Dark(SystemColors.Control), LinearGradientMode.Vertical);
brush.SetBlendTriangularShape(0.33F);
// Create the image
gr.FillRectangle(brush, rect);
gr.Dispose();
// Set this as the backgroundf
BackgroundImage = image;
}
}