public void AddMapping(KeyMapping keyMapping)
        {
            int rowNum = addRow(keyMapping);

            keyMappings.Add(keyMapping);
            KeyMappingAdded?.Invoke(this, keyMapping);
            KeyMappingsChanged?.Invoke(this, EventArgs.Empty);
            tableLayoutPanel1.ScrollControlIntoView(tableLayoutPanel1.Controls[tableLayoutPanel1.Controls.Count - 1]);
        }
        int addRow(KeyMapping keyMapping)
        {
            Point   scrollPosition = this.AutoScrollPosition;
            Control label;

            if (keyMapping.ReadOnly)
            {
                label = new Label()
                {
                    Text = keyMapping.Title.TrimEnd(':') + ":", Dock = DockStyle.Fill, AutoSize = true, TextAlign = ContentAlignment.MiddleLeft
                };
            }
            else
            {
                TextBox textbox = new TextBox()
                {
                    Text = keyMapping.Title.TrimEnd(':') + ":", Dock = DockStyle.Fill
                };
                textbox.TextChanged += BindingTitle_TextChanged;
                textbox.Focus();
                textbox.SelectAll();
                label = textbox;
            }

            KeyPicker bindingKeyPicker = new KeyPicker()
            {
                Dock = DockStyle.Top, ChosenKey = keyMapping.Key
            },
                      leftToonKeyPicker = new KeyPicker()
            {
                Dock = DockStyle.Top, ChosenKey = keyMapping.LeftToonKey
            },
                      rightToonKeyPicker = new KeyPicker()
            {
                Dock = DockStyle.Top, ChosenKey = keyMapping.RightToonKey
            };
            Button removeBtn = new Button()
            {
                Text = "Remove", AutoSize = true, Enabled = !keyMapping.ReadOnly
            };

            bindingKeyPicker.KeyChosen += KeyChooser_KeyChosen;
            removeBtn.Click            += RemoveBtn_Click;

            leftToonKeyPicker.KeyChosen  += LeftToonKeyPicker_KeyChosen;
            rightToonKeyPicker.KeyChosen += RightToonKeyPicker_KeyChosen;

            tableLayoutPanel1.SuspendLayout();
            tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.AutoSize));
            tableLayoutPanel1.RowCount++;

            int rowNum = tableLayoutPanel1.RowCount - 1;

            tableLayoutPanel1.Controls.Add(label, 0, rowNum);
            tableLayoutPanel1.Controls.Add(bindingKeyPicker, 1, rowNum);
            tableLayoutPanel1.Controls.Add(leftToonKeyPicker, 2, rowNum);
            tableLayoutPanel1.Controls.Add(rightToonKeyPicker, 3, rowNum);
            tableLayoutPanel1.Controls.Add(removeBtn, 4, rowNum);
            tableLayoutPanel1.ResumeLayout();
            this.AutoScrollPosition = new Point(Math.Abs(scrollPosition.X), Math.Abs(scrollPosition.Y));

            return(rowNum);
        }