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; } }
public void GroupSelection(KeyGroupType keysGroupType) { XkeySelection selection = GetSelection(); RemoveSelectedKeys(); KeyGroup keyGroup = new KeyGroup() { Type = keysGroupType, Name = selection.GetName() }; int topmostRow = -1; int leftmostColumn = -1; foreach (KeyBase selectedKey in selection.SelectedKeys) { selectedKey.ClearSelection(); keyGroup.Keys.Add(selectedKey); if (topmostRow == -1 || selectedKey.Row < topmostRow) { topmostRow = selectedKey.Row; } if (leftmostColumn == -1 || selectedKey.Column < leftmostColumn) { leftmostColumn = selectedKey.Column; } } keyGroup.Selected = true; keyGroup.SetPosition(leftmostColumn, topmostRow); keys.Add(keyGroup); OnSelectionChanged(); }