Example #1
0
        /**
         * Method to handle the event the "verify" button being pressed.
         *
         * Verifies the user entered code against the pre-generated one.
         * If the codes match, the user is rewarded with some cryptocurrency.
         * This reward is dependent on certain upgrades.
         */
        private void VerifyButton_Click(object sender, EventArgs e)
        {
            if (_generatedCode == null)
            {
                GenerateCode();
                CaptchaTextBox.Text = _generatedCode;
                MessageBox.Show("You hadn't generated a code yet, " +
                                "a new one has been generated for you.");
            }
            else
            {
                var userInput = VerifyTextBox.Text;

                if (_generatedCode.Equals(userInput.ToUpper()))
                {
                    // If upgrade purchased, increase balance twice.
                    if (_incomeDoubled)
                    {
                        _wallet.IncreaseBalance();
                        _wallet.IncreaseBalance();
                    }
                    else
                    {
                        _wallet.IncreaseBalance();
                    }

                    _codeCount++;
                    ResourceLabel.Text = _wallet.Balance.ToString(CultureInfo.InvariantCulture);
                    GenerateCode();
                    VerifiedLabel.Visible = true;
                    WarningTimer.Start();
                    VerifyTextBox.Text = "";
                    return;
                }

                //If the code is incorrect, generate a new one.
                VerificationWarningLabel.Text    = "Incorrect Code";
                VerifyTextBox.Text               = "";
                VerificationWarningLabel.Visible = true;
                WarningTimer.Start();
            }
        }
Example #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void WarningTimer_Tick(object sender, EventArgs e)
 {
     VerificationWarningLabel.Visible = false;
     VerifiedLabel.Visible            = false;
     WarningTimer.Stop();
 }