public ScoreHistoryPage() { var layout = new StackLayout { Padding = 5 }; using (var db = new GameContext ()) { var games = db.Games.OrderByDescending (g => g.ClicksPerSecond).Take (5).ToList(); layout.Children.Add (new Label { Text = string.Format("Your best {0} scores.", games.Count) , FontSize = 20 }); foreach (var game in games) { layout.Children.Add (new Frame { Padding = 10, Content = new StackLayout { Children = { new Label { Text = string.Format ("{0} clicks per second", game.ClicksPerSecond) }, new Label { Text = string.Format ("Played {0}", game.Played), FontSize = 10 } } } }); } } Content = layout; }
private bool HandleSecondTick() { _secondsRemaining--; if (_secondsRemaining > 0) { UpdateTimeLabel (); return true; } else { _playing = false; _timeLabel.Text = "Game complete (saving results...)"; using (var db = new GameContext ()) { db.Games.Add (new Game { Clicks = _clickCount, Duration = _gameDuration, ClicksPerSecond = (double)_clickCount / _gameDuration, Played = DateTime.Now }); db.SaveChanges (); } _timeLabel.Text = "Game complete (results saved)"; return false; } }