コード例 #1
0
        private void lstScriptActions_DoubleClick(object sender, EventArgs e)
        {
            if (lstScriptActions.SelectedItems.Count != 1)
            {
                return;
            }

            //bring up edit mode to edit the action
            ListViewItem selectedCommandItem = lstScriptActions.SelectedItems[0];

            //create new command editor form
            UI.Forms.frmCommandEditor editCommand = new UI.Forms.frmCommandEditor();

            //creation mode edit locks form to current command
            editCommand.creationMode = UI.Forms.frmCommandEditor.CreationMode.Edit;

            //set selected command from the listview item tag object which was assigned to the command
            var currentCommand = (Core.AutomationCommands.ScriptCommand)selectedCommandItem.Tag;

            //create clone of current command so databinding does not affect if changes are not saved
            editCommand.selectedCommand = Core.Common.Clone(currentCommand);;

            //set variables
            editCommand.scriptVariables = this.scriptVariables;

            //show edit command form and save changes on OK result
            if (editCommand.ShowDialog() == DialogResult.OK)
            {
                selectedCommandItem.Tag  = editCommand.selectedCommand;
                selectedCommandItem.Text = editCommand.selectedCommand.GetDisplayValue(); //+ "(" + cmdDetails.SelectedVariables() + ")";
                selectedCommandItem.SubItems.Add(editCommand.selectedCommand.GetDisplayValue());
            }
        }
コード例 #2
0
        public void Bind(UI.Forms.frmCommandEditor editor)
        {
            //preference to preload is false
            //if (UIControls is null)
            //{
            this.RenderUIComponents(editor);
            //}

            foreach (var ctrl in UIControls)
            {
                if (ctrl.DataBindings.Count > 0)
                {
                    var newBindingList = new List <Binding>();
                    foreach (Binding binding in ctrl.DataBindings)
                    {
                        newBindingList.Add(new Binding(binding.PropertyName, Command, binding.BindingMemberInfo.BindingField, false, DataSourceUpdateMode.OnPropertyChanged));
                    }

                    ctrl.DataBindings.Clear();

                    foreach (var newBinding in newBindingList)
                    {
                        ctrl.DataBindings.Add(newBinding);
                    }
                }

                if (ctrl is CommandItemControl)
                {
                    var control = (CommandItemControl)ctrl;
                    switch (control.HelperType)
                    {
                    case Core.Automation.Attributes.PropertyAttributes.PropertyUIHelper.UIAdditionalHelperType.ShowVariableHelper:
                        control.DataSource = editor.scriptVariables;
                        break;

                    default:
                        break;
                    }
                }

                //if (ctrl is UIPictureBox)
                //{

                //    var typedControl = (UIPictureBox)InputControl;

                //}

                //Todo: helper for loading variables, move to attribute
                if ((ctrl.Name == "v_userVariableName") && (ctrl is ComboBox))
                {
                    var variableCbo = (ComboBox)ctrl;
                    variableCbo.Items.Clear();
                    foreach (var var in editor.scriptVariables)
                    {
                        variableCbo.Items.Add(var.VariableName);
                    }
                }
            }
        }
コード例 #3
0
        private static void AddInputParameter(object sender, EventArgs e, UI.Forms.frmCommandEditor editor)
        {
            DataGridView inputControl = (DataGridView)CurrentEditor.flw_InputVariables.Controls["v_UserInputConfig"];
            var          inputTable   = (DataTable)inputControl.DataSource;
            var          newRow       = inputTable.NewRow();

            newRow["Size"] = "500,100";
            inputTable.Rows.Add(newRow);
        }
コード例 #4
0
        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;
            }
        }
コード例 #5
0
        private static void ShowHTMLBuilder(object sender, EventArgs e, UI.Forms.frmCommandEditor editor)
        {
            var htmlForm = new UI.Forms.Supplemental.frmHTMLBuilder();

            RichTextBox inputControl = (RichTextBox)editor.flw_InputVariables.Controls["v_InputHTML"];

            htmlForm.rtbHTML.Text = inputControl.Text;

            if (htmlForm.ShowDialog() == DialogResult.OK)
            {
                inputControl.Text = htmlForm.rtbHTML.Text;
            }
        }
コード例 #6
0
        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;
            }
        }
コード例 #7
0
        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;
            }
        }
コード例 #8
0
        private void uiBtnRunScript_Click(object sender, EventArgs e)
        {
            if (ScriptFilePath == null)
            {
                return;
            }

            UI.Forms.frmCommandEditor CommandEditor = new UI.Forms.frmCommandEditor(ScriptFilePath);


            Notify("Running Script..");
            UI.Forms.frmScriptEngine newEngine = new UI.Forms.frmScriptEngine(ScriptFilePath, this);
            newEngine.callBackForm = this;
            newEngine.Show();
        }
