aspatz

hallo,
i try to create a custom usercontrol inherited from panel. I want to create it with a custom 3D effect.

ColorStart and ColorStopp are two Properties.

private void PaintGradient()
{
Point[] pt = new Point[]{new Point(0, 0),
new Point(0, 100)};

PathGradientBrush pathBrush = new PathGradientBrush(pt);
// -- -- -- >>> here comes the OutOfMemoryException

pathBrush.CenterPoint = new PointF(0, 50);

Color[] surrColors = new Color[2];
surrColors[0] = ColorStart;
surrColors[1] = ColorStart;

pathBrush.SurroundColors = surrColors;
pathBrush.CenterColor = ColorStopp;

Bitmap bmp = new Bitmap(this.Width, this.Height);
Graphics g = Graphics.FromImage(bmp);

g.FillRectangle(pathBrush, new Rectangle(0, 0, this.Width, this.Height));
this.BackgroundImage = bmp;
this.BackgroundImageLayout = ImageLayout.Stretch;
}

did you have an idea why this error occures.
Thanks Arnold


Re: Windows Forms General Panel with 3D PathBrush -> OutOfMemory Exception

aspatz

i found the problem,
pathBrush cannot handle a Path like
>> new Point[]{new Point(0, 0), new Point(0, 100) <<
when i am changing it to
>> new Point[]{new Point(0, 0), new Point(1, 100) <<
than there is no Exception.