// Checks who wins public void CheckWin() { using (var con = new RockPaperScissorEntities()) { try { // Searches the right rule var rule = con.Situation.Where(x => (x.Sieger == h.Player1.Id || x.Sieger == h.Player2.Id) && (x.Verlierer == h.Player1.Id || x.Verlierer == h.Player2.Id)).ToList(); Situation s = rule.ElementAt(0); // gets the winner var winner = con.Zeichen.Where(x => x.Id == s.Sieger).ToList(); // looks who gets the point if (h.Player1.Id == s.Sieger) { pOne++; PointsOne.Content = pOne; } else { pTwo++; PointsTwo.Content = pTwo; } } catch (Exception e) { Console.WriteLine("Untentschieden"); } } }
// Fills ChooseOne and ChooseTwo public void FillDropDowns() { using (var con = new RockPaperScissorEntities()) { ChooseOne.ItemsSource = con.Zeichen.ToList(); ChooseTwo.ItemsSource = con.Zeichen.ToList(); } }
// get all the Images from the db public void ListOfImages() { using (var con = new RockPaperScissorEntities()) { List <Zeichen> z = con.Zeichen.ToList(); for (int i = 0; i < z.Count(); i++) { var pic = z.ElementAt(i).Bild.ToArray(); MemoryStream ms = new MemoryStream(pic); var bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.StreamSource = ms; bitmapImage.EndInit(); sings.Add(bitmapImage); } } }