private void PopulateWithProblemDetails()
        {
            ProblemCount += 1;
            var unanswered = CurrentProblemSet.Where(x => !x.Answered).ToList();

            if (unanswered.Count > 0)
            {
                currentProblemIndex      = GetRandom.Next(0, unanswered.Count() - 1);
                currentProblem           = unanswered[currentProblemIndex];
                calculationLabel.Content = currentProblem.Question;
                List <int> answerIndex = new List <int>()
                {
                    0, 1, 2, 3
                };
                Button[] buttons = { buttonOption1, buttonOption2, buttonOption3, buttonOption4 };
                for (int i = 0; i < 4; i++)
                {
                    int indexToUse = GetRandom.Next(0, answerIndex.Count);
                    buttons[i].Content = currentProblem.AvailableAnswers[answerIndex[indexToUse]];
                    answerIndex.RemoveAt(indexToUse);
                }
                currentProblem.StartTime = DateTime.Now;
            }
            else
            {
                FinalResults();
            }
        }
        private void FinalResults()
        {
            double totalTime = 0;

            CurrentProblemSet.ForEach(x => totalTime += x.TimeAnsweredIn);
            currentSelection         = null;
            calculationLabel.Content = "";
            buttonOption1.Content    = "";
            buttonOption2.Content    = "";
            buttonOption3.Content    = "";
            buttonOption4.Content    = "";
            currentProblem           = null;
            string previousStreak;
            string previousAverageTime = null;

            if (UserData.TryGetValue(Configuration["name"] + "_streak)_" + Configuration["factNumber"], out previousStreak))
            {
                previousAverageTime = UserData[Configuration["name"] + "_averageTime_" + Configuration["factNumber"]];
            }
            else
            {
                UserData[Configuration["name"] + "_streak_" + Configuration["factNumber"]]      = longestStreak.ToString();
                UserData[Configuration["name"] + "_averageTime_" + Configuration["factNumber"]] = (totalTime / CurrentProblemSet.Count).ToString();
            }

            string previousInfo = "";

            if (previousAverageTime != null && !String.IsNullOrEmpty(previousAverageTime.ToString()))
            {
                previousInfo = "Your previous streak was " + longestStreak + Environment.NewLine +
                               "Your average time to answer was " + totalTime / CurrentProblemSet.Count + Environment.NewLine;

                if (int.Parse(previousStreak.ToString()) < longestStreak)
                {
                    UserData[Configuration["name"] + "_streak_" + Configuration["factNumber"]] = longestStreak.ToString();
                }
                if (double.Parse(previousAverageTime.ToString()) < (totalTime / CurrentProblemSet.Count))
                {
                    UserData[Configuration["name"] + "_averageTime_" + Configuration["factNumber"]] = (totalTime / CurrentProblemSet.Count).ToString();
                }
            }

            Properties.Settings.Default["UserData"] = JsonConvert.SerializeObject(UserData);
            Properties.Settings.Default.Save();
            MessageBox.Show(previousInfo +
                            "Your longest streak was " + longestStreak + Environment.NewLine +
                            "Your average time to answer was " + totalTime / CurrentProblemSet.Count, "FinalResult");


            CurrentProblemSet = null;
            ConfigureWindow configWindow = new ConfigureWindow();

            configWindow.nameText.Text = Configuration["name"];
            configWindow.Show();
            this.Close();
        }