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