public VisualLineTextSource(VisualLine visualLine) { }
public void ValidateVisualColumn(VisualLine visualLine) { if (visualLine == null) { throw new ArgumentNullException("visualLine"); } int caretOffset = textView.Document.GetOffset(position); int firstOffset = visualLine.FirstDocumentLine.Offset; if (position.VisualColumn < 0) { position.VisualColumn = visualLine.GetVisualColumn(caretOffset - firstOffset); } else { int relativeOffset = visualLine.GetRelativeOffset(position.VisualColumn); relativeOffset += firstOffset; if (relativeOffset != caretOffset) { position.VisualColumn = visualLine.GetVisualColumn(caretOffset - firstOffset); } else { if (position.VisualColumn > visualLine.VisualLength) { position.VisualColumn = visualLine.VisualLength; } } } int newVisualColumn = visualLine.GetNextCaretPosition(position.VisualColumn - 1, false, CaretPositioningMode.Normal); if (newVisualColumn < 0) { newVisualColumn = visualLine.GetNextCaretPosition(position.VisualColumn + 1, true, CaretPositioningMode.Normal); } if (newVisualColumn >= 0 && newVisualColumn != position.VisualColumn) { int newOffset = visualLine.GetRelativeOffset(newVisualColumn) + firstOffset; Position = new TextViewPosition(textView.Document.GetLocation(newOffset), newVisualColumn); } }
Rect CalcCaretRectangle(VisualLine visualLine) { ValidateVisualColumn(visualLine); TextLine textLine = visualLine.GetTextLine(position.VisualColumn); double xPos = textLine.GetDistanceFromCharacterHit(new CharacterHit(position.VisualColumn, 0)); double top = visualLine.GetTextLineVisualTop(textLine); double bottom = top + textLine.Height; double fontSize = (double)textArea.GetValue(TextBlock.FontSizeProperty); return new Rect(xPos, bottom - fontSize, SystemParameters.CaretWidth, fontSize); }
public VisualLineText(VisualLine parentVisualLine, int length) : base(length, length) { }
public void Redraw(VisualLine line, DispatcherPriority priority) { //TODO: TextView.Redraw() throw new NotImplementedException(); }
VisualLine BuildVisualLine(DocumentLine documentLine, TextRunProperties textRunProperties, TextParagraphProperties paragraphProperties, VisualLineElementGenerator[] generators, IVisualLineTransformer[] transformers, Size availableSize) { if (heightTree.GetIsCollapsed(documentLine)) { throw new InvalidOperationException(); } var visualLine = new VisualLine(documentLine); var textSource = new VisualLineTextSource(visualLine) { Document = this.Document, GlobalTextRunProperties = textRunProperties, TextView = this }; visualLine.ConstructVisualElements(textSource, generators); visualLine.RunTransformers(textSource, transformers); int offset = 0; TextLineBreak lineBreak = null; var textLines = new List<TextLine>(); while (offset <= visualLine.VisualLength) { TextLine tl = textFormatter.FormatLine(textSource, offset, availableSize.Width, paragraphProperties, lineBreak); textLines.Add(tl); offset += tl.Length; lineBreak = tl.GetTextLineBreak(); } visualLine.SetTextLines(textLines); heightTree.SetHeight(visualLine.FirstDocumentLine, visualLine.Height); return visualLine; }