Renamed Decoration element
This commit is contained in:
@@ -40,7 +40,7 @@ namespace QuestPDF.Examples
|
||||
.Decoration(decoration =>
|
||||
{
|
||||
decoration
|
||||
.Header()
|
||||
.Before()
|
||||
.Background(Colors.Grey.Medium)
|
||||
.Padding(10)
|
||||
.Text("Notes", TextStyle.Default.Size(16).Color("#FFF"));
|
||||
@@ -501,7 +501,7 @@ namespace QuestPDF.Examples
|
||||
.SemiBold();
|
||||
|
||||
decoration
|
||||
.Header()
|
||||
.Before()
|
||||
.PaddingBottom(10)
|
||||
.Text("Example: scale component", headerFontStyle);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace QuestPDF.Examples
|
||||
.Padding(25)
|
||||
.Decoration(decoration =>
|
||||
{
|
||||
decoration.Header().Text(text =>
|
||||
decoration.Before().Text(text =>
|
||||
{
|
||||
text.DefaultTextStyle(TextStyle.Default.Size(20));
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace QuestPDF.Examples
|
||||
column.Item().Element(Acknowledgements);
|
||||
});
|
||||
|
||||
decoration.Footer().Element(Footer);
|
||||
decoration.After().Element(Footer);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace QuestPDF.ReportSample.Layouts
|
||||
.Decoration(decoration =>
|
||||
{
|
||||
decoration
|
||||
.Header()
|
||||
.Before()
|
||||
.PaddingBottom(5)
|
||||
.Text(Model.Title, Typography.Headline);
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace QuestPDF.ReportSample.Layouts
|
||||
.Decoration(decoration =>
|
||||
{
|
||||
decoration
|
||||
.Header()
|
||||
.Before()
|
||||
.PaddingBottom(5)
|
||||
.Text("Table of contents", Typography.Headline);
|
||||
|
||||
|
||||
@@ -17,22 +17,22 @@ namespace QuestPDF.Elements
|
||||
|
||||
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 Footer { get; set; } = new Empty();
|
||||
internal Element After { get; set; } = new Empty();
|
||||
|
||||
internal override IEnumerable<Element?> GetChildren()
|
||||
{
|
||||
yield return Header;
|
||||
yield return Before;
|
||||
yield return Content;
|
||||
yield return Footer;
|
||||
yield return After;
|
||||
}
|
||||
|
||||
internal override void CreateProxy(Func<Element?, Element?> create)
|
||||
{
|
||||
Header = create(Header);
|
||||
Before = create(Before);
|
||||
Content = create(Content);
|
||||
Footer = create(Footer);
|
||||
After = create(After);
|
||||
}
|
||||
|
||||
internal override SpacePlan Measure(Size availableSpace)
|
||||
@@ -68,17 +68,17 @@ namespace QuestPDF.Elements
|
||||
|
||||
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);
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
@@ -87,15 +87,15 @@ namespace QuestPDF.Elements
|
||||
Element = Content,
|
||||
Measurement = contentMeasurement,
|
||||
Size = new Size(availableSpace.Width, contentMeasurement.Height),
|
||||
Offset = new Position(0, headerMeasurement.Height)
|
||||
Offset = new Position(0, beforeMeasurement.Height)
|
||||
};
|
||||
|
||||
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)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace QuestPDF.Elements
|
||||
.Decoration(decoration =>
|
||||
{
|
||||
decoration
|
||||
.Header()
|
||||
.Before()
|
||||
.DebugPointer("Page header")
|
||||
.Element(Header);
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace QuestPDF.Elements
|
||||
.Element(Content);
|
||||
|
||||
decoration
|
||||
.Footer()
|
||||
.After()
|
||||
.DebugPointer("Page footer")
|
||||
.Element(Footer);
|
||||
});
|
||||
|
||||
@@ -8,16 +8,16 @@ namespace QuestPDF.Fluent
|
||||
{
|
||||
internal Decoration Decoration { get; } = new Decoration();
|
||||
|
||||
public IContainer Header()
|
||||
public IContainer Before()
|
||||
{
|
||||
var container = new Container();
|
||||
Decoration.Header = container;
|
||||
Decoration.Before = container;
|
||||
return container;
|
||||
}
|
||||
|
||||
public void Header(Action<IContainer> handler)
|
||||
public void Before(Action<IContainer> handler)
|
||||
{
|
||||
handler?.Invoke(Header());
|
||||
handler?.Invoke(Before());
|
||||
}
|
||||
|
||||
public IContainer Content()
|
||||
@@ -32,17 +32,45 @@ namespace QuestPDF.Fluent
|
||||
handler?.Invoke(Content());
|
||||
}
|
||||
|
||||
public IContainer Footer()
|
||||
public IContainer After()
|
||||
{
|
||||
var container = new Container();
|
||||
Decoration.Footer = container;
|
||||
Decoration.After = 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
|
||||
|
||||
@@ -101,9 +101,9 @@ namespace QuestPDF.Fluent
|
||||
container
|
||||
.Decoration(decoration =>
|
||||
{
|
||||
decoration.Header().Element(HeaderTable);
|
||||
decoration.Before().Element(HeaderTable);
|
||||
decoration.Content().Element(ContentTable);
|
||||
decoration.Footer().Element(FooterTable);
|
||||
decoration.After().Element(FooterTable);
|
||||
});
|
||||
|
||||
return container;
|
||||
|
||||
Reference in New Issue
Block a user