Exemplo n.º 1
0
 public ClickCommand(ClickCommandMap commandMap, string button)
 {
     _commandMap = commandMap;
     _button = button;
 }
Exemplo n.º 2
0
        private void LoadProfile(string path)
        {
            path = Path.GetFullPath(path);
            using (StreamReader reader = File.OpenText(path))
            {
                string line = null;
                int lineNumber = 0;
                ClickCommandMap commandMap = new ClickCommandMap();
                while ((line = reader.ReadLine()) != null)
                {
                    ++lineNumber;

                    // Ignore empty lines
                    if (string.IsNullOrEmpty(line))
                    {
                        continue;
                    }

                    // Ignore comment lines
                    if (line.StartsWith("#"))
                    {
                        continue;
                    }

                    string[] parts = line.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);

                    if (parts.Length != 2)
                    {
                        Log("Ignoring line " + lineNumber.ToString() + ". Syntax error: " + line);
                        continue;
                    }

                    string button = parts[0].Trim().ToLowerInvariant();
                    string specification = parts[1].Trim();

                    KeyEventSequence eventSequence = KeySequenceParser.Parse(specification);

                    if (eventSequence == null)
                    {
                        Log("Ignoring line " + lineNumber.ToString() + ". Syntax error: " + line);
                    }

                    commandMap[button] = eventSequence;

                }
                Command.UnregisterAll();
                Command.Register("CLICK", new ClickCommandFactory(commandMap));
                Log("Loaded profile " + path);

                _profileLoaded = true;
                SetIcon();
            }
        }
Exemplo n.º 3
0
 public ClickCommandFactory(ClickCommandMap commandMap)
 {
     _commandMap = commandMap;
 }