/// <summary>
        /// Loads the user's settings from settings.xml.
        /// </summary>
        private void LoadSettings()
        {
            var document = new XmlDocument();

            try
            {
                document.Load("settings.xml");

                delayStepper.Value = Int32.Parse(document.DocumentElement.SelectSingleNode("changedelay").InnerText);

                var inputNodes = document.DocumentElement.SelectNodes("input");
                for (int i = 0; i < inputNodes.Count; i++)
                {
                    var input = inputs[i];
                    foreach (XmlNode hotKeyNode in inputNodes[i].SelectNodes("hotkey"))
                    {
                        var hotKey = new HotKeyManager.HotKey((Keys)Int32.Parse(hotKeyNode.InnerText));
                        hotKey.isCtrl  = hotKeyNode.Attributes["ctrl"] != null && Boolean.Parse(hotKeyNode.Attributes["ctrl"].Value);
                        hotKey.isShift = hotKeyNode.Attributes["shift"] != null && Boolean.Parse(hotKeyNode.Attributes["shift"].Value);
                        hotKey.isAlt   = hotKeyNode.Attributes["alt"] != null && Boolean.Parse(hotKeyNode.Attributes["alt"].Value);
                        input.AddHotKey(hotKey);
                    }
                }
            }
            catch (Exception)
            {
                // Something blew up, fall back to default settings.
                SetDefaultSettings();
            }
        }
 private void OnNewHotKeyBound(bool wasRebindSuccessful, HotKeyManager.HotKey hotKey)
 {
     isListeningForNewHotKey = false;
     if (wasRebindSuccessful)
     {
         AddHotKey(hotKey);
     }
 }
        /// <summary>
        /// Assigns a new hotkey to this input.
        /// Whenever the hotkey is pressed, the <c>InputRequested</c> event
        /// will fire.
        /// </summary>
        /// <param name="hotKey">The hotkey to bind to this input.</param>
        public void AddHotKey(HotKeyManager.HotKey hotKey)
        {
            var binding = new HotKeyManager.HotKeyBinding
            {
                hotKey  = hotKey,
                handler = OnHotKeyPressed,
            };

            hotKeyManager.AddHotKey(binding);
            bindings.Add(binding);
            UpdateLabel();
        }