本文整理汇总了C#中ITextView.GetTextViewLineContainingBufferPosition方法的典型用法代码示例。如果您正苦于以下问题:C# ITextView.GetTextViewLineContainingBufferPosition方法的具体用法?C# ITextView.GetTextViewLineContainingBufferPosition怎么用?C# ITextView.GetTextViewLineContainingBufferPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITextView
的用法示例。
在下文中一共展示了ITextView.GetTextViewLineContainingBufferPosition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnsureLineVisible
/// <summary>
/// Do the vertical scrolling necessary to make sure the line is visible
/// </summary>
private void EnsureLineVisible(ITextView textView, SnapshotPoint point)
{
const double roundOff = 0.01;
var textViewLine = textView.GetTextViewLineContainingBufferPosition(point);
switch (textViewLine.VisibilityState)
{
case VisibilityState.FullyVisible:
// If the line is fully visible then no scrolling needs to occur
break;
case VisibilityState.Hidden:
case VisibilityState.PartiallyVisible:
{
ViewRelativePosition? pos = null;
if (textViewLine.Height <= textView.ViewportHeight + roundOff)
{
// The line fits into the view. Figure out if it needs to be at the top
// or the bottom
pos = textViewLine.Top < textView.ViewportTop
? ViewRelativePosition.Top
: ViewRelativePosition.Bottom;
}
else if (textViewLine.Bottom < textView.ViewportBottom)
{
// Line does not fit into view but we can use more space at the bottom
// of the view
pos = ViewRelativePosition.Bottom;
}
else if (textViewLine.Top > textView.ViewportTop)
{
pos = ViewRelativePosition.Top;
}
if (pos.HasValue)
{
textView.DisplayTextLineContainingBufferPosition(point, 0.0, pos.Value);
}
}
break;
case VisibilityState.Unattached:
{
var pos = textViewLine.Start < textView.TextViewLines.FormattedSpan.Start && textViewLine.Height <= textView.ViewportHeight + roundOff
? ViewRelativePosition.Top
: ViewRelativePosition.Bottom;
textView.DisplayTextLineContainingBufferPosition(point, 0.0, pos);
}
break;
}
}
示例2: EnsureVisible
/// <summary>
/// Ensure the given SnapshotPoint is visible on the screen
/// </summary>
public void EnsureVisible(ITextView textView, SnapshotPoint point)
{
const double roundOff = 0.01;
var textViewLine = textView.GetTextViewLineContainingBufferPosition(point);
switch (textViewLine.VisibilityState)
{
case VisibilityState.FullyVisible:
// If the line is fully visible then no scrolling needs to occur
break;
case VisibilityState.Hidden:
case VisibilityState.PartiallyVisible:
{
ViewRelativePosition? pos = null;
if (textViewLine.Height <= textView.ViewportHeight + roundOff)
{
// The line fits into the view. Figure out if it needs to be at the top
// or the bottom
pos = textViewLine.Top < textView.ViewportTop
? ViewRelativePosition.Top
: ViewRelativePosition.Bottom;
}
else if (textViewLine.Bottom < textView.ViewportBottom)
{
// Line does not fit into view but we can use more space at the bottom
// of the view
pos = ViewRelativePosition.Bottom;
}
else if (textViewLine.Top > textView.ViewportTop)
{
pos = ViewRelativePosition.Top;
}
if (pos.HasValue)
{
textView.DisplayTextLineContainingBufferPosition(point, 0.0, pos.Value);
}
}
break;
case VisibilityState.Unattached:
{
var pos = textViewLine.Start < textView.TextViewLines.FormattedSpan.Start && textViewLine.Height <= textView.ViewportHeight + roundOff
? ViewRelativePosition.Top
: ViewRelativePosition.Bottom;
textView.DisplayTextLineContainingBufferPosition(point, 0.0, pos);
}
break;
}
// Now that the line is visible we need to potentially do some horizontal scrolling
// take make sure that it's on screen
const double horizontalPadding = 2.0;
const double scrollbarPadding = 200.0;
var scroll = Math.Max(
horizontalPadding,
Math.Min(scrollbarPadding, textView.ViewportWidth / 4));
var bounds = textViewLine.GetCharacterBounds(point);
if (bounds.Left - horizontalPadding < textView.ViewportLeft)
{
textView.ViewportLeft = bounds.Left - scroll;
}
else if (bounds.Right + horizontalPadding > textView.ViewportRight)
{
textView.ViewportLeft = (bounds.Right + scroll) - textView.ViewportWidth;
}
}
示例3: EnsureLinePointVisible
/// <summary>
/// Do the horizontal scolling necessary to make the column of the given point visible
/// </summary>
private void EnsureLinePointVisible(ITextView textView, SnapshotPoint point)
{
var textViewLine = textView.GetTextViewLineContainingBufferPosition(point);
const double horizontalPadding = 2.0;
const double scrollbarPadding = 200.0;
var scroll = Math.Max(
horizontalPadding,
Math.Min(scrollbarPadding, textView.ViewportWidth / 4));
var bounds = textViewLine.GetCharacterBounds(point);
if (bounds.Left - horizontalPadding < textView.ViewportLeft)
{
textView.ViewportLeft = bounds.Left - scroll;
}
else if (bounds.Right + horizontalPadding > textView.ViewportRight)
{
textView.ViewportLeft = (bounds.Right + scroll) - textView.ViewportWidth;
}
}
示例4: IsMultiLineSpan
public static bool IsMultiLineSpan(ITextView textView, SnapshotSpan bufferSpan) {
var line1 = textView.GetTextViewLineContainingBufferPosition(bufferSpan.Start);
var line2 = textView.GetTextViewLineContainingBufferPosition(bufferSpan.End);
return line1.ExtentIncludingLineBreak != line2.ExtentIncludingLineBreak;
}