• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# VirtualSnapshotPoint类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中VirtualSnapshotPoint的典型用法代码示例。如果您正苦于以下问题:C# VirtualSnapshotPoint类的具体用法?C# VirtualSnapshotPoint怎么用?C# VirtualSnapshotPoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



VirtualSnapshotPoint类属于命名空间,在下文中一共展示了VirtualSnapshotPoint类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: MoveTo

        public CaretPosition MoveTo(VirtualSnapshotPoint bufferPosition, PositionAffinity caretAffinity) {
            _position = bufferPosition.Position.Position;

            return new CaretPosition(bufferPosition,
                  new MappingPointMock(bufferPosition.Position.Snapshot.TextBuffer, bufferPosition.Position),
                  PositionAffinity.Successor);
        }
开发者ID:AlexanderSher,项目名称:RTVS-Old,代码行数:7,代码来源:TextCaretMock.cs


示例2: TextCaret

		public TextCaret(IWpfTextView textView, IAdornmentLayer caretLayer, ISmartIndentationService smartIndentationService, IClassificationFormatMap classificationFormatMap) {
			if (textView == null)
				throw new ArgumentNullException(nameof(textView));
			if (caretLayer == null)
				throw new ArgumentNullException(nameof(caretLayer));
			if (smartIndentationService == null)
				throw new ArgumentNullException(nameof(smartIndentationService));
			if (classificationFormatMap == null)
				throw new ArgumentNullException(nameof(classificationFormatMap));
			this.textView = textView;
			imeState = new ImeState();
			this.smartIndentationService = smartIndentationService;
			preferredXCoordinate = 0;
			__preferredYCoordinate = 0;
			Affinity = PositionAffinity.Successor;
			currentPosition = new VirtualSnapshotPoint(textView.TextSnapshot, 0);
			textView.TextBuffer.ChangedHighPriority += TextBuffer_ChangedHighPriority;
			textView.TextBuffer.ContentTypeChanged += TextBuffer_ContentTypeChanged;
			textView.Options.OptionChanged += Options_OptionChanged;
			textView.VisualElement.AddHandler(UIElement.GotKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(VisualElement_GotKeyboardFocus), true);
			textView.VisualElement.AddHandler(UIElement.LostKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(VisualElement_LostKeyboardFocus), true);
			textView.LayoutChanged += TextView_LayoutChanged;
			textCaretLayer = new TextCaretLayer(this, caretLayer, classificationFormatMap);
			InputMethod.SetIsInputMethodSuspended(textView.VisualElement, true);
		}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:25,代码来源:TextCaret.cs


示例3: GetNewCaretPositionSetter

        protected override Action GetNewCaretPositionSetter()
        {
            var currentSnapshot = TextView.TextBuffer.CurrentSnapshot;

            var caretPos = TextView.Caret.Position.BufferPosition;
            var caretLine = currentSnapshot.GetLineFromPosition(caretPos.Position);
            int line = currentSnapshot.GetLineNumberFromPosition(caretPos);
            int column = caretPos - caretLine.Start;

            // Get start line of scroll bar
            var scrollBarLine = TextView.TextViewLines.FirstOrDefault(l => l.VisibilityState != VisibilityState.Hidden);
            int scrollBarPos = (scrollBarLine == null) ? 0 : currentSnapshot.GetLineNumberFromPosition(scrollBarLine.Start);
            int maxLine = currentSnapshot.LineCount;

            Action setNewCaretPosition = () =>
                {
                    var newCurrentSnapshot = TextView.TextBuffer.CurrentSnapshot;
                    int newMaxLine = newCurrentSnapshot.LineCount;

                    // Scale caret positions in a linear way
                    int newLine = (int) ((float)line * (float)newMaxLine / (float)maxLine);
                    var newCaretPos = newCurrentSnapshot.GetLineFromLineNumber(newLine).Start.Add(column);
                    var caretPoint = new VirtualSnapshotPoint(newCurrentSnapshot, newCaretPos);
                    TextView.Caret.MoveTo(caretPoint);

                    // Assume that the document scales in a linear way
                    int newScrollBarPos = (int) ((float)scrollBarPos * (float)newMaxLine / (float)maxLine);
                    TextView.ViewScroller.ScrollViewportVerticallyByLines(ScrollDirection.Down, newScrollBarPos);
                };

            return setNewCaretPosition;
        }
开发者ID:jaredpar,项目名称:FSharpVSPowerTools,代码行数:32,代码来源:FormatDocumentCommand.cs


示例4: MouseReferenceInfo

			public MouseReferenceInfo(SpanData<ReferenceInfo>? spanData, SpanData<ReferenceInfo>? realSpanData, VirtualSnapshotPoint point) {
				SpanData = spanData;
				RealSpanData = realSpanData;
				virtualSpaces = point.VirtualSpaces;
				position = point.Position.Position;
				versionNumber = point.Position.Snapshot.Version.VersionNumber;
			}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:7,代码来源:DocumentViewerMouseProcessor.cs


