public void GatherKeystrokes() { _keystrokes.Clear(); foreach (KeyboardLayoutName name in Enum.GetValues(typeof(KeyboardLayoutName))) { var xml = KeyboardPanel.GetKeyboardLayoutXml(name); if (xml != null) { var layout = KeyboardLayout.Load(xml); Walk(layout); } } KeystrokeCasesTest.AssertEverything(_keystrokes); }
void Walk(KeyLayout key) { var character = key as CharacterKeyLayout; if (character != null) { var unshifted = character.Value ?? character.Caption; _keystrokes.Add(KeyboardHost.AutoEscape(unshifted)); KeystrokeCasesTest.CheckCovered(unshifted); var shifted = character.ShiftValue ?? character.ShiftCaption ?? (unshifted.ToUpperInvariant() != unshifted ? unshifted.ToUpperInvariant() : unshifted); _keystrokes.Add(KeyboardHost.AutoEscape(shifted)); KeystrokeCasesTest.CheckCovered(shifted); switch (unshifted) { case "{HOME}": case "{END}": case "{LEFT}": case "{RIGHT}": Assert.AreEqual("+" + unshifted, shifted, "Special case shifts"); break; } } else { var group = key as ConditionalGroupLayout; if (group != null) { foreach (var conditional in group.Conditionals) { foreach (var childKey in conditional.Keys) { Walk(childKey); } } } } }