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 Dodawanie()
        {
            if (txtPL.Text != "" && txtENG.Text != "")
            {
                btnZatwierdz.IsEnabled = true;
                l1.Visibility          = Visibility.Hidden;
                l2.Visibility          = Visibility.Hidden;


                ListBoxItem item = new ListBoxItem();
                item.Content = txtPL.Text + " - " + txtENG.Text;
                SolidColorBrush myBrush = new SolidColorBrush(Colors.FloralWhite);
                item.Background          = myBrush;
                item.HorizontalAlignment = HorizontalAlignment.Stretch;
                listZwroty.Items.Add(item);

                baza.Dodaj_Zwrot(txtPL.Text, txtENG.Text);

                txtPL.Text  = "";
                txtENG.Text = "";
            }

            else if (txtPL.Text != "" && txtENG.Text == "")
            {
                l1.Visibility = Visibility.Hidden;
                l2.Visibility = Visibility.Visible;
            }

            else if (txtPL.Text == "" && txtENG.Text != "")
            {
                l2.Visibility = Visibility.Hidden;
                l1.Visibility = Visibility.Visible;
            }

            else if (txtPL.Text == "" && txtENG.Text == "")
            {
                l1.Visibility = Visibility.Visible;
                l2.Visibility = Visibility.Visible;
            }

            else if (txtPL.Text == "")
            {
                l1.Visibility = Visibility.Visible;
            }
            else if (txtENG.Text == "")
            {
                l2.Visibility = Visibility.Visible;
            }
        }
        public MainWindow()
        {
            InitializeComponent();

            try
            {
                stream = new FileStream("bazy" + ".dat", FileMode.Open);
            }
            catch
            {
                stream = new FileStream("bazy" + ".dat", FileMode.Create);
            }

            writer = new StreamWriter(stream);
            reader = new StreamReader(stream);


            while (!reader.EndOfStream)
            {
                ListBoxItem item = new ListBoxItem();
                item.Content = reader.ReadLine();
                SolidColorBrush myBrush = new SolidColorBrush(Colors.FloralWhite);
                item.Background          = myBrush;
                item.HorizontalAlignment = HorizontalAlignment.Stretch;

                lista.Items.Add(item);

                Poszczegolna_Baza baza = new Poszczegolna_Baza(item.Content.ToString());



                FileStream   stream2 = new FileStream(item.Content.ToString() + ".dat", FileMode.Open);
                StreamReader reader2 = new StreamReader(stream2);

                int   i     = 1;
                Zwrot zwrot = new Zwrot();

                while (!reader2.EndOfStream)
                {
                    if (i % 2 != 0)
                    {
                        zwrot = new Zwrot();
                        zwrot.setPL(reader2.ReadLine());
                    }

                    else if (i % 2 == 0)
                    {
                        zwrot.setENG(reader2.ReadLine());
                        baza.Dodaj_Zwrot(zwrot);
                    }

                    stream2.Position++;
                    i++;
                }

                App.bazy.Dodaj_Baze(baza);

                stream.Position++;
            }



            stream.Position = stream.Length;
        }
Beispiel #4
0
        private void Dodawanie()
        {
            if (txtPL.Text != "" && txtENG.Text != "")
            {
                warning1.Visibility = Visibility.Hidden;
                warning2.Visibility = Visibility.Hidden;


                ListBoxItem item = new ListBoxItem();
                item.Content = txtPL.Text + " - " + txtENG.Text;
                SolidColorBrush myBrush = new SolidColorBrush(Colors.FloralWhite);
                item.Background          = myBrush;
                item.HorizontalAlignment = HorizontalAlignment.Stretch;
                item.FontSize            = 24;

                lista.Items.Add(item);

                baza.Dodaj_Zwrot(txtPL.Text, txtENG.Text);

                FileStream   stream2 = new FileStream(baza.getNazwa() + ".dat", FileMode.OpenOrCreate);
                StreamWriter writer2 = new StreamWriter(stream2);

                stream2.Position = stream2.Length;

                writer2.WriteLine(txtPL.Text);
                writer2.WriteLine(txtENG.Text);

                //foreach (var item2 in baza.getZwroty())
                //{
                //    writer.WriteLine(item2.getPL());
                //    writer.WriteLine(item2.getENG());
                //}


                writer2.Close();
                stream2.Close();

                this.Close();
            }

            else if (txtPL.Text != "" && txtENG.Text == "")
            {
                warning1.Visibility = Visibility.Hidden;
                warning2.Visibility = Visibility.Visible;
            }

            else if (txtPL.Text == "" && txtENG.Text != "")
            {
                warning2.Visibility = Visibility.Hidden;
                warning1.Visibility = Visibility.Visible;
            }

            else if (txtPL.Text == "" && txtENG.Text == "")
            {
                warning1.Visibility = Visibility.Visible;
                warning2.Visibility = Visibility.Visible;
            }

            else if (txtPL.Text == "")
            {
                warning1.Visibility = Visibility.Visible;
            }
            else if (txtENG.Text == "")
            {
                warning2.Visibility = Visibility.Visible;
            }
        }