CrossViewDescriptor.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using FastReport.Table;
  5. using FastReport.Utils;
  6. namespace FastReport.CrossView
  7. {
  8. /// <summary>
  9. /// The base class for matrix element descriptors such as <see cref="CrossViewHeaderDescriptor"/> and
  10. /// <see cref="CrossViewCellDescriptor"/>.
  11. /// </summary>
  12. public class CrossViewDescriptor : IFRSerializable
  13. {
  14. #region Fields
  15. private string expression;
  16. private TableColumn templateColumn;
  17. private TableRow templateRow;
  18. private TableCell templateCell;
  19. #endregion
  20. #region Properties
  21. /// <summary>
  22. /// Gets or sets an expression which value will be used to fill the matrix.
  23. /// </summary>
  24. /// <remarks>
  25. /// <b>Expression</b> may be any valid expression. Usually it's a data column:
  26. /// <c>[DataSource.Column]</c>.
  27. /// </remarks>
  28. public string Expression
  29. {
  30. get { return expression; }
  31. set { expression = value; }
  32. }
  33. /// <summary>
  34. /// Gets or sets the template column bound to this descriptor.
  35. /// </summary>
  36. /// <remarks>
  37. /// This property is for internal use; usually you don't need to use it.
  38. /// </remarks>
  39. public TableColumn TemplateColumn
  40. {
  41. get { return templateColumn; }
  42. set { templateColumn = value; }
  43. }
  44. /// <summary>
  45. /// Gets or sets the template row bound to this descriptor.
  46. /// </summary>
  47. /// <remarks>
  48. /// This property is for internal use; usually you don't need to use it.
  49. /// </remarks>
  50. public TableRow TemplateRow
  51. {
  52. get { return templateRow; }
  53. set { templateRow = value; }
  54. }
  55. /// <summary>
  56. /// Gets or sets the template cell bound to this descriptor.
  57. /// </summary>
  58. /// <remarks>
  59. /// Using this property, you may access the matrix cell which is bound to
  60. /// this descriptor. It may be useful to change the cell's appearance.
  61. /// <note>
  62. /// Before using this property, you must initialize the matrix descriptors by
  63. /// calling the <see cref="CrossViewObject.BuildTemplate"/> method.
  64. /// </note>
  65. /// </remarks>
  66. /// <example>
  67. /// <code>
  68. /// CrossViewObject crossView;
  69. /// // change the fill color of the first matrix cell
  70. /// crossView.Data.Cells[0].TemplateCell.Fill = new SolidFill(Color.Red);
  71. /// </code>
  72. /// </example>
  73. public TableCell TemplateCell
  74. {
  75. get { return templateCell; }
  76. set { templateCell = value; }
  77. }
  78. #endregion
  79. #region Public Methods
  80. /// <summary>
  81. /// Assigns values from another descriptor.
  82. /// </summary>
  83. /// <param name="source">Descriptor to assign values from.</param>
  84. public virtual void Assign(CrossViewDescriptor source)
  85. {
  86. Expression = source.Expression;
  87. TemplateCell = source.TemplateCell;
  88. }
  89. /// <inheritdoc/>
  90. public virtual void Serialize(FRWriter writer)
  91. {
  92. CrossViewDescriptor c = writer.DiffObject as CrossViewDescriptor;
  93. if (Expression != c.Expression)
  94. writer.WriteStr("Expression", Expression);
  95. }
  96. /// <inheritdoc/>
  97. public void Deserialize(FRReader reader)
  98. {
  99. reader.ReadProperties(this);
  100. }
  101. #endregion
  102. }
  103. }