/// <summary> /// Sets the states of the various GUI components based on whether the hand is full or not. /// For example it disabled all the buttons until the hand is full. /// </summary> /// <param name="isCompleteHand"></param> private void setForHandState(bool isCompleteHand) { Button[] buttons = new Button[] { btn_Calculate, btn_SpecificMask, btn_Card1Holding, btn_Card2Holding, btn_Card3Holding, btn_Card4Holding, btn_Card5Holding }; foreach (var btn in buttons) { btn.IsEnabled = isCompleteHand; } lbl_HandType.Content = isCompleteHand ? CardUtilities.getHandValueName(CardUtilities.getSortedHandValue(handCards)) : ""; lbl_Instructions.Content = isCompleteHand ? "Click other cards you want removed from the deck." : "Click the cards you want to draw."; lbl_decrease.Content = "Uncalulated chance of value decreasing"; lbl_increase.Content = "Uncalulated chance of value increasing"; lbl_betterStart.Content = "Uncalulated chance of better starting hand"; lbl_returnRate.Content = "Uncalulated estimated return rate"; if (!isCompleteHand) { initialiseHandTypeLabels(); } }
private void cardLabelClicked(object sender, MouseButtonEventArgs e) { //This code will be executed when the new label is clicked - we want it to remove a card from the deck upon left cliking, right click will replace removed ones if (e.ChangedButton == MouseButton.Left) { //check if there are any still to be removed if (deckContent.Contains(((Label)sender).Content.ToString())) { deckContent.Remove(((Label)sender).Content.ToString()); //and remove one if there is passCardToHand(((Label)sender).Content.ToString()); } //check if there none left and grey out if there are if (!deckContent.Contains(((Label)sender).Content.ToString())) { ((Label)sender).Foreground = new SolidColorBrush(Colors.Gray); } if (handCards[4] != -1) { lbl_HandType.Content = CardUtilities.getHandValueName(CardUtilities.getSortedHandValue(handCards)); setForHandState(true); } else { setForHandState(false); } return; } //Put the card back in the deck if it was missing if (e.ChangedButton == MouseButton.Right) { //change the colour back to normal if (((Label)sender).Content.ToString()[1] == '♥' || ((Label)sender).Content.ToString()[1] == '♦') { ((Label)sender).Foreground = new SolidColorBrush(Colors.Red); } else { ((Label)sender).Foreground = new SolidColorBrush(Colors.Black); } //Check if the hand is holding a given card, and remove it from the hand if it is int x = CardUtilities.convertFromStringCard(((Label)sender).Content.ToString()); if (handCards.Contains(x)) { handCards.Remove(x); handCards.Add(-1); deckContent.Add(((Label)sender).Content.ToString()); updateHandDisplay(); } //if the card is missing from the deck replace it if (!deckContent.Contains(((Label)sender).Content.ToString())) { deckContent.Add(((Label)sender).Content.ToString()); } btn_Calculate.IsEnabled = false; btn_SpecificMask.IsEnabled = false; lbl_HandType.Content = ""; } }