public override List <Control> Render(IfrmCommandEditor editor)
        {
            base.Render(editor);


            RenderedControls.Add(UI.CustomControls.CommandControls.CreateDefaultLabelFor("v_WindowName", this));
            var WindowNameControl = UI.CustomControls.CommandControls.CreateStandardComboboxFor("v_WindowName", this).AddWindowNames();

            RenderedControls.AddRange(UI.CustomControls.CommandControls.CreateUIHelpersFor("v_WindowName", this, new Control[] { WindowNameControl }, editor));
            RenderedControls.Add(WindowNameControl);

            taskt.UI.CustomControls.CommandItemControl helperControl = new taskt.UI.CustomControls.CommandItemControl();

            var textInputGroup = CommandControls.CreateDefaultInputGroupFor("v_TextToSend", this, editor);

            RenderedControls.AddRange(textInputGroup);

            InputText = (TextBox)textInputGroup[2];

            helperControl.ForeColor      = Color.White;
            helperControl.CommandDisplay = "Encrypt Text";
            helperControl.Click         += HelperControl_Click;
            RenderedControls.Add(helperControl);

            RenderedControls.AddRange(CommandControls.CreateDefaultDropdownGroupFor("v_EncryptionOption", this, editor));

            return(RenderedControls);
        }
Exemplo n.º 2
0
        private static void RunImageCapture(object sender, EventArgs e)
        {
            //get input control
            CommandItemControl inputBox         = (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
                SurfaceAutomationCommand surfaceAutomationCommand = new SurfaceAutomationCommand();
                surfaceAutomationCommand.v_ImageCapture = imageSource;
                surfaceAutomationCommand.TestMode       = true;
                surfaceAutomationCommand.RunCommand(null);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.ToString());
            }
            //show all forms
            ShowAllForms();
        }
Exemplo n.º 3
0
        public static void ShowElementSelector(object sender, EventArgs e)
        {
            //create element selector form
            frmElementSelector newElementSelector = new frmElementSelector();

            //get copy of user element and append system elements, then load to combobox
            var elementList = CurrentEditor.ScriptElements.Select(f => "(" + f.ElementType.Description() + ") " + f.ElementName).ToList();

            newElementSelector.lstElements.Items.AddRange(elementList.ToArray());

            //if user pressed "OK"
            if (newElementSelector.ShowDialog() == DialogResult.OK)
            {
                //ensure that a element was actually selected
                if (newElementSelector.lstElements.SelectedItem == null)
                {
                    //return out as nothing was selected
                    MessageBox.Show("There were no elements selected!");
                    return;
                }

                //grab the referenced input assigned to the 'insert element' button instance
                CommandItemControl inputBox = (CommandItemControl)sender;
                //currently element insertion is only available for simply textboxes

                Regex regex = new Regex(@"\([\w\s]+\)\s");
                if (inputBox.Tag is TextBox)
                {
                    TextBox targetTextbox = (TextBox)inputBox.Tag;
                    //concat element name with brackets <vElement> as engine searches for the same
                    targetTextbox.Text = targetTextbox.Text + "<" + regex.Replace(newElementSelector.lstElements.SelectedItem.ToString(), "") + ">";
                }
                else if (inputBox.Tag is ComboBox)
                {
                    ComboBox targetCombobox = (ComboBox)inputBox.Tag;
                    //concat element name with brackets <vElement> as engine searches for the same
                    targetCombobox.Text = targetCombobox.Text + "<" + regex.Replace(newElementSelector.lstElements.SelectedItem.ToString(), "") + ">";
                }
                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 an element!", "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 + "<" + newElementSelector.lstElements.SelectedItem.ToString() + ">";
                }
            }
        }
Exemplo n.º 4
0
        private static void ShowFolderSelector(object sender, EventArgs e, IfrmCommandEditor editor)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                CommandItemControl inputBox      = (CommandItemControl)sender;
                TextBox            targetTextBox = (TextBox)inputBox.Tag;
                targetTextBox.Text = fbd.SelectedPath;
            }
        }
Exemplo n.º 5
0
        private static void ShowFileSelector(object sender, EventArgs e, IfrmCommandEditor editor)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                CommandItemControl inputBox = (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;
            }
        }
Exemplo n.º 6
0
        private static void ShowCodeBuilder(object sender, EventArgs e, IfrmCommandEditor editor)
        {
            //get textbox text
            CommandItemControl commandItem   = (CommandItemControl)sender;
            TextBox            targetTextbox = (TextBox)commandItem.Tag;

            frmCodeBuilder codeBuilder = new frmCodeBuilder(targetTextbox.Text);

            if (codeBuilder.ShowDialog() == DialogResult.OK)
            {
                targetTextbox.Text = codeBuilder.rtbCode.Text;
            }
        }
