コード例 #1
0
        public MainWindow()
        {
            InitializeComponent();
            ConfigureWindow configureWindow = new ConfigureWindow();

            configureWindow.Show();
            this.Close();
        }
コード例 #2
0
        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();
        }