public void Flip(int index) { Random rand = new Random(); Card.CardBack color = (Card.CardBack)rand.Next(0, 2); Flip(index, color); }
//used for flipping a specific card and setting its color public void Flip(int index, Card.CardBack color) { if (index <= picture_boxes.Count && index >= 0) //checks to make sure we haven't tried flipping a non existent card { if (( int )color <= 1 && ( int )color >= 0) { if (picture_boxes[index].Image != null) { flipped_cards.Add(new FlippedCard(picture_boxes[index].Image, index)); string back_of_card = string.Empty; switch (color) { case Card.CardBack.BLUE: back_of_card = "blue back of cards.png"; break; case Card.CardBack.RED: back_of_card = "red back of cards.png"; break; } for (int i = 0; i < image_list.Images.Count; i++) { if (image_list.Images.Keys[i].ToString() == back_of_card) { picture_boxes[index].Image = image_list.Images[i]; break; } } } else { throw new ArgumentOutOfRangeException(); } } else { throw new ArgumentException("Not a color"); } } else { throw new ArgumentOutOfRangeException(); } }