Exemplo n.º 7
0
        private static void ShowImageCapture(object sender, EventArgs e)
        {
            ApplicationSettings settings = new 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)
            {
                frmImageCapture imageCaptureForm = new frmImageCapture();

                if (imageCaptureForm.ShowDialog() == DialogResult.OK)
                {
                    CommandItemControl inputBox         = (CommandItemControl)sender;
                    UIPictureBox       targetPictureBox = (UIPictureBox)inputBox.Tag;
                    targetPictureBox.Image = imageCaptureForm.UserSelectedBitmap;
                    var convertedImage = Common.ImageToBase64(imageCaptureForm.UserSelectedBitmap);
                    targetPictureBox.EncodedImage = convertedImage;
                    imageCaptureForm.Close();
                }
            }

            ShowAllForms();

            if (minimizePreference)
            {
                settings.ClientSettings.MinimizeToTray = true;
                settings.Save(settings);
            }
        }
Exemplo n.º 8
0
        public override List <Control> Render(frmCommandEditor editor)
        {
            base.Render(editor);

            RenderedControls.AddRange(CommandControls.CreateDefaultInputGroupFor("v_DataTableName", this, editor));


            RenderedControls.AddRange(CommandControls.CreateDataGridViewGroupFor("v_AddDataDataTable", this, editor));

            taskt.UI.CustomControls.CommandItemControl loadSchemaControl = new taskt.UI.CustomControls.CommandItemControl();
            loadSchemaControl.ForeColor      = System.Drawing.Color.White;
            loadSchemaControl.CommandDisplay = "Load Column Names From Existing Table";
            loadSchemaControl.Click         += LoadSchemaControl_Click;
            RenderedControls.Add(loadSchemaControl);

            DataTableCreationCommands = editor.configuredCommands.Where(f => f is CreateDataTableCommand).Select(f => (CreateDataTableCommand)f).ToList();



            return(RenderedControls);
        }
Exemplo n.º 9
0
        public static void ShowVariableSelector(object sender, EventArgs e)
        {
            //create variable selector form
            frmVariableSelector newVariableSelector = new frmVariableSelector();

            //get copy of user variables and append system variables, then load to combobox
            var variableList = CurrentEditor.ScriptVariables.Select(f => f.VariableName).ToList();

            variableList.AddRange(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
                CommandItemControl inputBox = (CommandItemControl)sender;
                //currently variable insertion is only available for simply textboxes

                //load settings
                var settings = new 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("{",
                                                                            newVariableSelector.lstVariables.SelectedItem.ToString(), "}");
                }
                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("{",
                                                                              newVariableSelector.lstVariables.SelectedItem.ToString(), "}");
                }
                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("{", newVariableSelector.lstVariables.SelectedItem.ToString(), "}");
                }
            }
        }
