コード例 #1
0
        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);
        }
コード例 #2
0
        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);
                        }
                    }
                }
            }
        }