public override bool OnTouchEvent(MotionEvent ev) { try { var cropImage = (CropImage)_context; if (cropImage.Saving) { return(false); } switch (ev.Action) { case MotionEventActions.Down: foreach (var hv in _hightlightViews) { var edge = hv.GetHit(ev.GetX(), ev.GetY()); if (edge != HighlightView.HitPosition.None) { _motionEdge = edge; _mMotionHighlightView = hv; _mLastX = ev.GetX(); _mLastY = ev.GetY(); _mMotionHighlightView.Mode = (edge == HighlightView.HitPosition.Move) ? HighlightView.ModifyMode.Move : HighlightView.ModifyMode.Grow; break; } } break; case MotionEventActions.Up: if (_mMotionHighlightView != null) { CenterBasedOnHighlightView(_mMotionHighlightView); _mMotionHighlightView.Mode = HighlightView.ModifyMode.None; } _mMotionHighlightView = null; break; case MotionEventActions.Move: if (_mMotionHighlightView != null) { _mMotionHighlightView.HandleMotion(_motionEdge, ev.GetX() - _mLastX, ev.GetY() - _mLastY); _mLastX = ev.GetX(); _mLastY = ev.GetY(); if (true) { // This section of code is optional. It has some user // benefit in that moving the crop rectangle against // the edge of the screen causes scrolling but it means // that the crop rectangle is no longer fixed under // the user's finger. EnsureVisible(_mMotionHighlightView); } } break; } switch (ev.Action) { case MotionEventActions.Up: Center(true, true); break; case MotionEventActions.Move: // if we're not zoomed then there's no point in even allowing // the user to move the image around. This call to center puts // it back to the normalized location (with false meaning don't // animate). if (Math.Abs(GetScale() - 1F) < double.Epsilon) { Center(true, true); } break; } } catch (Exception) { } return(true); }
public override bool OnTouchEvent(MotionEvent ev) { var cropImage = (CropImage)_context; if (cropImage.Saving) { return(false); } switch (ev.Action) { case MotionEventActions.Down: foreach (var hv in _hightlightViews) { var edge = hv.GetHit(ev.GetX(), ev.GetY()); if (edge != HighlightView.HitPosition.None) { _motionEdge = edge; _mMotionHighlightView = hv; _mLastX = ev.GetX(); _mLastY = ev.GetY(); _mMotionHighlightView.Mode = (edge == HighlightView.HitPosition.Move) ? HighlightView.ModifyMode.Move : HighlightView.ModifyMode.Grow; break; } } break; case MotionEventActions.Up: if (_mMotionHighlightView != null) { CenterBasedOnHighlightView(_mMotionHighlightView); _mMotionHighlightView.Mode = HighlightView.ModifyMode.None; } _mMotionHighlightView = null; break; case MotionEventActions.Move: if (_mMotionHighlightView != null) { _mMotionHighlightView.HandleMotion(_motionEdge, ev.GetX() - _mLastX, ev.GetY() - _mLastY); _mLastX = ev.GetX(); _mLastY = ev.GetY(); if (true) { EnsureVisible(_mMotionHighlightView); } } break; } switch (ev.Action) { case MotionEventActions.Up: Center(true, true); break; case MotionEventActions.Move: if (Math.Abs(GetScale() - 1F) < double.Epsilon) { Center(true, true); } break; } return(true); }
public override bool OnTouchEvent(MotionEvent ev) { CropImage cropImage = (CropImage)context; if (cropImage.Saving) { return false; } switch (ev.Action) { case MotionEventActions.Down: for (int i = 0; i < hightlightViews.Count; i++) { HighlightView hv = hightlightViews[i]; var edge = hv.GetHit(ev.GetX(), ev.GetY()); if (edge != HighlightView.HitPosition.None) { motionEdge = edge; mMotionHighlightView = hv; mLastX = ev.GetX(); mLastY = ev.GetY(); mMotionHighlightView.Mode = (edge == HighlightView.HitPosition.Move) ? HighlightView.ModifyMode.Move : HighlightView.ModifyMode.Grow; break; } } break; case MotionEventActions.Up: if (mMotionHighlightView != null) { centerBasedOnHighlightView(mMotionHighlightView); mMotionHighlightView.Mode = HighlightView.ModifyMode.None; } mMotionHighlightView = null; break; case MotionEventActions.Move: if (mMotionHighlightView != null) { mMotionHighlightView.HandleMotion(motionEdge, ev.GetX() - mLastX, ev.GetY() - mLastY); mLastX = ev.GetX(); mLastY = ev.GetY(); if (true) { // This section of code is optional. It has some user // benefit in that moving the crop rectangle against // the edge of the screen causes scrolling but it means // that the crop rectangle is no longer fixed under // the user's finger. ensureVisible(mMotionHighlightView); } } break; } switch (ev.Action) { case MotionEventActions.Up: Center(true, true); break; case MotionEventActions.Move: // if we're not zoomed then there's no point in even allowing // the user to move the image around. This call to center puts // it back to the normalized location (with false meaning don't // animate). if (GetScale() == 1F) { Center(true, true); } break; } return true; }