本文整理汇总了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);
}
示例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);
}