示例#1
0
        private bool CheckIsDoubleTap(TouchDevice device)
        {
            if (this.AssociatedObject.TouchesOver.Count() == 1)
            {
                if (this.preTouchUpInfo != null && this.lastTouchUpInfo == null)
                {
                    bool isVaild = this.preTouchUpInfo.IsVaild(DateTime.Now);
                    if (isVaild == false)
                    {
                        this.preTouchUpInfo = null;
                        return(false);
                    }
                }
                else if (this.lastTouchUpInfo != null)
                {
                    bool isVaild = this.lastTouchUpInfo.IsVaild(DateTime.Now);
                    if (isVaild == false)
                    {
                        this.preTouchUpInfo  = null;
                        this.lastTouchUpInfo = null;

                        return(false);
                    }
                    else
                    {
                        double diffTime = (this.lastTouchUpInfo.TouchTime - this.preTouchUpInfo.TouchTime).TotalMilliseconds;
                        if (diffTime < GestureConsts.Current.VaildDoubleTapTimeDiff)
                        {
                            double diff = this.GetPowDis(this.lastTouchUpInfo.TouchPoint, this.preTouchUpInfo.TouchPoint);
                            if (diff < GestureConsts.Current.DoubleTapDistance)
                            {
                                this.currentResult = GestureResult.DoubleTap;
                                GestureArg   arg     = new GestureArg(this.AssociatedObject, this.currentResult, device);
                                List <Point> posInfo = new List <Point>();
                                posInfo.Add(this.preTouchUpInfo.TouchPoint);
                                posInfo.Add(this.lastTouchUpInfo.TouchPoint);
                                arg.Tag = posInfo;
                                if (this.OnGestureDetector != null)
                                {
                                    this.OnGestureDetector(this.AssociatedObject, arg);
                                }
                                this.isGestureBehavior = true;
                                this.preTouchUpInfo    = null;
                                this.lastTouchUpInfo   = null;
                                return(true);
                            }
                        }
                        this.preTouchUpInfo  = this.lastTouchUpInfo;
                        this.lastTouchUpInfo = null;
                    }
                }
            }
            return(false);
        }
示例#2
0
 private void CheckDoubleTapInfo(TouchDevice device)
 {
     if (this.AssociatedObject.TouchesOver.Count() == 1)
     {
         if (this.preTouchUpInfo == null)
         {
             this.preTouchUpInfo            = new TouchTapInfo();
             this.preTouchUpInfo.Id         = device.Id;
             this.preTouchUpInfo.TouchPoint = device.GetTouchPoint(Application.Current.MainWindow).Position;
             this.preTouchUpInfo.TouchTime  = DateTime.Now;
         }
         else
         {
             if (lastTouchUpInfo == null)
             {
                 lastTouchUpInfo            = new TouchTapInfo();
                 lastTouchUpInfo.Id         = device.Id;
                 lastTouchUpInfo.TouchPoint = device.GetTouchPoint(Application.Current.MainWindow).Position;
                 lastTouchUpInfo.TouchTime  = DateTime.Now;
             }
         }
     }
 }