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

R

raylopez99

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
 
F

Family Tree Mike

raylopez99 said:
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<Point> Points = new List<Point>();
void Form1_MouseMove(object sender, MouseEventArgs e)
{
Points.Add(e.Location);
}
 
R

RayLopez99

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

  List<Point> Points = new List<Point>();
  void Form1_MouseMove(object sender, MouseEventArgs e)
  {
   Points.Add(e.Location);
  }

YES! FTM you are a mind reader!!

Now what? (I'll wait for the other shoe to drop later).

RL
 
F

Family Tree Mike

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

List<Point> Points = new List<Point>();
void Form1_MouseMove(object sender, MouseEventArgs e)
{
Points.Add(e.Location);
}

YES! FTM you are a mind reader!!

Now what? (I'll wait for the other shoe to drop later).

RL[/QUOTE]


Here is my complete form code which just has a label on it that is updated
with the list count. I am not seeing any slow down. Maybe it is your
computer...

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
MouseMove += new MouseEventHandler(Form1_MouseMove);
}

List<Point> Points = new List<Point>();
void Form1_MouseMove(object sender, MouseEventArgs e)
{
Points.Add(e.Location);
label1.Text = string.Format("Current list size: {0}", Points.Count());
}
}
 
R

RayLopez99

On Nov 20, 5:37 pm, "Family Tree Mike"







Here is my complete form code which just has a label on it that is updated
with the list count.  I am not seeing any slow down.  Maybe it is your
computer...

 public partial class Form1 : Form
 {
  public Form1()
  {
   InitializeComponent();
   MouseMove += new MouseEventHandler(Form1_MouseMove);
  }

  List<Point> Points = new List<Point>();
  void Form1_MouseMove(object sender, MouseEventArgs e)
  {
   Points.Add(e.Location);
   label1.Text = string.Format("Current list size: {0}", Points.Count());
  }
 }

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
 
F

Family Tree Mike

RayLopez99 said:
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
 
R

RayLopez99

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top