示例5: CreateVisuals

        private void CreateVisuals(VirtualSnapshotPoint caretPosition)
        {
            if ( !settings.CurrentColumnHighlightEnabled ) {
            return; // not enabled
              }
              IWpfTextViewLineCollection textViewLines = view.TextViewLines;
              if ( textViewLines == null )
            return; // not ready yet.
              // make sure the caret position is on the right buffer snapshot
              if ( caretPosition.Position.Snapshot != this.view.TextBuffer.CurrentSnapshot )
            return;

              var line = this.view.GetTextViewLineContainingBufferPosition(
            caretPosition.Position
            );
              var charBounds = line.GetCharacterBounds(caretPosition);

              this.columnRect.Width = charBounds.Width;
              this.columnRect.Height = this.view.ViewportHeight;
              if ( this.columnRect.Height > 2 ) {
            this.columnRect.Height -= 2;
              }

              // Align the image with the top of the bounds of the text geometry
              Canvas.SetLeft(this.columnRect, charBounds.Left);
              Canvas.SetTop(this.columnRect, this.view.ViewportTop);

              layer.AddAdornment(
             AdornmentPositioningBehavior.OwnerControlled, null,
             CUR_COL_TAG, columnRect, null
              );
        }
开发者ID:bayulabster,项目名称:viasfora,代码行数:32,代码来源:CurrentColumnAdornment.cs


示例6: AddOneOnSameLine1

 public void AddOneOnSameLine1()
 {
     Create("dog cat");
     var point = new VirtualSnapshotPoint(_buffer.GetPoint(0));
     point = VirtualSnapshotPointUtil.AddOneOnSameLine(point);
     Assert.AreEqual(_buffer.GetPoint(1), point.Position);
     Assert.IsFalse(point.IsInVirtualSpace);
 }
开发者ID:rschatz,项目名称:VsVim,代码行数:8,代码来源:VirtualSnapshotPointUtilTest.cs


示例7: GetFSharpPos

 internal static Range.pos GetFSharpPos(VirtualSnapshotPoint point)
 {
     var containingLine = point.Position.GetContainingLine();
     // F# compiler line numbers start at 1
     int lineNumber = containingLine.LineNumber + 1;
     int charIndex = point.Position.Position - containingLine.Start.Position;
     return Range.mkPos(lineNumber, charIndex);
 }
开发者ID:jaredpar,项目名称:fantomas,代码行数:8,代码来源:TextUtils.cs


示例8: IsInSelection

		bool IsInSelection(VirtualSnapshotPoint point) {
			if (wpfTextView.Selection.IsEmpty)
				return false;
			foreach (var span in wpfTextView.Selection.VirtualSelectedSpans) {
				if (span.Contains(point))
					return true;
			}
			return false;
		}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:9,代码来源:DefaultTextViewMouseProcessor.cs


示例9: AddOneOnSameLine3

 public void AddOneOnSameLine3()
 {
     Create("dog");
     var point = new VirtualSnapshotPoint(_buffer.GetLine(0).EndIncludingLineBreak, 1);
     point = VirtualSnapshotPointUtil.AddOneOnSameLine(point);
     Assert.AreEqual(_buffer.GetLine(0).EndIncludingLineBreak, point.Position);
     Assert.IsTrue(point.IsInVirtualSpace);
     Assert.AreEqual(2, point.VirtualSpaces);
 }
开发者ID:rschatz,项目名称:VsVim,代码行数:9,代码来源:VirtualSnapshotPointUtilTest.cs


示例10: MouseLocation

		MouseLocation(ITextViewLine textViewLine, VirtualSnapshotPoint position, Point point) {
			if (textViewLine == null)
				throw new ArgumentNullException(nameof(textViewLine));
			TextViewLine = textViewLine;
			Position = position;
			Affinity = textViewLine.IsLastTextViewLineForSnapshotLine || position.Position != textViewLine.End ? PositionAffinity.Successor : PositionAffinity.Predecessor;
			Debug.Assert(position.VirtualSpaces == 0 || Affinity == PositionAffinity.Successor);
			Point = point;
		}
开发者ID:0xd4d,项目名称:dnSpy,代码行数:9,代码来源:MouseLocation.cs


