Background:
private System.Windows.Controls.Border _borderTouch;
private bool _mouseDown = false;
Private system. Windows. Point _ currentpoint = new system. Windows. Point (0, 0 );
Private system. Windows. Point _ lastpoint = new system. Windows. Point (0, 0 );
A WPF border control and registers mouse events.
touch.MouseLeftButtonDown += new MouseButtonEventHandler(touch_MouseLeftButtonDown); touch.MouseLeftButtonUp += new MouseButtonEventHandler(touch_MouseLeftButtonUp); touch.MouseLeave += new MouseEventHandler(touch_MouseLeave); touch.MouseMove += new MouseEventHandler(touch_MouseMove);
private void touch_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { //if (this._mouseDown) //{ this._mouseDown = false; //} } private void touch_MouseLeave(object sender, MouseEventArgs e) { //if (this._mouseDown) //{ this._mouseDown = false; //} } private void touch_MouseMove(object sender, MouseEventArgs e) { if (this._mouseDown) { _currentPoint = e.GetPosition(this._borderTouch); //if (_currentPoint == _lastPoint) return; //_lastPoint = _currentPoint; } } private void touch_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (!this._mouseDown) { this._mouseDown = true; _currentPoint = e.GetPosition(this._borderTouch); //_lastPoint = _currentPoint; } }Procedure:
1. Click the left mouse button to trigger touch_mouseleftbuttondown once,
2. Move the mouse to trigger touch_mousemove (Note: if the mouse does not move at a certain point, the same coordinates will only be triggered once, and the event will not be triggered again, if you move the mouse again ),
3. Trigger touch_mouseleave (touch_mouseleftbuttonup) once when the mouse leaves (or the left button is released.
Problem:
1. correspond to the above operations on my computer, including the number of triggering events.
My Computer Configuration:
2. But it is different on the second computer,
When the mouse does not move in 2nd processes, it will trigger more than 10 times and then it will not be triggered (that is, the same coordinates will trigger more than 10 touch_mousemove and then no longer trigger)
3rd processes are also triggered more than 10 times, and then the trigger is stopped.
Second Computer Configuration:
Solution:
What I want is, of course, the normal operation process on my computer, to synchronize to another computer.
I changed the code, but I don't know why there is such a difference.
1. Add touch_mousemove to determine whether the last coordinate is the same as the current coordinate. If it is the same, return
if (_currentPoint == _lastPoint) return; _lastPoint = _currentPoint;
2. touch_mouseleftbuttonup/touch_mouseleave add judgment
if (this._mouseDown) { this._mouseDown = false; }