Beispiel #1
0
        private void FinalizeRecording()
        {
            var commandList = GlobalHook.generatedCommands;


            var outputList = new List <Core.AutomationCommands.ScriptCommand>();


            if (chkGroupIntoSequence.Checked)
            {
                var newSequence = new Core.AutomationCommands.SequenceCommand();

                foreach (Core.AutomationCommands.ScriptCommand cmd in commandList)
                {
                    newSequence.v_scriptActions.Add(cmd);
                }


                if (newSequence.v_scriptActions.Count > 0)
                {
                    outputList.Add(newSequence);
                }
            }
            else if (chkGroupMovesIntoSequences.Checked)
            {
                var newSequence = new Core.AutomationCommands.SequenceCommand();

                foreach (Core.AutomationCommands.ScriptCommand cmd in commandList)
                {
                    if (cmd is Core.AutomationCommands.SendMouseMoveCommand)
                    {
                        var sendMouseCmd = (Core.AutomationCommands.SendMouseMoveCommand)cmd;
                        if (sendMouseCmd.v_MouseClick != "None")
                        {
                            outputList.Add(newSequence);
                            newSequence = new Core.AutomationCommands.SequenceCommand();
                            outputList.Add(cmd);
                        }
                        else
                        {
                            newSequence.v_scriptActions.Add(cmd);
                        }
                    }
                    else if (cmd is SendKeysCommand)
                    {
                        outputList.Add(newSequence);
                        newSequence = new Core.AutomationCommands.SequenceCommand();
                        outputList.Add(cmd);
                    }
                    else
                    {
                        newSequence.v_scriptActions.Add(cmd);
                    }
                }

                if (newSequence.v_scriptActions.Count > 0)
                {
                    outputList.Add(newSequence);
                }
            }

            else
            {
                outputList = commandList;
            }



            var commentCommand = new Core.AutomationCommands.CommentCommand();

            commentCommand.v_Comment = "Sequence Recorded " + DateTime.Now.ToString();
            outputList.Insert(0, commentCommand);

            foreach (var cmd in outputList)
            {
                callBackForm.AddCommandToListView(cmd);
            }

            this.Close();
        }
Beispiel #2
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());
                }
            }
        }