Exemplo n.º 1
0
        public static bool Recoginze(double width, double height)
        {
            double ratio = width / height;
            double size  = width * height;

            //double minSize = WhiteBoardParam.EraserMinWidth * WhiteBoardParam.EraserMinHeight;
            //double maxSize = WhiteBoardParam.EraserMaxWidth * WhiteBoardParam.EraserMaxHeight;
            if (isInTouchWall)
            {
                if (GestureDetector.IsErase(width, height))
                {
                    return(true);
                }
            }
            else
            {
                if (size > 6000)
                {
                    return(true);
                }

                if (size > 2000)
                {
                    if (ratio < 0.4 || ratio > 2.5)
                    {
                        return(true);
                    }
                }
                else if (size > 1000)
                {
                    return(ratio < 0.45 || ratio > 2.25);
                }
                else if (size > 800)
                {
                    return(ratio < 0.5 || ratio > 2);
                }
            }
            return(false);
        }
Exemplo n.º 2
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);
        }