Esempio n. 1
0
        public override void TouchesCancelled(NSSet touches, UIEvent evt)
        {
            base.TouchesCancelled(touches, evt);
            var touch = touches.AnyObject as UITouch;

            if (_view != null && touch != null)
            {
                _view.RaiseTapEnded((DateTime.Now - this._timeCalc).TotalMilliseconds);
            }
        }
        void HandleTouch(object sender, TouchEventArgs e)
        {
            RoundedBoxView view = this.Element as RoundedBoxView;

            if (view != null)
            {
                if (view.IsInteractable == false)
                {
                    e.Handled = false;
                }
                else
                {
                    if (e.Event.Action == MotionEventActions.Up)
                    {
                        _tapEnded = true;
                        Rect rc = new Rect();
                        GetDrawingRect(rc);
                        int x = (int)e.Event.GetX(), y = (int)e.Event.GetY();
                        view.RaiseTapEnded((DateTime.Now - this._timeCalc).TotalMilliseconds, rc.Contains(x, y) == false);
                        view.RaiseTapUp((DateTime.Now - this._timeCalc).TotalMilliseconds, rc.Contains(x, y) == false);
                    }

                    _detector.OnTouchEvent(e.Event);
                }
            }
        }
 void HandleTouch(object sender, TouchEventArgs e)
 {
     _detector.OnTouchEvent(e.Event);
     if (e.Event.Action == MotionEventActions.Up)
     {
         RoundedBoxView view = this.Element as RoundedBoxView;
         if (view != null)
         {
             view.RaiseTapEnded();
         }
     }
 }
        public RoundedBoxViewRenderer(Context context) : base(context)
        {
            _listener = new GeneralGestureListener();
            _detector = new GestureDetector(context, _listener);
            this.SetWillNotDraw(false);

            _listener.TapStarted += (s, e) =>
            {
                _tapEnded      = false;
                this._timeCalc = DateTime.Now; RoundedBoxView view = this.Element as RoundedBoxView; if (view != null)
                {
                    view.RaiseTapStarted();
                }
            };

            _listener.Tapped += (s, e) =>
            {
                RoundedBoxView view = this.Element as RoundedBoxView; if (view != null)
                {
                    view.RaiseTapped();
                }
            };

            _listener.LongPressed += (s, e) =>
            {
                RoundedBoxView view = this.Element as RoundedBoxView;

                if (view != null)
                {
                    view.RaiseLongPress((DateTime.Now - this._timeCalc).TotalMilliseconds);
                }

                if (!_tapEnded)
                {
                    _tapEnded = true;
                    view.RaiseTapEnded((DateTime.Now - this._timeCalc).TotalMilliseconds);
                }
            };

            //_listener.TapEnded += (s, e) => {RoundedBoxView view = this.Element as RoundedBoxView; if (view != null) view.RaiseTapEnded((DateTime.Now - this._timeCalc).TotalMilliseconds); };
        }
 public RoundedBoxViewRenderer()
 {
     _listener = new GeneralGestureListener();
     _detector = new GestureDetector(_listener);
     this.SetWillNotDraw(false);
     _listener.TapStarted += (s, e) => { RoundedBoxView view = this.Element as RoundedBoxView; if (view != null)
                                         {
                                             view.RaiseTapStarted();
                                         }
     };
     _listener.Tapped += (s, e) => { RoundedBoxView view = this.Element as RoundedBoxView; if (view != null)
                                     {
                                         view.RaiseTapped();
                                     }
     };
     _listener.TapEnded += (s, e) => { RoundedBoxView view = this.Element as RoundedBoxView; if (view != null)
                                       {
                                           view.RaiseTapEnded();
                                       }
     };
 }