Exemplo n.º 1
0
        private void ProcessForm_AddEditPlaySoundAction(Action edit_action, int index)
        {
            frm_AddEdit_PlaySoundAction newPlaySoundAction;

            if (edit_action == null)
            {
                newPlaySoundAction = new frm_AddEdit_PlaySoundAction();
            }
            else
            {
                newPlaySoundAction = new frm_AddEdit_PlaySoundAction(edit_action);
            }

            // On form OK we have changes (either new or edited action)
            if (newPlaySoundAction.ShowDialog() == DialogResult.OK)
            {
                // Make sure the returned action is sane
                if (newPlaySoundAction.get_action() != null)
                {
                    // Called by Add
                    if (edit_action == null)
                    {
                        // Insert number of times specified by the form
                        for (int i = 0; i < newPlaySoundAction.get_times_to_add(); i++)
                        {
                            sequence_to_edit.Add(newPlaySoundAction.get_action());
                        }
                    }
                    // Called by Edit
                    else
                    {
                        // Replace the current action with the new from the form
                        sequence_to_edit.action_sequence[index] = newPlaySoundAction.get_action();
                    }
                }
                // form returned null 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_AddEditPlaySoundAction(Action edit_action, int index)
        {
            frm_AddEdit_PlaySoundAction newPlaySoundAction;
            if (edit_action == null)
            {
                newPlaySoundAction = new frm_AddEdit_PlaySoundAction();
            }
            else
            {
                newPlaySoundAction = new frm_AddEdit_PlaySoundAction(edit_action);
            }

            // On form OK we have changes (either new or edited action)
            if (newPlaySoundAction.ShowDialog() == DialogResult.OK)
            {
                // Make sure the returned action is sane
                if (newPlaySoundAction.get_action() != null)
                {
                    // Called by Add
                    if (edit_action == null)
                    {
                        // Insert number of times specified by the form
                        for (int i = 0; i < newPlaySoundAction.get_times_to_add(); i++)
                        {
                            sequence_to_edit.Add(newPlaySoundAction.get_action());
                        }
                    }
                    // Called by Edit
                    else
                    {
                        // Replace the current action with the new from the form
                        sequence_to_edit.action_sequence[index] = newPlaySoundAction.get_action();
                    }
                }
                // form returned null 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];
            }
        }