示例11: MoveCaretToVirtualPoint1

        public void MoveCaretToVirtualPoint1()
        {
            var buffer = EditorUtil.CreateBuffer("foo","bar");
            var caret = MockObjectFactory.CreateCaret();
            var textView = MockObjectFactory.CreateTextView(buffer:buffer, caret:caret.Object);
            var point = new VirtualSnapshotPoint(buffer.GetLine(0), 2);

            caret.Setup(x => x.MoveTo(point)).Returns(new CaretPosition()).Verifiable();
            caret.Setup(x => x.EnsureVisible()).Verifiable();
            TextViewUtil.MoveCaretToVirtualPoint(textView.Object, point);
            caret.Verify();
        }
开发者ID:ChrisMarinos,项目名称:VsVim,代码行数:12,代码来源:TextViewUtilTest.cs


示例12: GetFormatted

        protected override string GetFormatted(bool isSignatureFile, string source, Fantomas.FormatConfig.FormatConfig config)
        {
            if (isFormattingCursor)
            {
                var caretPos = new VirtualSnapshotPoint(TextView.TextBuffer.CurrentSnapshot, TextView.Caret.Position.BufferPosition);
                Range.pos pos = TextUtils.GetFSharpPos(caretPos);
                return Fantomas.CodeFormatter.formatAroundCursor(isSignatureFile, pos, source, config);
            }

            Range.pos startPos = TextUtils.GetFSharpPos(TextView.Selection.Start);
            Range.pos endPos = TextUtils.GetFSharpPos(TextView.Selection.End);
            Range.range range = Range.mkRange("fsfile", startPos, endPos);

            return Fantomas.CodeFormatter.formatSelectionFromString(isSignatureFile, range, source, config);
        }
开发者ID:jskripsky,项目名称:fantomas,代码行数:15,代码来源:FormatSelectionCommand.cs


示例13: 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


示例14: GetNewCaretPositionSetter

        protected override Action GetNewCaretPositionSetter()
        {
            var caretPos = TextView.Caret.Position.BufferPosition;

            if (isFormattingCursor || caretPos == TextView.Selection.Start.Position)
            {
                int selStartPos = TextView.Selection.Start.Position.Position;

                // Get start line of scroll bar
                var scrollBarLine = TextView.TextViewLines.FirstOrDefault(l => l.VisibilityState != VisibilityState.Hidden);
                int scrollBarPos = (scrollBarLine == null) ? 0 : scrollBarLine.Snapshot.GetLineNumberFromPosition(scrollBarLine.Start);

                Action setNewCaretPosition = () =>
                {
                    // The caret is at the start of selection, its position is unchanged
                    int newSelStartPos = selStartPos;
                    var newActivePoint = new VirtualSnapshotPoint(TextView.TextBuffer.CurrentSnapshot, newSelStartPos);
                    TextView.Caret.MoveTo(newActivePoint);
                    TextView.ViewScroller.ScrollViewportVerticallyByLines(ScrollDirection.Down, scrollBarPos);
                };

                return setNewCaretPosition;
            }
            else
            {
                int selOffsetFromEnd = TextView.TextBuffer.CurrentSnapshot.Length - TextView.Selection.End.Position.Position;

                // Get start line of scroll bar
                var scrollBarLine = TextView.TextViewLines.FirstOrDefault(l => l.VisibilityState != VisibilityState.Hidden);
                int scrollBarPos = (scrollBarLine == null) ? 0 : scrollBarLine.Snapshot.GetLineNumberFromPosition(scrollBarLine.Start);

                Action setNewCaretPosition = () =>
                    {
                        // The caret is at the end of selection, its offset from the end of text is unchanged
                        int newSelEndPos = TextView.TextBuffer.CurrentSnapshot.Length - selOffsetFromEnd;
                        var newAnchorPoint = new VirtualSnapshotPoint(TextView.TextBuffer.CurrentSnapshot, newSelEndPos);

                        TextView.Caret.MoveTo(newAnchorPoint);
                        TextView.ViewScroller.ScrollViewportVerticallyByLines(ScrollDirection.Down, scrollBarPos);
                    };

                return setNewCaretPosition;
            }
        }
开发者ID:jskripsky,项目名称:fantomas,代码行数:44,代码来源:FormatSelectionCommand.cs


示例15: MoveCaretToVirtualPoint

        public void MoveCaretToVirtualPoint()
        {
            var buffer = CreateTextBuffer("foo","bar");
            var factory = new MockRepository(MockBehavior.Strict);
            var caret = MockObjectFactory.CreateCaret(factory: factory);
            caret.Setup(x => x.EnsureVisible()).Verifiable();

            var selection = MockObjectFactory.CreateSelection(factory: factory);
            selection.Setup(x => x.Clear()).Verifiable();

            var textView = MockObjectFactory.CreateTextView(
                textBuffer: buffer,
                selection: selection.Object,
                caret: caret.Object,
                factory: factory);
            var point = new VirtualSnapshotPoint(buffer.GetLine(0), 2);
            caret.Setup(x => x.MoveTo(point)).Returns(new CaretPosition()).Verifiable();

            TextViewUtil.MoveCaretToVirtualPoint(textView.Object, point);
            factory.Verify();
        }
