本文整理汇总了C#中IWpfTextView.GetTextViewLineContainingBufferPosition方法的典型用法代码示例。如果您正苦于以下问题:C# IWpfTextView.GetTextViewLineContainingBufferPosition方法的具体用法?C# IWpfTextView.GetTextViewLineContainingBufferPosition怎么用?C# IWpfTextView.GetTextViewLineContainingBufferPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWpfTextView
的用法示例。
在下文中一共展示了IWpfTextView.GetTextViewLineContainingBufferPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateGeometry
public static Geometry CreateGeometry(IWpfTextView textView, VirtualSnapshotSpan span, bool isMultiLine, bool clipToViewport = false) {
var padding = isMultiLine ? LineMarkerPadding : TextMarkerPadding;
var pos = span.Start;
PathGeometry geo = null;
bool createOutlinedPath = false;
while (pos <= span.End) {
var line = textView.GetTextViewLineContainingBufferPosition(pos.Position);
bool useVspaces = line.IsLastDocumentLine();
var lineExtent = new VirtualSnapshotSpan(new VirtualSnapshotPoint(line.Start), new VirtualSnapshotPoint(line.EndIncludingLineBreak, useVspaces ? span.End.VirtualSpaces : 0));
var extentTmp = lineExtent.Intersection(new VirtualSnapshotSpan(pos, span.End));
Debug.Assert(extentTmp != null);
if (line.VisibilityState != VisibilityState.Unattached && extentTmp != null && extentTmp.Value.Length != 0) {
var extent = extentTmp.Value;
Collection<TextBounds> textBounds;
if (extent.Start.IsInVirtualSpace) {
var leading = line.TextRight + extent.Start.VirtualSpaces * textView.FormattedLineSource.ColumnWidth;
double width = line.EndOfLineWidth;
int vspaces = span.End.VirtualSpaces - span.Start.VirtualSpaces;
if (vspaces > 0)
width = vspaces * textView.FormattedLineSource.ColumnWidth;
textBounds = new Collection<TextBounds>();
textBounds.Add(new TextBounds(leading, line.Top, width, line.Height, line.TextTop, line.TextHeight));
}
else if (extent.End.IsInVirtualSpace) {
textBounds = line.GetNormalizedTextBounds(extent.SnapshotSpan);
double width = extent.End.VirtualSpaces * textView.FormattedLineSource.ColumnWidth;
textBounds.Add(new TextBounds(line.TextRight, line.Top, width, line.Height, line.TextTop, line.TextHeight));
}
else
textBounds = line.GetNormalizedTextBounds(extent.SnapshotSpan);
AddGeometries(textView, textBounds, isMultiLine, clipToViewport, padding, SystemParameters.CaretWidth, ref geo, ref createOutlinedPath);
}
if (line.IsLastDocumentLine())
break;
pos = new VirtualSnapshotPoint(line.GetPointAfterLineBreak());
}
if (createOutlinedPath)
geo = geo.GetOutlinedPathGeometry();
if (geo != null && geo.CanFreeze)
geo.Freeze();
return geo;
}
示例2: SetDialogPosition
private void SetDialogPosition(IWpfTextView _view, QuickLookDialog dialog)
{
SnapshotSpan span = _view.Selection.SelectedSpans[0];
var textViewOrigin = (_view as System.Windows.UIElement).PointToScreen(new Point(0, 0));
var caretPos = _view.Selection.Start.Position;
var charBounds = _view
.GetTextViewLineContainingBufferPosition(caretPos)
.GetCharacterBounds(caretPos);
double textBottom = charBounds.Bottom;
double textX = charBounds.Left;
double newLeft = textViewOrigin.X + textX - _view.ViewportLeft;
double newTop = textViewOrigin.Y + textBottom - _view.ViewportTop;
dialog.Left = newLeft;
dialog.Top = newTop;
}