コード例 #9
0
 private void uiBtnCommandExplorer_Click(object sender, EventArgs e)
 {
     UI.Forms.frmCommandBrowser cmdBrowser = new UI.Forms.frmCommandBrowser();
     if (cmdBrowser.ShowDialog() == DialogResult.OK)
     {
         //bring up new command configuration form
         var newCommandForm = new UI.Forms.frmCommandEditor();
         newCommandForm.creationMode          = UI.Forms.frmCommandEditor.CreationMode.Add;
         newCommandForm.scriptVariables       = this.scriptVariables;
         newCommandForm.defaultStartupCommand = cmdBrowser.lblCommandName.Text;
         //if a command was selected
         if (newCommandForm.ShowDialog() == DialogResult.OK)
         {
             //add to listview
             AddCommandToListView(newCommandForm.selectedCommand);
         }
     }
 }
コード例 #10
0
        public static ComboBox AddVariableNames(this ComboBox cbo, UI.Forms.frmCommandEditor editor)
        {
            if (cbo == null)
            {
                return(null);
            }

            if (editor != null)
            {
                cbo.Items.Clear();

                foreach (var variable in editor.scriptVariables)
                {
                    cbo.Items.Add(variable.VariableName);
                }
            }

            return(cbo);
        }
コード例 #11
0
        private static void ShowElementRecorder(object sender, EventArgs e, UI.Forms.frmCommandEditor editor)
        {
            //get command reference
            Core.Automation.Commands.UIAutomationCommand cmd = (Core.Automation.Commands.UIAutomationCommand)editor.selectedCommand;

            //create recorder
            UI.Forms.Supplemental.frmThickAppElementRecorder newElementRecorder = new UI.Forms.Supplemental.frmThickAppElementRecorder();
            newElementRecorder.searchParameters = cmd.v_UIASearchParameters;

            //show form
            newElementRecorder.ShowDialog();

            ComboBox txtWindowName = (ComboBox)editor.flw_InputVariables.Controls["v_WindowName"];

            txtWindowName.Text = newElementRecorder.cboWindowTitle.Text;

            editor.WindowState = FormWindowState.Normal;
            editor.BringToFront();
        }
コード例 #12
0
        public override List <Control> Render(UI.Forms.frmCommandEditor editor)
        {
            //custom rendering
            base.Render(editor);


            //create control for variable name
            RenderedControls.Add(CommandControls.CreateDefaultLabelFor("v_userVariableName", this));
            var VariableNameControl = CommandControls.CreateStandardComboboxFor("v_userVariableName", this).AddVariableNames(editor);

            RenderedControls.AddRange(CommandControls.CreateUIHelpersFor("v_userVariableName", this, new Control[] { VariableNameControl }, editor));
            RenderedControls.Add(VariableNameControl);

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



            return(RenderedControls);
        }
コード例 #13
0
        private void AddNewCommand(string specificCommand = "")
        {
            //bring up new command configuration form
            var newCommandForm = new UI.Forms.frmCommandEditor();

            newCommandForm.creationMode    = UI.Forms.frmCommandEditor.CreationMode.Add;
            newCommandForm.scriptVariables = this.scriptVariables;
            if (specificCommand != "")
            {
                newCommandForm.defaultStartupCommand = specificCommand;
            }

            //if a command was selected
            if (newCommandForm.ShowDialog() == DialogResult.OK)
            {
                //add to listview
                AddCommandToListView(newCommandForm.selectedCommand);
            }
        }
