private void buttonRenamePerson_Click(object sender, RoutedEventArgs e)
 {
     // Item must be selected
     if (listBoxPersons.SelectedItem != null)
     {
         int index = listBoxPersons.SelectedIndex;
         // Open dialog to rename with current name
         NameItemDialog nameItemDialog = new NameItemDialog(persons[index], "Person");
         // If renamed
         if (nameItemDialog.ShowDialog() == true)
         {
             //Change name and update GUI
             persons[index] = nameItemDialog.ItemName;
             UpdateGUI();
         }
     }
 }
 private void buttonAddPerson_Click(object sender, RoutedEventArgs e)
 {
     // Item must be selected
     if (listBoxProjects.SelectedItem != null)
     {
         int index = listBoxProjects.SelectedIndex;
         // Open dialog to rename with current name
         NameItemDialog nameItemDialog = new NameItemDialog(string.Empty, "Project");
         // If renamed
         if (nameItemDialog.ShowDialog() == true)
         {
             //Change name and update GUI
             persons.Add(nameItemDialog.ItemName);
             listBoxPersons.ItemsSource = persons;
             UpdateGUI();
         }
     }
 }
 private void buttonRemovePerson_Click(object sender, RoutedEventArgs e)
 {
     // Item must be selected
     if (listBoxPersons.SelectedItem != null)
     {
         int index = listBoxPersons.SelectedIndex;
         // Open dialog to rename with current name
         NameItemDialog nameItemDialog = new NameItemDialog(persons[index], "Project");
         // Display warning
         MessageBoxResult messageBoxResult = MessageBox.Show(string.Format("Do you want to remove project {0}", projects[index].ProjectName), "Warning", MessageBoxButton.YesNo);
         if (messageBoxResult == MessageBoxResult.Yes)
         {
             // Remove for list and update GUI
             persons.RemoveAt(index);
             UpdateGUI();
         }
     }
 }