using System.Collections.Generic; namespace Avalonia.Media.TextFormatting { /// /// Represents a line of text that is used for text rendering. /// public abstract class TextLine { /// /// Gets the text range that is covered by the line. /// /// /// The text range that is covered by the line. /// public abstract TextRange TextRange { get; } /// /// Gets the text runs. /// /// /// The text runs. /// public abstract IReadOnlyList TextRuns { get; } /// /// Gets the line metrics. /// /// /// The line metrics. /// public abstract TextLineMetrics LineMetrics { get; } /// /// Gets the state of the line when broken by line breaking process. /// /// /// A value that represents the line break. /// public abstract TextLineBreak TextLineBreak { get; } /// /// Gets a value that indicates whether the line is collapsed. /// /// /// true, if the line is collapsed; otherwise, false. /// public abstract bool HasCollapsed { get; } /// /// Draws the at the given origin. /// /// The drawing context. public abstract void Draw(DrawingContext drawingContext); /// /// Create a collapsed line based on collapsed text properties. /// /// A list of /// objects that represent the collapsed text properties. /// /// A value that represents a collapsed line that can be displayed. /// public abstract TextLine Collapse(params TextCollapsingProperties[] collapsingPropertiesList); /// /// Gets the character hit corresponding to the specified distance from the beginning of the line. /// /// A value that represents the distance from the beginning of the line. /// The object at the specified distance from the beginning of the line. public abstract CharacterHit GetCharacterHitFromDistance(double distance); /// /// Gets the distance from the beginning of the line to the specified character hit. /// . /// /// The object whose distance you want to query. /// A that represents the distance from the beginning of the line. public abstract double GetDistanceFromCharacterHit(CharacterHit characterHit); /// /// Gets the next character hit for caret navigation. /// /// The current . /// The next . public abstract CharacterHit GetNextCaretCharacterHit(CharacterHit characterHit); /// /// Gets the previous character hit for caret navigation. /// /// The current . /// The previous . public abstract CharacterHit GetPreviousCaretCharacterHit(CharacterHit characterHit); /// /// Gets the previous character hit after backspacing. /// /// The current . /// The after backspacing. public abstract CharacterHit GetBackspaceCaretCharacterHit(CharacterHit characterHit); /// /// Gets the text line offset x. /// /// The line width. /// The paragraph width. /// The text alignment. /// The paragraph offset. internal static double GetParagraphOffsetX(double lineWidth, double paragraphWidth, TextAlignment textAlignment) { if (double.IsPositiveInfinity(paragraphWidth)) { return 0; } switch (textAlignment) { case TextAlignment.Center: return (paragraphWidth - lineWidth) / 2; case TextAlignment.Right: return paragraphWidth - lineWidth; default: return 0.0f; } } } }