本文整理汇总了C#中TextViewPosition类的典型用法代码示例。如果您正苦于以下问题:C# TextViewPosition类的具体用法?C# TextViewPosition怎么用?C# TextViewPosition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextViewPosition类属于命名空间,在下文中一共展示了TextViewPosition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EditorPositionState
public EditorPositionState(double verticalOffset, double horizontalOffset, TextViewPosition textViewPosition, double DesiredXPos)
{
this.VerticalOffset = verticalOffset;
this.HorizontalOffset = horizontalOffset;
this.TextViewPosition = textViewPosition;
this.DesiredXPos = DesiredXPos;
}
示例2: StartSelectionOrSetEndpoint
public override Selection StartSelectionOrSetEndpoint(TextViewPosition startPosition, TextViewPosition endPosition)
{
var document = textArea.Document;
if (document == null)
throw ThrowUtil.NoDocumentAssigned();
return Create(textArea, startPosition, endPosition);
}
示例3: SimpleSelection
/// <summary>
/// Creates a new SimpleSelection instance.
/// </summary>
internal SimpleSelection(TextArea textArea, TextViewPosition start, TextViewPosition end)
: base(textArea)
{
this.start = start;
this.end = end;
this.startOffset = textArea.Document.GetOffset(start.Location);
this.endOffset = textArea.Document.GetOffset(end.Location);
}
示例4: GetXPos
static double GetXPos(TextArea textArea, TextViewPosition pos)
{
DocumentLine documentLine = textArea.Document.GetLineByNumber(pos.Line);
VisualLine visualLine = textArea.TextView.GetOrConstructVisualLine(documentLine);
int vc = visualLine.ValidateVisualColumn(pos, true);
TextLine textLine = visualLine.GetTextLine(vc);
return visualLine.GetTextLineVisualXPosition(textLine, vc);
}
示例5: Create
internal static Selection Create(TextArea textArea, TextViewPosition start, TextViewPosition end)
{
if (textArea == null)
throw new ArgumentNullException("textArea");
if (textArea.Document.GetOffset(start.Location) == textArea.Document.GetOffset(end.Location) && start.VisualColumn == end.VisualColumn)
return textArea.emptySelection;
else
return new SimpleSelection(textArea, start, end);
}
示例6: Caret
internal Caret(TextArea textArea)
{
this.textArea = textArea;
this.textView = textArea.TextView;
position = new TextViewPosition(1, 1, 0);
caretAdorner = new CaretLayer(textView);
textView.InsertLayer(caretAdorner, KnownLayer.Caret, LayerInsertionPosition.Replace);
textView.VisualLinesChanged += TextView_VisualLinesChanged;
textView.ScrollOffsetChanged += TextView_ScrollOffsetChanged;
}
示例7: RectangleSelection
RectangleSelection(TextArea textArea, int startLine, double startXPos, TextViewPosition end)
: base(textArea)
{
InitDocument();
this.startLine = startLine;
endLine = end.Line;
this.startXPos = startXPos;
endXPos = GetXPos(textArea, end);
CalculateSegments();
topLeftOffset = segments.First().StartOffset;
bottomRightOffset = segments.Last().EndOffset;
}
示例8: GetOffsetForLinesInSegmentOnScreen
private static IEnumerable<Tuple<int, int>> GetOffsetForLinesInSegmentOnScreen(TextView textView, ISegment segment,
bool extendToFullWidthAtLineEnd = false)
{
var segmentStart = segment.Offset;
var segmentEnd = segment.Offset + segment.Length;
if (segmentStart > textView.TextDocument.TextLength)
{
segmentStart = textView.TextDocument.TextLength;
}
if (segmentEnd > textView.TextDocument.TextLength)
{
segmentEnd = textView.TextDocument.TextLength;
}
var start = new TextViewPosition(textView.TextDocument.GetLocation(segmentStart));
var end = new TextViewPosition(textView.TextDocument.GetLocation(segmentEnd));
foreach (var line in textView.VisualLines)
{
if (!line.DocumentLine.IsDeleted)
{
if (line.Offset > segmentEnd)
{
break;
}
if (line.EndOffset < segmentStart)
{
continue;
}
// find start and begining in current line.
var lineStartOffset = line.Offset;
if (segment.Offset > line.Offset)
{
lineStartOffset = line.Offset + (segment.Offset - line.Offset);
}
var lineEndOffset = line.EndOffset;
if (segment.EndOffset < line.EndOffset)
{
lineEndOffset = line.EndOffset - (line.EndOffset - segment.EndOffset);
}
// generate rect for section in this line.
yield return new Tuple<int, int>(lineStartOffset, lineEndOffset);
}
}
}
示例9: RectangleSelection
private RectangleSelection(TextArea textArea, TextViewPosition start, int endLine, double endXPos)
: base(textArea)
{
InitDocument();
this.startLine = start.Line;
this.endLine = endLine;
this.startXPos = GetXPos(textArea, start);
this.endXPos = endXPos;
CalculateSegments();
this.topLeftOffset = this.segments.First().StartOffset;
this.bottomRightOffset = this.segments.Last().EndOffset;
}
示例10: GetViewPortPosition
public static Rect GetViewPortPosition(TextView textView, int offset)
{
var position = new TextViewPosition(textView.GetLocation(offset));
if (position.Line > 0)
{
return GetTextPositionInViewPort(textView, position);
}
else
{
return new Rect();
}
}
示例11: GetWordUnderMouse
public static string GetWordUnderMouse(this TextDocument document, TextViewPosition position)
{
string wordHovered = string.Empty;
var line = position.Line;
var column = position.Column;
var offset = document.GetOffset(line, column);
if (offset >= document.TextLength)
offset--;
var textAtOffset = document.GetText(offset, 1);
// Get text backward of the mouse position, until the first space
while (!string.IsNullOrWhiteSpace(textAtOffset))
{
wordHovered = textAtOffset + wordHovered;
offset--;
if (offset < 0)
break;
textAtOffset = document.GetText(offset, 1);
}
// Get text forward the mouse position, until the first space
offset = document.GetOffset(line, column);
if (offset < document.TextLength - 1)
{
offset++;
textAtOffset = document.GetText(offset, 1);
while (!string.IsNullOrWhiteSpace(textAtOffset))
{
wordHovered = wordHovered + textAtOffset;
offset++;
if (offset >= document.TextLength)
break;
textAtOffset = document.GetText(offset, 1);
}
}
return wordHovered;
}
示例12: GetTextPositionInViewPort
public static Rect GetTextPositionInViewPort(TextView textView, TextViewPosition position)
{
if (position.Line - 1 < textView.VisualLines.Count)
{
return new Rect(textView.VisualLines[position.Line - 1].RenderedText.HitTestTextPosition(position.Column - 1).X + textView.TextSurfaceBounds.X,
textView.CharSize.Height * (position.Line - 1),
textView.CharSize.Width,
textView.CharSize.Height);
}
return new Rect(textView.TextSurfaceBounds.X + textView.CharSize.Width * (position.Column - 1),
textView.CharSize.Height * (position.Line - 1),
textView.CharSize.Width,
textView.CharSize.Height);
}
示例13: AddSpacesIfRequired
internal string AddSpacesIfRequired(string newText, TextViewPosition start, TextViewPosition end)
{
if (EnableVirtualSpace && InsertVirtualSpaces(newText, start, end)) {
var line = textArea.Document.GetLineByNumber(start.Line);
string lineText = textArea.Document.GetText(line);
var vLine = textArea.TextView.GetOrConstructVisualLine(line);
int colDiff = start.VisualColumn - vLine.VisualLengthWithEndOfLineMarker;
if (colDiff > 0) {
string additionalSpaces = "";
if (!textArea.Options.ConvertTabsToSpaces && lineText.Trim('\t').Length == 0) {
int tabCount = (int)(colDiff / textArea.Options.IndentationSize);
additionalSpaces = new string('\t', tabCount);
colDiff -= tabCount * textArea.Options.IndentationSize;
}
additionalSpaces += new string(' ', colDiff);
return additionalSpaces + newText;
}
}
return newText;
}
示例14: GetWordUnderMouse
public static string GetWordUnderMouse(this TextDocument document, TextViewPosition position, bool cancelDot)
{
string wordHovered = string.Empty;
int line = position.Line;
int column = position.Column;
int offset = document.GetOffset(line, column);
if (offset >= document.TextLength)
offset--;
string textAtOffset = document.GetText(offset, 1);
// Get text backward of the mouse position, until the first space
while (!string.IsNullOrWhiteSpace(textAtOffset) && !StringContainsBreaks(textAtOffset, true))
{
wordHovered = textAtOffset + wordHovered;
offset--;
if (offset < 0)
break;
textAtOffset = document.GetText(offset, 1);
}
// Get text forward the mouse position, until the first space
offset = document.GetOffset(line, column);
if (offset < document.TextLength - 1) {
offset++;
textAtOffset = document.GetText(offset, 1);
while (!string.IsNullOrWhiteSpace(textAtOffset) && !StringContainsBreaks(textAtOffset, false)) {
wordHovered = wordHovered + textAtOffset;
offset++;
if (offset >= document.TextLength)
break;
textAtOffset = document.GetText(offset, 1);
}
}
return wordHovered;
}
示例15: InsertVirtualSpaces
bool InsertVirtualSpaces(string newText, TextViewPosition start, TextViewPosition end)
{
return (!string.IsNullOrEmpty(newText) || !(IsInVirtualSpace(start) && IsInVirtualSpace(end)))
&& newText != "\r\n"
&& newText != "\n"
&& newText != "\r";
}