private void button5_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedItem != null)
            {
                int    selectedIndex = listBox1.SelectedIndex;
                string ime           = (string)listBox1.SelectedItem;
                fajl   fajll         = Klasa.baza.fajls.First(c => c.naziv.Equals(ime));
                Klasa.baza.fajls.Remove(fajll);
                Klasa.baza.SaveChanges();

                try
                {
                    imenaFajlova.RemoveAt(selectedIndex);
                }
                catch
                {
                }

                listBox1.DataSource = null;
                listBox1.DataSource = imenaFajlova;
            }
            else
            {
                MessageBox.Show("Izaberite fajl koji želite obrisati.");
            }
            if (listBox1.Items.Count == 0)
            {
                button5.Enabled = false;
            }
        }
 private void button7_Click(object sender, EventArgs e)
 {
     if (listBox1.SelectedItem != null)
     {
         fajl   f    = Klasa.baza.fajls.First(c => c.naziv.Equals((string)listBox1.SelectedItem));
         Byte[] data = new Byte[0];
         data = (Byte[])f.podaci;
         string myTempFile = Path.Combine(Path.GetTempPath(), f.naziv);
         File.WriteAllBytes(myTempFile, data);
         System.Diagnostics.Process.Start(myTempFile);
     }
     else
     {
         MessageBox.Show("Prvo izaberite fajl koji zelite da prikažete.");
     }
 }
        private void button6_Click(object sender, EventArgs e)
        {
            openFileDialog1.FileName = "";
            DialogResult dr = openFileDialog1.ShowDialog();

            if (dr == DialogResult.OK)
            {
                string   path   = openFileDialog1.FileName;
                string[] tmp    = path.Split('\\');
                string   sminka = tmp[tmp.Length - 1];
                fajl     fajl   = new fajl();
                fajl.podaci = File.ReadAllBytes(path);
                fajl.naziv  = sminka;
                imenaFajlova.Add(fajl.naziv);
                listBox1.DataSource      = null;
                listBox1.DataSource      = imenaFajlova;
                fajl.dogadjaj_iddogadjaj = dog.iddogadjaj;
                Klasa.baza.fajls.Add(fajl);
                Klasa.baza.SaveChanges();
                button5.Enabled = true;
            }
        }