本文整理汇总了C#中SourceRange.Overlaps方法的典型用法代码示例。如果您正苦于以下问题:C# SourceRange.Overlaps方法的具体用法?C# SourceRange.Overlaps怎么用?C# SourceRange.Overlaps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SourceRange
的用法示例。
在下文中一共展示了SourceRange.Overlaps方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddSelection
/// <summary>
/// Adds the selection in the specified TextView (or the active member if there is no selection) to this MultiSelect instance.
/// </summary>
public void AddSelection(TextView textView)
{
if (textView == null)
return;
TextViewSelection textViewSelection = textView.Selection;
if (textViewSelection == null)
return;
PartialSelection newPartialSelection = new PartialSelection(Selections.Count);
// TODO: Refactor this so we find the selected member in one method (currently we have memberSelected, nodeAtTopOfSelection and selectionScanner performing similar functionality).
SourcePoint finalCaretPosition = SourcePoint.Empty;
LanguageElement memberSelected = null;
if (!textViewSelection.Exists)
{
LanguageElement activeMember = CodeRush.Source.ActiveMember;
if (activeMember != null)
{
SourceRange declareRange = new SourceRange(activeMember.Range.Top, activeMember.NameRange.Bottom);
if (declareRange.Contains(textView.Caret.SourcePoint))
{
SourceRange fullBlockCutRange = activeMember.GetFullBlockCutRange();
textView.Selection.Set(fullBlockCutRange);
memberSelected = activeMember;
}
else
CodeRush.Command.Execute("SelectionExpand");
}
else
CodeRush.Command.Execute("SelectionExpand");
if (!textViewSelection.Exists)
return;
}
SourceRange selectionRange = new SourceRange(textViewSelection.Range.Top, textViewSelection.Range.Bottom);
for (int i = Selections.Count - 1; i >= 0; i--)
{
PartialSelection compareSelection = Selections[i];
if (selectionRange.Overlaps(compareSelection.Range))
{
selectionRange = SourceRange.Union(compareSelection.Range, selectionRange);
compareSelection.RemoveHighlighter();
Selections.RemoveAt(i);
}
}
if (memberSelected != null)
{
newPartialSelection.ElementName = memberSelected.Name;
newPartialSelection.ElementType = memberSelected.ElementType;
finalCaretPosition = memberSelected.Range.Top;
}
else
{
LanguageElement nodeAtTopOfSelection = CodeRush.Source.GetNodeAt(selectionRange.Top);
LanguageElement nodeBeforeEndOfSelection = CodeRush.Source.GetNodeBefore(selectionRange.Bottom);
if (nodeAtTopOfSelection == nodeBeforeEndOfSelection || nodeAtTopOfSelection.Parents(nodeBeforeEndOfSelection) && selectionRange.Contains(nodeAtTopOfSelection.Range))
{
newPartialSelection.ElementName = nodeAtTopOfSelection.Name;
newPartialSelection.ElementType = nodeAtTopOfSelection.ElementType;
}
else
{
SelectionScanner selectionScanner = new SelectionScanner();
selectionScanner.Scan();
if (selectionScanner.ElementsFound == 1)
newPartialSelection.ElementName = selectionScanner.ElementName;
newPartialSelection.ElementType = selectionScanner.ElementType;
}
}
newPartialSelection.Range = selectionRange;
SourceRange highlightRange;
if (memberSelected != null)
{
LanguageElement startNode;
LanguageElement endNode;
memberSelected.GetFullBlockNodes(out startNode, out endNode);
highlightRange = new SourceRange(startNode.Range.Top, endNode.Range.Bottom);
if (Selections.Count == 0)
ContainsOnlyMembers = true;
}
else
{
highlightRange = selectionRange;
ContainsOnlyMembers = false;
}
newPartialSelection.HighlightRange = highlightRange;
newPartialSelection.Text = textView.TextDocument.GetText(selectionRange);
if (finalCaretPosition == SourcePoint.Empty)
finalCaretPosition = textViewSelection.Range.Top;
newPartialSelection.CaretPosition = finalCaretPosition;
AddSelection(textView, newPartialSelection);
}