Ejemplo n.º 1
0
        void CheckForBoundaryHop(UITouch touch)
        {
            long 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;
            }
        }
        protected override void OnAttached()
        {
            // Get the iOS UIView corresponding to the Element that the effect is attached to
            view = Control == null ? Container : Control;

            // Get access to the TouchEffect class in the .NET Standard library
            TouchTracking.TouchEffect effect = (TouchTracking.TouchEffect)Element.Effects.FirstOrDefault(
                e => e is TouchTracking.TouchEffect);

            if (effect != null && view != null)
            {
                // Create a TouchRecognizer for this UIView
                touchRecognizer = new TouchRecognizer(Element, view, effect)
                {
                    ShouldRecognizeSimultaneously = (recognizer, gestureRecognizer) => true,
                };
                view.AddGestureRecognizer(touchRecognizer);
                touchRecognizer.Enabled = true;

                tapDetector = new UITapGestureRecognizer(() =>
                {
                    effect.OnTapAction(Element);
                })
                {
                    ShouldRecognizeSimultaneously = (recognizer, gestureRecognizer) => true,
                };
                view.AddGestureRecognizer(tapDetector);
                tapDetector.Enabled = true;
            }
        }
Ejemplo n.º 3
0
 public override void RegisterEvents(UIView view)
 {
     if (view != null)
     {
         _touchRecognizer = new TouchRecognizer(view, this);
         view.AddGestureRecognizer(_touchRecognizer);
     }
 }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
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);
            TouchTrackingPoint xfPoint = new TouchTrackingPoint((float)cgPoint.X, (float)cgPoint.Y);

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

            // Call that method
            onTouchAction(recognizer._view,
                          new TouchActionEventArgs(id, actionType, xfPoint, isInContact));
        }
Ejemplo n.º 6
0
        protected override void OnAttached()
        {
            // Get the iOS UIView corresponding to the Element that the effect is attached to
            view = Control == null ? Container : Control;

            // Get access to the TouchEffect class in the .NET Standard library
            TouchTracking.TouchEffect effect = (TouchTracking.TouchEffect)Element.Effects.FirstOrDefault(e => e is TouchTracking.TouchEffect);

            if (effect != null && view != null)
            {
                // Create a TouchRecognizer for this UIView
                touchRecognizer = new TouchRecognizer(Element, view, effect);
                view.AddGestureRecognizer(touchRecognizer);
            }
        }