private void MoveCardImage(int selectedStackIndex, int currentStackIndex) { // "Moves" playingCard object from one stack to another List <PlayingCard> selectedStack = stackList[selectedStackIndex]; List <PlayingCard> currentStack = stackList[currentStackIndex]; PlayingCard moveCard = selectedStack[selectedStack.Count - 1]; selectedStack.RemoveAt(selectedStack.Count - 1); if (currentStack.Count == 0) { moveCard.Location = stackBaseList[currentStackIndex].Location; } else { Point newLocation = currentStack[currentStack.Count - 1].Location; moveCard.Location = new Point(newLocation.X, newLocation.Y + 30); } currentStack.Add(moveCard); moveCard.BringToFront(); startStackIndex = -1; }
private void DealPlayingCards() { // Deals new PlayingCards to each PlayingCard stack. int currentStackIndex = 0; Point cardToLocation; foreach (Stack <int> intStack in currentGame.indexStacksList) { int dealtCardIndex = intStack.Peek(); Image dealCardImage = imgListOrderedDeck.Images[dealtCardIndex]; PlayingCard displayCard = currentGame.playingCardDeck[dealtCardIndex]; List <PlayingCard> currentStack = stackList[currentStackIndex]; if (intStack.Count == 1) { displayCard.Location = stackBaseList[currentStackIndex].Location; } else { cardToLocation = currentStack[currentStack.Count - 1].Location; displayCard.Location = new Point(cardToLocation.X, cardToLocation.Y + 30); } displayCard.Visible = true; displayCard.Image = dealCardImage; displayCard.Click += pbCardImage_Click; displayCard.DoubleClick += pbCardImage_DoubleClick; displayCard.Anchor = AnchorStyles.Top; currentStack.Add(displayCard); this.Controls.Add(displayCard); displayCard.BringToFront(); currentStackIndex++; } }