//u zavisnosti od selektovane vrednosti comboboxa stavi ikonicu
        private void tip_SelectionChanged(object sender, RoutedEventArgs e)
        {
            ComboBox     cb         = (ComboBox)sender;
            TipDogadjaja selektovan = (TipDogadjaja)cb.SelectedItem;

            if (selektovan == null)
            {
                return;
            }

            Dogadjaj d = new Dogadjaj();

            d.ikonica = selektovan.ikonica;

            string path = d.ikonica;

            image1.Source = new BitmapImage(new Uri(path));
            ikonica.Text  = path;
        }
        private void ukloni_Click(object sender, RoutedEventArgs e)
        {
            if (tab1.IsSelected)
            {
                Dogadjaj d = (Dogadjaj)listView1.SelectedItem;
                for (int i = 0; i < listaDog.Count; i++)
                {
                    if (listaDog.ElementAt(i).Equals(d))
                    {
                        listaDog.RemoveAt(i);
                        MainWindow.listaDog.RemoveAt(i);
                        break;
                    }
                }

                FileStream      stream = new FileStream("data1.bin", FileMode.OpenOrCreate, FileAccess.Write);
                BinaryFormatter bin    = new BinaryFormatter();
                bin.Serialize(stream, listaDog);
                stream.Close();
            }
            else if (tab2.IsSelected)
            {
                TipDogadjaja t = (TipDogadjaja)listView2.SelectedItem;
                listaTip.Remove(t);

                FileStream      stream = new FileStream("data.bin", FileMode.OpenOrCreate, FileAccess.Write);
                BinaryFormatter bin    = new BinaryFormatter();
                bin.Serialize(stream, listaTip);
                stream.Close();
            }
            else if (tab3.IsSelected)
            {
                EtiketaDogadjaja et = (EtiketaDogadjaja)listView3.SelectedItem;
                listaEt.Remove(et);

                FileStream      stream = new FileStream("data2.bin", FileMode.OpenOrCreate, FileAccess.Write);
                BinaryFormatter bin    = new BinaryFormatter();
                bin.Serialize(stream, listaEt);
                stream.Close();
            }
        }
Exemple #3
0
        private void dodaj_Click(object sender, RoutedEventArgs e)
        {
            bool   dodato     = true;
            string oznakaTipa = textBox1.Text;
            string nazivTipa  = textBox3.Text;
            string opisTipa   = textBox2.Text;
            string ikonaTipa  = textBox1_Copy.Text;

            //prolazak kroz listu tipova i provera da li vec postoji tip sa oznakom koju pokusavamo da unesemo
            for (int i = 0; i < listaTipova.Count(); i++)
            {
                if (listaTipova.ElementAt(i).oznaka.Equals(oznakaTipa))
                {
                    MessageBox.Show("Oznaka tipa događaja koju ste uneli već postoji!");
                    dodato = false;
                    break;
                }
                else
                {
                    dodato = true;
                }
            }

            //provera da li je oznaka broj
            int    num    = 0;
            string s      = textBox1.Text;
            bool   result = int.TryParse(s, out num);


            if (textBox1.Text != "Unesite oznaku..." && textBox3.Text != "Unesite naziv..." && textBox2.Text != "Unesite opis..." && result)
            {
                if (textBox1.Text != "" && textBox3.Text != "" && textBox2.Text != "")
                {
                    if (dodato)
                    {
                        if (ikonaTipa.Equals("Podrazumevana..."))
                        {
                            //ikonaTipa = "C:\\Users\\asd\\Desktop\\HCI projekat 2020\\HCI projekat 2020\\noimg.png";
                            ikonaTipa = "pack://application:,,,/noimg.png";
                        }
                        else
                        {
                            textBox1_Copy.Text = ikonaTipa;
                        }

                        TipDogadjaja t = new TipDogadjaja(oznakaTipa, nazivTipa, opisTipa, ikonaTipa);
                        listaTipova.Add(t);

                        MessageBox.Show("Uspešno ste napravili tip događaja!");
                        //image1.Source = new BitmapImage(new Uri("C:\\Users\\asd\\Desktop\\HCI projekat 2020\\HCI projekat 2020\\noimg.png"));
                        image1.Source = new BitmapImage(new Uri("pack://application:,,,/noimg.png"));

                        FileStream      stream = new FileStream("data.bin", FileMode.OpenOrCreate, FileAccess.Write);
                        BinaryFormatter bin    = new BinaryFormatter();
                        bin.Serialize(stream, listaTipova);

                        dataGrid.ItemsSource       = null;
                        dataGrid.ItemsSource       = listaTipova;
                        dataGrid.Columns[0].Header = "Oznaka";
                        dataGrid.Columns[1].Header = "Naziv";
                        dataGrid.Columns[2].Header = "Opis";
                        dataGrid.Columns[3].Header = "Ikonica";
                        clearAll();
                        stream.Close();
                    }
                }
                else
                {
                    MessageBox.Show("Odgovarajuća polja ne smeju biti prazna!");
                }
            }
            else
            {
                MessageBox.Show("Molimo Vas unesite odgovarajuće vrednosti!");
            }
        }