Example #1
0
        public void ConvertsSingleKeys()
        {
            var converter = new KeyConverter();

            Assert.AreEqual("a", converter.Convert(Keys.A));
            Assert.AreEqual("z", converter.Convert(Keys.Z));
            Assert.AreEqual("\n", converter.Convert(Keys.Return));
            Assert.AreEqual(" ", converter.Convert(Keys.Space));
        }
Example #2
0
        private void OnXnaKeyDown(Keys key)
        {
            var noesisKey = KeyConverter.Convert(key);

            if (noesisKey == Key.None)
            {
                return;
            }

            if (this.IsIgnored(key))
            {
                return;
            }

            //System.Diagnostics.Debug.WriteLine("Noesis key down: " + noesisKey);
            this.view.KeyDown(noesisKey);

            var keyChar = VirtualKeyHelper.KeyCodeToUnicode((System.Windows.Forms.Keys)key);

            if (keyChar.Length != 1 ||
                keyChar[0] == '\0')
            {
                // no char pressed or unknown char pressed
                return;
            }

            //System.Diagnostics.Debug.WriteLine("Noesis char: " + keyChar[0]);
            this.view.Char(keyChar[0]);
        }
Example #3
0
        public void ConvertsEnumerablesOfKeys()
        {
            var converter = new KeyConverter();

            var result = converter.Convert(new[] { Keys.A, Keys.B, Keys.C, Keys.Space, Keys.Return });

            Assert.AreEqual("abc \n", result);
        }
        private void OnXnaKeyUp(Keys key)
        {
            var noesisKey = KeyConverter.Convert(key);

            if (noesisKey == Key.None)
            {
                return;
            }

            //System.Diagnostics.Debug.WriteLine("Noesis key up: " + noesisKey);
            this.view.KeyUp(noesisKey);
        }
            public CommandBarActionDef(VsShortcutFinder vsShortcutFinder, DTE dte, string actionId,
                                       CommandID commandId, CommandBarControl control,
                                       CommandBarPopup[] parentPopups)
            {
                ActionId = actionId;

                // Lazily initialise. Talking to the command bar objects is SLOOOOOOOWWWWWW.
                backingFields = Lazy.Of(() =>
                {
                    Assertion.AssertNotNull(control, "control != null");

                    var sb = new StringBuilder();
                    foreach (var popup in parentPopups)
                    {
                        sb.AppendFormat("{0} \u2192 ", popup.Caption);
                    }

                    var fields = new BackingFields
                    {
                        Text = MnemonicStore.RemoveMnemonicMark(control.Caption),
                        Path = MnemonicStore.RemoveMnemonicMark(sb.ToString())
                    };

                    var command    = VsCommandHelpers.TryGetVsCommandAutomationObject(commandId, dte);
                    var vsShortcut = vsShortcutFinder.GetVsShortcut(command);
                    if (vsShortcut != null)
                    {
                        var details = new ShortcutDetails[vsShortcut.KeyboardShortcuts.Length];
                        for (int i = 0; i < vsShortcut.KeyboardShortcuts.Length; i++)
                        {
                            var keyboardShortcut = vsShortcut.KeyboardShortcuts[i];
                            details[i]           = new ShortcutDetails(KeyConverter.Convert(keyboardShortcut.Key),
                                                                       keyboardShortcut.Modifiers);
                        }
                        fields.VsShortcut = new ShortcutSequence(details);
                    }

                    return(fields);
                }, true);
            }