private void CountDown() { while (timer > 0.0) { try { Thread.Sleep(100); timer -= 0.1; // timer -= 1; delUpdateUITextBox DelUpdateUITextBox = new delUpdateUITextBox(UpdateClock); this.timeLabel.BeginInvoke(DelUpdateUITextBox, Math.Round(timer, 1).ToString()); } catch (Exception e) { break; } } EndForm endForm = new EndForm(user, "Czas się skończył!\n" + "Odpowiedziałęś na " + correctAnswers.ToString() + " z 10 pytań poprawnie!", correctAnswers, 0.0, stream); try { this.Invoke((MethodInvoker) delegate { endForm.Show(); this.Close(); }); } catch (Exception e) { } //var delUpdateBox = new delUpdateUITextBox(UpdateClock); }
//SPRAWDZANIE ODPOWIEDZI private void Answer(Button button) { answeredQuestions++; aButton.Enabled = false; bButton.Enabled = false; cButton.Enabled = false; dButton.Enabled = false; button.Enabled = true; if (button.Text == correctAnswer) { button.BackColor = Color.Green; correctAnswers++; } else { button.BackColor = Color.Red; } button.Update(); Thread.Sleep(20); Thread.Sleep(2000); string timeLeft = timeLabel.Text.Replace("Pozostały czas: ", "").Replace(" sekund", ""); timer = Convert.ToDouble(timeLeft); aButton.Enabled = true; bButton.Enabled = true; cButton.Enabled = true; dButton.Enabled = true; if (answeredQuestions == 10) { timeLeft = timeLabel.Text; //timerThread.Abort(); EndForm endForm = new EndForm(user, "Odpowiedziano na " + correctAnswers.ToString() + " z 10 pytań poprawnie!", correctAnswers, timer, stream); endForm.Show(); this.Close(); } else { correctAnswer = LoadQuestion(); } }