Example #1
0
        public CommandVO clone()
        {
            CommandVO copy = new CommandVO();

            copy.speech = this.speech;
            copy.delayBetweenCommands = this.delayBetweenCommands;

            foreach (CommandItemVO item in commandItems)
            {
                CommandItemVO itemCopy = new CommandItemVO();
                itemCopy.altPressed         = item.altPressed;
                itemCopy.applicationParams  = item.applicationParams;
                itemCopy.applicationPath    = item.applicationPath;
                itemCopy.appVarIndex        = item.appVarIndex;
                itemCopy.appVars            = item.appVars;
                itemCopy.clipboard          = item.clipboard;
                itemCopy.clipboardAutoPaste = item.clipboardAutoPaste;
                itemCopy.ctrlPressed        = item.ctrlPressed;
                itemCopy.delayBeforeFocus   = item.delayBeforeFocus;
                itemCopy.delayTime          = item.delayTime;
                itemCopy.key                     = item.key;
                itemCopy.shiftPressed            = item.shiftPressed;
                itemCopy.stopIfFocusNotFound     = item.stopIfFocusNotFound;
                itemCopy.type                    = item.type;
                itemCopy.varToClipboardAutoPaste = item.varToClipboardAutoPaste;

                copy.commandItems.Add(itemCopy);
            }

            return(copy);
        }
        // -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -



        // -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
        private void btnSave_Click(object sender, EventArgs e)
        {
            //ListViewItem lv = lvKeys.SelectedItems[0].SubItems;
            //MessageBox.Show(lv.SubItems[0].ToString());
            //MessageBox.Show(lvKeys.SelectedItems[0].SubItems[1].ToString());
            //return;

            if (tbKey.Text == "")
            {
                MessageBox.Show("Please select a key to press, select NONE if you just want to press CTRL, ALT or SHIFT.");
                return;
            }


            CommandItemVO civo = new CommandItemVO();

            civo.type         = "key";
            civo.key          = tbKey.Text;
            civo.ctrlPressed  = cbCtrl.Checked;
            civo.altPressed   = cbAlt.Checked;
            civo.shiftPressed = cbShift.Checked;

            fce.fceCommandManager.addCommandItem(civo);

            btnCancel_Click(null, null);
        }
Example #3
0
        // -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -



        // -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
        public void removeCommandItem(CommandItemVO civo)
        {
            t.log("FormCommandEditorCommandManager.removeCommand(CommandItemVO)");

            cvo.commandItems.Remove(civo);

            fce.fceListController.updateCommandListView();
        }
Example #4
0
        // -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -



        // -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
        public void addCommandItem(CommandItemVO civo)
        {
            t.log("FormCommandEditorCommandManager.addCommand(CommandItemVO)");

            cvo.addCommandItem(civo);

            fce.fceListController.updateCommandListView();
        }
