A friend in the group made the following code yesterday:
System.Drawing.Drawing2D.LinearGradientBrush brush=new System.Drawing.Drawing2D.LinearGradientBrush(new Point(1),new Point(1),Color.Red,Color.Green);
When the result is running, an outofmemoryexception occurs.
After repeated searches
The problem is found here.
Http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvb/thread/6feb8768-6235-44b1-a8b0-463d23def481/
I found what was causing the error.
My function calcgradientstartstop didn't work correctly, my gstart and gstop values didn't change.
Now I changed it and it works.
The error was because gstart coordinates (0, 0) were the same as gstop coordinates (0, 0 ),
And that doesn't work well ..
But now I have another problem
I edited my filling sub like this (I'm now using global variables )..
Instead of gstart and gstop I now use global vars mgradientstart and mgradientstop:
Code block
Private Sub drawFill(ByVal e As System.Windows.Forms.PaintEventArgs) Dim gStart As New PointF(0, 0) Dim gStop As New PointF(0, 0) If Me.cGradientFill Then Me.calcGradientStartStop() If Not (Me.mGradientStart.X = Me.mGradientStop.X) And Not (Me.mGradientStart.Y = Me.mGradientStop.Y) Then Dim grdnt As New Drawing.Drawing2D.LinearGradientBrush(Me.mGradientStart, Me.mGradientStop, Me.mGradientColor1, Me.mGradientColor2) e.Graphics.FillRegion(grdnt, Me.Region) Else MsgBox("Start and Stop Can't Have Same Value") End If Else e.Graphics.FillRegion(New SolidBrush(Me.mBgColor), Me.Region) End If End Sub
The problem is as follows:
Lineargradientbrush (new point (1), new point (1), color. Red, color. Green );
The points of the first two parameters of the constructor cannot be the same. Otherwise, an error is returned.
Recorded. It facilitates searching by others.