Example #1
0
 private void ShowOptions()
 {
     hook.Dispose();
     options = ShowOptionsForm();
     options.Save();
     BindHotKey();
     SetTime();
     ResetButton.Focus();
 }
Example #2
0
 private void TimeLabel_Click(object sender, EventArgs e)
 {
     if (simplified)
     {
         StartButton_Click(sender, e);
     }
     else
     {
         ShowOptions();
     }
     ResetButton.Focus();
 }
Example #3
0
        private void ShowAnswers()
        {
            Answer1.BackColor = Color.Turquoise;
            Answer2.BackColor = Color.Turquoise;
            Answer3.BackColor = Color.Turquoise;
            Answer4.BackColor = Color.Turquoise;

            ResetButton.Focus();

            TotalGames++;
            TimePlayed += TimeSpan.FromSeconds(Timer.GetCurrentSecondsElapsed());

            GameInProgress = false;
            contextMenuStrip1.Items[0].Text = "Total Games Played: " + TotalGames;
            contextMenuStrip1.Items[1].Text = "Total Time Played: " + TimePlayed;
            contextMenuStrip1.Items[2].Text = "Average: " + TimePlayed.TotalSeconds / TotalGames;

            double secondsPlayed = (TimePlayed - LastTimePlayed).TotalSeconds;

            LastTimePlayed = TimePlayed;

            TimeLabel.Text    = "Time: " + secondsPlayed.ToString("F2");
            TimeLabel.Visible = true;

            AverageLabel.Text    = "Avg: " + (TimePlayed.TotalSeconds / TotalGames).ToString("F2");
            AverageLabel.Visible = true;

            var answersKey = GetAnswersAsInt(Game.Answers);

            if (!Records.ContainsKey(answersKey))
            {
                Records.Add(answersKey, new GameRecord(new List <double>()
                {
                    secondsPlayed
                }));
            }
            else
            {
                FastLabel.Text = "Fast: " + Records[answersKey].Fastest.ToString("F2");
                SlowLabel.Text = "Slow: " + Records[answersKey].Slowest.ToString("F2");

                FastLabel.Visible = true;
                if (Records[answersKey].Fastest != Records[answersKey].Slowest)
                {
                    SlowLabel.Visible = true;
                }

                Records[answersKey].AddTime(secondsPlayed);
            }
        }
Example #4
0
        internal void FocusButton(ButtonType type)
        {
            switch (type)
            {
            case ButtonType.Ok:
                OkButton.Focus();
                break;

            case ButtonType.Cancel:
                CancelButton.Focus();
                break;

            case ButtonType.Reset:
                ResetButton.Focus();
                break;
            }
        }
Example #5
0
 private void MainForm_KeyDown(object sender, KeyEventArgs e)
 {
     if (BpmMultiplierUpDown.Focused || NewBpmTextBox.Focused)
     {
         return;
     }
     if (e.KeyCode == Keys.D1)
     {
         ResetButton_Click(null, null);
         ResetButton.Focus();
     }
     if (e.KeyCode == Keys.D2)
     {
         DeleteButton_Click(null, null);
         DeleteButton.Focus();
     }
     if (e.KeyCode == Keys.D3 && GenerateMapButton.Enabled)
     {
         GenerateMapButton_Click(null, null);
         GenerateMapButton.Focus();
     }
 }
Example #6
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                if (IsPostBack)
                {
                    SecretNumber thisGuess = SecretN;

                    Outcome guess = thisGuess.MakeGuess(int.Parse(InputTextBox.Text));
                    if (thisGuess.CanMakeGuess)
                    {
                        Button1.Enabled      = true;
                        InputTextBox.Enabled = true;
                        InputTextBox.Focus();

                        int  currentGuess = int.Parse(InputTextBox.Text);
                        bool exists       = thisGuess._previousGuesses.Contains(currentGuess);

                        if (!exists)
                        {
                            thisGuess._previousGuesses.Add(int.Parse(InputTextBox.Text));

                            //guessLabel.Text = thisGuess.Number.ToString();

                            if (guess == Outcome.High)
                            {
                                Label2.Text = "Du gissade för högt.";
                            }
                            else if (guess == Outcome.Low)
                            {
                                Label2.Text = "Du gissade för lågt.";
                            }
                        }
                        else
                        {
                            Label2.Text = "Du har redan gissat på " + currentGuess;
                        }
                    }
                    else if (guess == Outcome.Correct)
                    {
                        Button1.Enabled          = false;
                        InputTextBox.Enabled     = false;
                        Label2.Text              = "GRATTIS";
                        ResetPlaceHolder.Visible = true;
                        ResetButton.Focus();
                        Session.Clear();
                        thisGuess.Initialize();
                    }
                    else if (guess == Outcome.NoMoreGuesses)
                    {
                        Button1.Enabled          = false;
                        InputTextBox.Enabled     = false;
                        Label2.Text              = "Ledsen, inga gissningar kvar. Talet var " + thisGuess.Number;
                        ResetPlaceHolder.Visible = true;
                        ResetButton.Focus();
                        thisGuess.Initialize();
                    }

                    SecretN         = thisGuess;
                    guessLabel.Text = "Tidigare gissningar: " + String.Join(", ", thisGuess.PreviousGuesses);
                }
            }
        }