Example #5
0
        // -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -


        // -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
        private void btnAdd_Click(object sender, EventArgs e)
        {
            CommandItemVO civo = new CommandItemVO();

            civo.type              = "run application";
            civo.applicationPath   = tbApplicationPath.Text;
            civo.applicationParams = tbParams.Text;

            formCommandEditor.fceCommandManager.addCommandItem(civo);

            btnCancel_Click(null, null);
        }
        // -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -


        // -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
        private void timerTickHandler(Object myObject, EventArgs myEventArgs)
        {
            t.log("CommandExecutionHandler.startTimedCommandItemExecution(): tickCount = " + tickCount);
            tickCount++;

            if (tickCount > cvo.commandItems.Count)
            {
                timer.Stop();
                tickCount = 0;
            }
            else
            {
                CommandItemVO civo = cvo.commandItems[(tickCount - 1)];
                t.log("CommandExecutionHandler.startTimedCommandItemExecution(): civo.type = " + civo.type);

                IntPtr handle;

                switch (civo.type)
                {
                case "clipboard":

                    Clipboard.SetText(civo.clipboard);
                    if (civo.clipboardAutoPaste)
                    {
                        handle = GetActiveWindow();
                        SendKeys.Send("^(v)");
                    }

                    break;

                case "key":
                    t.log("\t\t" + "civo.key = " + civo.key);
                    KeyStringBuilder ksb       = new KeyStringBuilder();
                    String           keyString = ksb.getKeyString(civo.ctrlPressed, civo.altPressed, civo.shiftPressed, civo.key);

                    handle = GetActiveWindow();
                    SendKeys.Send(keyString);

                    break;

                case "run application":
                    t.log("\t\t" + "civo.applicationPath = " + civo.applicationPath);
                    t.log("\t\t" + "civo.applicationParams = " + civo.applicationParams);
                    Process proc = Process.Start(civo.applicationPath, civo.applicationParams);
                    break;
                }
            }
        }
        // -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -


        // -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
        public FormNewKeyCommand(FormCommandEditor formCommandEditor, CommandItemVO commandItemVOToEdit = null)
        {
            InitializeComponent();

            t = new T(true);
            t.log("FormNewKeyCommand()");

            this.fce = formCommandEditor;
            this.commandItemVOToEdit = commandItemVOToEdit;

            populateKeySelectionDropDown();

            if (commandItemVOToEdit != null)
            {
                cbCtrl.Checked  = commandItemVOToEdit.ctrlPressed;
                cbAlt.Checked   = commandItemVOToEdit.altPressed;
                cbShift.Checked = commandItemVOToEdit.shiftPressed;
                tbKey.Text      = commandItemVOToEdit.key;
            }
        }
        // -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -



        // -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
        private void btnEdit_Click(object sender, EventArgs e)
        {
            t.log("FormCommandEditor.btnEdit_Click()");

            if (lvCommandSequence.SelectedItems.Count < 1)
            {
                MessageBox.Show("Please select a command to edit first!");
                return;
            }

            int commandItemIndexToEdit = lvCommandSequence.SelectedIndices[0];

            t.log("commandItemIndexToEdit = " + commandItemIndexToEdit);

            CommandItemVO civo = fceCommandManager.getCommandItem(commandItemIndexToEdit);

            t.log("civo.type = " + civo.type);

            //return;

            switch (civo.type)
            {
            case "clipboard":
                formNewClipboardCommand = new FormNewClipboardCommand(this, civo);
                this.Hide();
                formNewClipboardCommand.Show();
                break;

            case "key":
                formNewKeyCommand = new FormNewKeyCommand(this, civo);
                this.Hide();
                formNewKeyCommand.Show();
                break;

            case "run application":
                formNewApplicationCommand = new FormNewApplicationCommand(this);
                this.Hide();
                formNewApplicationCommand.Show();
                break;
            }
        }
        // -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -



        // -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (this.commandItemVOToEdit == null)
            {
                // Save new civo
                CommandItemVO civo = new CommandItemVO();
                civo.type               = "clipboard";
                civo.clipboard          = rtClipboard.Text;
                civo.clipboardAutoPaste = cbAutoPaste.Checked;

                formCommandEditor.fceCommandManager.addCommandItem(civo);

                btnCancel_Click(null, null);
            }
            else
            {
                // Update civo (done as we are editing a reference to the variable which are the same
                commandItemVOToEdit.clipboard          = rtClipboard.Text;
                commandItemVOToEdit.clipboardAutoPaste = cbAutoPaste.Checked;
                formCommandEditor.fceListController.updateCommandListView();
                btnCancel_Click(null, null);
            }
        }
        // -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -


        // -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
        public FormNewClipboardCommand(FormCommandEditor formCommandEditor, CommandItemVO commandItemVOToEdit = null)
        {
            InitializeComponent();

            // Class specific debug
            t = new T(true);
            t.log("FormNewClipboardCommand()");

            this.formCommandEditor   = formCommandEditor;
            this.commandItemVOToEdit = commandItemVOToEdit;

            if (commandItemVOToEdit != null)
            {
                rtClipboard.Text = commandItemVOToEdit.clipboard;
                if (commandItemVOToEdit.clipboardAutoPaste)
                {
                    cbAutoPaste.Checked = true;
                }
                else
                {
                    cbAutoPaste.Checked = false;
                }
            }
        }
        public void saveProfileProceed()
        {
            t.log("ProfileManager.saveProfileProceed()");


            int NoOfCommands = fm.commandManager.commands.Count;
            int cnt          = 0;
            int percent      = 0;

            String xmlString = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";

            xmlString += "<xml>" + "\n\n";

            foreach (CommandVO cvo in fm.commandManager.commands)
            {
                cnt++;

                xmlString += "\t" + "<command>" + "\n";
                xmlString += "\t\t" + "<speech>" + cvo.speech + "</speech>" + "\n";
                xmlString += "\t\t" + "<command_sequence delayBetweenCommands=\"" + cvo.delayBetweenCommands + "\">" + "\n";

                for (int i = 0; i < cvo.commandItems.Count; i++)
                {
                    CommandItemVO civo = cvo.commandItems[i];
                    t.log("civo.type = " + civo.type);

                    switch (civo.type)
                    {
                    case "run application":
                        xmlString += "\t\t\t" + "<item type=\"" + civo.type + "\">\n";
                        xmlString += "\t\t\t\t" + "<path>" + civo.applicationPath + "</path>\n";
                        xmlString += "\t\t\t\t" + "<params>" + civo.applicationParams + "</params>\n";
                        xmlString += "\t\t\t" + "</item>" + "\n";
                        break;

                    case "clipboard":
                        xmlString += "\t\t\t" + "<item type=\"" + civo.type + "\" autoPaste=\"" + DTools.boolToNumberString(civo.clipboardAutoPaste) + "\">";
                        xmlString += "<![CDATA[" + civo.clipboard + "]]>";
                        xmlString += "</item>" + "\n";
                        break;

                    case "clipboard to var":
                        xmlString += "\t\t\t" + "<item type=\"" + civo.type + "\" var=\"" + civo.appVarIndex + "\"></item>\n";
                        break;

                    case "var to clipboard":
                        xmlString += "\t\t\t" + "<item type=\"" + civo.type + "\" var=\"" + civo.appVarIndex + "\"></item>\n";
                        break;

                    case "key":
                        xmlString += "\t\t\t" + "<item type=\"" + civo.type + "\" ";
                        xmlString += "ctrl=\"" + DTools.boolToNumberString(civo.ctrlPressed) + "\" ";
                        xmlString += "alt=\"" + DTools.boolToNumberString(civo.altPressed) + "\" ";
                        xmlString += "shift=\"" + DTools.boolToNumberString(civo.shiftPressed) + "\">";
                        xmlString += civo.key;
                        xmlString += "</item>" + "\n";
                        break;

                    case "delay":
                        xmlString += "\t\t\t" + "<item type=\"" + civo.type + "\" duration=\"" + civo.delayTime.ToString() + "\"></item>\n";
                        break;

                    case "focus on application":
                        xmlString += "\t\t\t" + "<item type=\"" + civo.type + "\" ";
                        xmlString += "delayBeforeFocus=\"" + civo.delayBeforeFocus.ToString() + "\" ";
                        xmlString += "stopIfFocusNotFound=\"" + DTools.boolToNumberString(civo.stopIfFocusNotFound) + "\" ";
                        xmlString += "/>\n";
                        break;
                    }
                }

                xmlString += "\t\t" + "</command_sequence>" + "\n";
                xmlString += "\t" + "</command>" + "\n\n";
            }

            xmlString += "</xml>" + "\n";

            //XDocument xDoc = XDocument.Load(xmlString);

            t.log(xmlString);


            //FileStream fileStream = new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.None);


            String profilePath = Vars.profilePath + "/" + activeProfile + ".xml";

            try
            {
                //xDoc.Save(fileStream);
                File.WriteAllText(profilePath, xmlString, Encoding.UTF8);
                fm.setStatus("Profile saved!");
                fm.speechRecognizer.startListening();
            }
            catch
            {
                fm.setStatus("Unable to save profile!");
            }

            fm.Show();

            fps.Close();
        }
