Exemplo n.º 1
0
        /// <summary>
        /// Loads Hotkey XML file and loads keycodes into hotkeyCode and Description into hotkeyDescription
        /// </summary>
        public static void LoadHotKeys()
        {
            hotkeyCode.Clear();
            hotkeyDescription.Clear();

            if (!File.Exists(HotKeyFile))
            {
                MainWindow.Logger.Error("Hotkey file not found, going to create default");
                CheckCreateFile.CreateDefaultXML();
            }

            XmlReader r = XmlReader.Create(HotKeyFile);   // "hotkeys.xml");

            while (r.Read())
            {
                if (!r.IsStartElement())
                {
                    continue;
                }

                switch (r.Name)
                {
                case "Hotkeys":
                    // Get Hotkey Version Number, used for modifying or updating to newer hotkey files (ie if new features are added)
                    if (r["HotkeyFileVer"].Length > 0)
                    {
                        CurrentHotKeyFileVersion = Convert.ToInt32(r["HotkeyFileVer"]);     // Current Hotkey File Version
                    }
                    break;

                case "bind":
                    if ((r["keyfunction"].Length > 0) && (r["keycode"] != null))
                    {
                        if (!hotkeyCode.ContainsKey(r["keyfunction"]))
                        {
                            hotkeyCode.Add(r["keyfunction"], r["keycode"]);
                        }
                        hotkeyDescription.Add(r["keyfunction"], r["key_description"]);
                    }
                    break;
                }
            }
            r.Close();

            // Check if CurrentFileVersion and NewFileVersion is different and if so, Update the file then reload by running ths process again.
            MainWindow.Logger.Info("Hotkey file found, checking if needing update/modification");
            if (CurrentHotKeyFileVersion < CheckCreateFile.HotKeyFileVer) // If CurrentHotKeyFileVersion does not equal HotKeyFileVer then update is required
            {
                CheckCreateFile.CheckAndUpdateXMLFile(CurrentHotKeyFileVersion);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Loads Hotkey XML file and loads keycodes into hotkeyCode and Description into hotkeyDescription
        /// </summary>
        public static void LoadHotKeys()
        {
            hotkeyCode.Clear();
            hotkeyDescription.Clear();

            string fileName = HotKeyFile;

            if (!File.Exists(fileName))
            {
                MainWindow.Logger.Error("Hotkey file not found, going to create default");
                CheckCreateFile.CreateDefaultXML();
            }

            //CheckCreateFile.UpdateHotKeyFile(); // Run XML Updater

            XmlReader r = XmlReader.Create(HotKeyFile);   // "hotkeys.xml");

            while (r.Read())
            {
                if (!r.IsStartElement())
                {
                    continue;
                }

                switch (r.Name)
                {
                case "hotkeys":
                    break;

                case "bind":
                    if ((r["keyfunction"].Length > 0) && (r["keycode"] != null))
                    {
                        if (!hotkeyCode.ContainsKey(r["keyfunction"]))
                        {
                            hotkeyCode.Add(r["keyfunction"], r["keycode"]);
                        }
                        hotkeyDescription.Add(r["keyfunction"], r["key_description"]);
                    }
                    break;
                }
            }
        }