Esempio n. 1
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     System.Windows.Data.CollectionViewSource eenScoreViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("eenScoreViewSource")));
     // Load data by setting the CollectionViewSource.Source property:
     // eenScoreViewSource.Source = [generic data source]
     using (var ent = new ScoresEntities())
     {
         List <EenScore> aap   = new List <EenScore>();
         var             leeuw = ent.Scores.OrderByDescending(x => x.Score).OrderByDescending(x => x.Lengte);
         foreach (var item in leeuw)
         {
             aap.Add(new EenScore {
                 Naam = item.Naam, ID = item.ID, Score = item.Score, Datum = item.Datum, Lengte = item.Lengte
             });
         }
         eenScoreViewSource.Source = aap;
     }
 }
Esempio n. 2
0
 public void GameOver(string tekst)
 {
     MessageBox.Show(tekst + score2);
     target.Visibility = Visibility.Hidden;
     timer.Stop();
     if (score2 > highscore)
     {
         highscore            = score2;
         lblHighScore.Content = highscore;
         Properties.Settings.Default.highscore = highscore;
         Properties.Settings.Default.Save();
         MessageBox.Show("proficiat u hebt de hoogste score");
     }
     try
     {
         InputBox inputDialog = new InputBox("Please enter your name:");
         string   machamp     = "";
         if (inputDialog.ShowDialog() == true)
         {
             machamp = inputDialog.Answer;
         }
         else              //als inputbox gesloten wordt zonder naam in te geven wordt de naam anonymous
         {
             machamp = "anonymous";
         }
         using (var ent = new ScoresEntities())
         {
             ent.Scores.Add(new EenScore {
                 Naam = machamp, Datum = DateTime.Today, Lengte = score + 1, Score = score2
             });
             ent.SaveChanges();
         }//misschien leuk om ook eens op te slaan in een tekstdocument
     }
     catch (Exception hitmonlee)
     {
         MessageBox.Show(hitmonlee.Message);
     }
 }