示例#1
0
        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);
                        }
                    }
                }
            }
        }
示例#2
0
 public KeyComboBox()
     : base()
 {
     foreach (var key in ScancodeKey.GetAllKeys())
     {
         this.Items.Add(key);
     }
     this.AutoCompleteMode   = AutoCompleteMode.Append;
     this.AutoCompleteSource = AutoCompleteSource.ListItems;
 }
示例#3
0
 public ScancodeKey(int scancode)
 {
     this.Scancode = scancode;
     this.Text     = ScancodeKey.GetText(scancode);
 }