예제 #1
0
        private string parse_Send(CustomButton customButton, string input_text)
        {
            CustomButton_Send     customButton_Send;
            List <VirtualKeyCode> vk      = new List <VirtualKeyCode>();
            const string          pattern = @"^(?:(?:(?:(?:\s*)(\w+)(?:\s*)\+(?:\s*))+(\w+)(?:\s*))|(?:\s*)(\w+)(?:\s*))$";
            Match match = Regex.Match(input_text, pattern);

            if (match.Success)
            {
                foreach (Capture capture in match.Groups[1].Captures)//only group 1 have multiple captures
                {
                    VirtualKeyCode KeyCode = capture_to_VK(capture.Value);
                    if (KeyCode == VirtualKeyCode.NONAME)
                    {
                        return("Performer [" + customButton.Text + "] — Syntax error in send command"
                               + ": unknown key name — " + capture.Value);
                    }
                    else
                    {
                        vk.Add(KeyCode);
                    }
                }
                foreach (Capture capture in match.Groups[2].Captures)
                {
                    VirtualKeyCode KeyCode = capture_to_VK(capture.Value);
                    if (KeyCode == VirtualKeyCode.NONAME)
                    {
                        return("Performer [" + customButton.Text + "] — Syntax error in send command"
                               + ": unknown key name — " + capture.Value);
                    }
                    else
                    {
                        vk.Add(KeyCode);
                    }
                }
                foreach (Capture capture in match.Groups[3].Captures)
                {
                    VirtualKeyCode KeyCode = capture_to_VK(capture.Value);
                    if (KeyCode == VirtualKeyCode.NONAME)
                    {
                        return("Performer [" + customButton.Text + "] — Syntax error in send command"
                               + ": unknown key name — " + capture.Value);
                    }
                    else
                    {
                        vk.Add(KeyCode);
                    }
                }
                customButton_Send = new CustomButton_Send(vk);
                customButton.actions.Add(customButton_Send);
                return("");
            }
            else
            {
                return("Performer [" + customButton.Text + "] — Syntax error in send command");
            }
        }
예제 #2
0
        private static void read_button_actions_from_file(XmlNode list_of_actions, CustomButton button)
        {
            XmlNode modifiers_node, ordinary_node, process_node;

            foreach (XmlNode action_node in list_of_actions.ChildNodes)
            {
                if (action_node.Attributes["IAction_type"].Value == "CustomButton_Send")
                {
                    CustomButton_Send customButton_Send;
                    modifiers_node = action_node.SelectSingleNode("modifier_keys");
                    string[] a = modifiers_node.InnerText.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    List <VirtualKeyCode> v = new List <VirtualKeyCode>();
                    foreach (string modifier in a)
                    {
                        v.Add((VirtualKeyCode)Enum.Parse(typeof(VirtualKeyCode), modifier));
                    }

                    ordinary_node = action_node.SelectSingleNode("ordinary_keys");
                    a             = ordinary_node.InnerText.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string ordinary in a)
                    {
                        v.Add((VirtualKeyCode)Enum.Parse(typeof(VirtualKeyCode), ordinary));
                    }
                    customButton_Send = new CustomButton_Send(v);
                    button.actions.Add(customButton_Send);
                }
                else if (action_node.Attributes["IAction_type"].Value == "CustomButton_Process")
                {
                    CustomButton_Process customButton_Process;
                    process_node         = action_node.SelectSingleNode("process");
                    customButton_Process = new CustomButton_Process(
                        (Process_type)Enum.Parse(typeof(Process_type), process_node.Attributes["process_type"].Value),
                        process_node.Attributes["process.StartInfo.FileName"].Value,
                        process_node.Attributes["process.StartInfo.Arguments"].Value);
                    button.actions.Add(customButton_Process);
                }
            }
        }