예제 #1
0
        void InitializeNativeRecognizer()
        {
            NativeView = Recognizer.View.GetNativeView();
            //NEED A MECHANISM TO GET TOUCHES FROM A PARENT VIEW OBSCURED BY ANOTHER VIEW
//			if (Recognizer.View is Xamarin.Forms.Layout<Xamarin.Forms.View>) {
//				GroupRecognizers.Add (Recognizer);
//			}
            if (NativeView == null)
            {
                throw new InvalidOperationException("attempted to initialize a native gesture recognizers for a view before it had created it's renderer");
            }
            //check if we already have a multi-cast listener
            Listener = GetMultiCastListener();
            if (Listener == null)
            {
                Listener = new MultiCastOnTouchListener();
//				NativeView.SetOnTouchListener (Listener);
                NativeView.Touch += (sender, e) => {
                    Console.WriteLine("Touch " + e);
                };
                NativeView.GenericMotion += (object sender, View.GenericMotionEventArgs e) => {
                    Console.WriteLine("motion " + e);
                };
            }
            Listener.AddListener(this);
            NativeGestureDetector = CreateGestureDetector();
            IsGestureInitialized  = true;
        }
        void InitializeNativeRecognizer()
        {
            NativeView = Recognizer.View.GetNativeView ();
            //NEED A MECHANISM TO GET TOUCHES FROM A PARENT VIEW OBSCURED BY ANOTHER VIEW
            //			if (Recognizer.View is Xamarin.Forms.Layout<Xamarin.Forms.View>) {
            //				GroupRecognizers.Add (Recognizer);
            //			}
            if (NativeView == null) {
                throw new InvalidOperationException ("attempted to initialize a native gesture recognizers for a view before it had created it's renderer");
            }
            //check if we already have a multi-cast listener
            Listener = GetMultiCastListener ();
            if (Listener == null) {
                Listener = new MultiCastOnTouchListener ();
            //				NativeView.SetOnTouchListener (Listener);
                NativeView.Touch += (sender, e) => {
                    Console.WriteLine ("Touch " + e);

                };
                NativeView.GenericMotion += (object sender, View.GenericMotionEventArgs e) => {
                    Console.WriteLine ("motion " + e);
                };
            }
            Listener.AddListener (this);
            NativeGestureDetector = CreateGestureDetector ();
            IsGestureInitialized = true;
        }