예제 #1
0
파일: Scores.cs 프로젝트: andmos/NDC2015
 public int Save(Score score)
 {
     TheScores.Add(score);
     TheScores = TheScores.OrderBy(s => s.ElapsedTime).ToList();
     var position = TheScores.IndexOf(score) + 1;
     File.WriteAllText(scoresPath, JsonConvert.SerializeObject(TheScores), Encoding.UTF8);
     WriteLeaderBoard(position);
     return position;
 }
예제 #2
0
        private void EndRound(object obj)
        {
            ShowSummary = !ShowSummary;

            if (ShowSummary)
            {
                ButtonText = FinishedText;
                stopWatch.Stop();
                uiUpdateTimer.Stop();

                if (obj is int)
                {
                    UpdateElapsedTime(null, null);
                    var score = new Score(stopWatch.Elapsed, Contestant, Phone);
                    var position = competition.SaveScore(score);
                    SummaryText = string.Format(SummaryTextSuccess, position);
                }
                else
                {
                    SummaryText = SummaryTextFailed;
                }
            }
            else
            {
                ButtonText = RunningText;
                enableButtonTwo = false;
                ButtonTwoCommand.OnCanExecuteChanged();

                competition.ResetTests();
                Contestant = "";
                Phone = "";
                OnPropertyChanged("Running");
            }
        }
예제 #3
0
 public int SaveScore(Score score)
 {
     uiUpdateTimer.Stop();
     Scores.Add(score);
     var position = scores.Save(score);
     Scores.Clear();
     Scores.AddRange(scores.TheScores.Take(10));
     return position;
 }