コード例 #14
0
        public static List <Control> CreateUIHelpersFor(string parameterName, Core.Automation.Commands.ScriptCommand parent, Control[] targetControls, UI.Forms.frmCommandEditor editor)
        {
            var variableProperties = parent.GetType().GetProperties().Where(f => f.Name == parameterName).FirstOrDefault();
            var propertyUIHelpers  = variableProperties.GetCustomAttributes(typeof(Core.Automation.Attributes.PropertyAttributes.PropertyUIHelper), true);
            var controlList        = new List <Control>();

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

            foreach (Core.Automation.Attributes.PropertyAttributes.PropertyUIHelper attrib in propertyUIHelpers)
            {
                taskt.UI.CustomControls.CommandItemControl helperControl = new taskt.UI.CustomControls.CommandItemControl();
                helperControl.Padding    = new System.Windows.Forms.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 Core.Automation.Attributes.PropertyAttributes.PropertyUIHelper.UIAdditionalHelperType.ShowVariableHelper:
                    //show variable selector
                    helperControl.CommandImage   = UI.Images.GetUIImage("VariableCommand");
                    helperControl.CommandDisplay = "Insert Variable";
                    helperControl.Click         += (sender, e) => ShowVariableSelector(sender, e);
                    break;

                case Core.Automation.Attributes.PropertyAttributes.PropertyUIHelper.UIAdditionalHelperType.ShowFileSelectionHelper:
                    //show file selector
                    helperControl.CommandImage   = UI.Images.GetUIImage("ClipboardGetTextCommand");
                    helperControl.CommandDisplay = "Select a File";
                    helperControl.Click         += (sender, e) => ShowFileSelector(sender, e, editor);
                    break;

                case Core.Automation.Attributes.PropertyAttributes.PropertyUIHelper.UIAdditionalHelperType.ShowFolderSelectionHelper:
                    //show file selector
                    helperControl.CommandImage   = UI.Images.GetUIImage("ClipboardGetTextCommand");
                    helperControl.CommandDisplay = "Select a Folder";
                    helperControl.Click         += (sender, e) => ShowFolderSelector(sender, e, editor);
                    break;

                case Core.Automation.Attributes.PropertyAttributes.PropertyUIHelper.UIAdditionalHelperType.ShowImageRecogitionHelper:
                    //show file selector
                    helperControl.CommandImage   = UI.Images.GetUIImage("OCRCommand");
                    helperControl.CommandDisplay = "Capture Reference Image";
                    helperControl.Click         += (sender, e) => ShowImageCapture(sender, e);

                    taskt.UI.CustomControls.CommandItemControl testRun = new taskt.UI.CustomControls.CommandItemControl();
                    testRun.Padding   = new System.Windows.Forms.Padding(10, 0, 0, 0);
                    testRun.ForeColor = Color.AliceBlue;

                    testRun.CommandImage   = UI.Images.GetUIImage("OCRCommand");
                    testRun.CommandDisplay = "Run Image Recognition Test";
                    testRun.ForeColor      = Color.AliceBlue;
                    testRun.Tag            = targetControls.FirstOrDefault();
                    testRun.Click         += (sender, e) => RunImageCapture(sender, e);
                    controlList.Add(testRun);
                    break;

                case Core.Automation.Attributes.PropertyAttributes.PropertyUIHelper.UIAdditionalHelperType.ShowCodeBuilder:
                    //show variable selector
                    helperControl.CommandImage   = UI.Images.GetUIImage("RunScriptCommand");
                    helperControl.CommandDisplay = "Code Builder";
                    helperControl.Click         += (sender, e) => ShowCodeBuilder(sender, e, editor);
                    break;

                case Core.Automation.Attributes.PropertyAttributes.PropertyUIHelper.UIAdditionalHelperType.ShowMouseCaptureHelper:
                    helperControl.CommandImage   = UI.Images.GetUIImage("SendMouseMoveCommand");
                    helperControl.CommandDisplay = "Capture Mouse Position";
                    helperControl.ForeColor      = Color.AliceBlue;
                    helperControl.Click         += (sender, e) => ShowMouseCaptureForm(sender, e);
                    break;

                case Core.Automation.Attributes.PropertyAttributes.PropertyUIHelper.UIAdditionalHelperType.ShowElementRecorder:
                    //show variable selector
                    helperControl.CommandImage   = UI.Images.GetUIImage("ClipboardGetTextCommand");
                    helperControl.CommandDisplay = "Element Recorder";
                    helperControl.Click         += (sender, e) => ShowElementRecorder(sender, e, editor);
                    break;

                case Core.Automation.Attributes.PropertyAttributes.PropertyUIHelper.UIAdditionalHelperType.GenerateDLLParameters:
                    //show variable selector
                    helperControl.CommandImage   = UI.Images.GetUIImage("ExecuteDLLCommand");
                    helperControl.CommandDisplay = "Generate Parameters";
                    helperControl.Click         += (sender, e) => GenerateDLLParameters(sender, e);
                    break;

                case Core.Automation.Attributes.PropertyAttributes.PropertyUIHelper.UIAdditionalHelperType.ShowDLLExplorer:
                    //show variable selector
                    helperControl.CommandImage   = UI.Images.GetUIImage("ExecuteDLLCommand");
                    helperControl.CommandDisplay = "Launch DLL Explorer";
                    helperControl.Click         += (sender, e) => ShowDLLExplorer(sender, e);
                    break;

                case Core.Automation.Attributes.PropertyAttributes.PropertyUIHelper.UIAdditionalHelperType.AddInputParameter:
                    //show variable selector
                    helperControl.CommandImage   = UI.Images.GetUIImage("ExecuteDLLCommand");
                    helperControl.CommandDisplay = "Add Input Parameter";
                    helperControl.Click         += (sender, e) => AddInputParameter(sender, e, editor);
                    break;

                case Core.Automation.Attributes.PropertyAttributes.PropertyUIHelper.UIAdditionalHelperType.ShowHTMLBuilder:
                    helperControl.CommandImage   = UI.Images.GetUIImage("ExecuteDLLCommand");
                    helperControl.CommandDisplay = "Launch HTML Builder";
                    helperControl.Click         += (sender, e) => ShowHTMLBuilder(sender, e, editor);
                    break;

                case Core.Automation.Attributes.PropertyAttributes.PropertyUIHelper.UIAdditionalHelperType.ShowIfBuilder:
                    //show variable selector
                    helperControl.CommandImage   = UI.Images.GetUIImage("VariableCommand");
                    helperControl.CommandDisplay = "Add New If Statement";
                    break;

                case Core.Automation.Attributes.PropertyAttributes.PropertyUIHelper.UIAdditionalHelperType.ShowLoopBuilder:
                    //show variable selector
                    helperControl.CommandImage   = UI.Images.GetUIImage("VariableCommand");
                    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);
        }
