private void DataGridUpdate() { showEltmtnts(); switch (SelectBut) { case selectedButtons.HeroesBut: List<PHero> Hp = new List<PHero>(); foreach (var item in new Repository().GetHeroesSource().ToList()) { Hp.Add(new PHero { NameHeroes = item.NameHeroes, WeigthHero = item.WeigthHero }); } dgrid.ItemsSource = Hp.ToList(); break; case selectedButtons.QuestionsBut: // var a = (new Repository().GetQuestionsSource()).Select(d => new { d.NameQestion }).Distinct().ToList(); var a = new Repository().GetQuestionsSource(); List<PQuestions> Pq = new List<PQuestions>(); foreach(var ia in a.Select(d => new { d.NameQestion }).Distinct()) { int summary = 0; foreach(var ia2 in a) { if(ia2.NameQestion==ia.NameQestion) { summary = (int)ia2.OtvetSelected + summary; } } Pq.Add(new PQuestions { NameQestion = ia.NameQestion, TotalWeight = summary }); } dgrid.ItemsSource = Pq.ToList(); break; case selectedButtons.DominatingBut: dgrid.ItemsSource = (new Repository().GetQuestionsSource()).Select(d => new { d.NameQestion, d.NameHeroes, d.OtvetQuest1, d.OtvetQuest2, d.OtvetQuest3, d.OtvetQuest4, d.OtvetQuest5, d.OtvetSelected }).ToList(); break; case selectedButtons.QuestionTree: break; case selectedButtons.HeroesLearnClear: // List<PHero> Hl = new List<PHero>(); foreach (var item in new Repository().GetHeroesSource().ToList()) { Hl.Add(new PHero { NameHeroes = item.NameHeroes, WeigthHero = item.WeigthHero }); } GridHeroLearnDataGrid1.ItemsSource = Hl.ToList(); break; } }
//начать заново, или первый старт public string NewStarting() { EntityStorage ent = new Repository().GetEntityStorage(); // lHeroes = ent.Heroes.ToList(); lHeroes = new List<HeroesProgramm>(); lHeroes.Clear(); foreach (var prHero in ent.Heroes.ToList()) { lHeroes.Add(new HeroesProgramm { NameHeroes = prHero.NameHeroes, TextHero = prHero.TextHero, WeigthHero = prHero.WeigthHero }); } lQuestions = ent.Qestion.ToList(); GetSortListHero(); //сортируем список героев Quest2 = GetQuestionDistinctList(lQuestions.ToList()).ToList(); //возвращаем quest2 список без повторяющихся вопросов Quest1 = new List<Questions>(); indexQuest2 = -1; IterAttempst = 0; BackQuestIter = 0; Random rd = new Random(); foreach (var t in Quest2) { indexQuest2++; if (t.NameQestion == ExpConfig.Default.PriorytyQuestions) { return Quest2[indexQuest2].NameQestion; } } indexQuest2 = rd.Next(0, Quest2.Count); return Quest2[indexQuest2].NameQestion; //TODO: EARST }
private void buttonSaveHeroes_Click(object sender, RoutedEventArgs e) { if (NewName1.Text != "" && NewName2.Text != "") { if (NewName1.Text == OldName1.Text && NewName2.Text == OldName2.Text) { ImageSave(Convert.ToString(LabelUpd.Content)); return; } // string NewHeroName = NewName1.Text + "(" + NewName2.Text + ")"; string OldHeroName = Convert.ToString(LabelUpd.Content); if (ImageSave(NewHeroName)) return; Exception ex = new Repository().updHero(OldHeroName, NewHeroName); if (ex != null) { MessageBox.Show(ex.Message); return; } new Repository().updHero(OldHeroName, NewHeroName); DataGridUpdate(); OldName1.Text = NewName1.Text; OldName2.Text = NewName2.Text; LabelUpd.Content = NewHeroName; ProgressSuccessLabel.Visibility = Visibility.Visible; // MessageBox.Show("Данные сохранены!"); } }