Esempio n. 1
0
        void AddSomeGesturesUsingCode()
        {
            //2 options:
            //1. use the standard xamarin api. e.g. view.GestureRecgonizers.Add(yourgesturerecognizer)
            //    and then call view.ProcessGestures();
            //    this has the benefit that when Xamarin add an api hook we can remove the view.ProcessGestures call and
            //    it will all be good.
            //2. use the extension method view.AddGestureRecognizer(yourgesturerecognizer)
            //    this is easier to use; and does everything under the hood; but it's a bit more obtrusive.
            //   in all cases, until Xamarin do more to open up the api, you must use the view extension method
            //   removeGestureRecognizer
            // comment on https://bugzilla.xamarin.com/show_bug.cgi?id=30467 to get Xamarin to expand
            // IGestureRecognizer with some add/remove hooks
            var tapRecognizer = new TwinTechs.Gestures.TapGestureRecognizer();

            tapRecognizer.OnAction += OnAction;
            Box2.AddGestureRecognizer(tapRecognizer);

            var tapRecognizerWith2Tocuhes = new TwinTechs.Gestures.TapGestureRecognizer();

            tapRecognizerWith2Tocuhes.OnAction += OnAction;
            tapRecognizerWith2Tocuhes.NumberOfTouchesRequired = 2;
            Label2.GestureRecognizers.Add(tapRecognizerWith2Tocuhes);
            Label2.ProcessGestureRecognizers();
        }
        void AddSomeGesturesUsingCode()
        {
            //2 options:
            //1. use the standard xamarin api. e.g. view.GestureRecgonizers.Add(yourgesturerecognizer)
            //    and then call view.ProcessGestures();
            //    this has the benefit that when Xamarin add an api hook we can remove the view.ProcessGestures call and
            //    it will all be good.
            //2. use the extension method view.AddGestureRecognizer(yourgesturerecognizer)
            //    this is easier to use; and does everything under the hood; but it's a bit more obtrusive.
            //   in all cases, until Xamarin do more to open up the api, you must use the view extension method
            //   removeGestureRecognizer
            // comment on https://bugzilla.xamarin.com/show_bug.cgi?id=30467 to get Xamarin to expand
            // IGestureRecognizer with some add/remove hooks
            var swipeRecognizer = new SwipeGestureRecognizer ();
            swipeRecognizer.OnAction += OnAction;
            swipeRecognizer.Direction = SwipeGestureRecognizerDirection.Left;
            Box2.AddGestureRecognizer (swipeRecognizer);

            var swipeRecognizerWith2Tocuhes = new TwinTechs.Gestures.TapGestureRecognizer ();
            swipeRecognizerWith2Tocuhes.OnAction += OnAction;
            swipeRecognizer.Direction = SwipeGestureRecognizerDirection.Right;
            swipeRecognizerWith2Tocuhes.NumberOfTouchesRequired = 2;
            Label2.GestureRecognizers.Add (swipeRecognizerWith2Tocuhes);
            Label2.ProcessGestureRecognizers ();
        }