Beispiel #1
0
        public static BufferHotkeyManager LoadFromTextFile(IBufferHolder parent, StreamReader reader)
        {
            BufferHotkeyManager manager = new BufferHotkeyManager(parent);
            string command, key, origLine, lowerLine;
            bool   ctrl, win, shift, alt;
            Hotkey newKey;

            while (!reader.EndOfStream)
            {
                origLine = reader.ReadLine();
                if (origLine.StartsWith("[") || origLine.StartsWith("//"))
                {
                    continue;
                }
                if (origLine.Contains("//")) // remove comments
                {
                    origLine = origLine.Substring(0, origLine.IndexOf("//"));
                }
                lowerLine = origLine.ToLower().Replace(" ", ""); // lower case, no space
                ctrl      = (lowerLine.Contains("ctrl+") || lowerLine.Contains("control+"));
                alt       = lowerLine.Contains("alt+");
                shift     = lowerLine.Contains("shift+");
                win       = (lowerLine.Contains("win+") || lowerLine.Contains("windows+"));
                if (win == true || alt == true || ctrl == true || shift == true)
                {
                    int lastPlus = origLine.LastIndexOf("+");
                    key = origLine.Substring(lastPlus + 1, origLine.Length - lastPlus - 1);
                }
                else
                {
                    key = origLine.Split('=')[1];
                }
                command = origLine.Split('=')[0];
                newKey  = new Hotkey((Keys)Enum.Parse(typeof(Keys), key, true), shift, ctrl, alt, win);
                if (parent.Commands.ContainsKey(command))
                {
                    newKey.Pressed += parent.Commands[command].Execute;
                    if (parent is ContainerControl)
                    {
                        newKey.Register((ContainerControl)parent);
                    }
                }
                manager.Hotkeys.Add(newKey);
            }
            reader.Close();
            return(manager);
        }
 public ShowOptionsDialogCommand(IBufferHolder formIn)
 {
     bufferHolder = formIn;
 }
Beispiel #3
0
 public static BufferHotkeyManager LoadFromTextFile(IBufferHolder parent)
 {
     return(LoadFromTextFile(parent, new StreamReader(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Blindspot\Settings\hotkeys.txt"))));
 }
Beispiel #4
0
 public BufferHotkeyManager(IBufferHolder parent)
     : this()
 {
     this.Parent = parent;
 }