/// <summary> /// Detect new gestures /// </summary> /// <returns></returns> private async void DetectGesture(List <Touch> touchList) { if (touchList != null && touchList.Count > 0) { await SortingGesture.Detect(touchList, controllers); await DeletingBoxGesture.Detect(touchList, controllers); } }
/// <summary> /// Detect the sorting gesture (Drag and drop the card to the sorting box). /// The touches in the sorting gesture will be removed from the touchList /// </summary> /// <param name="touchList"></param> /// <returns></returns> internal static async Task Detect(List <Touch> touchList, CentralControllers controllers) { List <Touch> usedTouches = new List <Touch>(); SortingGesture gesture = null; foreach (Touch touch in touchList) { if (touch.Type == typeof(Card) && !usedTouches.Contains(touch)) { Card card = touch.Sender as Card; SortingBox[] boxes = controllers.SortingBoxController.GetAllSortingBoxes(); foreach (SortingBox box in boxes) { bool isIntersect = await box.IsIntersected(card.Position); if (isIntersect) { foreach (Touch otherTouches in touchList) { if (touch.Sender == otherTouches.Sender && !usedTouches.Contains(otherTouches)) { usedTouches.Add(otherTouches); } } gesture = new SortingGesture(controllers.GestureController); gesture.AssociatedTouches = usedTouches; gesture.AssociatedObjects = new List <object>() { card, box }; gesture.AssociatedObjectTypes = new List <Type>() { typeof(Card), typeof(SortingBox) }; SortingListener listener = controllers.ListenerController.GetListener(typeof(SortingListener)) as SortingListener; RegisterListener(gesture, listener);// Register the gesture and add the gesture to the gesture list. } } } } foreach (Touch touch in usedTouches) { touchList.Remove(touch); } }