示例#1
0
        /// <summary>
        /// Update detector
        /// </summary>
        /// <param name="provider">touch provider</param>
        /// <returns>result of detection</returns>
        public override GestureDetectionResult Update(ITouchStateProvider provider)
        {
            if (TrackingToucheCount < FingerCount) // if do not get access to required touch try to get them
            {
                // remove pre touches that aquired but locked or used by another detector
                RemoveInvalidTouches();
                // lock tracking touches to get more free touches
                LockTrackingTouches();
                foreach (var t in provider.GetFreeTouches(TouchPhase.Began, BoundaryFrame))
                {
                    TrackTouch(t);
                    t.Lock(this);
                    if (TrackingToucheCount == FingerCount)
                    {
                        break;
                    }
                }
                if (TrackingToucheCount == FingerCount)// first time we get access to touches
                {
                    // we get access to required touch so begin detection
                    BeginDetection();
                }
                else
                {
                    // we do't have required touch to begin detection so unlock touches and let another detector to chance detection
                    UnlockTrackingTouches();
                    return(GestureDetectionResult.None);
                }
            }

            GestureDetectionResult result = GestureDetectionResult.None;

            if (TrackingToucheCount == FingerCount)
            {
                result = Detection();
            }
            if (!LockTouches) // unlock touches if we do'nt need them
            {
                UnlockTrackingTouches();
            }
            return(result);
        }
示例#2
0
        /// <summary>
        /// Update detector
        /// </summary>
        /// <param name="provider">Touch provider</param>
        /// <returns>Result of detection</returns>
        public override GestureDetectionResult Update(ITouchStateProvider provider)
        {
            int fc = 0;

            foreach (var t in provider.GetFreeTouches(TouchPhase.Began, BoundaryFrame))
            {
                if (t.TapCount == TapCount)
                {
                    TrackTouch(t);
                    fc++;
                }
                if (fc == FingerCount)
                {
                    OnDetect();
                    return(GestureDetectionResult.Detected);
                }
            }
            if (fc > 0)
            {
                return(GestureDetectionResult.Failed);
            }
            return(GestureDetectionResult.None);
        }
示例#3
0
 /// <summary>
 /// Update detector
 /// </summary>
 /// <param name="provider">touch provider</param>
 /// <returns>result of detection</returns>
 public abstract GestureDetectionResult Update(ITouchStateProvider provider);