/// <summary>
        /// Adds the specified quick launch item configuration to the system registry.
        /// </summary>
        /// <param name="item">The quick launch item to create configuration for.</param>
        public static void AddItem(QLaunchItem item)
        {
            RegistryKey qlaunchKey = Registry.CurrentUser.OpenSubKey(ExecutorKeyName, true);

            qlaunchKey.CreateSubKey(item.Name).Close();
            UpdateItem(item);
        }
        /// <summary>
        /// Handles the Click event of the btnSave control. Here we will update or create a new
        /// configuration section depending on _isAddMode value.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">
        /// The <see cref="System.EventArgs"/> instance containing the event data.
        /// </param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (0 == hkcLaunchHotkey.Text.Length ||
                -1 == cbMonitor.SelectedIndex ||
                -1 == cbWindowState.SelectedIndex ||
                String.IsNullOrEmpty(txtItemName.Text) ||
                String.IsNullOrEmpty(txtExecutablePath.Text))
            {
                MessageBox.Show(this,
                                "Please fill all the required fields",
                                "Validation error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
                return;
            }

            QLaunchItem item = new QLaunchItem
                {
                    AsyncKeyCode = hkcLaunchHotkey.HotkeyModifiers,
                    MainKeyCode = hkcLaunchHotkey.Hotkey,
                    CmdParameters = txtCmdParams.Text,
                    FilePath = txtExecutablePath.Text,
                    MonitorIndex = cbMonitor.SelectedIndex,
                    Name = txtItemName.Text,
                    WindowState = (WindowState) Enum.Parse(typeof (WindowState), cbWindowState.Text)
                };

            if (_isAddMode)
                QLaunchConfiguration.AddItem(item);
            else
                QLaunchConfiguration.UpdateItem(item);

            RefreshItemsList();
        }
        /// <summary>
        /// Removes configuration for the specified item from the system registry.
        /// </summary>
        /// <param name="item">The item whose configuration is to be removed.</param>
        public static void RemoveItem(QLaunchItem item)
        {
            RegistryKey qlaunchKey =
                Registry.CurrentUser.OpenSubKey(ExecutorKeyName, true);

            qlaunchKey.DeleteSubKey(item.Name);

            qlaunchKey.Close();
        }
        /// <summary>
        /// Updates the specified quick launch item configuration in the system registry.
        /// </summary>
        /// <param name="item">The quick launch item to update configuration for.</param>
        public static void UpdateItem(QLaunchItem item)
        {
            RegistryKey qlaunchKey =
                Registry.CurrentUser.OpenSubKey(ExecutorKeyName, true);

            RegistryKey itemConfig = qlaunchKey.OpenSubKey(item.Name, true);
            if (null != itemConfig)
            {
                itemConfig.SetValue(ValueAsyncKeys,
                                    ModifierCodeFromKey((int)item.AsyncKeyCode),
                                    RegistryValueKind.DWord);
                itemConfig.SetValue(ValueParams, item.CmdParameters, RegistryValueKind.String);
                itemConfig.SetValue(ValuePath, item.FilePath, RegistryValueKind.String);
                itemConfig.SetValue(ValueMainKey, (int)item.MainKeyCode, RegistryValueKind.DWord);
                itemConfig.SetValue(ValueMonitor, item.MonitorIndex, RegistryValueKind.DWord);
                itemConfig.SetValue(ValueWindowState, item.WindowState, RegistryValueKind.DWord);

                itemConfig.Close();
            }

            qlaunchKey.Close();
        }
        /// <summary>
        /// Reads the quick launher configuration from registry.
        /// </summary>
        /// <returns>
        /// List of the quick launch items currently stored in the system registry.
        /// </returns>
        public static List<QLaunchItem> ReadConfiguration()
        {
            RegistryKey qlaunchKey = Registry.CurrentUser.OpenSubKey(ExecutorKeyName, false);

            // All registered quick launch items are stored as subkeys, iterate through them and
            // parse their data
            string[] itemNames = qlaunchKey.GetSubKeyNames();
            List<QLaunchItem> retVal = new List<QLaunchItem>(itemNames.Length);
            foreach (string itemName in itemNames)
            {
                RegistryKey itemConfig = qlaunchKey.OpenSubKey(itemName, false);

                QLaunchItem item = new QLaunchItem
                    {
                        Name = itemName,
                        AsyncKeyCode =
                            (Keys)KeyCodeFromModifier((int) itemConfig.GetValue(ValueAsyncKeys)),
                        CmdParameters = (string) itemConfig.GetValue(ValueParams),
                        FilePath = (string)      itemConfig.GetValue(ValuePath),
                        MainKeyCode = (Keys)     itemConfig.GetValue(ValueMainKey),
                        MonitorIndex = (int)    (itemConfig.GetValue(ValueMonitor)??0),
                        WindowState = (WindowState)
                            (itemConfig.GetValue(ValueWindowState) ?? WindowState.SW_NORMAL)
                    };
                retVal.Add(item);

                itemConfig.Close();
            }

            qlaunchKey.Close();

            return retVal;
        }