예제 #1
0
 private void RemovePlayingCard(PlayingCard cardToRemove)
 {
     // Disposes playingCard object from Controls. Meant to be called by other methods.
     for (int i = 0; i < this.Controls.Count - 1; i++)
     {
         if (this.Controls[i] is PlayingCard &&
             this.Controls[i].Name == cardToRemove.Name)
         {
             this.Controls.RemoveAt(i);
         }
     }
 }
예제 #2
0
 private void CreatePlayingCardDeck()
 {
     /* CREATE DATA MODEL FOR CARD IMAGES IN IMGLIST
      * Create instances of playingCard object with value and suit
      * that corresponds to the image kept in imgListGameDeck.
      */
     for (int i = 0; i < this.suitList.Length; i++)
     {
         string suit = this.suitList[i];
         for (int value = 2; value <= 14; value++)
         {
             PlayingCard card = new PlayingCard(value, suit);
             this.playingCardDeck.Add(card);
         }
     }
 }
예제 #3
0
        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;
        }
예제 #4
0
        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++;
            }
        }