Ejemplo n.º 1
0
        public void OnKeyDown(KeyEventArgs e)
        {
            if (e.Modifiers == InputModifiers.None)
            {
                if (intellisenseControl.IsVisible)
                {
                    if (!IsCompletionKey(e))
                    {
                        switch (e.Key)
                        {
                        case Key.Down:
                        {
                            var index = intellisenseControl.CompletionData.IndexOf(intellisenseControl.SelectedCompletion);

                            if (index < intellisenseControl.CompletionData.Count - 1)
                            {
                                intellisenseControl.SelectedCompletion = intellisenseControl.CompletionData[index + 1];
                            }

                            e.Handled = true;
                        }
                        break;

                        case Key.Up:
                        {
                            var index = intellisenseControl.CompletionData.IndexOf(intellisenseControl.SelectedCompletion);

                            if (index > 0)
                            {
                                intellisenseControl.SelectedCompletion = intellisenseControl.CompletionData[index - 1];
                            }

                            e.Handled = true;
                        }
                        break;
                        }
                    }
                }

                if (completionAssistant.IsVisible)
                {
                    if (!e.Handled)
                    {
                        switch (e.Key)
                        {
                        case Key.Down:
                        {
                            completionAssistant.IncrementSignatureIndex();
                            e.Handled = true;
                        }
                        break;

                        case Key.Up:
                        {
                            completionAssistant.DecrementSignatureIndex();
                            e.Handled = true;
                        }
                        break;
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void OnKeyDown(KeyEventArgs e, int caretIndex, int line, int column)
        {
            if (e.Source == editor)
            {
                capturedOnKeyDown = e.Key;

                if (intellisenseControl.IsVisible)
                {
                    switch (capturedOnKeyDown)
                    {
                        case Key.Down:
                            {
                                var index = intellisenseControl.CompletionData.IndexOf(intellisenseControl.SelectedCompletion);

                                if (index < intellisenseControl.CompletionData.Count - 1)
                                {
                                    intellisenseControl.SelectedCompletion = intellisenseControl.CompletionData[index + 1];
                                }

                                e.Handled = true;
                            }
                            break;

                        case Key.Up:
                            {
                                var index = intellisenseControl.CompletionData.IndexOf(intellisenseControl.SelectedCompletion);

                                if (index > 0)
                                {
                                    intellisenseControl.SelectedCompletion = intellisenseControl.CompletionData[index - 1];
                                }

                                e.Handled = true;
                            }
                            break;

                        case Key.Back:
                            if (caretIndex - 1 >= intellisenseStartedAt)
                            {
                                intellisenseJobRunner.InvokeAsync(() =>
                                {
                                    UpdateFilter(caretIndex - 1);
                                });
                            }
                            break;

                        case Key.Enter:
                            intellisenseJobRunner.InvokeAsync(() =>
                            {
                                DoComplete(false);
                            });

                            e.Handled = true;
                            break;
                    }
                }

                if (completionAssistant.IsVisible)
                {
                    if (!e.Handled)
                    {
                        switch (e.Key)
                        {
                            case Key.Down:
                                {
                                    completionAssistant.IncrementSignatureIndex();
                                    e.Handled = true;
                                }
                                break;

                            case Key.Up:
                                {
                                    completionAssistant.DecrementSignatureIndex();
                                    e.Handled = true;
                                }
                                break;
                        }
                    }
                }

                if (e.Key == Key.Escape)
                {
                    if (completionAssistant.IsVisible)
                    {
                        intellisenseJobRunner.InvokeAsync(() =>
                        {
                            Dispatcher.UIThread.InvokeAsync(() =>
                            completionAssistant.Close());
                        });
                    }
                    else if (intellisenseControl.IsVisible)
                    {
                        intellisenseJobRunner.InvokeAsync(() =>
                        {
                            CloseIntellisense();
                        });
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public void OnKeyDown(KeyEventArgs e, int caretIndex, int line, int column)
        {
            capturedOnKeyDown = e.Key;

            if (!_hidden)
            {
                switch (capturedOnKeyDown)
                {
                case Key.Down:
                {
                    var index = intellisenseControl.CompletionData.IndexOf(intellisenseControl.SelectedCompletion);

                    if (index < intellisenseControl.CompletionData.Count - 1)
                    {
                        intellisenseControl.SelectedCompletion = intellisenseControl.CompletionData[index + 1];
                    }

                    e.Handled = true;
                }
                break;

                case Key.Up:
                {
                    var index = intellisenseControl.CompletionData.IndexOf(intellisenseControl.SelectedCompletion);

                    if (index > 0)
                    {
                        intellisenseControl.SelectedCompletion = intellisenseControl.CompletionData[index - 1];
                    }

                    e.Handled = true;
                }
                break;

                case Key.Back:
                    UpdateFilter(caretIndex - 1);
                    break;

                case Key.Tab:
                case Key.Enter:
                    DoComplete(false);
                    e.Handled = true;
                    break;
                }
            }

            if (completionAssistant.IsVisible)
            {
                if (!e.Handled)
                {
                    switch (e.Key)
                    {
                    case Key.Down:
                    {
                        completionAssistant.IncrementSignatureIndex();
                        e.Handled = true;
                    }
                    break;

                    case Key.Up:
                    {
                        completionAssistant.DecrementSignatureIndex();
                        e.Handled = true;
                    }
                    break;
                    }
                }
            }

            if (e.Key == Key.Escape)
            {
                if (completionAssistant.IsVisible)
                {
                    completionAssistant.Close();
                    e.Handled = true;
                }
                else if (!_hidden)
                {
                    CloseIntellisense();
                    e.Handled = true;
                }
            }
        }