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

            if (_view != null && touch != null)
            {
                this._timeCalc = DateTime.Now;
                _view.RaiseTapStarted();
            }
        }
        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();
                                       }
     };
 }