private static void Init() { if (Keys == null) { ScancodeKey.Keys = new List <ScancodeKey>(); ScancodeKey.ScancodeKeyMapping = new Dictionary <int, ScancodeKey>(); var assembly = Assembly.GetEntryAssembly(); using (var sr = new StreamReader(assembly.GetManifestResourceStream(assembly.GetName().Name + ".Resources.Mapping.txt"))) { while (!sr.EndOfStream) { var line = sr.ReadLine(); if (!string.IsNullOrWhiteSpace(line) && !(line.StartsWith("#", StringComparison.InvariantCulture))) { var parts = line.Split(new char[] { ' ' }, 2); var scancode = int.Parse(parts[0], NumberStyles.HexNumber, CultureInfo.InvariantCulture); var text = parts[1].Trim(); var key = new ScancodeKey(scancode, text); Keys.Add(key); ScancodeKeyMapping.Add(scancode, key); } } } } }
public KeyComboBox() : base() { foreach (var key in ScancodeKey.GetAllKeys()) { this.Items.Add(key); } this.AutoCompleteMode = AutoCompleteMode.Append; this.AutoCompleteSource = AutoCompleteSource.ListItems; }
public ScancodeKey(int scancode) { this.Scancode = scancode; this.Text = ScancodeKey.GetText(scancode); }