private void canvasCreated(Dogadjaj d)
        {
            BitmapImage logo  = new BitmapImage();
            Dugme       dugme = new Dugme();

            dugme.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(button_selected);
            dugme.Width           = 40;
            dugme.Height          = 40;
            dugme.Focusable       = false;
            dugme.Tag             = d;
            dugme.ToolTip         = "Oznaka: " + d.oznaka + ", Naziv: " + d.naziv;
            dugme.BorderBrush     = Brushes.Black;
            dugme.BorderThickness = new Thickness(2);

            double maxX = canvas123.Width - dugme.Width;
            double maxY = canvas123.Height - dugme.Height;


            if (initialized == false)
            {
                for (int i = 1; i < listaDog.Count; i++)
                {
                    listaDog.ElementAt(i).Y = listaDog.ElementAt(i - 1).Y + 45 / maxY;
                }

                initialized = true;
            }

            foreach (Dogadjaj dog in listaDog)
            {
                if (dog.oznaka != d.oznaka && d.X == dog.X && d.Y == dog.Y)
                {
                    d.Y = dog.Y + 45 / maxY;
                    break;
                }
            }

            Canvas.SetLeft(dugme, d.X * maxX);
            Canvas.SetTop(dugme, d.Y * maxY);

            canvas123.Children.Add(dugme);

            try
            {
                logo.BeginInit();
                logo.UriSource   = new Uri(d.ikonica);
                logo.CacheOption = BitmapCacheOption.OnLoad;
                logo.EndInit();
                ImageBrush img = new ImageBrush(logo);
                img.Stretch      = Stretch.UniformToFill;
                dugme.Background = img;
            }
            catch (FileNotFoundException e)
            {
                Console.WriteLine(e.StackTrace);
            }
        }
        //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();
            }
        }
        private void dodaj_Click(object sender, RoutedEventArgs e)
        {
            bool   dodato      = true;
            string oznakaDog   = oznakaTxt.Text;
            string nazivDog    = nazivTxt.Text;
            string opisDog     = opisTxt.Text;
            string drzavaDog   = drzavaTxt.Text;
            string gradDog     = gradTxt.Text;
            string troskoviDog = troskoviTxt.Text;
            string tipDog      = comboTip.Text;
            //string etiketaDog = comboEtikete.Text;
            string etiketaDog    = etiketaTxt.Text;
            string posecenostDog = comboBox1_Copy2.Text;
            string humKar        = "";

            if (radioButton1.IsChecked == true)
            {
                humKar = "Da";
            }
            else if (radioButton2.IsChecked == true)
            {
                humKar = "Ne";
            }

            string ikonaDog = ikonica.Text;
            string datDog   = datum.Text;

            //provera da li dogadjaj postoji vec pod unetom oznakom
            for (int i = 0; i < listaDogadjaja.Count(); i++)
            {
                if (listaDogadjaja.ElementAt(i).oznaka.Equals(oznakaDog))
                {
                    MessageBox.Show("Događaj pod takvom oznakom već postoji!");
                    dodato = false;
                    break;
                }
                else
                {
                    dodato = true;
                }
            }

            if (comboTip.SelectedItem == null)
            {
            }

            //provera da li je oznaka broj
            int    num     = 0;
            int    num2    = 0;
            string s       = oznakaTxt.Text;
            string s2      = troskoviTxt.Text;
            bool   result  = int.TryParse(s, out num);
            bool   result2 = int.TryParse(s2, out num2);

            //provera da li su uneti odgovarajuci podaci i da li su polja prazna
            if (oznakaTxt.Text != "Unesite oznaku..." && nazivTxt.Text != "Unesite naziv..." && comboTip.Text != "Odaberite..." && result && result2)
            {
                if (oznakaTxt.Text != "" && nazivTxt.Text != "" && comboTip.Text != "Odaberite...")
                {
                    if (dodato)
                    {
                        //nema ikone
                        if (ikonaDog.Equals("Podrazumevana..."))
                        {
                            //ikonaDog = "C:\\Users\\asd\\Desktop\\HCI projekat 2020\\HCI projekat 2020\\noimg.png";
                            ikonaDog = "pack://application:,,,/noimg.png";
                        }
                        else
                        {
                            ikonica.Text = ikonaDog;
                        }

                        DateTime      datum1 = RandomDay();
                        DateTime      datum2 = RandomDay();
                        DateTime      datum3 = RandomDay();
                        DateTime      datum4 = RandomDay();
                        List <String> ist    = new List <string>();

                        Random rnd  = new Random();
                        int    broj = rnd.Next(2, 5);

                        if (broj == 2)
                        {
                            ist.Add(datum1.ToString("MMM/dd/yyyy"));
                            ist.Add(datum2.ToString("MMM/dd/yyyy"));
                        }
                        else if (broj == 3)
                        {
                            ist.Add(datum1.ToString("MMM/dd/yyyy"));
                            ist.Add(datum2.ToString("MMM/dd/yyyy"));
                            ist.Add(datum3.ToString("MMM/dd/yyy"));
                        }
                        else if (broj == 4)
                        {
                            ist.Add(datum1.ToString("MMM/dd/yyyy"));
                            ist.Add(datum2.ToString("MMM/dd/yyyy"));
                            ist.Add(datum3.ToString("MMM/dd/yyyy"));
                            ist.Add(datum4.ToString("MMM/dd/yyyy"));
                        }

                        //instanciranje novog dogadjaja
                        Dogadjaj d = new Dogadjaj(oznakaDog, nazivDog, opisDog, tipDog, etiketaDog, posecenostDog, humKar, ikonaDog, troskoviDog, drzavaDog, gradDog, datDog, ist);
                        listaDogadjaja.Add(d);
                        MainWindow.listaDog.Add(d);

                        MessageBox.Show("Uspešno ste napravili događaj!");
                        //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("data1.bin", FileMode.OpenOrCreate, FileAccess.Write);
                        BinaryFormatter bin    = new BinaryFormatter();
                        bin.Serialize(stream, listaDogadjaja);

                        dataGrid.ItemsSource        = null;
                        dataGrid.ItemsSource        = listaDogadjaja;
                        dataGrid.Columns[0].Header  = "Oznaka";
                        dataGrid.Columns[1].Header  = "Naziv";
                        dataGrid.Columns[2].Header  = "Opis";
                        dataGrid.Columns[3].Header  = "Država";
                        dataGrid.Columns[4].Header  = "Grad";
                        dataGrid.Columns[5].Header  = "Troškovi održavanja";
                        dataGrid.Columns[6].Header  = "Tip";
                        dataGrid.Columns[7].Header  = "Etiketa";
                        dataGrid.Columns[8].Header  = "Posećenost";
                        dataGrid.Columns[9].Header  = "Humanitarnog karaktera";
                        dataGrid.Columns[10].Header = "Ikonica";
                        dataGrid.Columns[11].Header = "Datum održavanja";
                        dataGrid.Columns[12].Header = "Istorija održavanja";
                        clearAll();
                        stream.Close();
                    }
                }
                else
                {
                    MessageBox.Show("Odgovarajuća polja ne smeju biti prazna!");
                }
            }
            else
            {
                MessageBox.Show("Molimo Vas unesite odgovarajuće vrednosti!");
            }
        }