private void lstScriptActions_DoubleClick(object sender, EventArgs e) { if (lstScriptActions.SelectedItems.Count != 1) { return; } //bring up edit mode to edit the action ListViewItem selectedCommandItem = lstScriptActions.SelectedItems[0]; //create new command editor form UI.Forms.frmCommandEditor editCommand = new UI.Forms.frmCommandEditor(); //creation mode edit locks form to current command editCommand.creationMode = UI.Forms.frmCommandEditor.CreationMode.Edit; //set selected command from the listview item tag object which was assigned to the command var currentCommand = (Core.AutomationCommands.ScriptCommand)selectedCommandItem.Tag; //create clone of current command so databinding does not affect if changes are not saved editCommand.selectedCommand = Core.Common.Clone(currentCommand);; //set variables editCommand.scriptVariables = this.scriptVariables; //show edit command form and save changes on OK result if (editCommand.ShowDialog() == DialogResult.OK) { selectedCommandItem.Tag = editCommand.selectedCommand; selectedCommandItem.Text = editCommand.selectedCommand.GetDisplayValue(); //+ "(" + cmdDetails.SelectedVariables() + ")"; selectedCommandItem.SubItems.Add(editCommand.selectedCommand.GetDisplayValue()); } }
private void uiBtnCommandExplorer_Click(object sender, EventArgs e) { UI.Forms.frmCommandBrowser cmdBrowser = new UI.Forms.frmCommandBrowser(); if (cmdBrowser.ShowDialog() == DialogResult.OK) { //bring up new command configuration form var newCommandForm = new UI.Forms.frmCommandEditor(); newCommandForm.creationMode = UI.Forms.frmCommandEditor.CreationMode.Add; newCommandForm.scriptVariables = this.scriptVariables; newCommandForm.defaultStartupCommand = cmdBrowser.lblCommandName.Text; //if a command was selected if (newCommandForm.ShowDialog() == DialogResult.OK) { //add to listview AddCommandToListView(newCommandForm.selectedCommand); } } }
private void AddNewCommand(string specificCommand = "") { //bring up new command configuration form var newCommandForm = new UI.Forms.frmCommandEditor(); newCommandForm.creationMode = UI.Forms.frmCommandEditor.CreationMode.Add; newCommandForm.scriptVariables = this.scriptVariables; if (specificCommand != "") { newCommandForm.defaultStartupCommand = specificCommand; } //if a command was selected if (newCommandForm.ShowDialog() == DialogResult.OK) { //add to listview AddCommandToListView(newCommandForm.selectedCommand); } }
private void lstScriptActions_DoubleClick(object sender, EventArgs e) { if (lstScriptActions.SelectedItems.Count != 1) { return; } //bring up edit mode to edit the action ListViewItem selectedCommandItem = lstScriptActions.SelectedItems[0]; //set selected command from the listview item tag object which was assigned to the command var currentCommand = (Core.AutomationCommands.ScriptCommand)selectedCommandItem.Tag; //check if editing a sequence if (currentCommand is Core.AutomationCommands.SequenceCommand) { if (editMode) { MessageBox.Show("Embedding Sequence Commands within Sequence Commands not yet supported."); return; } //get sequence events Core.AutomationCommands.SequenceCommand sequence = (Core.AutomationCommands.SequenceCommand)currentCommand; frmScriptBuilder newBuilder = new frmScriptBuilder(); //append to new builder foreach (var cmd in sequence.v_scriptActions) { newBuilder.lstScriptActions.Items.Add(CreateScriptCommandListViewItem(cmd)); } //apply editor style format newBuilder.ApplyEditorFormat(); //if data has been changed if (newBuilder.ShowDialog() == DialogResult.OK) { //create updated list List <Core.AutomationCommands.ScriptCommand> updatedList = new List <Core.AutomationCommands.ScriptCommand>(); //update to list for (int i = 0; i < newBuilder.lstScriptActions.Items.Count; i++) { var command = (Core.AutomationCommands.ScriptCommand)newBuilder.lstScriptActions.Items[i].Tag; updatedList.Add(command); } //apply new list to existing sequence sequence.v_scriptActions = updatedList; //update label selectedCommandItem.Text = sequence.GetDisplayValue(); } } else { //create new command editor form UI.Forms.frmCommandEditor editCommand = new UI.Forms.frmCommandEditor(); //creation mode edit locks form to current command editCommand.creationMode = UI.Forms.frmCommandEditor.CreationMode.Edit; //create clone of current command so databinding does not affect if changes are not saved editCommand.selectedCommand = Core.Common.Clone(currentCommand);; //set variables editCommand.scriptVariables = this.scriptVariables; //show edit command form and save changes on OK result if (editCommand.ShowDialog() == DialogResult.OK) { selectedCommandItem.Tag = editCommand.selectedCommand; selectedCommandItem.Text = editCommand.selectedCommand.GetDisplayValue(); //+ "(" + cmdDetails.SelectedVariables() + ")"; selectedCommandItem.SubItems.Add(editCommand.selectedCommand.GetDisplayValue()); } } }