Просмотр исходного кода

Added more examples for the Shrink element

MarcinZiabek 3 лет назад
Родитель
Сommit
5cc0397acb
2 измененных файлов с 94 добавлено и 1 удалено
  1. 93 0
      QuestPDF.Examples/ShrinkExamples.cs
  2. 1 1
      QuestPDF/Fluent/ShrinkExtensions.cs

+ 93 - 0
QuestPDF.Examples/ShrinkExamples.cs

@@ -0,0 +1,93 @@
+using NUnit.Framework;
+using QuestPDF.Examples.Engine;
+using QuestPDF.Fluent;
+using QuestPDF.Helpers;
+
+namespace QuestPDF.Examples
+{
+    public class ShrinkExamples
+    {
+        [Test]
+        public void Shrink_Without()
+        {
+            RenderingTest
+                .Create()
+                .PageSize(300, 200)
+                .ProduceImages()
+                .ShowResults()
+                .Render(container =>
+                {
+                    container
+                        .Padding(20)
+                        .Border(2)
+                        .Background(Colors.Grey.Lighten2)
+                        .Padding(20)
+                        .Text("This is test.")
+                        .FontSize(20);
+                });
+        }
+        
+        [Test]
+        public void Shrink_Horizontal()
+        {
+            RenderingTest
+                .Create()
+                .PageSize(300, 200)
+                .ProduceImages()
+                .ShowResults()
+                .Render(container =>
+                {
+                    container
+                        .Padding(20)
+                        .Border(2)
+                        .ShrinkHorizontal()
+                        .Background(Colors.Grey.Lighten2)
+                        .Padding(20)
+                        .Text("This is test.")
+                        .FontSize(20);
+                });
+        }
+        
+        [Test]
+        public void Shrink_Vertical()
+        {
+            RenderingTest
+                .Create()
+                .PageSize(300, 200)
+                .ProduceImages()
+                .ShowResults()
+                .Render(container =>
+                {
+                    container
+                        .Padding(20)
+                        .Border(2)
+                        .ShrinkVertical()
+                        .Background(Colors.Grey.Lighten2)
+                        .Padding(20)
+                        .Text("This is test.")
+                        .FontSize(20);
+                });
+        }
+        
+        [Test]
+        public void Shrink_Both()
+        {
+            RenderingTest
+                .Create()
+                .PageSize(300, 200)
+                .ProduceImages()
+                .ShowResults()
+                .Render(container =>
+                {
+                    container
+                        .Padding(20)
+                        .Border(2)
+                        .Shrink()
+                        .Background(Colors.Grey.Lighten2)
+                        .Padding(20)
+                        .Text("This is test.")
+                        .FontSize(20);
+                });
+        }
+    }
+}

+ 1 - 1
QuestPDF/Fluent/ShrinkExtensions.cs

@@ -16,7 +16,7 @@ namespace QuestPDF.Fluent
         
         public static IContainer Shrink(this IContainer element)
         {
-            return element.ExtendVertical().ExtendHorizontal();
+            return element.ShrinkVertical().ShrinkHorizontal();
         }
         
         public static IContainer ShrinkVertical(this IContainer element)