Esempio n. 1
0
 /// <summary>
 /// Called when the edit actor button is clicked. Edits an existing actor.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void actorsListViewEditButton_Click(object sender, EventArgs e)
 {
     // Open the text input form
     TextInputForm dialog = new TextInputForm("Edit Actor", actorsListBox.Items[actorsListBox.SelectedIndex].ToString());
     DialogResult result = dialog.ShowDialog();
     // Only progress if the user clicks OK, the input is not empty and the input has been changed
     if (result != DialogResult.Cancel && dialog.mInput.Length != 0 && dialog.mInput != actorsListBox.Items[actorsListBox.SelectedIndex].ToString())
     {
         // Report the error if the edited name duplicates another actor
         if (mApp.mActors.Contains(dialog.mInput))
         {
             MessageBox.Show("Duplicate actor name \"" + dialog.mInput + "\"", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             // If everything is ok, update the list box
             actorsListBox.Items[actorsListBox.SelectedIndex] = dialog.mInput;
             // Update the contentObjectActorsCheckedListBox too
             contentObjectActorsCheckedListBox.Items[actorsListBox.SelectedIndex] = dialog.mInput;
             // Update the app store for actors
             mApp.mActors = actorsListBox.Items.OfType<string>().ToList();
         }
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Called when the new actor button is clicked, appends an actor to the actors list.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void actorsListViewNewButton_Click(object sender, EventArgs e)
 {
     // Open the text input form
     TextInputForm dialog = new TextInputForm("Add Actor");
     DialogResult result = dialog.ShowDialog();
     // If the user clicks OK and the result is not empty
     if (result != DialogResult.Cancel && dialog.mInput.Length != 0)
     {
         // Ensure that this actor does not already exist
         if (mApp.mActors.Contains(dialog.mInput))
         {
             // Report an error if duplicate
             MessageBox.Show("Duplicate actor name \"" + dialog.mInput + "\"", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             // Add the unique actor
             actorsListBox.Items.Add(dialog.mInput);
             // Copy the contents of actorsListBox to update the store in mApp
             mApp.mActors = actorsListBox.Items.OfType<string>().ToList();
             // Also update the available options in contentObjectActorsCheckedListBox
             contentObjectActorsCheckedListBox.Items.Add(dialog.mInput);
         }
     }
 }