Solved

Alternative to paint event

Posted on 2004-09-04
7
415 Views
Last Modified: 2010-05-18
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.  
0
Comment
Question by:prince_wow
  • 3
  • 3
7 Comments
 
LVL 4

Expert Comment

by:Javert93
ID: 12008543
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.
0
 
LVL 85

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 63 total points
ID: 12008764
If you are calculating your lines based on some parameters, then do the calculations once, and store them in a GraphicsPath instance.  Then, if your parameters haven't changed, you can simply redraw the GraphicsPath when the Paint event fires which should be faster than calculating them again.  If your parameters have changed, then you can recalculate the new lines and store them in a new GraphicsPath.

The tradeoff here is memory for speed.  Storing "millions" of lines in a GraphicsPath may not be feasible.

Regards,

Idle_Mind
0
 

Author Comment

by:prince_wow
ID: 12023497
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.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 4

Accepted Solution

by:
Javert93 earned 62 total points
ID: 12023559
You could use C++ managed extensions. You get the flexability of native C++ with the added benefit of being able to use the framework classes where and when you actually want them. C# is a close second, but only because it allows unmanged code blocks.
0
 

Author Comment

by:prince_wow
ID: 12023835
I haven't done much of Graphics in C++ or C#... can you suggest some websites that I can look in.
0
 
LVL 4

Expert Comment

by:Javert93
ID: 12028617
I don't know of any offhand for C++, but http://www.gotdotnet.com and http://www.thecodeproject.com are good resources for C#.
0
 

Author Comment

by:prince_wow
ID: 12036761
Thanks Javert93
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now