Example #1
0
        /// <summary>
        /// Adjusts the number of suits in the deck.
        /// </summary>
        /// <param name="sender">Button causing the event</param>
        /// <param name="e"></param>
        private void SuitClick(object sender, RoutedEventArgs e)
        {
            try
            {
                this.Tag = "Suit";
                int i = Int32.Parse(Suits.Text);

                if (i > 0 && i <= maxSuits)
                {
                    pack.SetNumSuits(i);
                    SuitMistake.Text = "";
                    AdjustHandSize(i * pack.GetNumCards() / NumHands);
                }
                else
                {
                    Suits.Text       = $"{maxSuits}";
                    SuitMistake.Text = "Please enter a valid number";
                    pack.SetNumSuits(maxSuits);
                    i = maxSuits;
                    AdjustHandSize(maxSuits * pack.GetNumCards() / NumHands);
                }

                NumericalUserInteraction numericalUserInteraction = new NumericalUserInteraction(((Button)sender).Tag.ToString(), DateTime.Now, i);
                EventFileWriter.TheWriter.WriteIntoFile(numericalUserInteraction);
            }
            catch (FormatException fEx)
            {
                Suits.Text       = $"{maxSuits}";
                SuitMistake.Text = "Please enter a valid number";
                pack.SetNumSuits(maxSuits);
                AdjustHandSize(maxSuits * pack.GetNumCards() / NumHands);
            }
        }
Example #2
0
        /// <summary>
        /// An event happening when the button adjusting the hand sizeUserInput is clicked
        /// </summary>
        /// <param name="sender">Button causing the event</param>
        /// <param name="e"></param>
        private void HandSizeClick(object sender, RoutedEventArgs e)
        {
            try
            {
                this.Tag = "HandSize";
                int i = Int32.Parse(HandSize.Text);
                i = AdjustHandSize(i);

                NumericalUserInteraction numericalUserInteraction = new NumericalUserInteraction(((Button)sender).Tag.ToString(), DateTime.Now, i);
                EventFileWriter.TheWriter.WriteIntoFile(numericalUserInteraction);
            }
            catch (FormatException fEx)
            {
                AdjustHandSize(pack.GetNumSuits() * pack.GetNumCards() / NumHands);
                HandSizeMistake.Text = "Please enter something making sense";
            }
        }