Example #1
0
        private void CreateDefaultEntries(string fileName)
        {
            WriteEntry("Creating default entries");

            List <string> commandExpressions = new List <string>();

            KeyCommandManager mgr = new KeyCommandManager(fileName);

            if (File.Exists(Application.StartupPath + "\\PS.EN.DE.exe"))
            {
                commandExpressions.Add("1<|>1<|>1<|>0<|>90<@><@>" + Application.StartupPath + "\\PS.EN.DE.exe<!args!>c<@>Lentracs Decypher Clipboard");
            }

            if (File.Exists(Application.StartupPath + "\\TrackInfo.exe"))
            {
                commandExpressions.Add("1<|>1<|>1<|>0<|>84<@><@>" + Application.StartupPath + "\\TrackInfo.exe<@>Track Info Bug Tracking");
            }

            commandExpressions.Add("0<|>0<|>0<|>1<|>83<@><@><!SETTINGS!><@>App Settings");     // App Settings
            commandExpressions.Add("1<|>1<|>1<|>0<|>68<@><@><!DISP_SHORT!><@>Show Shortcuts"); // Display Shortcuts

            foreach (string sObject in commandExpressions)
            {
                mgr.Save(new KeyCommand(sObject));
            }
        }
Example #2
0
        private List <KeyCommand> GetKeyCommands(string fileName)
        {
            StreamWriter writer = null;

            if (!File.Exists(fileName))
            {
                writer = File.CreateText(fileName);
                writer.Close();
                CreateDefaultEntries(fileName);
            }

            hotKeyList = new List <Hotkey>();
            //hotKeyList.RemoveAll(PredicateDelegate);

            manager = new KeyCommandManager(fileName);

            WriteEntry("Binding Keys");

            if (manager.KeyCommandCollection.Count > 0)
            {
                foreach (KeyCommand command in manager.KeyCommandCollection)
                {
                    MaintainHotKey(BindHotKey(command));
                }
            }
            else
            {
                // New conf file creation
                KeyCommand newCommand;
                if (File.Exists(Application.StartupPath + "\\PS.EN.DE.exe"))
                {
                    //E:\Projects\PS.EN.DE\PS.EN.DE\bin\Debug\PS.EN.DE.exe<!args!>c noui
                    //new Hotkey(Keys.Z, true, true, true, false, "", Application.StartupPath + "\\PS.EN.DE.exe<!args!>c noui", "Lentracs Decypher");

                    WriteEntry("Creating Hot Key For Encryptor");
                    newCommand            = new KeyCommand();
                    newCommand.KeyName    = "Lentracs Decypher";
                    newCommand.Key        = Keys.Z;
                    newCommand.CTRLMask   = true;
                    newCommand.ALTMask    = true;
                    newCommand.ShiftMask  = true;
                    newCommand.WINMask    = false;
                    newCommand.ExecString = Application.StartupPath + "\\PS.EN.DE.exe<!args!>c noui";
                    newCommand.SendKey    = "";

                    manager.Save(newCommand);
                }
                if (File.Exists(Application.StartupPath + "\\TrackInfo.exe"))
                {
                    //E:\Projects\PS.EN.DE\PS.EN.DE\bin\Debug\PS.EN.DE.exe<!args!>c noui
                    //new Hotkey(Keys.Z, true, true, true, false, "", Application.StartupPath + "\\PS.EN.DE.exe<!args!>c noui", "Lentracs Decypher");

                    WriteEntry("Creating Hot Key For TrackInfo");
                    newCommand            = new KeyCommand();
                    newCommand.KeyName    = "TrackInfo";
                    newCommand.Key        = Keys.T;
                    newCommand.CTRLMask   = true;
                    newCommand.ALTMask    = true;
                    newCommand.ShiftMask  = true;
                    newCommand.WINMask    = false;
                    newCommand.ExecString = Application.StartupPath + "\\TrackInfo.exe";
                    newCommand.SendKey    = "";

                    manager.Save(newCommand);
                }
            }

            return(manager.KeyCommandCollection);

            #region Old Commented



            //TextReader reader = new StreamReader(fileName);

            //List<KeyCommand> keyCommandList = new List<KeyCommand>();

            //string readLine = reader.ReadLine();
            //while (readLine != null)
            //{
            //    KeyCommand keyCommandObject = new KeyCommand(readLine);
            //    if (keyCommandObject.Key != Keys.None)
            //    {
            //        hotKeyList.Add(BindHotKey(keyCommandObject));
            //        keyCommandList.Add(keyCommandObject);
            //    }
            //    readLine = reader.ReadLine();
            //}
            //reader.Close();

            //return keyCommandList;

            #endregion
        }