Esempio n. 1
0
        /// <summary>
        /// This method sets the image of the Clicked Picture box
        /// </summary>
        private void _cardPictureBoxSetImage()
        {
            // get the index of the PictureBox in the DealtCardPictureBoxList
            int pictureBoxIndex = DealtCardPictureBoxList.IndexOf(this.CurrentClickedCard);

            // convert each card in the Hand object to a string
            string cardstring = this.Hand[pictureBoxIndex].Face.ToString().ToLower();

            cardstring += this.Hand[pictureBoxIndex].Suit.ToString().ToLower();

            Debug.WriteLine(cardstring);

            // use the cardstring to select the appropriate image
            Image cardImage = Properties.Resources.ResourceManager.GetObject(cardstring) as Image;

            // set the image of the current CardPictureBox to the cardimage
            this.CurrentClickedCard.Image = cardImage;
        }
Esempio n. 2
0
        /// <summary>
        /// This method shows different user messages based on where the highest card is in the Hand
        /// </summary>
        private void _showUserMessage()
        {
            // get the index of the PictureBox in the DealtCardPictureBoxList
            int pictureBoxIndex = DealtCardPictureBoxList.IndexOf(this.CurrentClickedCard);

            // If the highest card is selected then change background to Green
            if (this.Hand[pictureBoxIndex].Face >= this.Hand.HighestCards()[0].Face)
            {
                this.CurrentClickedCard.BackColor = Color.Green;
                UserMessageTextBox.Text           = "You Got It!";

                //Uncomment this --> ScoreBoard.Score += this.MaximumPoints;

                DealButton.Enabled = true;
            }
            // otherwise Red
            else
            {
                CurrentClickedCard.BackColor = Color.Red;
                UserMessageTextBox.Text      = "Try again ";
                UserMessageTextBox.Text     += (Hand.HighestCardIndex > pictureBoxIndex) ? "to the right" : "to the left";
                this.MaximumPoints          -= 20;
            }
        }