private IInputHandler CreateCodeCompletionInputHandler() { var inputHandler = new InputCommandsHandler(editview); AddCommandBinding(inputHandler, CodeCompletionCommands.SelectPreviousCompletion, ModifierKeys.None, Key.Up, new ExecutedRoutedEventHandler(SelectPreviousCompletion), new CanExecuteRoutedEventHandler(CanOperate)); AddCommandBinding(inputHandler, CodeCompletionCommands.SelectNextCompletion, ModifierKeys.None, Key.Down, new ExecutedRoutedEventHandler(SelectNextCompletion), new CanExecuteRoutedEventHandler(CanOperate)); AddCommandBinding(inputHandler, CodeCompletionCommands.SelectFirstCompletion, ModifierKeys.None, Key.Home, new ExecutedRoutedEventHandler(SelectFirstCompletion), new CanExecuteRoutedEventHandler(CanOperate)); AddCommandBinding(inputHandler, CodeCompletionCommands.SelectLastCompletion, ModifierKeys.None, Key.End, new ExecutedRoutedEventHandler(SelectLastCompletion), new CanExecuteRoutedEventHandler(CanOperate)); AddCommandBinding(inputHandler, CodeCompletionCommands.SelectPreviousPageCompletion, ModifierKeys.None, Key.PageUp, new ExecutedRoutedEventHandler(SelectPreviousPageCompletion), new CanExecuteRoutedEventHandler(CanOperate)); AddCommandBinding(inputHandler, CodeCompletionCommands.SelectNextPageCompletion, ModifierKeys.None, Key.PageDown, new ExecutedRoutedEventHandler(SelectNextPageCompletion), new CanExecuteRoutedEventHandler(CanOperate)); return(inputHandler); }
private void OnCompletionListSelectionChanged(object sender, SelectionChangedEventArgs e) { if (_completionList._listBox.SelectedIndex >= 0) { if (!_enterCommandPushed) { if (_completionRequestInputHandler == null) { var inputHandler = new InputCommandsHandler(_editview); var cmdBinding = new CommandBinding(CodeCompletionCommands.RequestCompletion, new ExecutedRoutedEventHandler(OnCompletionRequest)); inputHandler.CommandBindings.Add(cmdBinding); inputHandler.InputBindings.Add(new KeyBinding(CodeCompletionCommands.RequestCompletion, Key.Enter, ModifierKeys.None)); inputHandler.CommandBindings.Add(cmdBinding); inputHandler.InputBindings.Add(new KeyBinding(CodeCompletionCommands.RequestCompletion, Key.Tab, ModifierKeys.None)); _completionRequestInputHandler = inputHandler; } _editview.PushInputHandler(_completionRequestInputHandler); _enterCommandPushed = true; } ICompletionData completion = _completionList._listBox.SelectedItem as ICompletionData; Object description = completion.Description; if (description != null) { if (description is UIElement) { _tip.Content = description; } else { var textblock = new TextBlock { Text = description.ToString(), TextWrapping = TextWrapping.Wrap, }; _tip.Content = textblock; } _tip.IsOpen = true; } } else { _tip.IsOpen = false; } }
private void AddCommandBinding(InputCommandsHandler commandsHandler, ICommand command, ModifierKeys modifiers, Key key, ExecutedRoutedEventHandler executeHandler, CanExecuteRoutedEventHandler canExecuteHandler = null) { commandsHandler.CommandBindings.Add(new CommandBinding(command, executeHandler, canExecuteHandler)); commandsHandler.InputBindings.Add(CreateFrozenKeyBinding(command, modifiers, key)); }