/// <summary> /// The button callback to remove all highscores from the database /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ClearHighscores_Click(object sender, RoutedEventArgs e) { var db = (DatabaseService)SL.Get(typeof(DatabaseService)); db.ClearHighScores(); dataGrid.ItemsSource = null; }
/// <summary> /// The constructor initializes gui components and ensures service instances are initialized and present in the SL system /// </summary> public MainWindow() { InitializeComponent(); ((ServerService)SL.Get(typeof(ServerService))).StartService(); SL.Register(this); var db = (DatabaseService)SL.Get(typeof(DatabaseService)); dataGrid.ItemsSource = db.GetAllLevelsWithScores(); }
/// <summary> /// Upon window close the server service closes to prevent DB connection leaks. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void WindowClosing(object sender, System.ComponentModel.CancelEventArgs e) { ((ServerService)SL.Get(typeof(ServerService))).StopService(); }
/// <summary> /// This button causes the app to show all highscores for every level. A new highscore added needs manual refresh. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ShowLevelHighscoresButton_Click(object sender, RoutedEventArgs e) { var db = (DatabaseService)SL.Get(typeof(DatabaseService)); dataGrid.ItemsSource = db.GetAllLevelsWithHighscores(); }