public LinePartsTextSource(LinePartsCollection linePartsCollection) { if (linePartsCollection == null) { throw new ArgumentNullException(nameof(linePartsCollection)); } this.linePartsCollection = linePartsCollection; this.text = linePartsCollection.Span.GetText(); }
public WpfTextViewLine(IBufferGraph bufferGraph, LinePartsCollection linePartsCollection, int startColumn, int endColumn, ITextSnapshotLine bufferLine, SnapshotSpan span, ITextSnapshot visualSnapshot, TextLine textLine, double indentation, double virtualSpaceWidth) { if (bufferGraph == null) { throw new ArgumentNullException(nameof(bufferGraph)); } if (linePartsCollection == null) { throw new ArgumentNullException(nameof(linePartsCollection)); } if (bufferLine == null) { throw new ArgumentNullException(nameof(bufferLine)); } if (span.Snapshot != bufferLine.Snapshot) { throw new ArgumentException(); } if (visualSnapshot == null) { throw new ArgumentNullException(nameof(visualSnapshot)); } if (textLine == null) { throw new ArgumentNullException(nameof(textLine)); } this.IsValid = true; this.bufferGraph = bufferGraph; this.linePartsCollection = linePartsCollection; this.endColumn = endColumn; this.visualSnapshot = visualSnapshot; this.textLines = new ReadOnlyCollection <TextLine>(new[] { textLine }); Debug.Assert(textLines.Count == 1); // Assumed by all code accessing TextLine prop this.realTopSpace = 0; this.realBottomSpace = 0; this.realBaseline = TextLine.Baseline; this.isFirstTextViewLineForSnapshotLine = span.Start == bufferLine.Start; this.isLastTextViewLineForSnapshotLine = span.End == bufferLine.EndIncludingLineBreak; IsLastVisualLine = bufferLine.LineNumber + 1 == bufferLine.Snapshot.LineCount && IsLastTextViewLineForSnapshotLine; this.lineBreakLength = isLastTextViewLineForSnapshotLine ? bufferLine.LineBreakLength : 0; this.virtualSpaceWidth = virtualSpaceWidth; this.textLeft = indentation; this.textWidth = textLine.WidthIncludingTrailingWhitespace; this.extentIncludingLineBreak = span; this.realHeight = textLine.Height + DEFAULT_TOP_SPACE + DEFAULT_BOTTOM_SPACE; this.realTextHeight = textLine.TextHeight; this.endOfLineWidth = Math.Floor(this.realTextHeight * 0.58333333333333337); // Same as VS this.width = this.textWidth + (this.lineBreakLength == 0 ? 0 : this.endOfLineWidth); this.change = TextViewLineChange.NewOrReformatted; SetLineTransform(DefaultLineTransform); }
public void Dispose() { IsValid = false; foreach (var t in textLines) { t.Dispose(); } bufferGraph = null !; extentIncludingLineBreak = default; visualSnapshot = null !; linePartsCollection = null !; textLines = null !; drawingVisual = null; }
public WpfTextViewLine(IBufferGraph bufferGraph, LinePartsCollection linePartsCollection, int linePartsIndex, int linePartsLength, int startColumn, int endColumn, ITextSnapshotLine bufferLine, SnapshotSpan span, ITextSnapshot visualSnapshot, TextLine textLine, double indentation, double virtualSpaceWidth) { if (linePartsCollection is null) { throw new ArgumentNullException(nameof(linePartsCollection)); } if (linePartsIndex < 0) { throw new ArgumentOutOfRangeException(nameof(linePartsIndex)); } if (linePartsLength < 0) { throw new ArgumentOutOfRangeException(nameof(linePartsLength)); } if (linePartsIndex + linePartsLength > linePartsCollection.LineParts.Count) { throw new ArgumentOutOfRangeException(nameof(linePartsLength)); } if (bufferLine is null) { throw new ArgumentNullException(nameof(bufferLine)); } if (span.Snapshot != bufferLine.Snapshot) { throw new ArgumentException(); } if (textLine is null) { throw new ArgumentNullException(nameof(textLine)); } IsValid = true; this.linePartsIndex = linePartsIndex; this.linePartsLength = linePartsLength; this.bufferGraph = bufferGraph ?? throw new ArgumentNullException(nameof(bufferGraph)); this.linePartsCollection = linePartsCollection; this.startColumn = startColumn; this.endColumn = endColumn; this.visualSnapshot = visualSnapshot ?? throw new ArgumentNullException(nameof(visualSnapshot)); textLines = new ReadOnlyCollection <TextLine>(new[] { textLine }); Debug.Assert(textLines.Count == 1); // Assumed by all code accessing TextLine prop realTopSpace = 0; realBottomSpace = 0; realBaseline = TextLine.Baseline; double baseLineHeight = TextLine.TextHeight - TextLine.Baseline; var lineParts = linePartsCollection.LineParts; for (int i = 0; i < linePartsLength; i++) { var adornmentElement = lineParts[linePartsIndex + i].AdornmentElement; if (adornmentElement is null) { continue; } double adornmentBaseLineHeight = adornmentElement.TextHeight - adornmentElement.Baseline; if (adornmentBaseLineHeight > baseLineHeight) { baseLineHeight = adornmentBaseLineHeight; } if (adornmentElement.Baseline > realBaseline) { realBaseline = adornmentElement.Baseline; } if (adornmentElement.TopSpace > realTopSpace) { realTopSpace = adornmentElement.TopSpace; } if (adornmentElement.BottomSpace > realBottomSpace) { realBottomSpace = adornmentElement.BottomSpace; } } realTextHeight = Math.Ceiling(baseLineHeight + realBaseline); isFirstTextViewLineForSnapshotLine = span.Start == bufferLine.Start; isLastTextViewLineForSnapshotLine = span.End == bufferLine.EndIncludingLineBreak; IsLastVisualLine = bufferLine.LineNumber + 1 == bufferLine.Snapshot.LineCount && IsLastTextViewLineForSnapshotLine; lineBreakLength = isLastTextViewLineForSnapshotLine ? bufferLine.LineBreakLength : 0; this.virtualSpaceWidth = virtualSpaceWidth; textLeft = indentation; textWidth = TextLine.WidthIncludingTrailingWhitespace; extentIncludingLineBreak = span; endOfLineWidth = Math.Floor(realTextHeight * 0.58333333333333337); // Same as VS width = textWidth + (lineBreakLength == 0 ? 0 : endOfLineWidth); change = TextViewLineChange.NewOrReformatted; SetLineTransform(DefaultLineTransform); }
public void Dispose() { IsValid = false; foreach (var t in textLines) t.Dispose(); bufferGraph = null; extentIncludingLineBreak = default(SnapshotSpan); visualSnapshot = null; linePartsCollection = null; textLines = null; drawingVisual = null; }
public WpfTextViewLine(IBufferGraph bufferGraph, LinePartsCollection linePartsCollection, int linePartsIndex, int linePartsLength, int startColumn, int endColumn, ITextSnapshotLine bufferLine, SnapshotSpan span, ITextSnapshot visualSnapshot, TextLine textLine, double indentation, double virtualSpaceWidth) { if (bufferGraph == null) throw new ArgumentNullException(nameof(bufferGraph)); if (linePartsCollection == null) throw new ArgumentNullException(nameof(linePartsCollection)); if (linePartsIndex < 0) throw new ArgumentOutOfRangeException(nameof(linePartsIndex)); if (linePartsLength < 0) throw new ArgumentOutOfRangeException(nameof(linePartsLength)); if (linePartsIndex + linePartsLength > linePartsCollection.LineParts.Count) throw new ArgumentOutOfRangeException(nameof(linePartsLength)); if (bufferLine == null) throw new ArgumentNullException(nameof(bufferLine)); if (span.Snapshot != bufferLine.Snapshot) throw new ArgumentException(); if (visualSnapshot == null) throw new ArgumentNullException(nameof(visualSnapshot)); if (textLine == null) throw new ArgumentNullException(nameof(textLine)); IsValid = true; this.linePartsIndex = linePartsIndex; this.linePartsLength = linePartsLength; this.bufferGraph = bufferGraph; this.linePartsCollection = linePartsCollection; this.startColumn = startColumn; this.endColumn = endColumn; this.visualSnapshot = visualSnapshot; textLines = new ReadOnlyCollection<TextLine>(new[] { textLine }); Debug.Assert(textLines.Count == 1);// Assumed by all code accessing TextLine prop realTopSpace = 0; realBottomSpace = 0; realBaseline = TextLine.Baseline; double baseLineHeight = TextLine.TextHeight - TextLine.Baseline; var lineParts = linePartsCollection.LineParts; for (int i = 0; i < linePartsLength; i++) { var adornmentElement = lineParts[linePartsIndex + i].AdornmentElement; if (adornmentElement == null) continue; double adornmentBaseLineHeight = adornmentElement.TextHeight - adornmentElement.Baseline; if (adornmentBaseLineHeight > baseLineHeight) baseLineHeight = adornmentBaseLineHeight; if (adornmentElement.Baseline > realBaseline) realBaseline = adornmentElement.Baseline; if (adornmentElement.TopSpace > realTopSpace) realTopSpace = adornmentElement.TopSpace; if (adornmentElement.BottomSpace > realBottomSpace) realBottomSpace = adornmentElement.BottomSpace; } realTextHeight = Math.Ceiling(baseLineHeight + realBaseline); isFirstTextViewLineForSnapshotLine = span.Start == bufferLine.Start; isLastTextViewLineForSnapshotLine = span.End == bufferLine.EndIncludingLineBreak; IsLastVisualLine = bufferLine.LineNumber + 1 == bufferLine.Snapshot.LineCount && IsLastTextViewLineForSnapshotLine; lineBreakLength = isLastTextViewLineForSnapshotLine ? bufferLine.LineBreakLength : 0; this.virtualSpaceWidth = virtualSpaceWidth; textLeft = indentation; textWidth = TextLine.WidthIncludingTrailingWhitespace; extentIncludingLineBreak = span; endOfLineWidth = Math.Floor(realTextHeight * 0.58333333333333337);// Same as VS width = textWidth + (lineBreakLength == 0 ? 0 : endOfLineWidth); change = TextViewLineChange.NewOrReformatted; SetLineTransform(DefaultLineTransform); }
public LinePartsTextSource(LinePartsCollection linePartsCollection) { if (linePartsCollection == null) throw new ArgumentNullException(nameof(linePartsCollection)); this.linePartsCollection = linePartsCollection; text = linePartsCollection.Span.GetText(); }