private void buttonEdit_Click(object sender, RoutedEventArgs e)
 {
     if (SelectedResource != null)
     {
         int index  = 0;
         int brojac = -1;
         foreach (Resource r in Resources)
         {
             brojac++;
             if (r.Id.Equals(SelectedResource.Id))
             {
                 index = brojac;
             }
         }
         IndexesForUndo.Add(index);
         Resource resource = new Resource(SelectedResource);
         ResourcesForUndo.Add(resource);
         EditResource editResource = new EditResource(SelectedResource.Id, tw);
         editResource.Show();
     }
     else
     {
         MessageBox.Show("Molimo, odaberite resurs za ažuriranje", "Ažuriranje resursa");
     }
 }
 private void ButtonUndo_Click(object sender, RoutedEventArgs e)
 {
     if (ResourcesForUndo.Count() != 0)
     {
         Resource resource = ResourcesForUndo.ElementAt(ResourcesForUndo.Count() - 1);
         ResourcesForUndo.RemoveAt(ResourcesForUndo.Count() - 1);
         Resources.Add(resource);
         tw.database.SaveResources();
         tw.addToResourcesToShow();
     }
 }
        private void ButtonUndo_Click(object sender, RoutedEventArgs e)
        {
            if (ResourcesForUndo.Count() != 0)
            {
                int position = IndexesForUndo.Count() - 1;

                Resource resource = ResourcesForUndo.ElementAt(ResourcesForUndo.Count() - 1);
                ResourcesForUndo.RemoveAt(ResourcesForUndo.Count() - 1);
                int positionForInsert = IndexesForUndo.ElementAt(position);
                Resources.Insert(positionForInsert, resource);
                Resources.RemoveAt(positionForInsert + 1);
                IndexesForUndo.RemoveAt(position);
                tw.database.SaveResources();
            }
        }
        private void buttonDelete_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Are you sure?", "Delete Confirmation", System.Windows.MessageBoxButton.YesNo);

            if (messageBoxResult == MessageBoxResult.Yes)
            {
                Resource forDelete = new Resource(SelectedResource);
                ResourcesForUndo.Add(forDelete);
                tw.database.DeleteResource(forDelete);
                tw.addToResourcesToShow();
                tw.ResourcePins_Draw();
            }


            /*
             * DeleteResourceConfirmation d = new DeleteResourceConfirmation(SelectedResource.Id);
             * d.Show();
             */
        }