Browse Source

Renamed Decoration element

Marcin Ziąbek 3 years ago
parent
commit
b2cc7bbd36

+ 2 - 2
QuestPDF.Examples/ElementExamples.cs

@@ -40,7 +40,7 @@ namespace QuestPDF.Examples
                         .Decoration(decoration =>
                         .Decoration(decoration =>
                         {
                         {
                             decoration
                             decoration
-                                .Header()
+                                .Before()
                                 .Background(Colors.Grey.Medium)
                                 .Background(Colors.Grey.Medium)
                                 .Padding(10)
                                 .Padding(10)
                                 .Text("Notes", TextStyle.Default.Size(16).Color("#FFF"));
                                 .Text("Notes", TextStyle.Default.Size(16).Color("#FFF"));
@@ -501,7 +501,7 @@ namespace QuestPDF.Examples
                                 .SemiBold();
                                 .SemiBold();
     
     
                             decoration
                             decoration
-                                .Header()
+                                .Before()
                                 .PaddingBottom(10)
                                 .PaddingBottom(10)
                                 .Text("Example: scale component", headerFontStyle);
                                 .Text("Example: scale component", headerFontStyle);
     
     

+ 1 - 1
QuestPDF.Examples/InlinedExamples.cs

@@ -25,7 +25,7 @@ namespace QuestPDF.Examples
                         .Padding(25)
                         .Padding(25)
                         .Decoration(decoration =>
                         .Decoration(decoration =>
                         {
                         {
-                            decoration.Header().Text(text =>
+                            decoration.Before().Text(text =>
                             {
                             {
                                 text.DefaultTextStyle(TextStyle.Default.Size(20));
                                 text.DefaultTextStyle(TextStyle.Default.Size(20));
                                 
                                 

+ 1 - 1
QuestPDF.Examples/TextBenchmark.cs

@@ -129,7 +129,7 @@ namespace QuestPDF.Examples
                                 column.Item().Element(Acknowledgements);
                                 column.Item().Element(Acknowledgements);
                             });
                             });
 
 
-                        decoration.Footer().Element(Footer);
+                        decoration.After().Element(Footer);
                     });
                     });
             }
             }
             
             

+ 1 - 1
QuestPDF.ReportSample/Layouts/SectionTemplate.cs

@@ -21,7 +21,7 @@ namespace QuestPDF.ReportSample.Layouts
                 .Decoration(decoration =>
                 .Decoration(decoration =>
                 {
                 {
                     decoration
                     decoration
-                        .Header()
+                        .Before()
                         .PaddingBottom(5)
                         .PaddingBottom(5)
                         .Text(Model.Title, Typography.Headline);
                         .Text(Model.Title, Typography.Headline);
 
 

+ 1 - 1
QuestPDF.ReportSample/Layouts/TableOfContentsTemplate.cs

@@ -19,7 +19,7 @@ namespace QuestPDF.ReportSample.Layouts
                 .Decoration(decoration =>
                 .Decoration(decoration =>
                 {
                 {
                     decoration
                     decoration
-                        .Header()
+                        .Before()
                         .PaddingBottom(5)
                         .PaddingBottom(5)
                         .Text("Table of contents", Typography.Headline);
                         .Text("Table of contents", Typography.Headline);
 
 

+ 17 - 17
QuestPDF/Elements/Decoration.cs

@@ -17,22 +17,22 @@ namespace QuestPDF.Elements
     
     
     internal class Decoration : Element, ICacheable
     internal class Decoration : Element, ICacheable
     {
     {
-        internal Element Header { get; set; } = new Empty();
+        internal Element Before { get; set; } = new Empty();
         internal Element Content { get; set; } = new Empty();
         internal Element Content { get; set; } = new Empty();
-        internal Element Footer { get; set; } = new Empty();
+        internal Element After { get; set; } = new Empty();
 
 
         internal override IEnumerable<Element?> GetChildren()
         internal override IEnumerable<Element?> GetChildren()
         {
         {
-            yield return Header;
+            yield return Before;
             yield return Content;
             yield return Content;
-            yield return Footer;
+            yield return After;
         }
         }
         
         
         internal override void CreateProxy(Func<Element?, Element?> create)
         internal override void CreateProxy(Func<Element?, Element?> create)
         {
         {
-            Header = create(Header);
+            Before = create(Before);
             Content = create(Content);
             Content = create(Content);
-            Footer = create(Footer);
+            After = create(After);
         }
         }
 
 
         internal override SpacePlan Measure(Size availableSpace)
         internal override SpacePlan Measure(Size availableSpace)
@@ -68,17 +68,17 @@ namespace QuestPDF.Elements
 
 
         private IEnumerable<DecorationItemRenderingCommand> PlanLayout(Size availableSpace)
         private IEnumerable<DecorationItemRenderingCommand> PlanLayout(Size availableSpace)
         {
         {
-            var headerMeasurement = Header.Measure(availableSpace);
-            var footerMeasurement = Footer.Measure(availableSpace);
+            var beforeMeasurement = Before.Measure(availableSpace);
+            var afterMeasurement = After.Measure(availableSpace);
             
             
-            var contentSpace = new Size(availableSpace.Width, availableSpace.Height - headerMeasurement.Height - footerMeasurement.Height);
+            var contentSpace = new Size(availableSpace.Width, availableSpace.Height - beforeMeasurement.Height - afterMeasurement.Height);
             var contentMeasurement = Content.Measure(contentSpace);
             var contentMeasurement = Content.Measure(contentSpace);
 
 
             yield return new DecorationItemRenderingCommand
             yield return new DecorationItemRenderingCommand
             {
             {
-                Element = Header,
-                Measurement = headerMeasurement,
-                Size = new Size(availableSpace.Width, headerMeasurement.Height),
+                Element = Before,
+                Measurement = beforeMeasurement,
+                Size = new Size(availableSpace.Width, beforeMeasurement.Height),
                 Offset = Position.Zero
                 Offset = Position.Zero
             };
             };
             
             
@@ -87,15 +87,15 @@ namespace QuestPDF.Elements
                 Element = Content,
                 Element = Content,
                 Measurement = contentMeasurement,
                 Measurement = contentMeasurement,
                 Size = new Size(availableSpace.Width, contentMeasurement.Height),
                 Size = new Size(availableSpace.Width, contentMeasurement.Height),
-                Offset = new Position(0, headerMeasurement.Height)
+                Offset = new Position(0, beforeMeasurement.Height)
             };
             };
 
 
             yield return new DecorationItemRenderingCommand
             yield return new DecorationItemRenderingCommand
             {
             {
-                Element = Footer,
-                Measurement = footerMeasurement,
-                Size = new Size(availableSpace.Width, footerMeasurement.Height),
-                Offset = new Position(0, headerMeasurement.Height + contentMeasurement.Height)
+                Element = After,
+                Measurement = afterMeasurement,
+                Size = new Size(availableSpace.Width, afterMeasurement.Height),
+                Offset = new Position(0, beforeMeasurement.Height + contentMeasurement.Height)
             };
             };
         }
         }
     }
     }

+ 2 - 2
QuestPDF/Elements/Page.cs

@@ -45,7 +45,7 @@ namespace QuestPDF.Elements
                 .Decoration(decoration =>
                 .Decoration(decoration =>
                 {
                 {
                     decoration
                     decoration
-                        .Header()
+                        .Before()
                         .DebugPointer("Page header")
                         .DebugPointer("Page header")
                         .Element(Header);
                         .Element(Header);
                     
                     
@@ -57,7 +57,7 @@ namespace QuestPDF.Elements
                         .Element(Content);
                         .Element(Content);
                     
                     
                     decoration
                     decoration
-                        .Footer()
+                        .After()
                         .DebugPointer("Page footer")
                         .DebugPointer("Page footer")
                         .Element(Footer);
                         .Element(Footer);
                 });
                 });

+ 36 - 8
QuestPDF/Fluent/DecorationExtensions.cs

@@ -8,16 +8,16 @@ namespace QuestPDF.Fluent
     {
     {
         internal Decoration Decoration { get; } = new Decoration();
         internal Decoration Decoration { get; } = new Decoration();
         
         
-        public IContainer Header()
+        public IContainer Before()
         {
         {
             var container = new Container();
             var container = new Container();
-            Decoration.Header = container;
+            Decoration.Before = container;
             return container;
             return container;
         }
         }
         
         
-        public void Header(Action<IContainer> handler)
+        public void Before(Action<IContainer> handler)
         {
         {
-            handler?.Invoke(Header());
+            handler?.Invoke(Before());
         }
         }
         
         
         public IContainer Content()
         public IContainer Content()
@@ -32,17 +32,45 @@ namespace QuestPDF.Fluent
             handler?.Invoke(Content());
             handler?.Invoke(Content());
         }
         }
         
         
-        public IContainer Footer()
+        public IContainer After()
         {
         {
             var container = new Container();
             var container = new Container();
-            Decoration.Footer = container;
+            Decoration.After = container;
             return container;
             return container;
         }
         }
         
         
-        public void Footer(Action<IContainer> handler)
+        public void After(Action<IContainer> handler)
         {
         {
-            handler?.Invoke(Footer());
+            handler?.Invoke(After());
         }
         }
+
+        #region Obsolete
+
+        // public IContainer Header()
+        // {
+        //     var container = new Container();
+        //     Decoration.Before = container;
+        //     return container;
+        // }
+        //
+        // public void Header(Action<IContainer> handler)
+        // {
+        //     handler?.Invoke(Header());
+        // }
+        //
+        // public IContainer Footer()
+        // {
+        //     var container = new Container();
+        //     Decoration.After = container;
+        //     return container;
+        // }
+        //
+        // public void Footer(Action<IContainer> handler)
+        // {
+        //     handler?.Invoke(Footer());
+        // }
+
+        #endregion
     }
     }
     
     
     public static class DecorationExtensions
     public static class DecorationExtensions

+ 2 - 2
QuestPDF/Fluent/TableExtensions.cs

@@ -101,9 +101,9 @@ namespace QuestPDF.Fluent
             container
             container
                 .Decoration(decoration =>
                 .Decoration(decoration =>
                 {
                 {
-                    decoration.Header().Element(HeaderTable);
+                    decoration.Before().Element(HeaderTable);
                     decoration.Content().Element(ContentTable);
                     decoration.Content().Element(ContentTable);
-                    decoration.Footer().Element(FooterTable);
+                    decoration.After().Element(FooterTable);
                 });
                 });
 
 
             return container;
             return container;