// Form processing invokes handles form creation // Once the form exits these functions also handle refreshing/updating UI elements // and setting form global variables (such as if we need to save) // @edit_action : can either be an existing action (for editing) or null (create new) // @index : index of existing action, unused if new action. private void ProcessForm_AddEditPressAction(Action edit_action, int index) { frm_AddEdit_PressAction newPressAction; // Create a new action if (edit_action == null) { newPressAction = new frm_AddEdit_PressAction(); } // Edit an existing action else { newPressAction = new frm_AddEdit_PressAction(edit_action); } // Invoke Form if (newPressAction.ShowDialog() == DialogResult.OK) { // if OK pull out edited or new action if (newPressAction.get_action() != null) { // Called by Add if (edit_action == null) { // Insert number of times specified by the form for (int i = 0; i < newPressAction.get_times_to_add(); i++) { sequence_to_edit.Add(newPressAction.get_action()); } } // Called by Edit else { sequence_to_edit.action_sequence[index] = newPressAction.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]; } }
// Form processing invokes handles form creation // Once the form exits these functions also handle refreshing/updating UI elements // and setting form global variables (such as if we need to save) // @edit_action : can either be an existing action (for editing) or null (create new) // @index : index of existing action, unused if new action. private void ProcessForm_AddEditPressAction(Action edit_action, int index) { frm_AddEdit_PressAction newPressAction; // Create a new action if (edit_action == null) { newPressAction = new frm_AddEdit_PressAction(); } // Edit an existing action else { newPressAction = new frm_AddEdit_PressAction(edit_action); } // Invoke Form if (newPressAction.ShowDialog() == DialogResult.OK) { // if OK pull out edited or new action if (newPressAction.get_action() != null) { // Called by Add if (edit_action == null) { // Insert number of times specified by the form for (int i = 0; i < newPressAction.get_times_to_add(); i++) { sequence_to_edit.Add(newPressAction.get_action()); } } // Called by Edit else { sequence_to_edit.action_sequence[index] = newPressAction.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]; } }