private static KeyEnum.Type keyType = KeyEnum.Type.WindowsForms; // Default startup value for KeyType Property ..

        /// <summary>
        /// Initializes a new instance of the <see cref="KeyBindingReader" /> class.
        /// </summary>
        /// <param name="cfgFilePath"></param>
        public KeyBindingReader(string cfgFilePath)
        {
            this.cfgFilePath = cfgFilePath;

            // Load XDocument into memory for availability in any derived classes ..
            this.xCfg = HandleXml.ReadXDoc(this.cfgFilePath);
        }
Beispiel #2
0
        public static void CreateAliasFromXml()
        {
            HandleXml Xmlr = new HandleXml();

            // Xmlr.GetAddrFromXmlFile();
            HandleXml.GetAddrFromXmlFile();
            HandleXml.GetAdapterFromXmlFile();
        }
        /// <summary>
        /// Update Voice Attack Profile Name
        /// </summary>
        /// <remarks>
        ///   Format: XML
        ///             o <Profile/>[*]
        ///               |_ <Name/>
        ///               |_ <Commands/>
        ///                  |_ <Command/>
        /// </remarks>
        /// <param name="profileFilepath"></param>
        /// <param name="profileName"></param>
        /// <param name="updatedProfileName"></param>
        private void UpdateVoiceAttackProfileName(string profileFilepath, string profileName, string updatedProfileName)
        {
            var vap = HandleXml.ReadXDoc(profileFilepath);

            // Update XMLunsignedShort XMLName ..
            vap.Descendants(XMLName)
            .Where(item => item.SafeElementValue() == profileName).FirstOrDefault()
            .SetValue(updatedProfileName);

            vap.Save(profileFilepath);
        }
        /// <summary>
        /// Update Key Code associated to specific [Id] in Voice Attack
        /// </summary>
        /// <remarks>
        ///   Format: XML
        ///             o <Profile/>
        ///               |_ <Commands/>
        ///                  |_ <Command/>
        ///                      |_<Id/>
        ///                      !_<commandString/>
        ///                      |_<ActionSequence/>
        ///                        !_[some] <CommandAction/>
        ///                                 !_<Id/>
        ///                                 |_<ActionType/> = PressKey
        ///                                 |_<KeyCodes/>
        ///                                   (|_<unsignedShort/> = when modifier present)[*]
        ///                                    |_<unsignedShort/>[*]
        ///                      !_<Category/> = Keybindings
        /// </remarks>
        /// <param name="profileFilepath"></param>
        /// <param name="vakeyId"></param>
        /// <param name="keyCode"></param>
        private void UpdateVoiceAttackKeyCode(string profileFilepath, string vakeyId, string keyCode)
        {
            var vap = HandleXml.ReadXDoc(profileFilepath);

            // Update XMLunsignedShort XElement ..
            vap.Descendants(XMLunsignedShort)
            .Where(item => item.Parent.Parent.Element(XMLActionId).Value == vakeyId).FirstOrDefault()
            .SetValue(keyCode);

            vap.Save(profileFilepath);
        }
        /// <summary>
        /// Remove KeyCode(s) that do not match KeyCode value where Id = specific [Id] in Voice Attack
        /// </summary>
        /// <remarks>
        /// Search for any <unsignedShort/> elements whose grandparent (Parent.Parent) <id> element equals vakeyId
        /// and remove any <unsignedShort/> XElement(s) that do not match keyCode value ..
        ///   Format: XML
        ///             o <Profile/>
        ///               |_ <Commands/>
        ///                  |_ <Command/>
        ///                      |_<Id/>
        ///                      !_<commandString/>
        ///                      |_<ActionSequence/>
        ///                        !_[some] <CommandAction/>
        ///                                 !_<Id/>
        ///                                 |_<ActionType/> = PressKey
        ///                                 |_<KeyCodes/>
        ///                                   (|_<unsignedShort/> = when modifier present)[*]
        ///                                    |_<unsignedShort/>[*]
        ///                      !_<Category/> = Keybindings
        /// </remarks>
        /// <param name="vaprofile"></param>
        /// <param name="vakeyId"></param>
        /// <param name="keyCode"></param>
        private void RemoveAnyOtherVoiceAttackKeyCode(string profileFilepath, string vakeyId, string keyCode)
        {
            var vap = HandleXml.ReadXDoc(profileFilepath);

            // Remove all XMLunsignedShort XElements ...
            vap.Descendants(XMLunsignedShort)
            .Where(item => item.Parent.Parent.Element(XMLActionId).Value == vakeyId && item.Value != keyCode)
            .Remove();

            vap.Save(profileFilepath);
        }
        /// <summary>
        /// Add KeyCode for modifier associated to specific [Id] in Voice Attack
        /// </summary>
        /// <remarks>
        /// Search for any <unsignedShort/> elements whose grandparent (Parent.Parent) <id> element equals vakeyId
        /// and add a new <unsignedShort/> XElement with keyCode value physically before existing one ..
        ///   Format: XML
        ///             o <Profile/>
        ///               |_ <Commands/>
        ///                  |_ <Command/>
        ///                      |_<Id/>
        ///                      !_<commandString/>
        ///                      |_<ActionSequence/>
        ///                        !_[some] <CommandAction/>
        ///                                 !_<Id/>
        ///                                 |_<ActionType/> = PressKey
        ///                                 |_<KeyCodes/>
        ///                                   (|_<unsignedShort/> = when modifier present)[*]
        ///                                    |_<unsignedShort/>
        ///                      !_<Category/> = Keybindings
        /// </remarks>
        /// <param name="vaprofile"></param>
        /// <param name="vakeyId"></param>
        /// <param name="keyCode"></param>
        private void InsertVoiceAttackModifierKeyCode(string profileFilepath, string vakeyId, string keyCode)
        {
            var vap = HandleXml.ReadXDoc(profileFilepath);

            // Insert XMLunsignedShort XElement before existing one ..
            vap.Descendants(XMLunsignedShort)
            .Where(item => item.Parent.Parent.Element(XMLActionId).Value == vakeyId).FirstOrDefault()
            .AddBeforeSelf(new XElement(XMLunsignedShort, keyCode));

            vap.Save(profileFilepath);
        }
