prince_wow
asked on
Alternative to paint event
My project deals with huge number of lines (millions) drawn on a picture box. The problem is when the picture box is refreshed (eg. while minimizing-maximizing the form) it takes some time for the lines to appear on the form. In VB 6 the action is instantaneous setting autoredraw property to true. In VB.net however it takes quite some time, and the time is directly proportional to the number of lines.
I have tried keeping only the draw functions in the paint event, i.e. excluded all the mathematical functions from the paint event, yet it didn't help much.
Can anyone sugest an alternative to this approach.. .or other tips to improve the performance. By the way instead of Refresh method, i have also tried using invalidate.. that doesn't help either.
I have tried keeping only the draw functions in the paint event, i.e. excluded all the mathematical functions from the paint event, yet it didn't help much.
Can anyone sugest an alternative to this approach.. .or other tips to improve the performance. By the way instead of Refresh method, i have also tried using invalidate.. that doesn't help either.
Unfortunately, there is no alternative to using the Paint() event if you want to draw to the picture box. VB.NET no longer stores the rendered image, so there is no "AutoRedaw()" property to set. The Win32 API contain a lot of nifty functions that may speed up the painting process, and you can use the ClipRectangle property of the EventArgs object to limit your drawing scope, but I'm afraid you're stuck with the Paint() event.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Javert93 and Ideal_Mind.. With VB .net it seems it is impossible to make my application faster. As you said Ideal_mind I haven't included any calculation while redrawing..
I am trying to convert my current project in VB to VB.net for faster performance.. but I guess the conversion doesn't worth it. One more problem I am facing is User-defined Scale.. My application gets the Scale information from the binary file, and the graphics is drawn accordingly.. but in VB.net everything is in pixels, there is no userdefined Scale... I need to do the manual calculation of the scale for each and every drawing. With that while considering millions of lines the application becomes darn slow..
I am at the starting phase of conversion.. so can you guys suggest what alternative I might have for VB.net - slick and faster.
I am trying to convert my current project in VB to VB.net for faster performance.. but I guess the conversion doesn't worth it. One more problem I am facing is User-defined Scale.. My application gets the Scale information from the binary file, and the graphics is drawn accordingly.. but in VB.net everything is in pixels, there is no userdefined Scale... I need to do the manual calculation of the scale for each and every drawing. With that while considering millions of lines the application becomes darn slow..
I am at the starting phase of conversion.. so can you guys suggest what alternative I might have for VB.net - slick and faster.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I haven't done much of Graphics in C++ or C#... can you suggest some websites that I can look in.
I don't know of any offhand for C++, but http://www.gotdotnet.com and http://www.thecodeproject.com are good resources for C#.
ASKER
Thanks Javert93