Let's define "stops moving" as "remains within an x
pixel radius for n
ms".
Subscribe to the MouseMove event and use a timer (set to n
ms) to set your timeout. Each time the mouse moves, check against the tolerance. If it's outside your tolerance, reset the timer and record a new origin.
Pseudocode:
Point lastPoint;
const float tolerance = 5.0;
//you might want to replace this with event subscribe/unsubscribe instead
bool listening = false;
void OnMouseOver()
{
lastpoint = Mouse.Location;
timer.Start();
listening = true; //listen to MouseMove events
}
void OnMouseLeave()
{
timer.Stop();
listening = false; //stop listening
}
void OnMouseMove()
{
if(listening)
{
if(Math.abs(Mouse.Location - lastPoint) > tolerance)
{
//mouse moved beyond tolerance - reset timer
timer.Reset();
lastPoint = Mouse.Location;
}
}
}
void timer_Tick(object sender, EventArgs e)
{
//mouse "stopped moving"
}