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


C# ITextBuffer.GetPoint方法代码示例

本文整理汇总了C#中ITextBuffer.GetPoint方法的典型用法代码示例。如果您正苦于以下问题:C# ITextBuffer.GetPoint方法的具体用法?C# ITextBuffer.GetPoint怎么用?C# ITextBuffer.GetPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITextBuffer的用法示例。


在下文中一共展示了ITextBuffer.GetPoint方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateTextViewWithVisibleLines

        public static Tuple<Mock<ITextView>, MockRepository> CreateTextViewWithVisibleLines(
            ITextBuffer buffer,
            int startLine,
            int? endLine = null,
            int? caretPosition = null)
        {
            var factory = new MockRepository(MockBehavior.Strict);
            var endLineValue = endLine ?? startLine;
            var caretPositionValue = caretPosition ?? buffer.GetLine(startLine).Start.Position;
            var caret = factory.Create<ITextCaret>();
            caret.SetupGet(x => x.Position).Returns(
                new CaretPosition(
                    new VirtualSnapshotPoint(buffer.GetPoint(caretPositionValue)),
                    factory.Create<IMappingPoint>().Object,
                    PositionAffinity.Predecessor));

            var firstLine = factory.Create<ITextViewLine>();
            firstLine.SetupGet(x => x.Start).Returns(buffer.GetLine(startLine).Start);

            var lastLine = factory.Create<ITextViewLine>();
            lastLine.SetupGet(x => x.End).Returns(buffer.GetLine(endLineValue).End);

            var lines = factory.Create<ITextViewLineCollection>();
            lines.SetupGet(x => x.FirstVisibleLine).Returns(firstLine.Object);
            lines.SetupGet(x => x.LastVisibleLine).Returns(lastLine.Object);

            var visualBuffer = CreateTextBuffer(factory: factory);
            var textViewModel = factory.Create<ITextViewModel>();
            textViewModel.SetupGet(x => x.VisualBuffer).Returns(visualBuffer.Object);

            var properties = new PropertyCollection();
            var textView = factory.Create<ITextView>();
            var bufferGraph = factory.Create<IBufferGraph>();
            textView.SetupGet(x => x.TextBuffer).Returns(buffer);
            textView.SetupGet(x => x.TextViewLines).Returns(lines.Object);
            textView.SetupGet(x => x.Caret).Returns(caret.Object);
            textView.SetupGet(x => x.InLayout).Returns(false);
            textView.SetupGet(x => x.TextSnapshot).Returns(() => buffer.CurrentSnapshot);
            textView.SetupGet(x => x.Properties).Returns(properties);
            textView.SetupGet(x => x.BufferGraph).Returns(bufferGraph.Object);
            textView.SetupGet(x => x.TextViewModel).Returns(textViewModel.Object);
            textView.SetupGet(x => x.VisualSnapshot).Returns(visualBuffer.Object.CurrentSnapshot);
            return Tuple.Create(textView, factory);
        }
开发者ID:sehe,项目名称:VsVim,代码行数:44,代码来源:MockObjectFactory.cs

示例2: CreateTextViewWithVisibleLines

        public static Tuple<Mock<ITextView>, MockRepository> CreateTextViewWithVisibleLines(
            ITextBuffer textBuffer,
            int startLine,
            int? endLine = null,
            int? caretPosition = null,
            MockRepository factory = null)
        {
            factory = factory ?? new MockRepository(MockBehavior.Strict);
            var endLineValue = endLine ?? startLine;
            var caretPositionValue = caretPosition ?? textBuffer.GetLine(startLine).Start.Position;
            var caret = factory.Create<ITextCaret>();
            caret.SetupGet(x => x.Position).Returns(
                new CaretPosition(
                    new VirtualSnapshotPoint(textBuffer.GetPoint(caretPositionValue)),
                    factory.Create<IMappingPoint>().Object,
                    PositionAffinity.Predecessor));

            var firstLine = factory.Create<ITextViewLine>();
            firstLine.SetupGet(x => x.Start).Returns(textBuffer.GetLine(startLine).Start);

            var lastLine = factory.Create<ITextViewLine>();
            lastLine.SetupGet(x => x.End).Returns(textBuffer.GetLine(endLineValue).End);

            var lines = factory.Create<ITextViewLineCollection>();
            lines.SetupGet(x => x.FirstVisibleLine).Returns(firstLine.Object);
            lines.SetupGet(x => x.LastVisibleLine).Returns(lastLine.Object);

            var visualBuffer = CreateTextBuffer(factory: factory);
            var textViewModel = factory.Create<ITextViewModel>();
            textViewModel.SetupGet(x => x.VisualBuffer).Returns(visualBuffer.Object);

            var textDataModel = CreateTextDataModel(textBuffer, factory);

            // When creating the CommonOperations linked to the textview, 
            // the roles are checked for the outlining manager.
            // Pretend we don't support anything
            var roles = factory.Create<ITextViewRoleSet>();
            roles.Setup(x => x.Contains(It.IsAny<String>())).Returns(false);

            var properties = new PropertyCollection();
            var textView = factory.Create<ITextView>();
            var options = factory.Create<IEditorOptions>();
            var bufferGraph = factory.Create<IBufferGraph>();
            textView.SetupGet(x => x.TextBuffer).Returns(textBuffer);
            textView.SetupGet(x => x.TextViewLines).Returns(lines.Object);
            textView.SetupGet(x => x.Caret).Returns(caret.Object);
            textView.SetupGet(x => x.InLayout).Returns(false);
            textView.SetupGet(x => x.TextSnapshot).Returns(() => textBuffer.CurrentSnapshot);
            textView.SetupGet(x => x.Properties).Returns(properties);
            textView.SetupGet(x => x.BufferGraph).Returns(bufferGraph.Object);
            textView.SetupGet(x => x.TextViewModel).Returns(textViewModel.Object);
            textView.SetupGet(x => x.VisualSnapshot).Returns(visualBuffer.Object.CurrentSnapshot);
            textView.SetupGet(x => x.Roles).Returns(roles.Object); 
            textView.SetupGet(x => x.Options).Returns(options.Object);
            textView.SetupGet(x => x.TextDataModel).Returns(textDataModel.Object);
            return Tuple.Create(textView, factory);
        }
开发者ID:Kazark,项目名称:VsVim,代码行数:57,代码来源:MockObjectFactory.cs


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