예제 #1
0
        protected override void OnAttached()
        {
            // Get the Android View 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 touchEffect =
                (TouchTracking.TouchEffect)Element.Effects.
                FirstOrDefault(e => e is TouchTracking.TouchEffect);

            if (touchEffect != null && view != null)
            {
                formsElement = Element;

                libTouchEffect = touchEffect;

                // Save fromPixels function
                fromPixels = view.Context.FromPixels;

                tapDetector = new InternalGestureDetector
                {
                    TapAction = motionEvent =>
                    {
                        libTouchEffect.OnTapAction(formsElement);
                    },
                };

                gestureRecognizer = new GestureDetectorCompat(view.Context, tapDetector);

                // Set event handler on View
                view.Touch += OnTouch;
            }
        }
        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;
            }
        }