public void RestartGame() { stpAnswers.Children.Clear(); lblQuestion.Text = ""; lblTimer.Content = ""; if (this.IsVisible) { double result = (double)mScore / (double)mMaxQuestions; result *= 100; string message = "Congratulations!" + Environment.NewLine + "You earned " + mScore + "/" + mMaxQuestions + " points!" + Environment.NewLine + "That makes " + (int)result + "%" + Environment.NewLine + "You managed to finish in just " + new DateTime((DateTime.Now - mTimerStart).Ticks).ToString("HH:mm:ss") + "!"; MessageBox.Show(message); } ShufflerWindow w1 = new ShufflerWindow(); w1.ShowDialog(); mMainTimer.Interval = new TimeSpan(0, 0, 1); mMainTimer.Start(); mTimerStart = DateTime.Now; mMainTimer.Tick += (s, ea) => { TimeSpan diff = DateTime.Now - mTimerStart; string formatted = new DateTime(diff.Ticks).ToString("HH:mm:ss"); lblTimer.Content = formatted; }; mCurrentQuestion = 0; mScore = 0; mMaxQuestions = w1.HowMany; mCurrentCollection = mMainCollection.RandomizeCollection(mMaxQuestions); LoadQuestion(); }