FastReport
210 строк · 6.8 Кб
1using System;
2using System.Collections.Generic;
3using System.Text;
4using FastReport.Table;
5using FastReport.Utils;
6
7namespace FastReport.CrossView
8{
9
10/// <summary>
11/// The descriptor that is used to describe one CrossView data cell.
12/// </summary>
13/// <remarks>
14/// The <see cref="CrossViewCellDescriptor"/> class is used to define one data cell of the CrossView.
15/// To set visual appearance of the data cell, use the <see cref="CrossViewDescriptor.TemplateCell"/>
16/// property.
17/// <para/>The collection of descriptors used to represent the CrossView data cells is stored
18/// in the <b>CrossViewObject.Data.Cells</b> property.
19/// </remarks>
20public class CrossViewCellDescriptor : CrossViewDescriptor
21{
22#region Fields
23internal string xFieldName;
24internal string yFieldName;
25internal string measureName;
26internal bool isXGrandTotal;
27internal bool isYGrandTotal;
28internal bool isXTotal;
29internal bool isYTotal;
30#pragma warning disable FR0001 // Field names must be longer than 2 characters.
31internal int x;
32internal int y;
33#pragma warning restore FR0001 // Field names must be longer than 2 characters.
34#endregion
35
36#region Properties
37/// <summary>
38/// Gets a value indicating that this is the "GrandTotal" element on X axis.
39/// </summary>
40public bool IsXGrandTotal
41{
42set { isXGrandTotal = value; }
43get { return isXGrandTotal; }
44}
45
46/// <summary>
47/// Gets a value indicating that this is the "GrandTotal" element on Y axis.
48/// </summary>
49public bool IsYGrandTotal
50{
51set { isYGrandTotal = value; }
52get { return isYGrandTotal; }
53}
54
55/// <summary>
56/// Gets a value indicating that this is the "Total" element on X axis.
57/// </summary>
58public bool IsXTotal
59{
60set { isXTotal = value; }
61get { return isXTotal; }
62}
63
64/// <summary>
65/// Gets a value indicating that this is the "Total" element on Y axis.
66/// </summary>
67public bool IsYTotal
68{
69set { isYTotal = value; }
70get { return isYTotal; }
71}
72
73/// <summary>
74/// Gets the name of field in X axis.
75/// </summary>
76public string XFieldName
77{
78set { xFieldName = value; }
79get { return xFieldName; }
80}
81
82/// <summary>
83/// Gets the name of field in Y axis.
84/// </summary>
85public string YFieldName
86{
87set { yFieldName = value; }
88get { return yFieldName; }
89}
90
91/// <summary>
92/// Gets the name of measure in cube.
93/// </summary>
94public string MeasureName
95{
96set { measureName = value; }
97get { return measureName; }
98}
99
100/// <summary>
101/// Gets the x coordinate.
102/// </summary>
103public int X
104{
105set { x = value; }
106get { return x; }
107}
108
109/// <summary>
110/// Gets the y coordinate.
111/// </summary>
112public int Y
113{
114set { y = value; }
115get { return y; }
116}
117#endregion
118
119#region Public Methods
120/// <inheritdoc/>
121public override void Assign(CrossViewDescriptor source)
122{
123base.Assign(source);
124CrossViewCellDescriptor src = source as CrossViewCellDescriptor;
125if (src != null)
126{
127isXTotal = src.isXTotal;
128isYTotal = src.isYTotal;
129isXGrandTotal = src.isXGrandTotal;
130isYGrandTotal = src.isYGrandTotal;
131xFieldName = src.xFieldName;
132yFieldName = src.yFieldName;
133measureName = src.measureName;
134x = src.x;
135y = src.y;
136}
137}
138
139/// <inheritdoc/>
140public override void Serialize(FRWriter writer)
141{
142CrossViewCellDescriptor c = writer.DiffObject as CrossViewCellDescriptor;
143base.Serialize(writer);
144writer.ItemName = "Cell";
145if (IsXTotal != c.IsXTotal)
146writer.WriteBool("IsXTotal", IsXTotal);
147if (IsYTotal != c.IsYTotal)
148writer.WriteBool("IsYTotal", IsYTotal);
149if (IsXGrandTotal != c.IsXGrandTotal)
150writer.WriteBool("IsXGrandTotal", IsXGrandTotal);
151if (IsYGrandTotal != c.IsYGrandTotal)
152writer.WriteBool("IsYGrandTotal", IsYGrandTotal);
153if (XFieldName != c.XFieldName)
154writer.WriteStr("XFieldName", XFieldName);
155if (YFieldName != c.YFieldName)
156writer.WriteStr("YFieldName", YFieldName);
157if (MeasureName != c.MeasureName)
158writer.WriteStr("MeasureName", MeasureName);
159if (X != c.X)
160writer.WriteInt("X", X);
161if (Y != c.Y)
162writer.WriteInt("Y", Y);
163}
164#endregion
165
166/// <summary>
167/// Initializes a new instance of the <see cref="CrossViewCellDescriptor"/> class
168/// </summary>
169/// <param name="xFieldName">The Field Name in X axis.</param>
170/// <param name="yFieldName">The Field Name in Y axis.</param>
171/// <param name="measureName">The Measure Name.</param>
172/// <param name="isXTotal">Indicates the "XTotal" element.</param>
173/// <param name="isYTotal">Indicates the "YTotal" element.</param>
174/// <param name="isXGrandTotal">Indicates the "XGrandTotal" element.</param>
175/// <param name="isYGrandTotal">Indicates the "YGrandTotal" element.</param>
176public CrossViewCellDescriptor(string xFieldName, string yFieldName, string measureName, bool isXTotal, bool isYTotal, bool isXGrandTotal, bool isYGrandTotal)
177{
178this.isXGrandTotal = isXGrandTotal;
179this.isYGrandTotal = isYGrandTotal;
180this.measureName = measureName;
181if (isXGrandTotal)
182{
183this.xFieldName = "";
184this.isXTotal = false;
185}
186else
187{
188this.xFieldName = xFieldName;
189this.isXTotal = isXTotal;
190}
191if (isYGrandTotal)
192{
193this.yFieldName = "";
194this.isYTotal = false;
195}
196else
197{
198this.yFieldName = yFieldName;
199this.isYTotal = isYTotal;
200}
201}
202/// <summary>
203/// Initializes a new instance of the <see cref="CrossViewCellDescriptor"/> class
204/// </summary>
205public CrossViewCellDescriptor()
206: this("", "", "", false, false, false, false)
207{
208}
209}
210}
211