Пример #1
0
        private void OnTouch(object sender, View.TouchEventArgs args)
        {
            switch (args.Event.Action)
            {
            case MotionEventActions.Down:
                _tapTime = DateTime.Now;
                _rect    = new Rect(_viewOverlay.Left, _viewOverlay.Top, _viewOverlay.Right, _viewOverlay.Bottom);
                TapAnimation(250, 0, 80);
                break;

            case MotionEventActions.Move:
                _touchEndInside = _rect.Contains(
                    _viewOverlay.Left + (int)args.Event.GetX(),
                    _viewOverlay.Top + (int)args.Event.GetY());
                break;

            case MotionEventActions.Up:
                if (_touchEndInside)
                {
                    if ((DateTime.Now - _tapTime).Milliseconds > 1500)
                    {
                        _viewOverlay.PerformLongClick();
                    }
                    else
                    {
                        _viewOverlay.CallOnClick();
                    }
                }

                goto case MotionEventActions.Cancel;

            case MotionEventActions.Cancel:
                args.Handled = false;
                TapAnimation(250, 80);
                break;
            }
        }