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


C# IWpfTextView.GetTextViewLineContainingBufferPosition方法代码示例

本文整理汇总了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;
		}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:44,代码来源:MarkerHelper.cs

示例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;
        }
开发者ID:codic-project,项目名称:codic-vs-extension,代码行数:19,代码来源:CodicExtensionPackage.cs


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