Solved

Alternative to paint event

Posted on 2004-09-04
7
425 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 86

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

615 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