private void ControlTouch(object sender, TouchEventArgs args) { if (_appEmergency != null) { if (args.Event.Action == MotionEventActions.Down) { _appEmergency.DoStarted(); _startX = args.Event.GetX() / Resources.DisplayMetrics.Density; _startY = args.Event.GetY() / Resources.DisplayMetrics.Density; Console.WriteLine("Start coordinates => {0}, {1}", _startX, _startY); } else if (args.Event.Action == MotionEventActions.Move) { var x = (args.Event.GetX() / Resources.DisplayMetrics.Density); var y = (args.Event.GetY() / Resources.DisplayMetrics.Density); var deltaX = x - _startX; var deltaY = y - _startY; Console.WriteLine("Coordinates => {0}, {1} ---- Delta => {2}, {3}", x, y, deltaX, deltaY); _appEmergency.DoRunning(deltaX, deltaY); } else if (args.Event.Action == MotionEventActions.Up) { _appEmergency.DoCompleted(); _startX = 0; _startY = 0; } } }
public override void TouchesMoved(NSSet touches, UIEvent evt) { base.TouchesMoved(touches, evt); if (_appEmergency != null) { var touch = (touches.AnyObject as UITouch); var location = touch.LocationInView(this); var prevLocation = touch.PreviousLocationInView(this); _appEmergency.DoRunning(location.X - prevLocation.X, location.Y - prevLocation.Y); } }