Exemplo n.º 10
0
        public static List <Control> CreateUIHelpersFor(string parameterName, ScriptCommand parent, Control[] targetControls,
                                                        IfrmCommandEditor editor)
        {
            var variableProperties = parent.GetType().GetProperties().Where(f => f.Name == parameterName).FirstOrDefault();
            var propertyUIHelpers  = variableProperties.GetCustomAttributes(typeof(PropertyUIHelper), true);
            var controlList        = new List <Control>();

            if (propertyUIHelpers.Count() == 0)
            {
                return(controlList);
            }

            foreach (PropertyUIHelper attrib in propertyUIHelpers)
            {
                CommandItemControl helperControl = new CommandItemControl();
                helperControl.Padding    = new Padding(10, 0, 0, 0);
                helperControl.ForeColor  = Color.AliceBlue;
                helperControl.Font       = new Font("Segoe UI Semilight", 10);
                helperControl.Name       = parameterName + "_helper";
                helperControl.Tag        = targetControls.FirstOrDefault();
                helperControl.HelperType = attrib.AdditionalHelper;

                switch (attrib.AdditionalHelper)
                {
                case UIAdditionalHelperType.ShowVariableHelper:
                    //show variable selector
                    helperControl.CommandImage   = Resources.command_parse;
                    helperControl.CommandDisplay = "Insert Variable";
                    helperControl.Click         += (sender, e) => ShowVariableSelector(sender, e);
                    break;

                case UIAdditionalHelperType.ShowElementHelper:
                    //show element selector
                    helperControl.CommandImage   = Resources.command_element;
                    helperControl.CommandDisplay = "Insert Element";
                    helperControl.Click         += (sender, e) => ShowElementSelector(sender, e);
                    break;

                case UIAdditionalHelperType.ShowFileSelectionHelper:
                    //show file selector
                    helperControl.CommandImage   = Resources.command_files;
                    helperControl.CommandDisplay = "Select a File";
                    helperControl.Click         += (sender, e) => ShowFileSelector(sender, e, (frmCommandEditor)editor);
                    break;

                case UIAdditionalHelperType.ShowFolderSelectionHelper:
                    //show file selector
                    helperControl.CommandImage   = Resources.command_folders;
                    helperControl.CommandDisplay = "Select a Folder";
                    helperControl.Click         += (sender, e) => ShowFolderSelector(sender, e, (frmCommandEditor)editor);
                    break;

                case UIAdditionalHelperType.ShowImageCaptureHelper:
                    //show file selector
                    helperControl.CommandImage   = Resources.command_camera;
                    helperControl.CommandDisplay = "Capture Reference Image";
                    helperControl.Click         += (sender, e) => ShowImageCapture(sender, e);

                    CommandItemControl testRun = new CommandItemControl();
                    testRun.Padding   = new Padding(10, 0, 0, 0);
                    testRun.ForeColor = Color.AliceBlue;

                    testRun.CommandImage   = Resources.command_camera;
                    testRun.CommandDisplay = "Run Image Recognition Test";
                    testRun.ForeColor      = Color.AliceBlue;
                    testRun.Font           = new Font("Segoe UI Semilight", 10);
                    testRun.Tag            = targetControls.FirstOrDefault();
                    testRun.Click         += (sender, e) => RunImageCapture(sender, e);
                    controlList.Add(testRun);
                    break;

                case UIAdditionalHelperType.ShowCodeBuilder:
                    //show variable selector
                    helperControl.CommandImage   = Resources.command_script;
                    helperControl.CommandDisplay = "Code Builder";
                    helperControl.Click         += (sender, e) => ShowCodeBuilder(sender, e, (frmCommandEditor)editor);
                    break;

                case UIAdditionalHelperType.ShowMouseCaptureHelper:
                    helperControl.CommandImage   = Resources.command_input;
                    helperControl.CommandDisplay = "Capture Mouse Position";
                    helperControl.ForeColor      = Color.AliceBlue;
                    helperControl.Click         += (sender, e) => ShowMouseCaptureForm(sender, e);
                    break;

                case UIAdditionalHelperType.ShowElementRecorder:
                    //show variable selector
                    helperControl.CommandImage   = Resources.command_camera;
                    helperControl.CommandDisplay = "Element Recorder";
                    helperControl.Click         += (sender, e) => ShowElementRecorder(sender, e, (frmCommandEditor)editor);
                    break;

                case UIAdditionalHelperType.GenerateDLLParameters:
                    //show variable selector
                    helperControl.CommandImage   = Resources.command_run_code;
                    helperControl.CommandDisplay = "Generate Parameters";
                    helperControl.Click         += (sender, e) => GenerateDLLParameters(sender, e);
                    break;

                case UIAdditionalHelperType.ShowDLLExplorer:
                    //show variable selector
                    helperControl.CommandImage   = Resources.command_run_code;
                    helperControl.CommandDisplay = "Launch DLL Explorer";
                    helperControl.Click         += (sender, e) => ShowDLLExplorer(sender, e);
                    break;

                case UIAdditionalHelperType.AddInputParameter:
                    //show variable selector
                    helperControl.CommandImage   = Resources.command_run_code;
                    helperControl.CommandDisplay = "Add Input Parameter";
                    helperControl.Click         += (sender, e) => AddInputParameter(sender, e, (frmCommandEditor)editor);
                    break;

                case UIAdditionalHelperType.ShowHTMLBuilder:
                    helperControl.CommandImage   = Resources.command_web;
                    helperControl.CommandDisplay = "Launch HTML Builder";
                    helperControl.Click         += (sender, e) => ShowHTMLBuilder(sender, e, (frmCommandEditor)editor);
                    break;

                case UIAdditionalHelperType.ShowIfBuilder:
                    //show variable selector
                    helperControl.CommandImage   = Resources.command_begin_if;
                    helperControl.CommandDisplay = "Add New If Statement";
                    break;

                case UIAdditionalHelperType.ShowLoopBuilder:
                    //show variable selector
                    helperControl.CommandImage   = Resources.command_startloop;
                    helperControl.CommandDisplay = "Add New Loop Statement";
                    break;

                    //default:
                    //    MessageBox.Show("Command Helper does not exist for: " + attrib.additionalHelper.ToString());
                    //    break;
                }

                controlList.Add(helperControl);
            }

            return(controlList);
        }