Ejemplo n.º 1
0
        private void CheckForBoundaryHop(UITouch touch)
        {
            var id = touch.Handle.ToInt64();

            // TODO: Might require converting to a List for multiple hits
            TouchRecognizer recognizerHit = null;

            foreach (UIView view in _viewDictionary.Keys)
            {
                CGPoint location = touch.LocationInView(view);

                if (new CGRect(new CGPoint(), view.Frame.Size).Contains(location))
                {
                    recognizerHit = _viewDictionary[view];
                }
            }

            if (recognizerHit != _idToTouchDictionary[id])
            {
                if (_idToTouchDictionary[id] != null)
                {
                    FireEvent(_idToTouchDictionary[id], id, TouchActionType.Exited, touch, true);
                }
                if (recognizerHit != null)
                {
                    FireEvent(recognizerHit, id, TouchActionType.Entered, touch, true);
                }

                _idToTouchDictionary[id] = recognizerHit;
            }
        }
Ejemplo n.º 2
0
        private void FireEvent(TouchRecognizer recognizer, long id, TouchActionType actionType, UITouch touch, bool isInContact)
        {
            // Convert touch location to Xamarin.Forms Point value
            CGPoint cgPoint = touch.LocationInView(recognizer.View);
            Point   xfPoint = new Point(cgPoint.X, cgPoint.Y);

            // Get the method to call for firing events
            Action <Element, TouchActionEventArgs> onTouchAction = recognizer._touchEffect.OnTouchAction;

            // Call that method
            onTouchAction(recognizer._element,
                          new TouchActionEventArgs(id, actionType, xfPoint, isInContact));
        }