本文整理汇总了C#中ITextView.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# ITextView.Contains方法的具体用法?C# ITextView.Contains怎么用?C# ITextView.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITextView
的用法示例。
在下文中一共展示了ITextView.Contains方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Find
internal static ITextRange Find(FindToolBar findToolBar, TextEditor textEditor, ITextView textView, ITextView masterPageTextView)
{
string searchText;
FindFlags findFlags;
ITextContainer textContainer;
ITextRange textSelection;
ITextPointer contentStart;
ITextPointer contentEnd;
ITextPointer startPointer = null;
ITextRange findResult = null;
Invariant.Assert(findToolBar != null);
Invariant.Assert(textEditor != null);
// Set up our FindOptions from the options in the Find Toolbar.
findFlags = FindFlags.None;
findFlags |= (findToolBar.SearchUp ? FindFlags.FindInReverse : FindFlags.None);
findFlags |= (findToolBar.MatchCase ? FindFlags.MatchCase : FindFlags.None);
findFlags |= (findToolBar.MatchWholeWord ? FindFlags.FindWholeWordsOnly : FindFlags.None);
findFlags |= (findToolBar.MatchDiacritic ? FindFlags.MatchDiacritics : FindFlags.None);
findFlags |= (findToolBar.MatchKashida ? FindFlags.MatchKashida : FindFlags.None);
findFlags |= (findToolBar.MatchAlefHamza ? FindFlags.MatchAlefHamza : FindFlags.None);
// Get the text container for our content.
textContainer = textEditor.TextContainer;
textSelection = textEditor.Selection;
// Initialize other Find parameters
searchText = findToolBar.SearchText;
CultureInfo cultureInfo = GetDocumentCultureInfo(textContainer);
// The find behavior below is defined in section 2.2.3 of this spec:
// http://d2/DRX/Development%20Documents/02.01.00%20-%20UI%20Design.DocumentViewer.mht
// Determine if we have a starting selection
if (textSelection.IsEmpty)
{
if (textView != null && !textView.IsValid)
{
textView = null;
}
// Determine if the IP/Selection is in view.
if (textView != null && textView.Contains(textSelection.Start))
{
// Case 1: Selection is empty and IP is currently visible.
// Search from this IP to the start/end of the document.
//We treat the start of the selection as the IP.
contentStart = findToolBar.SearchUp ? textContainer.Start : textSelection.Start;
contentEnd = findToolBar.SearchUp ? textSelection.Start : textContainer.End;
}
else
{
// Case 4: Selection is empty and IP is not currently visible.
// Search from the top of the current TextView to the end of the document,
// if searching down. If searchind up, search from the start of the document
// to the end position of the current TextView.
if (masterPageTextView != null && masterPageTextView.IsValid)
{
foreach (TextSegment textSegment in masterPageTextView.TextSegments)
{
if (textSegment.IsNull)
{
continue;
}
if (startPointer == null)
{
// Set initial masterPointer value.
startPointer = !findToolBar.SearchUp ? textSegment.Start : textSegment.End;
}
else
{
if (!findToolBar.SearchUp)
{
if (textSegment.Start.CompareTo(startPointer) < 0)
{
// Start is before the current masterPointer
startPointer = textSegment.Start;
}
}
else
{
// end is after than the current masterPointer
if (textSegment.End.CompareTo(startPointer) > 0)
{
startPointer = textSegment.End;
}
}
}
}
}
if (startPointer != null)
{
// Now build the content range from that pointer to the start/end of the document.
// Set content start/end pointer to the content of the find document
contentStart = findToolBar.SearchUp ? textContainer.Start : startPointer;
contentEnd = findToolBar.SearchUp ? startPointer : textContainer.End;
//.........这里部分代码省略.........