private List <string> ShowInput(InputCommand inputs) { var inputForm = new frmUserInput { InputCommand = inputs }; var dialogResult = inputForm.ShowDialog(); if (dialogResult == DialogResult.OK) { var responses = new List <string>(); foreach (var ctrl in inputForm.InputControls) { if (ctrl is CheckBox) { var checkboxCtrl = (CheckBox)ctrl; responses.Add(checkboxCtrl.Checked.ToString()); } else { responses.Add(ctrl.Text); } } return(responses); } else { return(null); } }
public static string GetUserInput(string title, string defaultValue, Form owner) { var form = new frmUserInput(); form.Value = defaultValue; form.Title = title; form.ShowDialog(owner); return(form.Value); }
public List <string> ShowInput(InputCommand inputs) { if (InvokeRequired) { var d = new ShowInputDelegate(ShowInput); Invoke(d, new object[] { inputs }); return(null); } else { var inputForm = new frmUserInput(); inputForm.InputCommand = inputs; var dialogResult = inputForm.ShowDialog(); if (dialogResult == DialogResult.OK) { var responses = new List <string>(); foreach (var ctrl in inputForm.InputControls) { if (ctrl is CheckBox) { var checkboxCtrl = (CheckBox)ctrl; responses.Add(checkboxCtrl.Checked.ToString()); } else { responses.Add(ctrl.Text); } } return(responses); } else { return(null); } } }
public override void RunCommand(object sender) { var engine = (IAutomationEngineInstance)sender; var header = v_InputHeader.ConvertUserVariableToString(engine); var directions = v_InputDirections.ConvertUserVariableToString(engine); //translate variables for each label foreach (DataRow rw in v_UserInputConfig.Rows) { rw["DefaultValue"] = rw["DefaultValue"].ToString().ConvertUserVariableToString(engine); string targetVariable = rw["StoreInVariable"].ToString(); if (string.IsNullOrEmpty(targetVariable)) { var message = "User Input question '" + rw["Label"] + "' is missing variables to apply results to! " + "Results for the item will not be tracked. To fix this, assign a variable in the designer!"; MessageBox.Show(message, "Input Command", MessageBoxButtons.OK, MessageBoxIcon.Information); } } //get input from user List <object> userInputs = new List <object>(); var inputForm = new frmUserInput(header, directions, v_UserInputConfig); var dialogResult = inputForm.ShowDialog(); if (dialogResult == DialogResult.OK) { foreach (var ctrl in inputForm.InputControls) { if (ctrl is CheckBox) { var checkboxCtrl = (CheckBox)ctrl; userInputs.Add(checkboxCtrl.Checked); } else { userInputs.Add(ctrl.Text); } } inputForm.Dispose(); } else { inputForm.Dispose(); userInputs = null; } //check if user provided input if (userInputs != null) { //loop through each input and assign for (int i = 0; i < userInputs.Count; i++) { //get target variable string targetVariable = v_UserInputConfig.Rows[i]["StoreInVariable"].ToString(); //store user data in variable if (!string.IsNullOrEmpty(targetVariable)) { userInputs[i].StoreInUserVariable(engine, targetVariable, nameof(v_UserInputConfig), this); } } } }