I have some weird drawing artifacts, and I hope someone can help me.
Basically, I have a left dock panel that should have a gradient background that didn't work correctly. I changed the colors for debugging
screenshot http://img509.imageshack.us/img509/5650/18740614.png
The panel is docked on the left and has transparent control over it (from here you can see small nettles along the edges along the edges, where the transparent control was correctly painted, choosing the background color).
When I resize the panel slowly, I get red lines at the bottom left, which, as I expected, will be covered with yellow bays. The code I use is as follows:
sidePanel.Paint += new PaintEventHandler(OnPaint);
private void OnPaint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Panel pb = sender as Panel;
PaintControl(pb.Width, pb.Height, sender, e, true);
}
private static void PaintControl(int width, int height, object sender, PaintEventArgs e, bool sidebar)
{
Rectangle baseRectangle = new Rectangle(0, 0, width -1, height-1);
using (LinearGradientBrush gradientBrush = new LinearGradientBrush(baseRectangle, WizardBaseForm.StartColour, WizardBaseForm.EndColour, 90))
{
e.Graphics.Clear(Color.Yellow);
e.Graphics.DrawRectangle(Pens.Red, baseRectangle);
e.Graphics.FillRectangle(Brushes.Yellow, baseRectangle);
}
}
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
this.Invalidate();
}
- , , .