コード例 #15
0
ファイル: ScriptCommand.cs プロジェクト: patrickliu/taskt
 public virtual List <Control> Render(UI.Forms.frmCommandEditor editor)
 {
     RenderedControls = new List <Control>();
     return(RenderedControls);
 }
コード例 #16
0
ファイル: ScriptCommand.cs プロジェクト: patrickliu/taskt
 public virtual void Refresh(UI.Forms.frmCommandEditor editor = null)
 {
 }
コード例 #17
0
        private void lstScriptActions_DoubleClick(object sender, EventArgs e)
        {
            if (lstScriptActions.SelectedItems.Count != 1)
            {
                return;
            }


            //bring up edit mode to edit the action
            ListViewItem selectedCommandItem = lstScriptActions.SelectedItems[0];


            //set selected command from the listview item tag object which was assigned to the command
            var currentCommand = (Core.AutomationCommands.ScriptCommand)selectedCommandItem.Tag;


            //check if editing a sequence
            if (currentCommand is Core.AutomationCommands.SequenceCommand)
            {
                if (editMode)
                {
                    MessageBox.Show("Embedding Sequence Commands within Sequence Commands not yet supported.");
                    return;
                }


                //get sequence events
                Core.AutomationCommands.SequenceCommand sequence = (Core.AutomationCommands.SequenceCommand)currentCommand;
                frmScriptBuilder newBuilder = new frmScriptBuilder();

                //append to new builder
                foreach (var cmd in sequence.v_scriptActions)
                {
                    newBuilder.lstScriptActions.Items.Add(CreateScriptCommandListViewItem(cmd));
                }


                //apply editor style format
                newBuilder.ApplyEditorFormat();

                //if data has been changed
                if (newBuilder.ShowDialog() == DialogResult.OK)
                {
                    //create updated list
                    List <Core.AutomationCommands.ScriptCommand> updatedList = new List <Core.AutomationCommands.ScriptCommand>();

                    //update to list
                    for (int i = 0; i < newBuilder.lstScriptActions.Items.Count; i++)
                    {
                        var command = (Core.AutomationCommands.ScriptCommand)newBuilder.lstScriptActions.Items[i].Tag;
                        updatedList.Add(command);
                    }

                    //apply new list to existing sequence
                    sequence.v_scriptActions = updatedList;

                    //update label
                    selectedCommandItem.Text = sequence.GetDisplayValue();
                }
            }
            else
            {
                //create new command editor form
                UI.Forms.frmCommandEditor editCommand = new UI.Forms.frmCommandEditor();

                //creation mode edit locks form to current command
                editCommand.creationMode = UI.Forms.frmCommandEditor.CreationMode.Edit;

                //create clone of current command so databinding does not affect if changes are not saved
                editCommand.selectedCommand = Core.Common.Clone(currentCommand);;

                //set variables
                editCommand.scriptVariables = this.scriptVariables;

                //show edit command form and save changes on OK result
                if (editCommand.ShowDialog() == DialogResult.OK)
                {
                    selectedCommandItem.Tag  = editCommand.selectedCommand;
                    selectedCommandItem.Text = editCommand.selectedCommand.GetDisplayValue(); //+ "(" + cmdDetails.SelectedVariables() + ")";
                    selectedCommandItem.SubItems.Add(editCommand.selectedCommand.GetDisplayValue());
                }
            }
        }