예제 #1
0
        /// <summary>
        /// Called when touch up
        /// </summary>
        /// <param name="touchEventArgs">Touch arguments</param>
        public void OnTouchUp(TouchEventArgs touchEventArgs)
        {
            if (this.currentTouchDisabled)
            {
                this.currentTouchDisabled = false;
                return;
            }

            this.currentStartTouch = null;

            if (this.cancellationTokenSource != null)
            {
                this.cancellationTokenSource.Cancel();
                this.cancellationTokenSource = null;
            }

            this.TouchUp?.Invoke(this, touchEventArgs);

            if (this.IsClicking)
            {
                this.Clicked?.Invoke(this, EventArgs.Empty);
            }

            this.IsClicking = false;
        }
예제 #2
0
        /// <summary>
        /// Called when touch leave
        /// </summary>
        /// <param name="touchEventArgs">Touch arguments</param>
        public void OnTouchLeave(TouchEventArgs touchEventArgs)
        {
            if (this.currentTouchDisabled)
            {
                return;
            }

            this.IsClicking        = false;
            this.currentStartTouch = null;
            this.TouchLeave?.Invoke(this, touchEventArgs);
        }
예제 #3
0
        /// <summary>
        /// Called when touch move
        /// </summary>
        /// <param name="touchEventArgs">Touch arguments</param>
        public void OnTouchMove(TouchEventArgs touchEventArgs)
        {
            if (this.currentTouchDisabled)
            {
                return;
            }

            if (this.currentStartTouch != null && this.currentStartTouch.Position.Distance(touchEventArgs.Position) > moveTolerance)
            {
                this.currentStartTouch = null;
            }

            this.TouchMove?.Invoke(this, touchEventArgs);
        }
예제 #4
0
        /// <summary>
        /// Called when touch is down
        /// </summary>
        /// <param name="touchEventArgs">Touch arguments</param>
        public void OnTouchDown(TouchEventArgs touchEventArgs)
        {
            this.currentStartTouch = new StartTouch(touchEventArgs.Position);
            this.IsClicking        = true;

            if (this.cancellationTokenSource != null)
            {
                this.cancellationTokenSource.Cancel();
                this.cancellationTokenSource = null;
            }

            this.cancellationTokenSource = new CancellationTokenSource();

            this.longPressDelayTask = Task.Delay(this.LongPressTime, cancellationTokenSource.Token);
            this.longPressDelayTask.ContinueWith(t =>
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    this.cancellationTokenSource = null;

                    if (this.currentStartTouch == null || t.IsCanceled)
                    {
                        return;
                    }

                    if (this.LongPressCancelClick)
                    {
                        this.IsClicking = false;
                    }

                    this.LongPressed?.Invoke(this, new TouchEventArgs(this.currentStartTouch.Position));
                    this.currentStartTouch = null;
                });
            });

            this.TouchDown?.Invoke(this, touchEventArgs);
        }
예제 #5
0
 /// <summary>
 /// this method disable the current tracking of a current touch device
 /// </summary>
 public void DisableCurrentTouch()
 {
     this.IsClicking           = false;
     this.currentStartTouch    = null;
     this.currentTouchDisabled = true;
 }