public ClickCommand(ClickCommandMap commandMap, string button) { _commandMap = commandMap; _button = button; }
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(); } }
public ClickCommandFactory(ClickCommandMap commandMap) { _commandMap = commandMap; }