private static void RunImageCapture(object sender, EventArgs e) { //get input control CustomControls.CommandItemControl inputBox = (CustomControls.CommandItemControl)sender; UIPictureBox targetPictureBox = (UIPictureBox)inputBox.Tag; string imageSource = targetPictureBox.EncodedImage; if (string.IsNullOrEmpty(imageSource)) { MessageBox.Show("Please capture an image before attempting to test!"); return; } //hide all HideAllForms(); try { //run image recognition Core.Automation.Commands.ImageRecognitionCommand imageRecognitionCommand = new Core.Automation.Commands.ImageRecognitionCommand(); imageRecognitionCommand.v_ImageCapture = imageSource; imageRecognitionCommand.TestMode = true; imageRecognitionCommand.RunCommand(null); } catch (Exception ex) { MessageBox.Show("Error: " + ex.ToString()); } //show all forms ShowAllForms(); }
private void ShowVariableSelector(object sender, EventArgs e) { //create variable selector form UI.Forms.Supplemental.frmVariableSelector newVariableSelector = new Supplemental.frmVariableSelector(); //get copy of user variables and append system variables, then load to combobox var variableList = scriptVariables.Select(f => f.variableName).ToList(); variableList.AddRange(Core.Common.GenerateSystemVariables().Select(f => f.variableName)); newVariableSelector.lstVariables.Items.AddRange(variableList.ToArray()); //if user pressed "OK" if (newVariableSelector.ShowDialog() == DialogResult.OK) { //ensure that a variable was actually selected if (newVariableSelector.lstVariables.SelectedItem == null) { //return out as nothing was selected MessageBox.Show("There were no variables selected!"); return; } //grab the referenced input assigned to the 'insert variable' button instance CustomControls.CommandItemControl inputBox = (CustomControls.CommandItemControl)sender; //currently variable insertion is only available for simply textboxes TextBox targetTextbox = (TextBox)inputBox.Tag; //concat variable name with brackets [vVariable] as engine searches for the same targetTextbox.Text = targetTextbox.Text + string.Concat("[", newVariableSelector.lstVariables.SelectedItem.ToString(), "]"); } }
private static void ShowFolderSelector(object sender, EventArgs e, UI.Forms.frmCommandEditor editor) { FolderBrowserDialog fbd = new FolderBrowserDialog(); if (fbd.ShowDialog() == DialogResult.OK) { CustomControls.CommandItemControl inputBox = (CustomControls.CommandItemControl)sender; TextBox targetTextBox = (TextBox)inputBox.Tag; targetTextBox.Text = fbd.SelectedPath; } }
private static void ShowFileSelector(object sender, EventArgs e, UI.Forms.frmCommandEditor editor) { OpenFileDialog ofd = new OpenFileDialog(); if (ofd.ShowDialog() == DialogResult.OK) { CustomControls.CommandItemControl inputBox = (CustomControls.CommandItemControl)sender; //currently variable insertion is only available for simply textboxes TextBox targetTextbox = (TextBox)inputBox.Tag; //concat variable name with brackets [vVariable] as engine searches for the same targetTextbox.Text = ofd.FileName; } }
private static void ShowCodeBuilder(object sender, EventArgs e, UI.Forms.frmCommandEditor editor) { //get textbox text CustomControls.CommandItemControl commandItem = (CustomControls.CommandItemControl)sender; TextBox targetTextbox = (TextBox)commandItem.Tag; UI.Forms.Supplemental.frmCodeBuilder codeBuilder = new Forms.Supplemental.frmCodeBuilder(targetTextbox.Text); if (codeBuilder.ShowDialog() == DialogResult.OK) { targetTextbox.Text = codeBuilder.rtbCode.Text; } }
private void ShowImageCapture(object sender, EventArgs e) { HideAllForms(); var userAcceptance = MessageBox.Show(this, "The image capture process will now begin and display a screenshot of the current desktop in a custom full-screen window. You may stop the capture process at any time by pressing the 'ESC' key, or selecting 'Close' at the top left. Simply create the image by clicking once to start the rectangle and clicking again to finish. The image will be cropped to the boundary within the red rectangle. Shall we proceed?", "Image Capture", MessageBoxButtons.YesNo); if (userAcceptance == DialogResult.Yes) { Supplement_Forms.frmImageCapture imageCaptureForm = new Supplement_Forms.frmImageCapture(); if (imageCaptureForm.ShowDialog() == DialogResult.OK) { CustomControls.CommandItemControl inputBox = (CustomControls.CommandItemControl)sender; PictureBox targetPictureBox = (PictureBox)inputBox.Tag; targetPictureBox.Image = imageCaptureForm.userSelectedBitmap; targetPictureBox.Text = Core.Common.ImageToBase64(imageCaptureForm.userSelectedBitmap); } } ShowAllForms(); }
private static void ShowImageCapture(object sender, EventArgs e) { ApplicationSettings settings = new Core.ApplicationSettings().GetOrCreateApplicationSettings(); var minimizePreference = settings.ClientSettings.MinimizeToTray; if (minimizePreference) { settings.ClientSettings.MinimizeToTray = false; settings.Save(settings); } HideAllForms(); var userAcceptance = MessageBox.Show("The image capture process will now begin and display a screenshot of the current desktop in a custom full-screen window. You may stop the capture process at any time by pressing the 'ESC' key, or selecting 'Close' at the top left. Simply create the image by clicking once to start the rectangle and clicking again to finish. The image will be cropped to the boundary within the red rectangle. Shall we proceed?", "Image Capture", MessageBoxButtons.YesNo); if (userAcceptance == DialogResult.Yes) { Forms.Supplement_Forms.frmImageCapture imageCaptureForm = new Forms.Supplement_Forms.frmImageCapture(); if (imageCaptureForm.ShowDialog() == DialogResult.OK) { CustomControls.CommandItemControl inputBox = (CustomControls.CommandItemControl)sender; UIPictureBox targetPictureBox = (UIPictureBox)inputBox.Tag; targetPictureBox.Image = imageCaptureForm.userSelectedBitmap; var convertedImage = Core.Common.ImageToBase64(imageCaptureForm.userSelectedBitmap); var convertedLength = convertedImage.Length; targetPictureBox.EncodedImage = convertedImage; imageCaptureForm.Show(); } } ShowAllForms(); if (minimizePreference) { settings.ClientSettings.MinimizeToTray = true; settings.Save(settings); } }
public static void ShowVariableSelector(object sender, EventArgs e) { //create variable selector form UI.Forms.Supplemental.frmItemSelector newVariableSelector = new Forms.Supplemental.frmItemSelector(); //get copy of user variables and append system variables, then load to combobox var variableList = CurrentEditor.scriptVariables.Select(f => f.VariableName).ToList(); variableList.AddRange(Core.Common.GenerateSystemVariables().Select(f => f.VariableName)); newVariableSelector.lstVariables.Items.AddRange(variableList.ToArray()); //if user pressed "OK" if (newVariableSelector.ShowDialog() == DialogResult.OK) { //ensure that a variable was actually selected if (newVariableSelector.lstVariables.SelectedItem == null) { //return out as nothing was selected MessageBox.Show("There were no variables selected!"); return; } //grab the referenced input assigned to the 'insert variable' button instance CustomControls.CommandItemControl inputBox = (CustomControls.CommandItemControl)sender; //currently variable insertion is only available for simply textboxes //load settings var settings = new Core.ApplicationSettings().GetOrCreateApplicationSettings(); if (inputBox.Tag is TextBox) { TextBox targetTextbox = (TextBox)inputBox.Tag; //concat variable name with brackets [vVariable] as engine searches for the same targetTextbox.Text = targetTextbox.Text + string.Concat(settings.EngineSettings.VariableStartMarker, newVariableSelector.lstVariables.SelectedItem.ToString(), settings.EngineSettings.VariableEndMarker); } else if (inputBox.Tag is ComboBox) { ComboBox targetCombobox = (ComboBox)inputBox.Tag; //concat variable name with brackets [vVariable] as engine searches for the same targetCombobox.Text = targetCombobox.Text + string.Concat(settings.EngineSettings.VariableStartMarker, newVariableSelector.lstVariables.SelectedItem.ToString(), settings.EngineSettings.VariableEndMarker); } else if (inputBox.Tag is DataGridView) { DataGridView targetDGV = (DataGridView)inputBox.Tag; if (targetDGV.SelectedCells.Count == 0) { MessageBox.Show("Please make sure you have selected an action and selected a cell before attempting to insert a variable!", "No Cell Found", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (targetDGV.SelectedCells[0].ColumnIndex == 0) { MessageBox.Show("Invalid Cell Selected!", "Invalid Cell Selected", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } targetDGV.SelectedCells[0].Value = targetDGV.SelectedCells[0].Value + string.Concat(settings.EngineSettings.VariableStartMarker, newVariableSelector.lstVariables.SelectedItem.ToString(), settings.EngineSettings.VariableEndMarker); } } }