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 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); } }