private void CreateWhileCondition(object sender, EventArgs e, IfrmCommandEditor parentEditor, ICommandControls commandControls) { var automationCommands = new List <AutomationCommand>() { CommandsHelper.ConvertToAutomationCommand(typeof(BeginWhileCommand)) }; IfrmCommandEditor editor = commandControls.CreateCommandEditorForm(automationCommands, null); editor.SelectedCommand = new BeginWhileCommand(); editor.ScriptContext = parentEditor.ScriptContext; editor.TypeContext = parentEditor.TypeContext; if (((Form)editor).ShowDialog() == DialogResult.OK) { //get data var configuredCommand = editor.SelectedCommand as BeginWhileCommand; var displayText = configuredCommand.GetDisplayValue(); var serializedData = JsonConvert.SerializeObject(configuredCommand); parentEditor.ScriptContext = editor.ScriptContext; parentEditor.TypeContext = editor.TypeContext; //add to list v_WhileConditionsTable.Rows.Add(displayText, serializedData); } commandControls.AddIntellisenseListBoxToCommandForm(); }
private void IfConditionHelper_CellContentClick(object sender, DataGridViewCellEventArgs e, IfrmCommandEditor parentEditor, ICommandControls commandControls) { 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 = commandControls.CreateBeginIfCommand(commandData); var automationCommands = new List <AutomationCommand>() { CommandsHelper.ConvertToAutomationCommand(ifCommand.GetType()) }; IfrmCommandEditor editor = commandControls.CreateCommandEditorForm(automationCommands, null); editor.SelectedCommand = ifCommand; editor.EditingCommand = ifCommand; editor.OriginalCommand = ifCommand; editor.CreationModeInstance = CreationMode.Edit; editor.ScriptEngineContext = parentEditor.ScriptEngineContext; editor.TypeContext = parentEditor.TypeContext; if (((Form)editor).ShowDialog() == DialogResult.OK) { parentEditor.ScriptEngineContext = editor.ScriptEngineContext; parentEditor.TypeContext = editor.TypeContext; var editedCommand = editor.SelectedCommand 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."); } } }