Example #12
0
 public void removeCommandItem(CommandItemVO civo)
 {
     commandItems.Remove(civo);
 }
Example #13
0
 public void addCommandItem(CommandItemVO civo)
 {
     commandItems.Add(civo);
 }
Example #14
0
        // -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -



        // -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
        public void getCommandsFromLoadedProfile()
        {
            t.log("CommandManager.getCommandsFromLoadedProfile()");

            fm.setStatus("Parsing profile commands...");

            commands = new List <CommandVO>();

            XmlNodeList xmlCommandsList = fm.profileManager.xmlDoc.SelectNodes("//command");

            //t.log("\t" + "xmlCommandsList.Count = " + xmlCommandsList.Count);
            //t.log("\t" + "xmlCommandsList.GetType = " + xmlCommandsList.GetType());


            t.log("------------------------------------------------------------");
            foreach (XmlNode commandRootNode in xmlCommandsList)
            {
                //t.log("\t" + commandRootNode.ChildNodes[0].InnerText.ToString());

                // Parse the outer VO (ID = String speech)
                CommandVO cvo = new CommandVO();
                cvo.speech = commandRootNode.ChildNodes[0].InnerText.ToString();

                // Parse the inner VO (list)
                XmlNodeList xmlCommandItems = commandRootNode.SelectNodes("command_sequence/item");
                //t.log("\t\t" + "CommandItem: " + xmlCommandItems.ToString());

                t.log("\n");
                t.log("\t\t" + "command = " + cvo.speech);


                //Console.WriteLine("###### " + commandRootNode.ChildNodes[1].OuterXml.ToString());
                foreach (XmlNode commandItemNode in xmlCommandItems)
                {
                    //t.log("\t\t" + "CommandItem: " + commandItemNode.OuterXml.ToString());
                    //t.log("\t\t\t" + "XML = " + commandItemNode.OuterXml.ToString());

                    String commandItemType = commandItemNode.Attributes[0].Value.ToString();

                    CommandItemVO civo = new CommandItemVO();
                    civo.type = commandItemType;


                    int index = -1;

                    t.log("\t\t" + "commandItemType = " + commandItemType);
                    switch (commandItemType)
                    {
                    case "run application":
                        t.log("\t\t\t" + commandItemNode.ChildNodes[0].InnerXml.ToString());
                        civo.applicationPath = commandItemNode.ChildNodes[0].InnerXml.ToString();

                        t.log("\t\t\t" + commandItemNode.ChildNodes[1].InnerXml.ToString());
                        civo.applicationParams = commandItemNode.ChildNodes[1].InnerXml.ToString();
                        break;

                    case "clipboard":
                        t.log("\t\t\t" + "commandItemNode.InnerText = " + commandItemNode.InnerText.ToString());
                        t.log("\t\t\t" + "commandItemNode.Attributes[1].Value = " + commandItemNode.Attributes[1].Value.ToString());

                        civo.clipboard          = commandItemNode.InnerText.ToString();
                        civo.clipboardAutoPaste = DTools.intStringToBoolean(commandItemNode.Attributes[1].Value.ToString());


                        break;

                    case "clipboard to var":
                        index               = int.Parse(commandItemNode.Attributes[1].Value.ToString());
                        civo.appVarIndex    = index;
                        civo.appVars[index] = Clipboard.GetText();
                        //t.log("\t\t\t" + "index = " + index.ToString());
                        //t.log("\t\t\t" + "civo.appVars[index] = " + civo.appVars[index].ToString());
                        break;

                    case "var to clipboard":
                        //index = int.Parse(commandItemNode.Attributes[1].Value.ToString());
                        //Clipboard.SetText(civo.appVars[index]);
                        break;

                    case "output var":
                        //index = int.Parse(commandItemNode.Attributes[1].Value.ToString());
                        break;

                    case "key":
                        civo.key          = commandItemNode.ChildNodes[0].InnerText.ToString();
                        civo.ctrlPressed  = DTools.intStringToBoolean(commandItemNode.Attributes[1].Value.ToString());
                        civo.altPressed   = DTools.intStringToBoolean(commandItemNode.Attributes[2].Value.ToString());
                        civo.shiftPressed = DTools.intStringToBoolean(commandItemNode.Attributes[3].Value.ToString());
                        break;

                    case "focus on application":
                        break;

                    case "delay":
                        t.log("\t\t\t" + "commandItemNode.Attributes[1].Value = " + commandItemNode.Attributes[1].Value.ToString());
                        civo.delayTime = float.Parse(commandItemNode.Attributes[1].Value);
                        break;
                    }


                    cvo.addCommandItem(civo);
                } // commandItemNode for loop end


                //t.log("\t----------------------------------");

                commands.Add(cvo);
            } // rootCommandNode for loop end
            t.log("------------------------------------------------------------");

            //Console.WriteLine(commands.ToString());

            fm.setStatus("Profile commands parsed...");

            fm.fmCommandListController.updateCommandListView();
        }