private void OnTouchEvent(TouchActivityEvent ev) { for (int i = 0; i < ev.Pointers.Count; ++i) { TouchActivityEvent.PointerInfo pointer = ev.Pointers[i]; switch (ev.Action) { case MotionEventActions.Down: case MotionEventActions.PointerDown: { TouchDown?.Invoke(this, pointer.X, pointer.Y, pointer.Id); break; } case MotionEventActions.Up: case MotionEventActions.PointerUp: { TouchUp?.Invoke(this, pointer.X, pointer.Y, pointer.Id); break; } case MotionEventActions.Move: { TouchMove?.Invoke(this, pointer.X, pointer.Y, pointer.Id); break; } } } }
internal void OnTouchMove(TouchEventArgs args) { if (HandleTouchDownEnter) { TouchState = TouchStates.Touched; ChangeVisualState(); } TouchMove?.Invoke(this, args); }
public override void TouchesMoved(NSSet touches, UIEvent?evt) { base.TouchesMoved(touches, evt); var viewPoints = this.GetPointsInView(evt); PointF viewPoint = viewPoints.Length > 0 ? viewPoints[0] : PointF.Zero; var point = new Point(viewPoint.X, viewPoint.Y); TouchMove?.Invoke(this, new TouchEventArgs(point)); }
internal void Internal_OnTouchMove(ref Vector2 pointerPosition, int pointerId) { Vector2 pos = pointerPosition / _dpiScale; bool handled = false; TouchMove?.Invoke(ref pos, pointerId, ref handled); if (handled) { return; } GUI.OnTouchMove(pos, pointerId); }
private void Update() { bool touchInProgress = currentTouchPhase == TouchPhase.Moved || currentTouchPhase == TouchPhase.Stationary; touchPosition = Input.mousePosition; if (touchInProgress || boundRect.Contains(touchPosition.Value)) { if (Input.GetMouseButtonDown(0)) { currentTouchPhase = TouchPhase.Began; TouchStart?.Invoke(currentTouchPhase, touchPosition.Value); } if (Input.GetMouseButton(0)) { if (!lastTouchPosition.HasValue) { lastTouchPosition = touchPosition.Value; } TouchDelta = (touchPosition.Value - lastTouchPosition.Value) / scaleFactor; lastTouchPosition = touchPosition.Value; if (TouchDelta.magnitude > 0) { currentTouchPhase = TouchPhase.Moved; TouchMove?.Invoke(currentTouchPhase, TouchDelta); } else { currentTouchPhase = TouchPhase.Stationary; TouchStationary?.Invoke(currentTouchPhase, touchPosition.Value); } } if (Input.GetMouseButtonUp(0)) { lastTouchPosition = null; currentTouchPhase = TouchPhase.Ended; TouchEnd?.Invoke(currentTouchPhase, touchPosition.Value); } } }
private void FireTouchEvent(Touch i_touch, Vector2 i_startPos = default) { switch (i_touch.phase) { case TouchPhase.Began: TouchStart?.Invoke(i_touch, i_touch.position); break; case TouchPhase.Moved: TouchMove?.Invoke(i_touch, i_touch.position, i_touch.position - i_startPos); break; case TouchPhase.Ended: TouchEnd?.Invoke(i_touch); startPosByTouch.Remove(i_touch); allTouches.Remove(i_touch); break; } }
public virtual void OnTouchMove(Point point) { TouchMove?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Called, when mouse/finger/pen moves over map /// </summary> /// <param name="touchPoints">List of all touched points</param> private bool OnTouchMove(List <Geometries.Point> touchPoints) { var args = new TouchedEventArgs(touchPoints); TouchMove?.Invoke(this, args); if (args.Handled) { return(true); } switch (_mode) { case TouchMode.Dragging: { if (touchPoints.Count != 1) { return(false); } var touchPosition = touchPoints.First(); if (!Map.PanLock && _previousCenter != null && !_previousCenter.IsEmpty()) { _viewport.Transform(touchPosition, _previousCenter); RefreshGraphics(); } _previousCenter = touchPosition; } break; case TouchMode.Zooming: { if (touchPoints.Count != 2) { return(false); } var(prevCenter, prevRadius, prevAngle) = (_previousCenter, _previousRadius, _previousAngle); var(center, radius, angle) = GetPinchValues(touchPoints); double rotationDelta = 0; if (!Map.RotationLock) { _innerRotation += angle - prevAngle; _innerRotation %= 360; if (_innerRotation > 180) { _innerRotation -= 360; } else if (_innerRotation < -180) { _innerRotation += 360; } if (Viewport.Rotation == 0 && Math.Abs(_innerRotation) >= Math.Abs(UnSnapRotationDegrees)) { rotationDelta = _innerRotation; } else if (Viewport.Rotation != 0) { if (Math.Abs(_innerRotation) <= Math.Abs(ReSnapRotationDegrees)) { rotationDelta = -Viewport.Rotation; } else { rotationDelta = _innerRotation - Viewport.Rotation; } } } _viewport.Transform(center, prevCenter, Map.ZoomLock ? 1 : radius / prevRadius, rotationDelta); (_previousCenter, _previousRadius, _previousAngle) = (center, radius, angle); RefreshGraphics(); } break; } return(true); }
private void OnTouchMove(float x, float y, ulong id) { TouchMove?.Invoke(this, (int)(x * _width), (int)(y * _height), id); }
private void ProcessTouches(SensorDataEventArgs eventArgs) { List <EchoPoint> currPts = new List <EchoPoint>(); // first: calculate the new points for (int i = 0; i < eventArgs.Peaks.Length; i++) { double distance = GetDistance(eventArgs.Peaks[i]); double pressure = eventArgs.Amplitudes[i] / 1000.0; pressure = Math.Min(Math.Max(0.0, pressure), 1.0); EchoPoint echoPt = new EchoPoint(i, distance, pressure, eventArgs.Peaks[i], eventArgs.Amplitudes[i]); currPts.Add(echoPt); } // match the points if (m_prevPoints.Count == 0) { // we did not have previous points if (currPts.Count != 0) { // match those points to new points for (int i = 0; i < currPts.Count; i++) { m_prevPoints.Add(currPts[i]); TouchDown?.Invoke(this, new EchoPointEventArgs(currPts[i])); } } else { // nothing to do here } } else if (m_prevPoints.Count == 1) { // there was one previous point if (currPts.Count == 0) { // the point disappeared TouchUp?.Invoke(this, new EchoPointEventArgs(m_prevPoints[0])); m_prevPoints.RemoveAt(0); } else if (currPts.Count == 1) { // this is the same point (double-check distance) m_prevPoints[0].Update(currPts[0]); TouchMove?.Invoke(this, new EchoPointEventArgs(m_prevPoints[0])); } else if (currPts.Count == 2) { // we added a point // find out which one was the original double distance1 = Math.Abs(currPts[0].Distance - m_prevPoints[0].Distance); double distance2 = Math.Abs(currPts[1].Distance - m_prevPoints[0].Distance); int correctId = m_prevPoints[0].Id == 0 ? 1 : 0; if (distance1 > distance2) { // the first point is new currPts[0].Id = correctId; m_prevPoints[0].Update(currPts[1]); TouchMove?.Invoke(this, new EchoPointEventArgs(m_prevPoints[0])); m_prevPoints.Add(currPts[0]); TouchDown?.Invoke(this, new EchoPointEventArgs(currPts[0])); } else { // the other one is new currPts[1].Id = correctId; m_prevPoints[0].Update(currPts[0]); TouchMove?.Invoke(this, new EchoPointEventArgs(m_prevPoints[0])); m_prevPoints.Add(currPts[1]); TouchDown?.Invoke(this, new EchoPointEventArgs(currPts[1])); } } } else if (m_prevPoints.Count == 2) { // there were two previous points if (currPts.Count == 0) { // the points disappeared TouchUp?.Invoke(this, new EchoPointEventArgs(m_prevPoints[0])); TouchUp?.Invoke(this, new EchoPointEventArgs(m_prevPoints[1])); m_prevPoints.Clear(); } else if (currPts.Count == 1) { // we removed only one point // find out which one double distance1 = Math.Abs(currPts[0].Distance - m_prevPoints[0].Distance); double distance2 = Math.Abs(currPts[0].Distance - m_prevPoints[1].Distance); if (distance1 > distance2) { // the first previous is gone m_prevPoints[1].Update(currPts[0]); TouchMove?.Invoke(this, new EchoPointEventArgs(m_prevPoints[1])); TouchUp?.Invoke(this, new EchoPointEventArgs(m_prevPoints[0])); m_prevPoints.RemoveAt(0); } else { // the second previous is gone m_prevPoints[0].Update(currPts[0]); TouchMove?.Invoke(this, new EchoPointEventArgs(m_prevPoints[0])); TouchUp?.Invoke(this, new EchoPointEventArgs(m_prevPoints[1])); m_prevPoints.RemoveAt(1); } } else { // both are still here -> update them bool prevFlipped = m_prevPoints[0].Distance > m_prevPoints[1].Distance; bool currFlipped = currPts[0].Distance > currPts[1].Distance; if ((!prevFlipped && !currFlipped) || (prevFlipped && currFlipped)) { m_prevPoints[0].Update(currPts[0]); m_prevPoints[1].Update(currPts[1]); TouchMove?.Invoke(this, new EchoPointEventArgs(m_prevPoints[0])); TouchMove?.Invoke(this, new EchoPointEventArgs(m_prevPoints[1])); } else if ((!prevFlipped && currFlipped) || (prevFlipped && !currFlipped)) { m_prevPoints[0].Update(currPts[1]); m_prevPoints[1].Update(currPts[0]); TouchMove?.Invoke(this, new EchoPointEventArgs(m_prevPoints[0])); TouchMove?.Invoke(this, new EchoPointEventArgs(m_prevPoints[1])); } } } }
public virtual void OnTouchMove(TouchEventArgs ev) { TouchMove?.Invoke(this, ev); }
internal void OnTouchMove(Model model, TouchEventArgs e) => TouchMove?.Invoke(model, e);
public void OnTouchMove(int x, int y, ulong id) { TouchMove?.Invoke(this, x, y, id); }
/// <summary> /// Called, when mouse/finger/pen moves over map /// </summary> /// <param name="touchPoints">List of all touched points</param> private bool OnTouchMove(List <Geometries.Point> touchPoints) { var args = new TouchedEventArgs(touchPoints); TouchMove?.Invoke(this, args); if (args.Handled) { return(true); } switch (_mode) { case TouchMode.Dragging: { if (touchPoints.Count != 1) { return(false); } var touchPosition = touchPoints.First(); if (_previousCenter != null && !_previousCenter.IsEmpty()) { _map.Viewport.Transform(touchPosition.X, touchPosition.Y, _previousCenter.X, _previousCenter.Y); ViewportLimiter.LimitExtent(_map.Viewport, _map.PanMode, _map.PanLimits, _map.Envelope); InvalidateCanvas(); } _previousCenter = touchPosition; } break; case TouchMode.Zooming: { if (touchPoints.Count < 2) { return(false); } var(prevCenter, prevRadius, prevAngle) = (_previousCenter, _previousRadius, _previousAngle); var(center, radius, angle) = GetPinchValues(touchPoints); double rotationDelta = 0; if (RotationLock) { _innerRotation += angle - prevAngle; _innerRotation %= 360; if (_innerRotation > 180) { _innerRotation -= 360; } else if (_innerRotation < -180) { _innerRotation += 360; } if (_map.Viewport.Rotation == 0 && Math.Abs(_innerRotation) >= Math.Abs(UnSnapRotationDegrees)) { rotationDelta = _innerRotation; } else if (_map.Viewport.Rotation != 0) { if (Math.Abs(_innerRotation) <= Math.Abs(ReSnapRotationDegrees)) { rotationDelta = -_map.Viewport.Rotation; } else { rotationDelta = _innerRotation - _map.Viewport.Rotation; } } } _map.Viewport.Transform(center.X, center.Y, prevCenter.X, prevCenter.Y, radius / prevRadius, rotationDelta); (_previousCenter, _previousRadius, _previousAngle) = (center, radius, angle); ViewportLimiter.Limit(_map.Viewport, _map.ZoomMode, _map.ZoomLimits, _map.Resolutions, _map.PanMode, _map.PanLimits, _map.Envelope); InvalidateCanvas(); } break; } return(true); }
public virtual void OnTouchMove() => TouchMove?.Invoke(this, EventArgs.Empty);