private void ProcessForm_AddEditSpeechAction(Action edit_action, int index) { frm_AddEdit_SpeakAction newSpeakAction; if (edit_action == null) { newSpeakAction = new frm_AddEdit_SpeakAction(); } else { newSpeakAction = new frm_AddEdit_SpeakAction(edit_action); } // On form OK we have changes (either new or edited action) if (newSpeakAction.ShowDialog() == DialogResult.OK) { // Make sure the returned action is sane if (newSpeakAction.get_action() != null) { // Called by Add if (edit_action == null) { // Insert number of times specified by the form for (int i = 0; i < newSpeakAction.get_times_to_add(); i++) { sequence_to_edit.Add(newSpeakAction.get_action()); } } // Called by Edit else { // Replace the current action with the new from the form sequence_to_edit.action_sequence[index] = newSpeakAction.get_action(); } } else { MessageBox.Show("WARNING: Press form returned an invalid action."); return; } ActionSequenceEdited = true; refresh_dgActionSequence(); // Bring Selection back to edited element dgActionSequence.CurrentCell = dgActionSequence.Rows[index].Cells[0]; } }
private void ProcessForm_AddEditSpeechAction(Action edit_action, int index) { frm_AddEdit_SpeakAction newSpeakAction; if(edit_action == null) { newSpeakAction = new frm_AddEdit_SpeakAction(); } else { newSpeakAction = new frm_AddEdit_SpeakAction(edit_action); } // On form OK we have changes (either new or edited action) if (newSpeakAction.ShowDialog() == DialogResult.OK) { // Make sure the returned action is sane if (newSpeakAction.get_action() != null) { // Called by Add if (edit_action == null) { // Insert number of times specified by the form for (int i = 0; i < newSpeakAction.get_times_to_add(); i++) { sequence_to_edit.Add(newSpeakAction.get_action()); } } // Called by Edit else { // Replace the current action with the new from the form sequence_to_edit.action_sequence[index] = newSpeakAction.get_action(); } } else { MessageBox.Show("WARNING: Press form returned an invalid action."); return; } ActionSequenceEdited = true; refresh_dgActionSequence(); // Bring Selection back to edited element dgActionSequence.CurrentCell = dgActionSequence.Rows[index].Cells[0]; } }