FastReport
105 строк · 3.5 Кб
1using System;
2using System.Collections;
3using System.Drawing;
4using System.ComponentModel;
5using FastReport.Utils;
6
7namespace FastReport
8{
9/// <summary>
10/// This class represents a child band.
11/// </summary>
12/// <remarks>
13/// Typical use of child band is to print several objects that can grow or shrink. It also can be done
14/// using the shift feature (via <see cref="ShiftMode"/> property), but in some cases it's not possible.
15/// </remarks>
16public partial class ChildBand : BandBase
17{
18private bool fillUnusedSpace;
19private int completeToNRows;
20private bool printIfDatabandEmpty;
21
22/// <summary>
23/// Gets or sets a value indicating that band will be used to fill unused space on a page.
24/// </summary>
25/// <remarks>
26/// If you set this property to <b>true</b>, the band will be printed several times to fill
27/// unused space on a report page.
28/// </remarks>
29[Category("Behavior")]
30[DefaultValue(false)]
31public bool FillUnusedSpace
32{
33get { return fillUnusedSpace; }
34set { fillUnusedSpace = value; }
35}
36
37/// <summary>
38/// Gets or sets a value that determines the overall number of data rows printed by the data band.
39/// </summary>
40/// <remarks>
41/// Using this property, you may complete the data band upto N data rows.
42/// If the data band has less number of rows, this band will be used to print empty rows.
43/// </remarks>
44[Category("Behavior")]
45[DefaultValue(0)]
46public int CompleteToNRows
47{
48get { return completeToNRows; }
49set { completeToNRows = value; }
50}
51
52/// <summary>
53/// Gets or sets a value indicating that the band will be printed if its parent databand is empty.
54/// </summary>
55/// <remarks>
56/// The child band with this property set to true, connected to a databand can be used to print "No data"
57/// text if the databand has no rows.
58/// </remarks>
59[Category("Behavior")]
60[DefaultValue(false)]
61public bool PrintIfDatabandEmpty
62{
63get { return printIfDatabandEmpty; }
64set { printIfDatabandEmpty = value; }
65}
66
67internal BandBase GetTopParentBand
68{
69get
70{
71BandBase band = this;
72while (band is ChildBand)
73{
74band = band.Parent as BandBase;
75}
76
77return band;
78}
79}
80
81/// <inheritdoc/>
82public override void Assign(Base source)
83{
84base.Assign(source);
85ChildBand src = source as ChildBand;
86FillUnusedSpace = src.FillUnusedSpace;
87CompleteToNRows = src.CompleteToNRows;
88PrintIfDatabandEmpty = src.PrintIfDatabandEmpty;
89}
90
91/// <inheritdoc/>
92public override void Serialize(FRWriter writer)
93{
94ChildBand c = writer.DiffObject as ChildBand;
95base.Serialize(writer);
96
97if (FillUnusedSpace != c.FillUnusedSpace)
98writer.WriteBool("FillUnusedSpace", FillUnusedSpace);
99if (CompleteToNRows != c.CompleteToNRows)
100writer.WriteInt("CompleteToNRows", CompleteToNRows);
101if (PrintIfDatabandEmpty != c.PrintIfDatabandEmpty)
102writer.WriteBool("PrintIfDatabandEmpty", PrintIfDatabandEmpty);
103}
104}
105}