public Wynik(int ile, int wynik, List <int> bledy, Poszczegolna_Baza baza, List <string> bledySTR, Window window) { InitializeComponent(); this.window = window; this.bledy = bledy; this.baza = baza; this.bledySTR = bledySTR; lblWynik.Content = "Wynik: " + wynik + "/" + ile + " pkt "; int i = 0; bazaBledow = new Poszczegolna_Baza(); foreach (var item in bledy) { ListBoxItem item2 = new ListBoxItem(); item2.Content = baza.getZwroty().ElementAt(item).getPL() + " - " + baza.getZwroty().ElementAt(item).getENG(); SolidColorBrush myBrush = new SolidColorBrush(Colors.LightCyan); item2.Background = myBrush; item2.HorizontalAlignment = HorizontalAlignment.Stretch; listWynik.Items.Add(item2); bazaBledow.Dodaj_Zwrot(baza.getZwroty().ElementAt(item).getPL(), baza.getZwroty().ElementAt(item).getENG()); ListBoxItem item3 = new ListBoxItem(); item3.Content = bledySTR.ElementAt(i++); SolidColorBrush myBrush2 = new SolidColorBrush(Colors.LightCyan); item3.Background = myBrush2; item3.HorizontalAlignment = HorizontalAlignment.Stretch; listBłąd.Items.Add(item3); } }
private void Button_Click_1(object sender, RoutedEventArgs e) { ListBoxItem item = new ListBoxItem(); item.Content = txtNazwa.Text; SolidColorBrush myBrush = new SolidColorBrush(Colors.FloralWhite); item.Background = myBrush; item.HorizontalAlignment = HorizontalAlignment.Stretch; lista2.FontSize = 28; if (txtNazwa.Text == "") { l3.Visibility = Visibility.Visible; } else if (txtNazwa.Text != "") { try { FileStream CzyJestBaza = new FileStream(txtNazwa.Text + ".dat", FileMode.Open); MessageBox.Show(this, "Baza o podanej nazwie już istnieje!", "Błąd"); CzyJestBaza.Close(); } catch { lista2.Items.Add(item); baza.setNazwa(txtNazwa.Text); App.bazy.Dodaj_Baze(baza); writer.WriteLine(txtNazwa.Text); FileStream stream2 = new FileStream(txtNazwa.Text + ".dat", FileMode.OpenOrCreate); writer = new StreamWriter(stream2); foreach (var item2 in baza.getZwroty()) { writer.WriteLine(item2.getPL()); writer.WriteLine(item2.getENG()); } this.Close(); writer.Close(); stream2.Close(); } l3.Visibility = Visibility.Hidden; } btnN1.IsEnabled = true; btnN2.IsEnabled = false; }
public TEST(Poszczegolna_Baza baza, Window window) { InitializeComponent(); this.baza = baza; this.window = window; tab = new int[baza.getZwroty().Count]; wynikowe = new string[baza.getZwroty().Count]; random = new Random(); i = random.Next(0, baza.getZwroty().Count); wylosowane = new int[baza.getZwroty().Count]; wylosowane[0] = i; Losowanie(); zwrotPL.Text = baza.getZwroty().ElementAt(i).getPL(); ile++; bledy = new List <int>(); bledySTR = new List <string>(); CountPytania.Content = "Pytanie " + 1 + " z " + baza.getZwroty().Count; }
private void Testowanie() { int pkt = 0; wynikowe[i] = sprENG.Text; CountPytania.Content = "Pytanie " + (ile + 1) + " z " + baza.getZwroty().Count; //if (baza.getZwroty().ElementAt(i).getENG().ToUpper().Equals(wynikowe[i].ToUpper())) // pkt++; //else //{ // bledy.Add(i); //} if (ile < baza.getZwroty().Count) { i = wylosowane[ile]; zwrotPL.Text = baza.getZwroty().ElementAt(i).getPL(); ile++; wynikowe[i] = sprENG.Text; sprENG.Text = ""; } else { for (int j = 0; j < baza.getZwroty().Count; j++) { if (baza.getZwroty().ElementAt(j).getENG().ToUpper().Equals(wynikowe[j].ToUpper())) { pkt++; } else { bledy.Add(j); bledySTR.Add(wynikowe[j]); } } Wynik wynik = new Wynik(baza.getZwroty().Count, pkt, bledy, baza, bledySTR, this); this.Content = wynik.Content; } }
private void btnUsun2_Click(object sender, RoutedEventArgs e) { btnUsun2.IsEnabled = false; App.bazy.getBazy().ElementAt <Poszczegolna_Baza>(lista.SelectedIndex).getZwroty().RemoveAt(listBaza.SelectedIndex); listBaza.Items.RemoveAt(listBaza.SelectedIndex); FileStream stream2 = new FileStream(baza.getNazwa() + ".dat", FileMode.Truncate); StreamWriter writer2 = new StreamWriter(stream2); foreach (var item in baza.getZwroty()) { writer2.WriteLine(item.getPL()); writer2.WriteLine(item.getENG()); } writer2.Close(); stream2.Close(); }