Ejemplo n.º 1
0
        private async void OnTextEntered(object sender, TextCompositionEventArgs e)
        {
            string keystring = string.Empty;

            keystring = e == null ? "" : e.Text;
            var position = Editor.CaretOffset;

            if (position > 0 && _interactiveManager.IsCompletionTriggerCharacter(position - 1))
            {
                if (keystring != "(")
                {
                    _completionWindow                 = new CompletionWindow(Editor.TextArea);
                    _completionWindow.Opacity         = 0.9;
                    _completionWindow.WindowStyle     = WindowStyle.None;
                    _completionWindow.Width           = 300;
                    _completionWindow.Background      = Brushes.Black;
                    _completionWindow.BorderThickness = new Thickness(0);
                    var data = _completionWindow.CompletionList.CompletionData;

                    var completionDataList = await _interactiveManager.GetCompletionAsync(position, keystring);

                    foreach (var completionData in completionDataList)
                    {
                        data.Add(new AvalonEditCompletionData(completionData));
                    }

                    _completionWindow.Show();
                    _completionWindow.Closed += delegate
                    {
                        _completionWindow = null;
                    };
                }
                else if (keystring == "(" || keystring == ",")
                {
                    _insightWindow            = new RoslynEditorInsightWindow(Editor.TextArea);
                    _insightWindow.Foreground = Brushes.WhiteSmoke;
                    _insightWindow.Background = Brushes.Black;

                    var items = _interactiveManager.GetInsightTip(Editor.CaretOffset);
                    if (items != null && items.Count > 0)
                    {
                        _insightWindow.AddRangeItems(items);
                    }

                    _insightWindow.Show();
                    _insightWindow.Closed += delegate
                    {
                        _insightWindow = null;
                    };
                }
            }

            istypeset = false;
        }