public Boolean OnFling(MotionEvent?e1, MotionEvent?e2, Single velocityX, Single velocityY) { //System.Diagnostics.Debug.WriteLine("[OKYN] ANDROID REPORTS FLING vx: " + velocityX + // " vy: " + velocityY); if (e1 == null) { return(false); } var pos = GetPosition(e1); var vx = velocityX * 0.5; var vy = 0 - velocityY * 0.5; if (Math.Abs(vx) >= MinimumFlingVelocity || Math.Abs(vy) >= MinimumFlingVelocity) { var flingArgs = new FlingEventArgs(vx * _dpiRatio, vy * _dpiRatio, pos, this, RemoveFlingInteraction); AddInteraction(InputAction.Fling); if (!_inputHandler.OnMouseInput(flingArgs, InputAction.Fling)) { flingArgs.SetHandled(false); //RemoveInteraction(InputAction.Fling); } } return(true); }
public Boolean OnInput(FlingEventArgs args) { if (!IsScrollWithMouseDrag) { return(false); } var working = _flingHandler.OnInput(args); if (working) { args.InputContext.TryCaptureMouseInput(this); } return(working); }
public virtual bool OnFling(FlingEventArgs e) { if (this.FlingGesture != null) { this.FlingGesture(this, e); } return e.Handled; }
public Boolean PreFilterMessage(ref Message m) { ValuePoint2D pos; switch ((MessageTypes)m.Msg) { case MessageTypes.WM_LBUTTONDOWN: pos = GetPosition(m); //if (m.HWnd != _window.Handle) //{ // var surrogate = _window.Controls.FindControl(m.HWnd); // if (surrogate == null) // return false; //} _leftButtonWentDown = pos; //System.Diagnostics.Debug.WriteLine("on l button down"); _inputHandler.OnMouseInput( new MouseDownEventArgs(pos, MouseButtons.Left, this), InputAction.LeftMouseButtonDown); break; case MessageTypes.WM_RBUTTONDOWN: pos = GetPosition(m); _rightButtonWentDown = pos; _inputHandler.OnMouseInput( new MouseDownEventArgs(pos, MouseButtons.Right, this), InputAction.RightMouseButtonDown); break; case MessageTypes.WM_RBUTTONUP: _inputHandler.OnMouseInput( new MouseUpEventArgs(GetPosition(m), _rightButtonWentDown, MouseButtons.Right, this, true), InputAction.RightMouseButtonUp); _rightButtonWentDown = default; _lastDragPosition = default; break; case MessageTypes.WM_MOUSEWHEEL: var args = new MouseWheelEventArgs(CursorPosition, (Int64)m.WParam >= Int32.MaxValue ? 1 : -1, this); _inputHandler.OnMouseInput(args, InputAction.MouseWheel); break; case MessageTypes.WM_LBUTTONUP: pos = GetPosition(m); var dt = _lastDragTimestamp - _nextToLastDragTimestamp; FlingEventArgs?flingArgs = null; if (_lastDragPosition != null && _nextToLastDragPosition != null && dt > 0) { var ddt = dt / 100000.0; var vx = (_lastDragPosition.Value.X - _nextToLastDragPosition.Value.X) / ddt; var vy = (_nextToLastDragPosition.Value.Y - _lastDragPosition.Value.Y) / ddt; if (vx.IsNotZero() || vy.IsNotZero()) { vx *= 50; vy *= 50; if (Math.Abs(vx) >= MinimumFlingVelocity || Math.Abs(vy) >= MinimumFlingVelocity) { flingArgs = new FlingEventArgs(vx, vy, pos, this, null); } } } var lBtnArgs = new MouseUpEventArgs(pos, _leftButtonWentDown, MouseButtons.Left, this, true); _leftButtonWentDown = default; _lastDragPosition = default; _nextToLastDragPosition = default; _nextToLastDragTimestamp = 0; _lastDragTimestamp = 0; //System.Diagnostics.Debug.WriteLine("on l button up"); _inputHandler.OnMouseInput(lBtnArgs, InputAction.LeftMouseButtonUp); if (flingArgs != null) { _inputHandler.OnMouseInput(flingArgs.Value, InputAction.Fling); } break; case MessageTypes.WM_MOUSEMOVE: pos = GetPosition(m.LParam); //shouldn't be needed but stops debugging headaches for now //if (_leftButtonWentDown != null && // !IsButtonPressed(MouseButtons.Left)) // _leftButtonWentDown = default; //if (_rightButtonWentDown != null && // !IsButtonPressed(MouseButtons.Right)) _rightButtonWentDown = default; var letsUse = _leftButtonWentDown ?? _rightButtonWentDown; if (letsUse == null) { _inputHandler.OnMouseMove(pos, this); break; } ValueSize lastDragChange; if (_lastDragPosition == null) { lastDragChange = new ValueSize(pos.X - letsUse.Value.X, pos.Y - letsUse.Value.Y); } else { lastDragChange = new ValueSize(pos.X - _lastDragPosition.Value.X, pos.Y - _lastDragPosition.Value.Y); } if (lastDragChange.IsEmpty) { break; } _nextToLastDragPosition = _lastDragPosition; _lastDragPosition = pos; _nextToLastDragTimestamp = _lastDragTimestamp; _lastDragTimestamp = DateTime.Now.Ticks; //if (_nextToLastDragPosition != null) //{ // Debug.WriteLine("last drag: " + _lastDragPosition + " t: " + _lastDragTimestamp + // " 2nd: " + _nextToLastDragPosition + " t: " + _nextToLastDragTimestamp); //} var dragArgs = new DragEventArgs(letsUse, pos, lastDragChange, _leftButtonWentDown != null ? MouseButtons.Left : MouseButtons.Right, this); //Debug.WriteLine("Sending drag event: " + dragArgs.LastChange.Height); _inputHandler.OnMouseInput(dragArgs, InputAction.MouseDrag); break; case MessageTypes.WM_QUERYDRAGICON: break; case MessageTypes.WM_MOUSEHWHEEL: throw new NotImplementedException(); } return(false); }