ChildBand.cs 3.1 KB

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