The goal of the program is to record how fast, how long and the amplitude of mouse wheel rotation. I can record the amplitude in MouseWheel event. but my confusion is that I can record how long/fast?
The way I am doing now is to implement the MouseWheel event in a window. Then in another dispatch timer's handler, I check if mousewheel event does not last for a certain period (say 1s), I record the time. Is this the correct way?
private void Window_MouseWheel(object sender, MouseWheelEventArgs e)
{
scrollVal += (Math.Abs(e.Delta) / limitScrollSpeed);
scroll_stopwatch.Reset(); //this makes small scrolls to be one bigger scroll
scroll_stopwatch.Start();
scrollRecord_stopwatch.Start();
}
private void dispatcherTimer_Tick(object sender, EventArgs e)
{
if (scroll_stopwatch.ElapsedMilliseconds >= clearScrollTimeMS)
{
scroll_stopwatch.Stop();
scroll_stopwatch.Reset();
scrollVal = 0;
scrollRecord_stopwatch.Stop();
scrollDuration = (scrollRecord_stopwatch.ElapsedMilliseconds - 1000) / 1000.0f;
scrollRecord_stopwatch.Reset();
}
}
Use the
MouseWheelEventArgs.Timestamp
property.Your event handler would look something like this:
Only have to use the stopwatch to decide if the scrolling has "stopped."