Beispiel #7
0
        /// <summary>
        /// Update Elite Dangerous Binds Preset Name
        /// </summary>
        /// <remarks>
        ///   Format: XML
        ///             o <Root PresetName=[*]/>
        ///               |_ <KeyboardLayout/>
        ///               |_ <things/>
        ///                  |_<Binding/>
        ///                  |_<Inverted/>
        ///                  |_<Deadzone/>
        ///               |_ <things/>
        ///                  |_<Primary/>
        ///                     |_<Device = {NoDevice}/>
        ///                     |_<Key/ = empty>
        /// </remarks>
        /// <param name="eliteDangerousBinds"></param>
        /// <param name="presetName"></param>
        /// <param name="updatedPresetName"></param>
        private void UpdateBindsPresetName(string eliteDangerousBinds, string presetName, string updatedPresetName)
        {
            var binds = HandleXml.ReadXDoc(eliteDangerousBinds);

            // Update attribute of root node ..
            binds.Root
            .Attributes(XMLPresetName)
            .Where(item => item.Value == presetName).FirstOrDefault()
            .SetValue(updatedPresetName);

            binds.Save(eliteDangerousBinds);
        }
Beispiel #8
0
        /// <summary>
        /// Update unbound Elite Dangerous Actions with Key Codes from Voice Attack
        /// </summary>
        /// </remarks>
        /// <param name="eliteDangerousBinds"></param>
        /// <param name="devicePriority"></param>
        /// <param name="actionName"></param>
        /// <param name="modifierKeyValue"></param>
        /// <returns></returns>
        private bool UpdateVacantEliteDangerousBinding(string eliteDangerousBinds, string devicePriority, string actionName, string regularKeyValue, string modifierKeyValue)
        {
            // Initialise ..
            var  binds   = HandleXml.ReadXDoc(eliteDangerousBinds);
            bool success = false;

            // Attempt to update regular key codes ..
            success = this.UpdateVacantEliteDangerousRegularKeyBinding(binds, devicePriority, actionName, regularKeyValue);

            // Attempt to update modifier key codes ..
            if (modifierKeyValue.Length > 0)
            {
                success = this.UpdateVacantEliteDangerousModifierKeyBinding(binds, devicePriority, actionName, regularKeyValue, modifierKeyValue);
            }

            if (success)
            {
                binds.Save(eliteDangerousBinds);
            }

            return(success);
        }