Пример #1
0
        public void WczytajDane(string sciezka)
        {
            Automaty.Clear();

            /* pierwsza linia - liczba rund i liczba automatow */
            StreamReader reader = new StreamReader(sciezka);

            string[] mass = reader.ReadLine().Split(' ');
            LiczbaRund      = int.Parse(mass[0]);
            LiczbaAutomatow = int.Parse(mass[1]);

            //kolejne linie - nagrody dla automatow
            for (int i = 0; i < LiczbaAutomatow; i++)
            {
                Automat  automat = new Automat(i + 1);
                string[] tmp     = reader.ReadLine().Split(' ');
                for (int j = 0; j < tmp.Length; j++)
                {
                    automat.DodajNagrode(int.Parse(tmp[j]));
                }
                Automaty.Add(automat);
            }

            NotifyPropertyChanged("Automaty");
            OstatniAutomatID = Automaty.Count;
        }
        private void Button_usunNagrode_Click(object sender, RoutedEventArgs e)
        {
            Automat automat = Listbox_automaty.SelectedItem as Automat;
            Nagroda nagroda = Listbox_nagrody.SelectedItem as Nagroda;

            automat.Nagrody.Remove(nagroda);
            Resetuj();
        }
        private void Button_usunAutomat_Click(object sender, RoutedEventArgs e)
        {
            Automat automat = Listbox_automaty.SelectedItem as Automat;

            DaneWejsciowe.Instancja.Automaty.Remove(automat);
            DaneWejsciowe.Instancja.LiczbaAutomatow--;
            Resetuj();
        }
        private void Button_dodajAutomat_Click(object sender, RoutedEventArgs e)
        {
            Automat automat = new Automat(DaneWejsciowe.Instancja.OstatniAutomatID + 1);

            DaneWejsciowe.Instancja.Automaty.Add(automat);
            DaneWejsciowe.Instancja.LiczbaAutomatow++;
            DaneWejsciowe.Instancja.OstatniAutomatID = automat.ID;
            Resetuj();
        }
        private void Button_dodajNagrode_Click(object sender, RoutedEventArgs e)
        {
            Wczytaj dodajNagrodeOkno = new Wczytaj();

            if (dodajNagrodeOkno.ShowDialog() == true)
            {
                Automat automat = Listbox_automaty.SelectedItem as Automat;
                automat.DodajNagrode(int.Parse(dodajNagrodeOkno.Wartosc_tb.Text));
                Resetuj();
            }
        }
 private void Listbox_automaty_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (Listbox_automaty.SelectedItem != null)
     {
         Automat temp = (Automat)Listbox_automaty.SelectedItem;
         Textbox_automat.Text        = "Automat " + temp.ID;
         Listbox_nagrody.ItemsSource = temp.Nagrody;
     }
     else
     {
         Textbox_automat.Text        = "";
         Listbox_nagrody.ItemsSource = null;
     }
 }
Пример #7
0
 public Osobnik()
 {
     rand           = new Random();
     Chromosom      = new Automat[DaneWejsciowe.Instancja.LiczbaRund];
     Przystosowanie = 0;
 }