diff --git a/QuestPDF.ReportSample/QuestPDF.ReportSample.csproj b/QuestPDF.ReportSample/QuestPDF.ReportSample.csproj index fddd3d8..a4353d5 100644 --- a/QuestPDF.ReportSample/QuestPDF.ReportSample.csproj +++ b/QuestPDF.ReportSample/QuestPDF.ReportSample.csproj @@ -8,6 +8,7 @@ + diff --git a/QuestPDF.UnitTests/BoxTests.cs b/QuestPDF.UnitTests/BoxTests.cs index c7153d1..bfdffd4 100644 --- a/QuestPDF.UnitTests/BoxTests.cs +++ b/QuestPDF.UnitTests/BoxTests.cs @@ -1,5 +1,5 @@ using NUnit.Framework; -using QuestPDF.Drawing.SpacePlan; +using QuestPDF.Drawing; using QuestPDF.Elements; using QuestPDF.Infrastructure; using QuestPDF.UnitTests.TestEngine; @@ -21,7 +21,7 @@ namespace QuestPDF.UnitTests Child = x.CreateChild() }) .DrawElement(new Size(400, 300)) - .ExpectChildMeasure(expectedInput: new Size(400, 300), returns: new Wrap()) + .ExpectChildMeasure(expectedInput: new Size(400, 300), returns: SpacePlan.Wrap()) .CheckDrawResult(); } @@ -34,7 +34,7 @@ namespace QuestPDF.UnitTests Child = x.CreateChild() }) .MeasureElement(new Size(400, 300)) - .ExpectChildMeasure(expectedInput: new Size(400, 300), returns: new PartialRender(200, 100)) + .ExpectChildMeasure(expectedInput: new Size(400, 300), returns: SpacePlan.PartialRender(200, 100)) .ExpectChildDraw(new Size(200, 100)) .CheckDrawResult(); } @@ -48,7 +48,7 @@ namespace QuestPDF.UnitTests Child = x.CreateChild() }) .MeasureElement(new Size(500, 400)) - .ExpectChildMeasure(expectedInput: new Size(500, 400), returns: new FullRender(300, 200)) + .ExpectChildMeasure(expectedInput: new Size(500, 400), returns: SpacePlan.FullRender(300, 200)) .ExpectChildDraw(new Size(300, 200)) .CheckDrawResult(); } diff --git a/QuestPDF.UnitTests/LayersTests.cs b/QuestPDF.UnitTests/LayersTests.cs index 57a35ec..d6528ab 100644 --- a/QuestPDF.UnitTests/LayersTests.cs +++ b/QuestPDF.UnitTests/LayersTests.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using NUnit.Framework; -using QuestPDF.Drawing.SpacePlan; +using QuestPDF.Drawing; using QuestPDF.Elements; using QuestPDF.Infrastructure; using QuestPDF.UnitTests.TestEngine; @@ -45,8 +45,8 @@ namespace QuestPDF.UnitTests TestPlan .For(GetLayers) .MeasureElement(new Size(800, 600)) - .ExpectChildMeasure(MainLayer, new Size(800, 600), new Wrap()) - .CheckMeasureResult(new Wrap()); + .ExpectChildMeasure(MainLayer, new Size(800, 600), SpacePlan.Wrap()) + .CheckMeasureResult(SpacePlan.Wrap()); } [Test] @@ -55,8 +55,8 @@ namespace QuestPDF.UnitTests TestPlan .For(GetLayers) .MeasureElement(new Size(800, 600)) - .ExpectChildMeasure(MainLayer, new Size(800, 600), new PartialRender(700, 500)) - .CheckMeasureResult(new PartialRender(700, 500)); + .ExpectChildMeasure(MainLayer, new Size(800, 600), SpacePlan.PartialRender(700, 500)) + .CheckMeasureResult(SpacePlan.PartialRender(700, 500)); } [Test] @@ -65,8 +65,8 @@ namespace QuestPDF.UnitTests TestPlan .For(GetLayers) .MeasureElement(new Size(800, 600)) - .ExpectChildMeasure(MainLayer, new Size(800, 600), new FullRender(500, 400)) - .CheckMeasureResult(new FullRender(500, 400)); + .ExpectChildMeasure(MainLayer, new Size(800, 600), SpacePlan.FullRender(500, 400)) + .CheckMeasureResult(SpacePlan.FullRender(500, 400)); } #endregion @@ -80,9 +80,9 @@ namespace QuestPDF.UnitTests .For(GetLayers) .MeasureElement(new Size(800, 600)) - .ExpectChildMeasure(BackgroundLayer, new Size(800, 600), new FullRender(100, 200)) - .ExpectChildMeasure(MainLayer, new Size(800, 600), new PartialRender(200, 300)) - .ExpectChildMeasure(ForegroundLayer, new Size(800, 600), new FullRender(300, 400)) + .ExpectChildMeasure(BackgroundLayer, new Size(800, 600), SpacePlan.FullRender(100, 200)) + .ExpectChildMeasure(MainLayer, new Size(800, 600), SpacePlan.PartialRender(200, 300)) + .ExpectChildMeasure(ForegroundLayer, new Size(800, 600), SpacePlan.FullRender(300, 400)) .ExpectChildDraw(BackgroundLayer, new Size(800, 600)) @@ -99,9 +99,9 @@ namespace QuestPDF.UnitTests .For(GetLayers) .MeasureElement(new Size(800, 600)) - .ExpectChildMeasure(BackgroundLayer, new Size(800, 600), new PartialRender(100, 200)) - .ExpectChildMeasure(MainLayer, new Size(800, 600), new PartialRender(200, 300)) - .ExpectChildMeasure(ForegroundLayer, new Size(800, 600), new Wrap()) + .ExpectChildMeasure(BackgroundLayer, new Size(800, 600), SpacePlan.PartialRender(100, 200)) + .ExpectChildMeasure(MainLayer, new Size(800, 600), SpacePlan.PartialRender(200, 300)) + .ExpectChildMeasure(ForegroundLayer, new Size(800, 600), SpacePlan.Wrap()) .ExpectChildDraw(BackgroundLayer, new Size(800, 600)) .ExpectChildDraw(MainLayer, new Size(800, 600)) @@ -116,9 +116,9 @@ namespace QuestPDF.UnitTests .For(GetLayers) .MeasureElement(new Size(800, 600)) - .ExpectChildMeasure(BackgroundLayer, new Size(800, 600), new Wrap()) - .ExpectChildMeasure(MainLayer, new Size(800, 600), new PartialRender(200, 300)) - .ExpectChildMeasure(ForegroundLayer, new Size(800, 600), new PartialRender(300, 400)) + .ExpectChildMeasure(BackgroundLayer, new Size(800, 600), SpacePlan.Wrap()) + .ExpectChildMeasure(MainLayer, new Size(800, 600), SpacePlan.PartialRender(200, 300)) + .ExpectChildMeasure(ForegroundLayer, new Size(800, 600), SpacePlan.PartialRender(300, 400)) .ExpectChildDraw(MainLayer, new Size(800, 600)) .ExpectChildDraw(ForegroundLayer, new Size(800, 600)) diff --git a/QuestPDF.UnitTests/RotateTests.cs b/QuestPDF.UnitTests/RotateTests.cs index 9ed94cc..9148fff 100644 --- a/QuestPDF.UnitTests/RotateTests.cs +++ b/QuestPDF.UnitTests/RotateTests.cs @@ -1,5 +1,4 @@ using NUnit.Framework; -using QuestPDF.Drawing.SpacePlan; using QuestPDF.Elements; using QuestPDF.Infrastructure; using QuestPDF.UnitTests.TestEngine; diff --git a/QuestPDF.UnitTests/RowTests.cs b/QuestPDF.UnitTests/RowTests.cs index 0a5e69b..fc1db47 100644 --- a/QuestPDF.UnitTests/RowTests.cs +++ b/QuestPDF.UnitTests/RowTests.cs @@ -184,11 +184,11 @@ namespace QuestPDF.UnitTests }); // assert - var expected = new SimpleRow + var expected = new BinaryRow { - Left = new SimpleRow + Left = new BinaryRow { - Left = new SimpleRow + Left = new BinaryRow { Left = new Constrained { @@ -202,7 +202,7 @@ namespace QuestPDF.UnitTests MaxWidth = 25 } }, - Right = new SimpleRow + Right = new BinaryRow { Left = new Constrained { @@ -217,9 +217,9 @@ namespace QuestPDF.UnitTests } } }, - Right = new SimpleRow + Right = new BinaryRow { - Left = new SimpleRow + Left = new BinaryRow { Left = new Constrained { @@ -233,7 +233,7 @@ namespace QuestPDF.UnitTests MaxWidth = 25 } }, - Right = new SimpleRow + Right = new BinaryRow { Left = new Constrained { @@ -241,7 +241,7 @@ namespace QuestPDF.UnitTests MaxWidth = 200, Child = childD }, - Right = new SimpleRow + Right = new BinaryRow { Left = new Constrained { diff --git a/QuestPDF.UnitTests/ScaleTests.cs b/QuestPDF.UnitTests/ScaleTests.cs index 0084fde..cffda83 100644 --- a/QuestPDF.UnitTests/ScaleTests.cs +++ b/QuestPDF.UnitTests/ScaleTests.cs @@ -1,5 +1,5 @@ using NUnit.Framework; -using QuestPDF.Drawing.SpacePlan; +using QuestPDF.Drawing; using QuestPDF.Elements; using QuestPDF.Infrastructure; using QuestPDF.UnitTests.TestEngine; @@ -22,8 +22,8 @@ namespace QuestPDF.UnitTests ScaleY = 2 }) .MeasureElement(new Size(900, 800)) - .ExpectChildMeasure(new Size(300, 400), new Wrap()) - .CheckMeasureResult(new Wrap()); + .ExpectChildMeasure(new Size(300, 400), SpacePlan.Wrap()) + .CheckMeasureResult(SpacePlan.Wrap()); } [Test] @@ -37,8 +37,8 @@ namespace QuestPDF.UnitTests ScaleY = 2 }) .MeasureElement(new Size(900, 800)) - .ExpectChildMeasure(new Size(300, 400), new PartialRender(200, 350)) - .CheckMeasureResult(new PartialRender(600, 700)); + .ExpectChildMeasure(new Size(300, 400), SpacePlan.PartialRender(200, 350)) + .CheckMeasureResult(SpacePlan.PartialRender(600, 700)); } [Test] @@ -52,8 +52,8 @@ namespace QuestPDF.UnitTests ScaleY = 2 }) .MeasureElement(new Size(900, 800)) - .ExpectChildMeasure(new Size(300, 400), new FullRender(250, 300)) - .CheckMeasureResult(new FullRender(750, 600)); + .ExpectChildMeasure(new Size(300, 400), SpacePlan.FullRender(250, 300)) + .CheckMeasureResult(SpacePlan.FullRender(750, 600)); } [Test] @@ -67,8 +67,8 @@ namespace QuestPDF.UnitTests ScaleY = 1 }) .MeasureElement(new Size(800, 600)) - .ExpectChildMeasure(new Size(400, 600), new FullRender(300, 500)) - .CheckMeasureResult(new FullRender(600, 500)); + .ExpectChildMeasure(new Size(400, 600), SpacePlan.FullRender(300, 500)) + .CheckMeasureResult(SpacePlan.FullRender(600, 500)); } [Test] @@ -82,8 +82,8 @@ namespace QuestPDF.UnitTests ScaleY = -3 }) .MeasureElement(new Size(800, 600)) - .ExpectChildMeasure(new Size(800, 200), new FullRender(800, 100)) - .CheckMeasureResult(new FullRender(800, 300)); + .ExpectChildMeasure(new Size(800, 200), SpacePlan.FullRender(800, 100)) + .CheckMeasureResult(SpacePlan.FullRender(800, 300)); } #endregion diff --git a/QuestPDF.UnitTests/ShowOnceTest.cs b/QuestPDF.UnitTests/ShowOnceTest.cs index 2ec2f42..da92c53 100644 --- a/QuestPDF.UnitTests/ShowOnceTest.cs +++ b/QuestPDF.UnitTests/ShowOnceTest.cs @@ -1,5 +1,4 @@ -using Moq; -using NUnit.Framework; +using NUnit.Framework; using QuestPDF.Drawing; using QuestPDF.Elements; using QuestPDF.Infrastructure; diff --git a/QuestPDF.UnitTests/SimpleRotateTests.cs b/QuestPDF.UnitTests/SimpleRotateTests.cs index fe8455c..df4a1a0 100644 --- a/QuestPDF.UnitTests/SimpleRotateTests.cs +++ b/QuestPDF.UnitTests/SimpleRotateTests.cs @@ -1,5 +1,5 @@ using NUnit.Framework; -using QuestPDF.Drawing.SpacePlan; +using QuestPDF.Drawing; using QuestPDF.Elements; using QuestPDF.Infrastructure; using QuestPDF.UnitTests.TestEngine; @@ -21,8 +21,8 @@ namespace QuestPDF.UnitTests TurnCount = 0 }) .MeasureElement(new Size(400, 300)) - .ExpectChildMeasure(new Size(400, 300), new Wrap()) - .CheckMeasureResult(new Wrap()); + .ExpectChildMeasure(new Size(400, 300), SpacePlan.Wrap()) + .CheckMeasureResult(SpacePlan.Wrap()); } [Test] @@ -35,8 +35,8 @@ namespace QuestPDF.UnitTests TurnCount = 0 }) .MeasureElement(new Size(400, 300)) - .ExpectChildMeasure(new Size(400, 300), new PartialRender(300, 200)) - .CheckMeasureResult(new PartialRender(300, 200)); + .ExpectChildMeasure(new Size(400, 300), SpacePlan.PartialRender(300, 200)) + .CheckMeasureResult(SpacePlan.PartialRender(300, 200)); } [Test] @@ -49,8 +49,8 @@ namespace QuestPDF.UnitTests TurnCount = 1 }) .MeasureElement(new Size(400, 300)) - .ExpectChildMeasure(new Size(300, 400), new FullRender(200, 300)) - .CheckMeasureResult(new FullRender(300, 200)); + .ExpectChildMeasure(new Size(300, 400), SpacePlan.FullRender(200, 300)) + .CheckMeasureResult(SpacePlan.FullRender(300, 200)); } [Test] @@ -63,8 +63,8 @@ namespace QuestPDF.UnitTests TurnCount = 2 }) .MeasureElement(new Size(400, 300)) - .ExpectChildMeasure(new Size(400, 300), new FullRender(200, 100)) - .CheckMeasureResult(new FullRender(200, 100)); + .ExpectChildMeasure(new Size(400, 300), SpacePlan.FullRender(200, 100)) + .CheckMeasureResult(SpacePlan.FullRender(200, 100)); } [Test] @@ -77,8 +77,8 @@ namespace QuestPDF.UnitTests TurnCount = 3 // or -1 }) .MeasureElement(new Size(500, 400)) - .ExpectChildMeasure(new Size(400, 500), new FullRender(300, 350)) - .CheckMeasureResult(new FullRender(350, 300)); + .ExpectChildMeasure(new Size(400, 500), SpacePlan.FullRender(300, 350)) + .CheckMeasureResult(SpacePlan.FullRender(350, 300)); } #endregion diff --git a/QuestPDF.UnitTests/StackTests.cs b/QuestPDF.UnitTests/StackTests.cs index 2f456e6..58218bb 100644 --- a/QuestPDF.UnitTests/StackTests.cs +++ b/QuestPDF.UnitTests/StackTests.cs @@ -1,6 +1,7 @@ using NUnit.Framework; using QuestPDF.Drawing; using QuestPDF.Elements; +using QuestPDF.Fluent; using QuestPDF.Infrastructure; using QuestPDF.UnitTests.TestEngine; diff --git a/QuestPDF.UnitTests/TestEngine/Operations/ChildMeasureOperation.cs b/QuestPDF.UnitTests/TestEngine/Operations/ChildMeasureOperation.cs index 6586059..d40d68b 100644 --- a/QuestPDF.UnitTests/TestEngine/Operations/ChildMeasureOperation.cs +++ b/QuestPDF.UnitTests/TestEngine/Operations/ChildMeasureOperation.cs @@ -3,13 +3,13 @@ using QuestPDF.Infrastructure; namespace QuestPDF.UnitTests.TestEngine.Operations { - internal class ChildMeasureOperationBase : OperationBase + internal class ChildMeasureOperation : OperationBase { public string ChildId { get; } public Size Input { get; } public SpacePlan Output { get; } - public ChildMeasureOperationBase(string childId, Size input, SpacePlan output) + public ChildMeasureOperation(string childId, Size input, SpacePlan output) { ChildId = childId; Input = input; diff --git a/QuestPDF.UnitTests/TestEngine/SimpleContainerTests.cs b/QuestPDF.UnitTests/TestEngine/SimpleContainerTests.cs index 542be2f..75347aa 100644 --- a/QuestPDF.UnitTests/TestEngine/SimpleContainerTests.cs +++ b/QuestPDF.UnitTests/TestEngine/SimpleContainerTests.cs @@ -1,5 +1,4 @@ -using QuestPDF.Drawing.SpacePlan; -using QuestPDF.Elements; +using QuestPDF.Drawing; using QuestPDF.Infrastructure; namespace QuestPDF.UnitTests.TestEngine @@ -23,8 +22,8 @@ namespace QuestPDF.UnitTests.TestEngine Child = x.CreateChild() }) .MeasureElement(new Size(400, 300)) - .ExpectChildMeasure(new Size(400, 300), new Wrap()) - .CheckMeasureResult(new Wrap()); + .ExpectChildMeasure(new Size(400, 300), SpacePlan.Wrap()) + .CheckMeasureResult(SpacePlan.Wrap()); } private static void Measure_PartialRender() where TElement : Element, IContainer, new() @@ -35,8 +34,8 @@ namespace QuestPDF.UnitTests.TestEngine Child = x.CreateChild() }) .MeasureElement(new Size(400, 300)) - .ExpectChildMeasure(new Size(400, 300), new PartialRender(200, 100)) - .CheckMeasureResult(new PartialRender(200, 100)); + .ExpectChildMeasure(new Size(400, 300), SpacePlan.PartialRender(200, 100)) + .CheckMeasureResult(SpacePlan.PartialRender(200, 100)); } private static void Measure_FullRender() where TElement : Element, IContainer, new() @@ -47,8 +46,8 @@ namespace QuestPDF.UnitTests.TestEngine Child = x.CreateChild() }) .MeasureElement(new Size(400, 300)) - .ExpectChildMeasure(new Size(400, 300), new FullRender(250, 150)) - .CheckMeasureResult(new FullRender(250, 150)); + .ExpectChildMeasure(new Size(400, 300), SpacePlan.FullRender(250, 150)) + .CheckMeasureResult(SpacePlan.FullRender(250, 150)); } #endregion diff --git a/QuestPDF.UnitTests/TestEngine/TestPlan.cs b/QuestPDF.UnitTests/TestEngine/TestPlan.cs index 055a4db..8bbe290 100644 --- a/QuestPDF.UnitTests/TestEngine/TestPlan.cs +++ b/QuestPDF.UnitTests/TestEngine/TestPlan.cs @@ -6,6 +6,8 @@ using NUnit.Framework; using QuestPDF.Drawing; using QuestPDF.Elements; using QuestPDF.Helpers; +using QuestPDF.Infrastructure; +using QuestPDF.UnitTests.TestEngine.Operations; namespace QuestPDF.UnitTests.TestEngine { @@ -270,10 +272,10 @@ namespace QuestPDF.UnitTests.TestEngine var canvas = new FreeCanvas(); value.HandleVisitor(x => x.Initialize(null, canvas)); - var valueMeasure = value.Measure(availableSpace); + var valueMeasure = value.Measure(availableSpace.Value); expected.HandleVisitor(x => x.Initialize(null, canvas)); - var expectedMeasure = expected.Measure(availableSpace); + var expectedMeasure = expected.Measure(availableSpace.Value); valueMeasure.Should().BeEquivalentTo(expectedMeasure); } @@ -284,11 +286,11 @@ namespace QuestPDF.UnitTests.TestEngine var valueCanvas = new OperationRecordingCanvas(); value.HandleVisitor(x => x.Initialize(null, valueCanvas)); - value.Draw(availableSpace); + value.Draw(availableSpace.Value); var expectedCanvas = new OperationRecordingCanvas(); expected.HandleVisitor(x => x.Initialize(null, expectedCanvas)); - expected.Draw(availableSpace); + expected.Draw(availableSpace.Value); valueCanvas.Operations.Should().BeEquivalentTo(expectedCanvas.Operations); } diff --git a/QuestPDF.UnitTests/TranslateTests.cs b/QuestPDF.UnitTests/TranslateTests.cs index f035346..bb96552 100644 --- a/QuestPDF.UnitTests/TranslateTests.cs +++ b/QuestPDF.UnitTests/TranslateTests.cs @@ -1,5 +1,4 @@ using NUnit.Framework; -using QuestPDF.Drawing.SpacePlan; using QuestPDF.Elements; using QuestPDF.Infrastructure; using QuestPDF.UnitTests.TestEngine; diff --git a/QuestPDF.UnitTests/UnconstrainedTests.cs b/QuestPDF.UnitTests/UnconstrainedTests.cs index 317eea0..a2aec6f 100644 --- a/QuestPDF.UnitTests/UnconstrainedTests.cs +++ b/QuestPDF.UnitTests/UnconstrainedTests.cs @@ -1,5 +1,5 @@ using NUnit.Framework; -using QuestPDF.Drawing.SpacePlan; +using QuestPDF.Drawing; using QuestPDF.Elements; using QuestPDF.Infrastructure; using QuestPDF.UnitTests.TestEngine; @@ -20,8 +20,8 @@ namespace QuestPDF.UnitTests Child = x.CreateChild() }) .MeasureElement(new Size(900, 800)) - .ExpectChildMeasure(Size.Max, new Wrap()) - .CheckMeasureResult(new Wrap()); + .ExpectChildMeasure(Size.Max, SpacePlan.Wrap()) + .CheckMeasureResult(SpacePlan.Wrap()); } [Test] @@ -33,8 +33,8 @@ namespace QuestPDF.UnitTests Child = x.CreateChild() }) .MeasureElement(new Size(900, 800)) - .ExpectChildMeasure(Size.Max, new PartialRender(1200, 1600)) - .CheckMeasureResult(new PartialRender(Size.Zero)); + .ExpectChildMeasure(Size.Max, SpacePlan.PartialRender(1200, 1600)) + .CheckMeasureResult(SpacePlan.PartialRender(Size.Zero)); } [Test] @@ -46,8 +46,8 @@ namespace QuestPDF.UnitTests Child = x.CreateChild() }) .MeasureElement(new Size(900, 800)) - .ExpectChildMeasure(Size.Max, new FullRender(1200, 1600)) - .CheckMeasureResult(new FullRender(Size.Zero)); + .ExpectChildMeasure(Size.Max, SpacePlan.FullRender(1200, 1600)) + .CheckMeasureResult(SpacePlan.FullRender(Size.Zero)); } #endregion @@ -63,7 +63,7 @@ namespace QuestPDF.UnitTests Child = x.CreateChild() }) .DrawElement(new Size(900, 800)) - .ExpectChildMeasure(Size.Max, new Wrap()) + .ExpectChildMeasure(Size.Max, SpacePlan.Wrap()) .CheckDrawResult(); } @@ -76,7 +76,7 @@ namespace QuestPDF.UnitTests Child = x.CreateChild() }) .DrawElement(new Size(900, 800)) - .ExpectChildMeasure(Size.Max, new PartialRender(1200, 1600)) + .ExpectChildMeasure(Size.Max, SpacePlan.PartialRender(1200, 1600)) .ExpectChildDraw(new Size(1200, 1600)) .CheckDrawResult(); } @@ -90,7 +90,7 @@ namespace QuestPDF.UnitTests Child = x.CreateChild() }) .DrawElement(new Size(900, 800)) - .ExpectChildMeasure(Size.Max, new FullRender(1600, 1000)) + .ExpectChildMeasure(Size.Max, SpacePlan.FullRender(1600, 1000)) .ExpectChildDraw(new Size(1600, 1000)) .CheckDrawResult(); } diff --git a/QuestPDF/Drawing/TextRender.cs b/QuestPDF/Drawing/TextRender.cs deleted file mode 100644 index a4ca9b9..0000000 --- a/QuestPDF/Drawing/TextRender.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace QuestPDF.Drawing.SpacePlan -{ - internal class TextRender : FullRender - { - public float Ascent { get; set; } - public float Descent { get; set; } - - public TextRender(float width, float height) : base(width, height) - { - - } - } -} \ No newline at end of file diff --git a/QuestPDF/Elements/Row.cs b/QuestPDF/Elements/Row.cs index fbdb61e..f779f6c 100644 --- a/QuestPDF/Elements/Row.cs +++ b/QuestPDF/Elements/Row.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using QuestPDF.Drawing; using QuestPDF.Infrastructure; namespace QuestPDF.Elements diff --git a/QuestPDF/Elements/Text/Items/TextBlockElement.cs b/QuestPDF/Elements/Text/Items/TextBlockElement.cs index 472d803..32fbad7 100644 --- a/QuestPDF/Elements/Text/Items/TextBlockElement.cs +++ b/QuestPDF/Elements/Text/Items/TextBlockElement.cs @@ -1,4 +1,4 @@ -using QuestPDF.Drawing.SpacePlan; +using QuestPDF.Drawing; using QuestPDF.Elements.Text.Calculation; using QuestPDF.Infrastructure; @@ -15,16 +15,14 @@ namespace QuestPDF.Elements.Text.Items var measurement = Element.Measure(new Size(request.AvailableWidth, Size.Max.Height)); - if (measurement is Wrap || measurement is PartialRender) + if (measurement.Type != SpacePlanType.FullRender) return null; - - var elementSize = measurement as Size; return new TextMeasurementResult { - Width = elementSize.Width, + Width = measurement.Width, - Ascent = -elementSize.Height, + Ascent = -measurement.Height, Descent = 0, LineHeight = 1, diff --git a/QuestPDF/Elements/Text/TextBlock.cs b/QuestPDF/Elements/Text/TextBlock.cs index 106e7e8..283a294 100644 --- a/QuestPDF/Elements/Text/TextBlock.cs +++ b/QuestPDF/Elements/Text/TextBlock.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; -using QuestPDF.Drawing.SpacePlan; +using QuestPDF.Drawing; using QuestPDF.Elements.Text.Calculation; using QuestPDF.Elements.Text.Items; using QuestPDF.Infrastructure; @@ -22,21 +22,21 @@ namespace QuestPDF.Elements.Text CurrentElementIndex = 0; } - internal override ISpacePlan Measure(Size availableSpace) + internal override SpacePlan Measure(Size availableSpace) { if (!RenderingQueue.Any()) - return new FullRender(Size.Zero); + return SpacePlan.FullRender(Size.Zero); var lines = DivideTextItemsIntoLines(availableSpace.Width, availableSpace.Height).ToList(); if (!lines.Any()) - return new PartialRender(Size.Zero); + return SpacePlan.PartialRender(Size.Zero); var width = lines.Max(x => x.Width); var height = lines.Sum(x => x.LineHeight); if (width > availableSpace.Width + Size.Epsilon || height > availableSpace.Height + Size.Epsilon) - return new Wrap(); + return SpacePlan.Wrap(); var fullyRenderedItemsCount = lines .SelectMany(x => x.Elements) @@ -44,9 +44,9 @@ namespace QuestPDF.Elements.Text .Count(x => x.Any(y => y.Measurement.IsLast)); if (fullyRenderedItemsCount == RenderingQueue.Count) - return new FullRender(width, height); + return SpacePlan.FullRender(width, height); - return new PartialRender(width, height); + return SpacePlan.PartialRender(width, height); } internal override void Draw(Size availableSpace)