protected void InitButton(Button btn, UInt32 scanCode) { if (!_buttons.Contains(btn)) { _buttons.Add(btn); btn.Click += btnMapping_Click; btn.AutoEllipsis = true; } btn.Text = InputApi.GetKeyName(scanCode); btn.Tag = scanCode; }
private string GetKeyNames() { List <UInt32> scanCodes = new List <uint>() { Key1, Key2, Key3 }; List <string> keyNames = scanCodes.Select((UInt32 scanCode) => InputApi.GetKeyName(scanCode)).Where((keyName) => !string.IsNullOrWhiteSpace(keyName)).ToList(); keyNames.Sort((string a, string b) => { if (a == b) { return(0); } if (a == "Ctrl") { return(-1); } else if (b == "Ctrl") { return(1); } if (a == "Alt") { return(-1); } else if (b == "Alt") { return(1); } if (a == "Shift") { return(-1); } else if (b == "Shift") { return(1); } return(a.CompareTo(b)); }); return(string.Join("+", keyNames)); }