public override void Draw(TextDrawingRequest request) { request.Canvas.Translate(new Position(0, request.TotalAscent)); request.Canvas.DrawSectionLink(SectionName, new Size(request.TextSize.Width, request.TextSize.Height)); request.Canvas.Translate(new Position(0, -request.TotalAscent)); base.Draw(request); }
public void Draw(TextDrawingRequest request) { Element.VisitChildren(x => (x as IStateResettable)?.ResetState()); Element.VisitChildren(x => x.Initialize(request.PageContext, request.Canvas)); request.Canvas.Translate(new Position(0, request.TotalAscent)); Element.Draw(new Size(request.TextSize.Width, -request.TotalAscent)); request.Canvas.Translate(new Position(0, -request.TotalAscent)); }
public override void Draw(TextDrawingRequest request) { UpdatePageNumberText(request.PageContext); base.Draw(request); }
internal override void Draw(Size availableSpace) { var lines = DivideTextItemsIntoLines(availableSpace.Width, availableSpace.Height).ToList(); if (!lines.Any()) { return; } var heightOffset = 0f; var widthOffset = 0f; foreach (var line in lines) { widthOffset = 0f; var alignmentOffset = GetAlignmentOffset(line.Width); Canvas.Translate(new Position(alignmentOffset, 0)); Canvas.Translate(new Position(0, -line.Ascent)); foreach (var item in line.Elements) { var textDrawingRequest = new TextDrawingRequest { Canvas = Canvas, PageContext = PageContext, StartIndex = item.Measurement.StartIndex, EndIndex = item.Measurement.EndIndex, TextSize = new Size(item.Measurement.Width, line.LineHeight), TotalAscent = line.Ascent }; item.Item.Draw(textDrawingRequest); Canvas.Translate(new Position(item.Measurement.Width, 0)); widthOffset += item.Measurement.Width; } Canvas.Translate(new Position(-alignmentOffset, 0)); Canvas.Translate(new Position(-line.Width, line.Ascent)); Canvas.Translate(new Position(0, line.LineHeight)); heightOffset += line.LineHeight; } Canvas.Translate(new Position(0, -heightOffset)); lines .SelectMany(x => x.Elements) .GroupBy(x => x.Item) .Where(x => x.Any(y => y.Measurement.IsLast)) .Select(x => x.Key) .ToList() .ForEach(x => RenderingQueue.Dequeue()); var lastElementMeasurement = lines.Last().Elements.Last().Measurement; CurrentElementIndex = lastElementMeasurement.IsLast ? 0 : lastElementMeasurement.EndIndex; if (!RenderingQueue.Any()) { ResetState(); } float GetAlignmentOffset(float lineWidth) { if (Alignment == HorizontalAlignment.Left) { return(0); } var emptySpace = availableSpace.Width - lineWidth; if (Alignment == HorizontalAlignment.Right) { return(emptySpace); } if (Alignment == HorizontalAlignment.Center) { return(emptySpace / 2); } throw new ArgumentException(); } }