当前位置: 首页>>代码示例>>C#>>正文


C# ICompletionData.Where方法代码示例

本文整理汇总了C#中ICompletionData.Where方法的典型用法代码示例。如果您正苦于以下问题:C# ICompletionData.Where方法的具体用法?C# ICompletionData.Where怎么用?C# ICompletionData.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICompletionData的用法示例。


在下文中一共展示了ICompletionData.Where方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShowCompletionWindow

        /// <summary>
        /// Shows the completion window.
        /// </summary>
        /// <param name="completionData">The completion data.</param>
        /// <param name="symbol">The symbol (pre-selection in the completion window).</param>
        /// <param name="key">The key typed.</param>
        private void ShowCompletionWindow(ICompletionData[] completionData, string symbol, char key)
        {
            // If there is no completion data in this context, we close existing windows.
            if (completionData == null || completionData.Length == 0)
            {
                _completionWindow?.Close();
                return;
            }

            // Get the text used to filter the list box.
            string selectionText;
            if (string.IsNullOrEmpty(symbol))
                selectionText = (key != '\0') ? key.ToString() : null;
            else if (key != '\0')
                selectionText = symbol + key;
            else
                selectionText = symbol;

            // Filter and sort the completion data.
            var filteredData = completionData.Where(d => string.IsNullOrEmpty(selectionText)
                                                          || d.Text.Length > selectionText.Length && d.Text.StartsWith(selectionText, true, null))
                                              .OrderBy(d => d.Text)
                                              .ToArray();

            // If there is no completion data in this context, we close existing windows.
            if (filteredData.Length == 0)
            {
                _completionWindow?.Close();
                return;
            }

            // Close insight windows.
            _overloadInsightWindow?.Close();

            // Create new window or we only update the existing one.
            if (_completionWindow == null)
            {
                _completionWindow = new CompletionWindow(_textEditor.TextArea) { MaxHeight = 300 };
            }

            // Set new completion items.
            _completionWindow.CompletionList.CompletionData.Clear();
            foreach (var data in filteredData)
            {
                if (!(data is GuessCompletionData) || data.Text != selectionText)
                    _completionWindow.CompletionList.CompletionData.Add(data);
            }

            // Select current item.
            if (selectionText != null)
                _completionWindow.CompletionList.SelectItem(selectionText);

            // Remember start offset of current identifier, to close window when cursor
            // moves back too far.
            if (symbol != null)
            {
                _completionStartOffset = _textEditor.CaretOffset - symbol.Length;
                _completionWindow.StartOffset = _completionStartOffset;
            }
            else
            {
                _completionStartOffset = _textEditor.CaretOffset;
            }

            // Show window.
            _completionWindow.Show();

            // Delete instance when window is closed.
            _completionWindow.Closed += delegate { _completionWindow = null; };
        }
开发者ID:,项目名称:,代码行数:76,代码来源:


注:本文中的ICompletionData.Where方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。