private void RemoveResultCard(object sender, SearchCardIdEventArgs e) { _unsaved = true; Deck.Element element = ActiveSection.Cards.FirstOrDefault(c => c.Card.Id == e.CardId); if (element == null) { return; } element.Quantity -= 1; if (element.Quantity == 0) { ActiveSection.Cards.Remove(element); } }
private void PickUpDeckCard(object sender, MouseEventArgs e) { if (MouseButtonState.Pressed.Equals(e.LeftButton)) { Deck.Element getCard = ActiveSection.Cards.ElementAt(cardIndex); DataObject dragCard = new DataObject("Card", getCard); if (System.Windows.Forms.Control.ModifierKeys == System.Windows.Forms.Keys.Shift) { ActiveSection.Cards.RemoveAt(cardIndex); DragDrop.DoDragDrop(DeckCard, dragCard, DragDropEffects.All); } else { RemoveResultCard(null, new SearchCardIdEventArgs { CardId = getCard.Card.Id }); DragDrop.DoDragDrop(DeckCard, dragCard, DragDropEffects.Copy); } } }
private void PickUnlimitedCard(object sender, RoutedEventArgs e) { var src = e.OriginalSource as FrameworkElement; if (src == null) { return; } var card = src.DataContext as CardModel; if (card == null) { return; } var section = deckTabs.SelectedItem as Deck.Section; if (section == null) { return; } // Hide the big card preview RaiseEvent(new CardEventArgs(CardControl.CardHoveredEvent, sender)); OpenQuantityPopup(qty => { Deck.Element element = section.Cards.FirstOrDefault(x => x.Card.Id == card.Id); if (element != null) { element.Quantity += (byte)qty; } else { section.Cards.Add(new Deck.Element { Card = card, Quantity = (byte)qty }); } }); }
private void AddResultCard(object sender, SearchCardIdEventArgs e) { _unsaved = true; Deck.Element element = ActiveSection.Cards.FirstOrDefault(c => c.Card.Id == e.CardId); if (element != null) { element.Quantity += 1; } else { CardModel Card = Game.GetCardById(e.CardId); if (Card.isDependent()) { MessageBox.Show("Unable to add " + Card.Name + "to the deck. It is marked as dependent, which implies it is the alternate version of another card. Please try to add the original instead.", "Warning: Add dependent card failed.", MessageBoxButton.OK); } ActiveSection.Cards.Add(new Deck.Element { Card = Game.GetCardById(e.CardId), Quantity = 1 }); } }
private void DeckDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent("Card")) { _unsaved = true; Deck.Element dragCard = e.Data.GetData("Card") as Deck.Element; Deck.Section dropSection = (Deck.Section)((FrameworkElement)sender).DataContext; Deck.Element element = dropSection.Cards.FirstOrDefault(c => c.Card.Id == dragCard.Card.Id); if (e.Effects == DragDropEffects.Copy) { if (element != null) { element.Quantity += 1; } else { dropSection.Cards.Add(new Deck.Element { Card = Game.GetCardById(dragCard.Card.Id), Quantity = 1 }); } } else { if (element != null) { element.Quantity = (byte)(element.Quantity + dragCard.Quantity); } else { dropSection.Cards.Add(new Deck.Element { Card = Game.GetCardById(dragCard.Card.Id), Quantity = dragCard.Quantity }); } } } e.Handled = true; }
private void PickPoolCard(object sender, RoutedEventArgs e) { var src = e.OriginalSource as FrameworkElement; if (src == null) { return; } var card = src.DataContext as CardModel; if (card == null) { return; } var section = deckTabs.SelectedItem as Deck.Section; if (section == null) { return; } CardPool.Remove(card); Deck.Element element = section.Cards.FirstOrDefault(x => x.Card.Id == card.Id); if (element != null) { element.Quantity++; } else { section.Cards.Add(new Deck.Element { Card = card, Quantity = 1 }); } // RaiseEvent(new CardEventArgs(CardControl.CardHoveredEvent, sender)); }
private void PickUpCard(object sender, MouseEventArgs e) { if (MouseButtonState.Pressed.Equals(e.LeftButton)) { var row = (DataRowView)resultsGrid.SelectedItem; if (row == null) { return; } if (CardAdded == null) { return; } var rowid = row["id"] as string; if (rowid != null) { Deck.Element getCard = new Deck.Element { Card = Game.GetCardById(Guid.Parse(rowid)), Quantity = 1 }; DataObject dragCard = new DataObject("Card", getCard); DragDrop.DoDragDrop(SearchCard, dragCard, DragDropEffects.Copy); } } }