(Not logged on) | Register | Log On

You can subscribe to this discussion group using an RSS feed reader. The Joel on Software Discussion Group

A place to discuss Joel on Software

This community works best when people use their real names. Please register for a free account.

Other Groups:
Joel on Software
Business of Software
Design of Software (CLOSED)
.NET Questions (CLOSED)
TechInterview.org
CityDesk
FogBugz
Fog Creek Copilot


The Old Forum


Your hosts:
Albert D. Kallal
Li-Fan Chen
Stephen Jones

repainting mouse-resized sketch in C# sloooow; suggestions?

if I have a sketch with 130 points connected with short lines, it takes 10ms to draw it on a C# control on the Paint event. That's usually fine, but if I want to resize it with the mouse, and the mouse is moving fast, it starts looking ugly (basically, just blank temporarily). Worst comes to worst, I will just get rid of this "in flight repainting of resized sketch" feature. Nevertheless, before I do that - maybe there is some magical, easy to use API that I could use in my app that can do the same sort of painting that C# controls do, only 100 times faster?
Michael L Send private email
Tuesday, November 10, 2009
 
 
oops, never mind, the ugly behavior was just a code bug, too much time wasted on outputting text to log. Turns out that 10ms repaint is in fact fine as far as maintaining the illusion of smooth resizing is concerned, even for fast mouse moves. To make it look truly ugly, I had to increase repaint time to 100ms using sleep().

Nevertheless, the larger question I think still stands. Having a sketch complex enough that would take 50ms and more to paint doesn't seem very far fetched. So probably a better API would still be nice.
Michael L Send private email
Tuesday, November 10, 2009
 
 
Or double buffering.

Or ask on stackoverflow?
Architecture Astronaut Send private email
Wednesday, November 11, 2009
 
 
Do your painting in background thread, and don't repaint on _every_ mouse move, but only if the thread is idle.
Joel Coehoorn Send private email
Wednesday, November 11, 2009
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz