private void butDefaults_Click(object sender, EventArgs e)
        {
            if (DarkMessageBox.Show(this, "Do you really want to restore ALL key bindings to their default?", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
            {
                return;
            }

            _currConfig = new HotkeySets();
            RedrawList();
        }
        public FormKeyboardLayout(Editor editor)
        {
            InitializeComponent();

            _editor                = editor;
            _currConfig            = _editor.Configuration.UI_Hotkeys.Clone();
            commandList.DataSource = new SortableBindingList <CommandObj>(CommandHandler.Commands);
            listenKeys.Text        = _listenerMessage;

            _columnMessageWrongColor = commandList.BackColor.MixWith(Color.DarkRed, 0.55);

            CheckForConflicts();
        }
 private void commandList_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
 {
     if (commandList.Columns[e.ColumnIndex].Name == commandListColumnHotkeys.Name)
     {
         // Parse
         string errorMessage;
         HotkeySets.ParseHotkeys(e.FormattedValue.ToString(), out errorMessage);
         if (errorMessage != null)
         {
             if (DarkMessageBox.Show(this, errorMessage, "Invalid input", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning) != DialogResult.Cancel)
             {
                 e.Cancel = true; // We cancel the cell parsing, the user can retry inputting something.
             }
         }
     }
 }
        private void commandList_CellParsing(object sender, DataGridViewCellParsingEventArgs e)
        {
            if (e.RowIndex < 0 || e.RowIndex >= commandList.Rows.Count)
            {
                return;
            }

            if (commandList.Columns[e.ColumnIndex].Name == commandListColumnHotkeys.Name)
            {
                // Parse
                string             errorMessage;
                SortedSet <Hotkey> hotkeys = HotkeySets.ParseHotkeys(e.Value.ToString(), out errorMessage);
                if (hotkeys == null)
                {
                    return;
                }

                // Set
                CommandObj entry = (CommandObj)(commandList.Rows[e.RowIndex].DataBoundItem);
                _currConfig[entry] = hotkeys;

                CheckForConflicts();
            }
        }