private int GetMendedFingerCount(IEnumerable <IManipulator> manipulators) { int sum = 0; foreach (var mani in manipulators) { TouchDevice device = (TouchDevice)mani; TouchPoint point = device.GetTouchPoint(Application.Current.MainWindow); double width = point.Size.Width; double height = GestureDetector.GetMendedHeight(point.Size.Width, point.Size.Height); double ratio = height / width; if (ratio > GestureConsts.Current.FingerHeightWidhtRatio || ratio < (1 / GestureConsts.Current.FingerHeightWidhtRatio)) { sum += 2; } else { sum += 1; } } return(sum); }
public static bool Recoginze(Size size) { double height = GestureDetector.GetMendedHeight(size.Width, size.Height); return(Recoginze(size.Width, height)); }
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); }