コード例 #1
0
        private bool CheckIsAreaGesture(ManipulationDeltaEventArgs e)
        {
            int fingerCount = this.AssociatedObject.TouchesOver.Count();

            if (fingerCount > this.gestureFingerCount)
            {
                this.gestureFingerCount = fingerCount;
            }

            TouchDevice device       = (TouchDevice)e.Manipulators.First();
            TouchPoint  point        = device.GetTouchPoint(Application.Current.MainWindow);
            double      mendedHeight = GestureDetector.GetMendedHeight(point.Size.Width, point.Size.Height);

            if (GestureDetector.IsErase(point.Size.Width, mendedHeight))
            {
                if (this.OnGestureDetector != null)
                {
                    this.currentResult = GestureResult.Brush;
                    GestureArg arg = new GestureArg(this.AssociatedObject, this.currentResult, device);
                    arg.Tag = new Rect(point.Position.X, point.Position.Y, point.Size.Width, mendedHeight);
                    this.OnGestureDetector(this.AssociatedObject, arg);
                }
                this.isGestureBehavior = true;
                return(true);
            }
            else
            {
                if (this.gestureFingerCount == 1)
                {
                    double checkWidht  = point.Size.Width;
                    double checkHeight = mendedHeight;
                    double checkRadio  = checkHeight / checkWidht;
                    bool   isZoom      = this.IsZoom(e.CumulativeManipulation.Scale);
                    if (
                        (checkRadio > GestureConsts.Current.FingerHeightWidhtRatio || checkWidht < (1 / GestureConsts.Current.FingerHeightWidhtRatio)) &&
                        (Math.Min(checkWidht, checkHeight) > GestureConsts.Current.OneFingerSize)
                        )
                    {
                        if (this.gestureStatusBehavior != null)
                        {
                            this.gestureStatusBehavior(new GestureArg(this.AssociatedObject, GestureResult.MultipleFingers, device));
                        }
                        if (e.CumulativeManipulation.Translation.Length > GestureConsts.Current.MultiFingerDragThreshold && isZoom == false)
                        {
                            if (this.OnGestureDetector != null)
                            {
                                this.currentResult = GestureResult.Drag;
                                GestureArg arg = new GestureArg(this.AssociatedObject, this.currentResult, device);
                                arg.Tag = e.CumulativeManipulation.Translation;
                                this.OnGestureDetector(this.AssociatedObject, arg);
                            }
                            this.isGestureBehavior = true;
                            return(true);
                        }
                    }

                    else if (e.CumulativeManipulation.Translation.Length > GestureConsts.Current.MultiFingerDragThreshold && isZoom == false)
                    {
                        if (this.OnGestureDetector != null)
                        {
                            this.currentResult = GestureResult.OneFinger;
                            this.OnGestureDetector(this.AssociatedObject, new GestureArg(this.AssociatedObject, this.currentResult, device));
                        }
                        this.isGestureBehavior = true;
                        return(true);
                    }
                }
            }
            return(false);
        }
コード例 #2
0
        public static bool Recoginze(Size size)
        {
            double height = GestureDetector.GetMendedHeight(size.Width, size.Height);

            return(Recoginze(size.Width, height));
        }
コード例 #3
0
ファイル: GestureDetector.cs プロジェクト: tingxin/Kiosk
 public static void AttachGestureDetector(this FrameworkElement element, Action <GestureArg> callback, Action <GestureArg, ManipulationDelta, ManipulationDelta> gestureDetalBehavior = null, Action <GestureArg> gestureStatusBehavior = null)
 {
     GestureDetector.AttachGestureDetector(element, callback, null, gestureDetalBehavior, gestureStatusBehavior);
 }