public async void ShowUserSelectedCard(CardViewModel card) { try { AutoLoop = false; // Clone to new instance card = card.Clone() as CardViewModel; if (QueuedAndCurrentCards.Count < 2) { QueuedAndCurrentCards.Insert(0, card); } else { QueuedAndCurrentCards[0] = card; } // Wait a little so animation occurs await Task.Delay(200); await RotateAndSendAsync(); } catch { } }
private async Task RotateAndSendAsync() { try { // Add a new queued card if needed if (QueuedAndCurrentCards.Count <= 2) { QueuedAndCurrentCards.Insert(0, FindNewCardFromGallery()); } // If we have enough cards if (QueuedAndCurrentCards.Count >= 2) { // Remove the current QueuedAndCurrentCards.Remove(QueuedAndCurrentCards.Last()); // Grab the to-send one var toSend = QueuedAndCurrentCards.Last(); // Flag it as current CurrentCard = toSend; // Send the new current await SendCardAsync(toSend); } } catch { } }
private CardViewModel FindNewCardFromGallery() { var notInUpNextQueue = GalleryCards.Where(gc => !QueuedAndCurrentCards.Any(existing => existing.Equals(gc))).ToArray(); return(notInUpNextQueue[new Random().Next(0, notInUpNextQueue.Length)].Clone() as CardViewModel); }