/// <summary> /// Initializes a new instance of the <see cref="LineInfoResult"/> class. /// </summary> /// <param name="value">The value being examined.</param> public LineInfoResult(LineInfo value) { this.value = value; }
protected static LineInfoResult TheResultingValue(LineInfo obj) { return new LineInfoResult(obj); }
/// <summary> /// Gets a <see cref="LineInfo"/> structure which describes the line that comes immediately /// after the specified line. /// </summary> /// <param name="previous">A <see cref="LineInfo"/> structure which describes the previous line.</param> /// <param name="next">A <see cref="LineInfo"/> structure which describes the line that comes after <paramref name="previous"/>.</param> /// <returns><see langword="true"/> if a line was retrieved; otherwise, <see langword="false"/>.</returns> public Boolean GetNextLineInfo(LineInfo previous, out LineInfo next) { return(GetNextLineInfoRef(ref previous, out next)); }
/// <summary> /// Gets a <see cref="LineInfo"/> structure which describes the line that comes immediately /// after the specified line. /// </summary> /// <param name="previous">A <see cref="LineInfo"/> structure which describes the previous line.</param> /// <param name="next">A <see cref="LineInfo"/> structure which describes the line that comes after <paramref name="previous"/>.</param> /// <returns><see langword="true"/> if a line was retrieved; otherwise, <see langword="false"/>.</returns> public Boolean GetNextLineInfoRef(ref LineInfo previous, out LineInfo next) { if (previous.Source != this) throw new ArgumentException(UltravioletStrings.LineInfoIsNotFromSameSource); if (previous.LineIndex + 1 == LineCount) { next = default(LineInfo); return false; } var acquiredPointers = !HasAcquiredPointers; if (acquiredPointers) AcquirePointers(); if (StreamPositionInObjects != previous.OffsetInCommands) Seek(previous.OffsetInCommands); Seek(1 + StreamPositionInObjects + ((TextLayoutLineInfoCommand*)Data)->LengthInCommands); var lineInfo = (TextLayoutLineInfoCommand*)Data; next = new LineInfo(this, previous.LineIndex + 1, StreamPositionInObjects, previous.OffsetInGlyphs + previous.LengthInGlyphs, lineInfo->Offset, previous.Y + previous.Height, lineInfo->LineWidth, lineInfo->LineHeight, lineInfo->LengthInCommands, lineInfo->LengthInGlyphs); if (acquiredPointers) ReleasePointers(); return true; }
/// <summary> /// Gets a <see cref="LineInfo"/> structure which describes the line that comes immediately /// after the specified line. /// </summary> /// <param name="previous">A <see cref="LineInfo"/> structure which describes the previous line.</param> /// <param name="next">A <see cref="LineInfo"/> structure which describes the line that comes after <paramref name="previous"/>.</param> /// <returns><see langword="true"/> if a line was retrieved; otherwise, <see langword="false"/>.</returns> public Boolean GetNextLineInfo(LineInfo previous, out LineInfo next) { return GetNextLineInfoRef(ref previous, out next); }
/// <summary> /// Gets a <see cref="LineInfo"/> structure which describes the specified line of formatted text. /// </summary> /// <param name="index">The index of the line for which to retrieve metadata.</param> /// <returns>A <see cref="LineInfo"/> structure which describes the specified line of formatted text.</returns> public LineInfo GetLineInfo(Int32 index) { Contract.EnsureRange(index >= 0 && index < LineCount, nameof(index)); var acquiredPointers = !HasAcquiredPointers; if (acquiredPointers) AcquirePointers(); Seek(0); var blockOffset = ((TextLayoutBlockInfoCommand*)Data)->Offset; SeekNextCommand(); var lineInfo = (TextLayoutLineInfoCommand*)Data; var linePosition = 0; var lineGlyphStart = 0; for (int i = 0; i < index; i++) { linePosition += lineInfo->LineHeight; lineGlyphStart += lineInfo->LengthInGlyphs; Seek(1 + StreamPositionInObjects + lineInfo->LengthInCommands); lineInfo = (TextLayoutLineInfoCommand*)Data; } var result = new LineInfo(this, index, StreamPositionInObjects, lineGlyphStart, lineInfo->Offset, blockOffset + linePosition, lineInfo->LineWidth, lineInfo->LineHeight, lineInfo->LengthInCommands, lineInfo->LengthInGlyphs); if (acquiredPointers) ReleasePointers(); return result; }