public void Draw(Graphics graphics, Byte[] keyCode, Byte[] blockedKeys, KeyLayout xkeyLayout, bool isFocused) { for (int i = 0; i < keyCode.Length; i++) { DrawColumn(graphics, i, keyCode[i], blockedKeys[i], xkeyLayout, isFocused); } }
public KeyLayout GetLayout(Byte[] keyCode, Byte[] blockedKeys) { KeyLayout result = new KeyLayout(); for (int columnIndex = 0; columnIndex < keyCode.Length; columnIndex++) { for (int rowIndex = 0; rowIndex < Hardware.Keyboard.NumRows; rowIndex++) { int mask = (int)Math.Round(Math.Pow(2, rowIndex)); if (!Hardware.Keyboard.IsValidKey(columnIndex, rowIndex)) { continue; } Key xkey = new Key(); xkey.SetPosition(columnIndex, rowIndex); int keyCodeMask = keyCode[columnIndex]; if ((mask & keyCodeMask) == mask) { int blockedKeyMask = blockedKeys[columnIndex]; if ((mask & blockedKeyMask) == mask) { xkey.IsBlocked = true; } } result.Keys.Add(xkey); } } return(result); }
public void Draw(Graphics graphics, XkeysDataHandler xkeysDataHandler, KeyLayout xkeyLayout, bool isFocused) { if (xkeyLayout != null) { foreach (KeyBase key in xkeyLayout.Keys) { int columnIndex = key.Column; byte keyCode = xkeysDataHandler.LastKeyCode[columnIndex]; byte blockedKeyMask = xkeysDataHandler.BlockedKeysMask[columnIndex]; KeyGroup xkeyGroup = key as KeyGroup; KeyGroupType keyType; if (xkeyGroup != null) { keyType = xkeyGroup.Type; } else { keyType = KeyGroupType.NoGroup; } DrawKey(graphics, columnIndex, key.Row, keyCode, blockedKeyMask, xkeyLayout, keyType, isFocused); } } else { Draw(graphics, xkeysDataHandler.LastKeyCode, xkeysDataHandler.BlockedKeysMask, xkeyLayout, isFocused); } }
public void Ungroup(KeyLayout layout) { layout.Remove(this); foreach (KeyBase key in keys) { layout.Keys.Add(key); } }
public string GetDisplayShortcut(KeyLayout xkeyLayout = null) { if (xkeyLayout == null) { return(CustomBindingName); } return(xkeyLayout.GetBindingName(_AnyShiftModifier, _CtrlKeyDown, _ShiftKeyDown, _AltKeyDown, CustomData)); }
void RestoreDefaultLayout() { if (xkeyLayout != null) { xkeyLayout.SelectionChanged -= xkeyLayout_SelectionChanged; } xkeyLayout = xkeysPainter.GetLayout(XkeysRaw.Data.LastKeyCode, XkeysRaw.Data.BlockedKeysMask); xkeyLayout.SelectionChanged += xkeyLayout_SelectionChanged; }
public XkeysEditControl() { InitializeComponent(); xkeysEngine = new XkeysEngine(); xkeysEngine.XkeyPressed += xkeysEngine_XkeyPressed; _Shortcut = new CustomInputShortcut(); XkeysRaw.Data.DataChanged += Data_DataChanged; xkeysPainter.SetKeySizeToFit(xkeyPreview.ClientRectangle.Size); xkeyLayout = xkeysPainter.GetLayout(XkeysRaw.Data.LastKeyCode, XkeysRaw.Data.BlockedKeysMask); xkeyLayout.Load(); }
void DrawColumn(Graphics graphics, int columnIndex, byte keyCode, int blockedKeyMask, KeyLayout xkeyLayout, bool isFocused) { for (int rowIndex = 0; rowIndex < Hardware.Keyboard.NumRows; rowIndex++) { DrawKey(graphics, columnIndex, rowIndex, keyCode, blockedKeyMask, xkeyLayout, KeyGroupType.NoGroup, isFocused); } }
void DrawKey(Graphics graphics, int columnIndex, int rowIndex, byte keyCode, int blockedKeyMask, KeyLayout xkeyLayout, KeyGroupType keyType, bool isFocused) { int mask = (int)Math.Round(Math.Pow(2, rowIndex)); if (Hardware.Keyboard.IsValidKey(columnIndex, rowIndex)) { bool isSelected; string keyName = string.Empty; bool blockOverride = false; if (xkeyLayout != null) { isSelected = xkeyLayout.IsSelected(columnIndex, rowIndex); keyName = xkeyLayout.GetKeyName(columnIndex, rowIndex); Key key = xkeyLayout.GetKey(columnIndex, rowIndex) as Key; if (key != null) { blockOverride = key.IsBlocked; } } else { isSelected = false; } if ((mask & keyCode) == mask) { if (blockOverride || (mask & blockedKeyMask) == mask) { DrawBlockedKey(graphics, columnIndex, rowIndex, keyType, isSelected); } else { DrawKeyDown(graphics, columnIndex, rowIndex, keyType, isSelected, keyName, isFocused); } } else if (blockOverride) { DrawBlockedKey(graphics, columnIndex, rowIndex, keyType, isSelected); } else { foreach (KeyBase selectedKey in selectedKeys) { if (columnIndex == selectedKey.Column && rowIndex == selectedKey.Row) { DrawSelectedKey(graphics, columnIndex, rowIndex, keyType, isSelected, keyName); return; } } DrawKeyUp(graphics, columnIndex, rowIndex, keyType, isSelected, keyName); } } }
public XkeysEngine() { xkeyLayout = new KeyLayout(); xkeyLayout.Load(); XkeysRaw.Data.DataChanged += Data_DataChanged; }