bool IsViewInBounds(Android.Views.View v, int x, int y)
 {
     v.GetDrawingRect(_rect);
     v.GetLocationOnScreen(_location);
     _rect.Offset(_location[0], _location[1]);
     return(_rect.Contains(x, y));
 }
Ejemplo n.º 2
0
 private bool IsViewInBounds(int x, int y)
 {
     View.GetDrawingRect(_rect);
     View.GetLocationOnScreen(_location);
     _rect.Offset(_location[0], _location[1]);
     return(_rect.Contains(x, y));
 }
Ejemplo n.º 3
0
        private int GetCharacterIndexAtPoint(Point point)
        {
            point.X -= LogicalToPhysicalPixels(Padding.Left);
            point.Y -= LogicalToPhysicalPixels(Padding.Top);
            var layout = _arrangeLayout.Layout;
            var rect   = new Android.Graphics.Rect(0, 0, layout.Width, layout.Height);

            if (rect.Contains((int)point.X, (int)point.Y))
            {
                int line   = layout.GetLineForVertical((int)point.Y);
                int offset = layout.GetOffsetForHorizontal(line, (int)point.X);

                return(offset);
            }

            return(-1);
        }
Ejemplo n.º 4
0
        void _contentView_Touch(object sender, View.TouchEventArgs e)
        {
            if (e.Event.Action != MotionEventActions.Down || !_dlgView.IsCanceledOnTouchOutside)
            {
                e.Handled = false;
                return;
            }

            Android.Graphics.Rect rect = new Android.Graphics.Rect();
            _renderer.View.GetHitRect(rect);

            if (!rect.Contains((int)e.Event.GetX(), (int)e.Event.GetY()))
            {
                _dlgView.DialogNotifierInternal.Cancel();
                return;
            }

            e.Handled = false;
        }
Ejemplo n.º 5
0
        private void OnTouch(object sender, View.TouchEventArgs args)
        {
            switch (args.Event.Action)
            {
            case MotionEventActions.Down:
                _tapTime = DateTime.Now;
                _rect    = new Android.Graphics.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;
            }
        }