private void AddNewCommand(string specificCommand = "") { //bring up new command configuration form frmCommandEditor newCommandForm = new frmCommandEditor(_automationCommands, GetConfiguredCommands()) { CreationModeInstance = CreationMode.Add, ScriptVariables = _scriptVariables, ScriptElements = _scriptElements }; if (specificCommand != "") { newCommandForm.DefaultStartupCommand = specificCommand; } newCommandForm.ProjectPath = ScriptProjectPath; newCommandForm.HTMLElementRecorderURL = HTMLElementRecorderURL; //if a command was selected if (newCommandForm.ShowDialog() == DialogResult.OK) { //add to listview CreateUndoSnapshot(); AddCommandToListView(newCommandForm.SelectedCommand); } if (newCommandForm.SelectedCommand.CommandName == "SeleniumElementActionCommand") { CreateUndoSnapshot(); _scriptElements = newCommandForm.ScriptElements; HTMLElementRecorderURL = newCommandForm.HTMLElementRecorderURL; } }
private void IfConditionHelper_CellContentClick(object sender, DataGridViewCellEventArgs e) { var senderGrid = (DataGridView)sender; if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0) { var buttonSelected = senderGrid.Rows[e.RowIndex].Cells[e.ColumnIndex] as DataGridViewButtonCell; var selectedRow = v_IfConditionsTable.Rows[e.RowIndex]; if (buttonSelected.Value.ToString() == "Edit") { //launch editor var statement = selectedRow["Statement"]; var commandData = selectedRow["CommandData"].ToString(); var ifCommand = JsonConvert.DeserializeObject <BeginIfCommand>(commandData); var automationCommands = CommandControls.GenerateCommandsandControls().Where(f => f.Command is BeginIfCommand).ToList(); frmCommandEditor editor = new frmCommandEditor(automationCommands, null); editor.SelectedCommand = ifCommand; editor.EditingCommand = ifCommand; editor.OriginalCommand = ifCommand; editor.CreationModeInstance = CreationMode.Edit; editor.ScriptVariables = _scriptVariables; editor.ScriptElements = _scriptElements; if (editor.ShowDialog() == DialogResult.OK) { var editedCommand = editor.EditingCommand as BeginIfCommand; var displayText = editedCommand.GetDisplayValue(); var serializedData = JsonConvert.SerializeObject(editedCommand); selectedRow["Statement"] = displayText; selectedRow["CommandData"] = serializedData; } } else if (buttonSelected.Value.ToString() == "Delete") { //delete v_IfConditionsTable.Rows.Remove(selectedRow); } else { throw new NotImplementedException("Requested Action is not implemented."); } } }
private void AddNewCommand(string specificCommand = "") { //bring up new command configuration form frmCommandEditor newCommandForm = new frmCommandEditor(_automationCommands, GetConfiguredCommands(), _typeContext) { CreationModeInstance = CreationMode.Add }; if (specificCommand != "") { newCommandForm.DefaultStartupCommand = specificCommand; } newCommandForm.ScriptEngineContext.Variables = new List <ScriptVariable>(_scriptVariables); newCommandForm.ScriptEngineContext.Arguments = new List <ScriptArgument>(_scriptArguments); newCommandForm.ScriptEngineContext.Elements = new List <ScriptElement>(_scriptElements); newCommandForm.ScriptEngineContext.Container = AContainer; newCommandForm.ScriptEngineContext.ProjectPath = ScriptProjectPath; newCommandForm.HTMLElementRecorderURL = HTMLElementRecorderURL; //if a command was selected if (newCommandForm.ShowDialog() == DialogResult.OK) { //add to listview CreateUndoSnapshot(); AddCommandToListView(newCommandForm.SelectedCommand); _scriptVariables = newCommandForm.ScriptEngineContext.Variables; _scriptArguments = newCommandForm.ScriptEngineContext.Arguments; uiScriptTabControl.SelectedTab.Tag = new ScriptObject(_scriptVariables, _scriptArguments, _scriptElements); } if (newCommandForm.SelectedCommand.CommandName == "SeleniumElementActionCommand") { CreateUndoSnapshot(); _scriptElements = newCommandForm.ScriptEngineContext.Elements; HTMLElementRecorderURL = newCommandForm.HTMLElementRecorderURL; } ResetVariableArgumentBindings(); newCommandForm.Dispose(); }
private void CreateLoopCondition(object sender, EventArgs e) { var automationCommands = UIControlsHelper.GenerateCommandsandControls().Where(f => f.Command is BeginLoopCommand).ToList(); frmCommandEditor editor = new frmCommandEditor(automationCommands, null); editor.SelectedCommand = new BeginLoopCommand(); var res = editor.ShowDialog(); if (res == DialogResult.OK) { //get data var configuredCommand = editor.SelectedCommand as BeginLoopCommand; var displayText = configuredCommand.GetDisplayValue(); var serializedData = JsonConvert.SerializeObject(configuredCommand); //add to list v_LoopConditionsTable.Rows.Add(displayText, serializedData); } }
private void AddNewCommand(string specificCommand = "") { //bring up new command configuration form frmCommandEditor newCommandForm = new frmCommandEditor(AutomationCommands, GetConfiguredCommands(), TypeContext) { CreationModeInstance = CreationMode.Add }; if (specificCommand != "") { newCommandForm.DefaultStartupCommand = specificCommand; } newCommandForm.ScriptContext = ScriptContext; newCommandForm.AContainer = AContainer; newCommandForm.ProjectPath = ScriptProjectPath; newCommandForm.HTMLElementRecorderURL = HTMLElementRecorderURL; //if a command was selected if (newCommandForm.ShowDialog() == DialogResult.OK) { //add to listview CreateUndoSnapshot(); AddCommandToListView(newCommandForm.SelectedCommand); } if (newCommandForm.SelectedCommand.CommandName == "SeleniumElementActionCommand") { CreateUndoSnapshot(); HTMLElementRecorderURL = newCommandForm.HTMLElementRecorderURL; } ResetVariableArgumentBindings(); newCommandForm.Dispose(); ScriptContext.AddIntellisenseControls(Controls); }
private void lstScriptActions_DoubleClick(object sender, EventArgs e) { try { if (SelectedTabScriptActions.SelectedItems.Count != 1) { return; } //bring up edit mode to edit the action ListViewItem selectedCommandItem = SelectedTabScriptActions.SelectedItems[0]; //set selected command from the listview item tag object which was assigned to the command var currentCommand = (ScriptCommand)selectedCommandItem.Tag; //create new command editor form frmCommandEditor editCommand = new frmCommandEditor(_automationCommands, GetConfiguredCommands(), TypeContext); editCommand.ScriptEngineContext.Container = AContainer; //creation mode edit locks form to current command editCommand.CreationModeInstance = CreationMode.Edit; editCommand.EditingCommand = currentCommand; //create clone of current command so databinding does not affect if changes are not saved editCommand.OriginalCommand = CommonMethods.Clone(currentCommand); editCommand.ScriptEngineContext.Variables = new List <ScriptVariable>(ScriptVariables); editCommand.ScriptEngineContext.Arguments = new List <ScriptArgument>(ScriptArguments); editCommand.ScriptEngineContext.Elements = new List <ScriptElement>(ScriptElements); editCommand.ScriptEngineContext.ProjectPath = ScriptProjectPath; if (currentCommand.CommandName == "SeleniumElementActionCommand") { editCommand.HTMLElementRecorderURL = HTMLElementRecorderURL; } //show edit command form and save changes on OK result if (editCommand.ShowDialog() == DialogResult.OK) { CreateUndoSnapshot(); selectedCommandItem.Tag = editCommand.SelectedCommand; selectedCommandItem.Text = editCommand.SelectedCommand.GetDisplayValue(); selectedCommandItem.SubItems.Add(editCommand.SelectedCommand.GetDisplayValue()); ScriptVariables = editCommand.ScriptEngineContext.Variables; ScriptArguments = editCommand.ScriptEngineContext.Arguments; } if (editCommand.SelectedCommand.CommandName == "SeleniumElementActionCommand") { CreateUndoSnapshot(); ScriptElements = editCommand.ScriptEngineContext.Elements; HTMLElementRecorderURL = editCommand.HTMLElementRecorderURL; } ResetVariableArgumentBindings(); editCommand.Dispose(); } catch (Exception ex) { Notify($"Error: {ex.Message}", Color.Red); } }
private void lstScriptActions_DoubleClick(object sender, EventArgs e) { if (_selectedTabScriptActions.SelectedItems.Count != 1) { return; } //bring up edit mode to edit the action ListViewItem selectedCommandItem = _selectedTabScriptActions.SelectedItems[0]; //set selected command from the listview item tag object which was assigned to the command var currentCommand = (ScriptCommand)selectedCommandItem.Tag; //check if editing a sequence if (currentCommand is SequenceCommand) { if (_editMode) { MessageBox.Show("Embedding Sequence Commands within Sequence Commands not yet supported."); return; } //get sequence events SequenceCommand sequence = (SequenceCommand)currentCommand; frmScriptBuilder newBuilder = new frmScriptBuilder(); newBuilder.ScriptProject = ScriptProject; newBuilder.ScriptProjectPath = ScriptProjectPath; //add variables/elements newBuilder._scriptVariables = _scriptVariables; newBuilder._scriptElements = _scriptElements; TabPage newtabPage = new TabPage("Sequence"); newtabPage.Name = "Sequence"; newtabPage.ToolTipText = "Sequence"; newBuilder.uiScriptTabControl.TabPages.Add(newtabPage); newtabPage.Controls.Add(newBuilder._selectedTabScriptActions); newBuilder.uiScriptTabControl.SelectedTab = newtabPage; //append to new builder foreach (var cmd in sequence.ScriptActions) { newBuilder._selectedTabScriptActions.Items.Add(CreateScriptCommandListViewItem(cmd)); } //apply editor style format newBuilder.ApplyEditorFormat(sequence.v_Comment); newBuilder._parentBuilder = this; //if data has been changed if (newBuilder.ShowDialog() == DialogResult.OK) { CreateUndoSnapshot(); //create updated list List <ScriptCommand> updatedList = new List <ScriptCommand>(); //update to list for (int i = 0; i < newBuilder._selectedTabScriptActions.Items.Count; i++) { var command = (ScriptCommand)newBuilder._selectedTabScriptActions.Items[i].Tag; updatedList.Add(command); } //apply new list to existing sequence sequence.ScriptActions = updatedList; sequence.v_Comment = newBuilder.Text; //update label selectedCommandItem.Text = sequence.GetDisplayValue(); //update variables/elements _scriptVariables = newBuilder._scriptVariables; _scriptElements = newBuilder._scriptElements; } } else { //create new command editor form frmCommandEditor editCommand = new frmCommandEditor(_automationCommands, GetConfiguredCommands()); //creation mode edit locks form to current command editCommand.CreationModeInstance = CreationMode.Edit; //editCommand.defaultStartupCommand = currentCommand.SelectionName; editCommand.EditingCommand = currentCommand; //create clone of current command so databinding does not affect if changes are not saved editCommand.OriginalCommand = Common.Clone(currentCommand); //set variables editCommand.ScriptVariables = _scriptVariables; //set elements editCommand.ScriptElements = _scriptElements; editCommand.ProjectPath = ScriptProjectPath; if (currentCommand.CommandName == "SeleniumElementActionCommand") { editCommand.HTMLElementRecorderURL = HTMLElementRecorderURL; } //show edit command form and save changes on OK result if (editCommand.ShowDialog() == DialogResult.OK) { CreateUndoSnapshot(); selectedCommandItem.Tag = editCommand.SelectedCommand; selectedCommandItem.Text = editCommand.SelectedCommand.GetDisplayValue(); //+ "(" + cmdDetails.SelectedVariables() + ")"; selectedCommandItem.SubItems.Add(editCommand.SelectedCommand.GetDisplayValue()); } if (editCommand.SelectedCommand.CommandName == "SeleniumElementActionCommand") { CreateUndoSnapshot(); _scriptElements = editCommand.ScriptElements; HTMLElementRecorderURL = editCommand.HTMLElementRecorderURL; } } }