By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,601 Members | 989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,601 IT Pros & Developers. It's quick & easy.

How to speed up a program that uses mouse points a lot?

P: n/a
I'm wondering, since my program uses a lot of mouse points when the
mouse is moving, but for resolution purposes doesn't really need to
collect so many mouse points, is it conventional to use a timer so
that mouse points are only collected every 100 or 500 ms--i.e. when
the timer fires-- rather than every 10ms (or whatever the default is
when the mouse is moving)?

It seems my program is bogging down with so many mouse points being
collected (though truth is, I have slow hardware).

Any thoughts appreciated.

RL
Nov 20 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"raylopez99" <ra********@yahoo.comwrote in message
news:e8**********************************@v42g2000 yqv.googlegroups.com...
I'm wondering, since my program uses a lot of mouse points when the
mouse is moving, but for resolution purposes doesn't really need to
collect so many mouse points, is it conventional to use a timer so
that mouse points are only collected every 100 or 500 ms--i.e. when
the timer fires-- rather than every 10ms (or whatever the default is
when the mouse is moving)?

It seems my program is bogging down with so many mouse points being
collected (though truth is, I have slow hardware).

Any thoughts appreciated.

RL

Are you doing somthing allong these lines and finding it slow?

List<PointPoints = new List<Point>();
void Form1_MouseMove(object sender, MouseEventArgs e)
{
Points.Add(e.Location);
}
Nov 21 '08 #2

P: n/a
"RayLopez99" <ra********@gmail.comwrote in message
news:13**********************************@w22g2000 yqd.googlegroups.com...
Thanks FTM.
well this confirmed that standard practice for most conventional apps
is not to put a timer to limit the number of points collected by the
mouse. So it must be the extra logic I'm doing (which is
considerable). The lag is not too bad now, but if it gets worse I
might limit the number of points collected with a timer.

RL

If the time lag gets too bad, I don't think I would resort to a timer. I
would fall back to the logic used in geographic information systems (GIS)
for thinning complex line segments. One option would be to keep ever N-th
point. Another option is to keep points "significantly different" from the
last point. That would entail looking at the deltas between the last kept
X, Y to the new X, Y. The first option is more likely quicker, while the
second is likely more visually accurate.

Mike

Nov 21 '08 #3

P: n/a
On Nov 21, 1:35*pm, "Family Tree Mike"
<FamilyTreeM...@ThisOldHouse.comwrote:
"RayLopez99" <raylope...@gmail.comwrote in message

news:13**********************************@w22g2000 yqd.googlegroups.com...
Thanks FTM.
well this confirmed that standard practice for most conventional apps
is not to put a timer to limit the number of points collected by the
mouse. So it must be the extra logic I'm doing (which is
considerable). *The lag is not too bad now, but if it gets worse I
might limit the number of points collected with a timer.
RL

If the time lag gets too bad, I don't think I would resort to a timer. *I
would fall back to the logic used in geographic information systems (GIS)
for thinning complex line segments. *One option would be to keep ever N-th
point. *Another option is to keep points "significantly different" fromthe
last point. *That would entail looking at the deltas between the last kept
X, Y to the new X, Y. *The first option is more likely quicker, while the
second is likely more visually accurate.

Mike
Yeah thanks. I like that first option, just do a modulus %N operation
and take every Nth point. I'll keep that in mind. The delta's idea
is good too.

RL
Nov 21 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.