private void initialiseHandTypeLabels()
        {
            //if one is null they both should be
            if (handTypeLabels == null)
            {
                handTypeLabels = new Dictionary <string, Label>()
                {
                    { CardUtilities.getHandValueName(0), lbl_HighCards }, { CardUtilities.getHandValueName(1), lbl_Pairs }, { CardUtilities.getHandValueName(2), lbl_jacksOrBetter }, { CardUtilities.getHandValueName(3), lbl_TwoPairs }, { CardUtilities.getHandValueName(4), lbl_Triple }, { CardUtilities.getHandValueName(5), lbl_Straight }, { CardUtilities.getHandValueName(6), lbl_Flush }, { CardUtilities.getHandValueName(7), lbl_FullHouse }, { CardUtilities.getHandValueName(8), lbl_FourOfAKind }, { CardUtilities.getHandValueName(9), lbl_StraightFlush }, { CardUtilities.getHandValueName(10), lbl_RoyalFlush }
                };
                handTypeCountLabels = new Dictionary <string, Label>()
                {
                    { CardUtilities.getHandValueName(0), lbl_HighCardsCount }, { CardUtilities.getHandValueName(1), lbl_PairsCount }, { CardUtilities.getHandValueName(2), lbl_jacksOrBetterCount }, { CardUtilities.getHandValueName(3), lbl_TwoPairsCount }, { CardUtilities.getHandValueName(4), lbl_TripleCount }, { CardUtilities.getHandValueName(5), lbl_StraightCount }, { CardUtilities.getHandValueName(6), lbl_FlushCount }, { CardUtilities.getHandValueName(7), lbl_FullHouseCount }, { CardUtilities.getHandValueName(8), lbl_FourOfAKindCount }, { CardUtilities.getHandValueName(9), lbl_StraightFlushCount }, { CardUtilities.getHandValueName(10), lbl_RoyalFlushCount }
                };
            }
            //high card,lowpair,jack+ pair,2pair
            int[]  initialProbabilities = new int[] { 1302540, 760320, 337920, 123552, 54912, 10200, 5108, 3744, 624, 36, 4 };
            double total = initialProbabilities.Sum();

            int i = 0;

            foreach (var pair in handTypeLabels)
            {
                handTypeLabels[pair.Key].Content         = CardUtilities.getHandValueName(i);// +(CardUtilities.getHandValueName(i).Contains("Flush") ? "es" : "s"); //If you want to pluralise
                handTypeCountLabels[pair.Key].Content    = handTypeCountLabels[pair.Key].Content = string.Format("%{0:0.00}", ((initialProbabilities[i]) / total * 100));
                handTypeCountLabels[pair.Key].Foreground = new SolidColorBrush(Colors.Black);
                handTypeLabels[pair.Key].Foreground      = new SolidColorBrush(Colors.Black);
                i++;
            }
        }
 private bool checkAssendingPayoffs()
 {
     for (int i = 1; i < payoffTable.Count; i++)
     {
         if (payoffTable[CardUtilities.getHandValueName(i)] < payoffTable[CardUtilities.getHandValueName(i - 1)])
         {
             MessageBoxResult output = MessageBox.Show("Your payoff table is not in ascending order, \nyou can continue and potentially get some \nbizzarre results, or stop now and fix it.\n\nContinue?", "Non-ascending payoffs", MessageBoxButton.YesNo);
             return(output == MessageBoxResult.Yes);
         }
     }
     return(true);
 }
        private void initializePayoffTable()
        {
            for (int i = 0; i < payoffTableBoxes.Count; i++)
            {
                if (payoffTableBoxes[i].Text == "")
                {
                    payoffTableBoxes[i].Text = "0";
                }

                double temp;
                if (double.TryParse(payoffTableBoxes[i].Text, out temp))
                {
                    payoffTable[CardUtilities.getHandValueName(i)] = temp;
                }
                else
                {
                    payoffTableBoxes[i].Text = "0";
                    payoffTable[CardUtilities.getHandValueName(i)] = 0;
                }
            }
        }
        /// <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       = "";
            }
        }