Example #1
0
        /// <summary>
        /// Display the winner for X amount of time
        /// </summary>
        /// <param name="winner"></param>
        /// <param name="Interval"></param>
        private void DisplayWinner(string winner, int Interval = 2500)
        {
            // start checking -> disable user input on the forms panels
            checking = true;

            // Show winner
            lblWinner.Text = winner;
            lblWinner.Show();

            // start a timer of set interval
            var t = new Timer();

            t.Interval = Interval;
            if (Game.Delays == false)
            {
                t.Interval = 1;
            }

            // after the interval has finished
            t.Tick += (s, e) =>
            {
                // hide the winner, stop timer
                lblWinner.Hide();
                t.Stop();

                // reset the game
                Game.ResetGame();

                // refresh form. ( Every panel gets cleared from all drawn shapes )
                Refresh();

                //Otherwise it selects a button as focus... for some reason...
                ActiveControl = lblWinner;

                // Disable checking and allow user input
                checking = false;

                lblWinner.Text = "";

                // check if the opponent is a CPU, and do their move if yes
                CPUturn();
            };
            // start the timer
            t.Start();
        }