Browse Source

Included examples for DSL and complex layouts

Marcin Ziąbek 4 years ago
parent
commit
04af33fc31
2 changed files with 81 additions and 3 deletions
  1. 78 0
      QuestPDF.Examples/ElementExamples.cs
  2. 3 3
      QuestPDF.Examples/FrameExample.cs

+ 78 - 0
QuestPDF.Examples/ElementExamples.cs

@@ -755,5 +755,83 @@ namespace QuestPDF.Examples
                         });
                         });
                 });
                 });
         }
         }
+        
+        [Test]
+        public void ComplexLayout()
+        {
+            RenderingTest
+                .Create()
+                .PageSize(500, 225)
+                .FileName()
+                .Render(container =>
+                {
+                    container
+                        .Padding(25)
+                        .Stack(stack =>
+                        {
+                            stack.Item().Row(row =>
+                            {
+                                row.RelativeColumn().LabelCell("Label 1");
+                                
+                                row.RelativeColumn(3).Grid(grid =>
+                                {
+                                    grid.Columns(3);
+                                    
+                                    grid.Item(2).LabelCell("Label 2");
+                                    grid.Item().LabelCell("Label 3");
+                                    
+                                    grid.Item(2).ValueCell().Text("Value 2");
+                                    grid.Item().ValueCell().Text("Value 3");
+                                });
+                            });
+                            
+                            stack.Item().Row(row =>
+                            {
+                                row.RelativeColumn().ValueCell().Text("Value 1");
+                                
+                                row.RelativeColumn(3).Grid(grid =>
+                                {
+                                    grid.Columns(3);
+                                    
+                                    grid.Item().LabelCell("Label 4");
+                                    grid.Item(2).LabelCell("Label 5");
+                                    
+                                    grid.Item().ValueCell().Text("Value 4");
+                                    grid.Item(2).ValueCell().Text("Value 5");
+                                });
+                            });
+                            
+                            stack.Item().Row(row =>
+                            {
+                                row.RelativeColumn().LabelCell("Label 6");
+                                row.RelativeColumn().ValueCell().Text("Value 6");
+                            });
+                        });
+                });
+        }
+        
+        [Test]
+        public void DomainSpecificLanguage()
+        {
+            RenderingTest
+                .Create()
+                .PageSize(600, 310)
+                .FileName()
+                .Render(container =>
+                {
+                    container
+                        .Padding(25)
+                        .Grid(grid =>
+                        {
+                            grid.Columns(10);
+                            
+                            for(var i=1; i<=4; i++)
+                            {
+                                grid.Item(2).LabelCell(Placeholders.Label());
+                                grid.Item(3).ValueCell().Image(Placeholders.Image(200, 150));
+                            }
+                        });
+                });
+        }
     }
     }
 }
 }

+ 3 - 3
QuestPDF.Examples/FrameExample.cs

@@ -12,11 +12,11 @@ namespace QuestPDF.Examples
         {
         {
             return container
             return container
                 .Border(1)
                 .Border(1)
-                .Background(dark ? "#EEE" : "#FFF")
+                .Background(dark ? Colors.Grey.Lighten2 : Colors.White)
                 .Padding(10);
                 .Padding(10);
         }
         }
         
         
-        public static IContainer LabelCell(this IContainer container) => container.Cell(true);
+        public static void LabelCell(this IContainer container, string text) => container.Cell(true).Text(text, TextStyle.Default.Medium());
         public static IContainer ValueCell(this IContainer container) => container.Cell(false);
         public static IContainer ValueCell(this IContainer container) => container.Cell(false);
     }
     }
     
     
@@ -40,7 +40,7 @@ namespace QuestPDF.Examples
                             {
                             {
                                 stack.Item().Row(row =>
                                 stack.Item().Row(row =>
                                 {
                                 {
-                                    row.RelativeColumn(2).LabelCell().Text(Placeholders.Label());
+                                    row.RelativeColumn(2).LabelCell(Placeholders.Label());
                                     row.RelativeColumn(3).ValueCell().Text(Placeholders.Paragraph());
                                     row.RelativeColumn(3).ValueCell().Text(Placeholders.Paragraph());
                                 });
                                 });
                             }
                             }