开发者ID:bajtos,项目名称:VsVim,代码行数:21,代码来源:TextViewUtilTest.cs


示例16: Execute

        public IExecuteResult Execute(IEnumerable<Node> enodes, IWpfTextView textView, DragDropInfo dragDropInfo)
        {
            var dropLocation = GetDropLocation();
            var nodes = new List<Node>(enodes);
            normaliseNamespaces(dropLocation, nodes);

            var dropAction = getDropAction(nodes, dragDropInfo, dropLocation);

            if (dropAction != null)
            {
                // store the start buffer position
                var droppedPosition = dragDropInfo.VirtualBufferPosition.Position.Position;

                var result =  dropAction.Execute(nodes, textView, dragDropInfo);

                if (result.SelectAfterDrop)
                {

                    var startLine = textView.TextSnapshot.GetLineFromPosition(droppedPosition);
                    if (result.SelectionStartLine > 0)
                    {
                        startLine = textView.TextSnapshot.GetLineFromLineNumber(result.SelectionStartLine);
                    }
                    var start = new VirtualSnapshotPoint(startLine,Math.Max(0,  result.SelectionStartInChars));

                    var endLine = startLine;
                    if (result.SelectionHeightInLines > 1)
                       endLine= textView.TextSnapshot.GetLineFromLineNumber(startLine.LineNumber +
                                                                    result.SelectionHeightInLines - 1);

                    var end = new VirtualSnapshotPoint(endLine, result.SelectionWidthInChars + result.SelectionStartInChars );
                    textView.Selection.Mode = TextSelectionMode.Box;

                    textView.Selection.Select(start, end);
                }
                textView.Caret.MoveTo(textView.Selection.End);

            }
            return ExecuteResult.None ;
        }
开发者ID:stickleprojects,项目名称:VSDropAssist,代码行数:40,代码来源:SmartDropAction.cs


示例17: CaretHandlerBase

        protected CaretHandlerBase(VirtualSnapshotPoint location, int tabSize)
        {
            if (location.Position.Snapshot != null) {
                var line = location.Position.GetContainingLine();
                LineNumber = line.LineNumber;
                Position = location.Position.Position - line.Start.Position + location.VirtualSpaces;

                int bufferIndent = 0;
                int visualIndent = 0;
                foreach (var c in line.GetText().Take(Position)) {
                    if (c == '\t')
                        bufferIndent += tabSize - (bufferIndent % tabSize);
                    else if (c == ' ')
                        bufferIndent += 1;
                    else
                        break;
                    visualIndent += 1;
                }
                Position += bufferIndent - visualIndent;
                Modified = new List<LineSpan>();
            }
        }
开发者ID:iccfish,项目名称:indent-guides-mod,代码行数:22,代码来源:CaretHandlerBase.cs


示例18: GetSelectedSpans

		List<VirtualSnapshotSpan> GetSelectedSpans() {
			var list = new List<VirtualSnapshotSpan>();

			if (Mode == TextSelectionMode.Stream)
				list.Add(StreamSelectionSpan);
			else {
				var helper = new BoxSelectionHelper(this);
				var start = Start;
				while (start <= End) {
					var line = TextView.GetTextViewLineContainingBufferPosition(start.Position);
					list.Add(helper.GetSpan(line));
					if (line.IsLastDocumentLine())
						break;
					start = new VirtualSnapshotPoint(line.GetPointAfterLineBreak());
				}
			}

			// At least one span must be included, even if the span's empty
			if (list.Count == 0)
				list.Add(StreamSelectionSpan);

			return list;
		}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:23,代码来源:TextSelection.cs


示例19: TryGetSearchStringAtPoint

		string TryGetSearchStringAtPoint(VirtualSnapshotPoint point) {
			if (point.IsInVirtualSpace)
				return null;

			var extent = textStructureNavigator.GetExtentOfWord(point.Position);
			if (extent.IsSignificant)
				return extent.Span.GetText();

			var line = point.Position.GetContainingLine();
			if (line.Start == point.Position)
				return null;

			extent = textStructureNavigator.GetExtentOfWord(point.Position - 1);
			if (extent.IsSignificant)
				return extent.Span.GetText();

			return null;
		}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:18,代码来源:SearchService.cs


示例20: GetExtendedCharacterBounds

 public TextBounds GetExtendedCharacterBounds(VirtualSnapshotPoint bufferPosition) {
     throw new NotImplementedException();
 }
开发者ID:AlexanderSher,项目名称:RTVS-Old,代码行数:3,代码来源:TextViewLineMock.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# VirtueName类代码示例发布时间:2022-05-24
下一篇:
C# VirtualPath类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap