void UpdateControlsBasedOnSelection()
        {
            updatingInternally = true;
            try
            {
                XkeySelection selection = xkeyLayout.GetSelection();
                bool          isTall    = selection.GetGroupType() == KeyGroupType.Tall;
                bool          isWide    = selection.GetGroupType() == KeyGroupType.Wide;
                bool          isSquare  = selection.GetGroupType() == KeyGroupType.Square;

                chkTall.Checked                 = isTall;
                chkWide.Checked                 = isWide;
                chkSquareButton.Checked         = isSquare;
                chkKeyRepeatsifHeldDown.Checked = selection.AllKeysRepeatIfHeldDown();
                chkBlocker.Enabled              = selection.HasOnlySingleKeys();
                txtKeyName.Enabled              = selection.Count > 0;
                if (chkBlocker.Enabled)
                {
                    chkBlocker.Checked = selection.IsBlocked();
                }
                chkTall.Enabled = isTall || selection.CanBeTall();
                chkWide.Enabled = isWide || selection.CanBeWide();
                chkKeyRepeatsifHeldDown.Enabled = selection.Count > 0;
                chkSquareButton.Enabled         = isSquare || selection.CanBeSquare();
                txtKeyName.Text = selection.GetName();
            }
            finally
            {
                updatingInternally = false;
            }
        }
        private void chkBlocker_CheckedChanged(object sender, EventArgs e)
        {
            if (updatingInternally)
            {
                return;
            }
            XkeySelection selection = xkeyLayout.GetSelection();

            if (selection.GetGroupType() != KeyGroupType.NoGroup)
            {
                return;
            }

            bool allAreBlocked = true;

            foreach (KeyBase selectedKey in selection.SelectedKeys)
            {
                Key xkey = selectedKey as Key;
                if (xkey != null)
                {
                    if (!xkey.IsBlocked)
                    {
                        allAreBlocked = false;
                    }
                }
            }

            bool newBlockSetting;

            if (allAreBlocked)
            {
                newBlockSetting = false;
            }
            else
            {
                newBlockSetting = true;
            }
            foreach (KeyBase selectedKey in selection.SelectedKeys)
            {
                Key xkey = selectedKey as Key;
                if (xkey != null)
                {
                    xkey.IsBlocked = newBlockSetting;
                }
            }
            xkeyLayout.BlockSettingsChanged();
            RefreshKeyLayout();
            txtKeyName.Focus();
        }
        private void chkWide_CheckedChanged(object sender, EventArgs e)
        {
            if (updatingInternally)
            {
                return;
            }
            XkeySelection selection = xkeyLayout.GetSelection();

            if (selection.GetGroupType() == KeyGroupType.Wide)
            {
                xkeyLayout.UngroupSelection();
            }
            else if (selection.Count == 2)
            {
                xkeyLayout.GroupSelection(KeyGroupType.Wide);
            }
            txtKeyName.Focus();
        }