FastReport

Форк
0
/
CrossViewCellDescriptor.cs 
210 строк · 6.8 Кб
1
using System;
2
using System.Collections.Generic;
3
using System.Text;
4
using FastReport.Table;
5
using FastReport.Utils;
6

7
namespace 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>
20
    public class CrossViewCellDescriptor : CrossViewDescriptor
21
    {
22
        #region Fields
23
        internal string xFieldName;
24
        internal string yFieldName;
25
        internal string measureName;
26
        internal bool isXGrandTotal;
27
        internal bool isYGrandTotal;
28
        internal bool isXTotal;
29
        internal bool isYTotal;
30
#pragma warning disable FR0001 // Field names must be longer than 2 characters.
31
        internal int x;
32
        internal 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>
40
        public bool IsXGrandTotal
41
        {
42
            set { isXGrandTotal = value; }
43
            get { return isXGrandTotal; }
44
        }
45

46
        /// <summary>
47
        /// Gets a value indicating that this is the "GrandTotal" element on Y axis.
48
        /// </summary>
49
        public bool IsYGrandTotal
50
        {
51
            set { isYGrandTotal = value; }
52
            get { return isYGrandTotal; }
53
        }
54

55
        /// <summary>
56
        /// Gets a value indicating that this is the "Total" element on X axis.
57
        /// </summary>
58
        public bool IsXTotal
59
        {
60
            set { isXTotal = value; }
61
            get { return isXTotal; }
62
        }
63

64
        /// <summary>
65
        /// Gets a value indicating that this is the "Total" element on Y axis.
66
        /// </summary>
67
        public bool IsYTotal
68
        {
69
            set { isYTotal = value; }
70
            get { return isYTotal; }
71
        }
72

73
        /// <summary>
74
        /// Gets the name of field in X axis.
75
        /// </summary>
76
        public string XFieldName
77
        {
78
            set { xFieldName = value; }
79
            get { return xFieldName; }
80
        }
81

82
        /// <summary>
83
        /// Gets the name of field in Y axis.
84
        /// </summary>
85
        public string YFieldName
86
        {
87
            set { yFieldName = value; }
88
            get { return yFieldName; }
89
        }
90

91
        /// <summary>
92
        /// Gets the name of measure in cube.
93
        /// </summary>
94
        public string MeasureName
95
        {
96
            set { measureName = value; }
97
            get { return measureName; }
98
        }
99

100
        /// <summary>
101
        /// Gets the x coordinate.
102
        /// </summary>
103
        public int X
104
        {
105
            set { x = value; }
106
            get { return x; }
107
        }
108

109
        /// <summary>
110
        /// Gets the y coordinate.
111
        /// </summary>
112
        public int Y
113
        {
114
            set { y = value; }
115
            get { return y; }
116
        }
117
        #endregion
118

119
        #region Public Methods
120
        /// <inheritdoc/>
121
        public override void Assign(CrossViewDescriptor source)
122
        {
123
            base.Assign(source);
124
            CrossViewCellDescriptor src = source as CrossViewCellDescriptor;
125
            if (src != null)
126
            {
127
                isXTotal = src.isXTotal;
128
                isYTotal = src.isYTotal;
129
                isXGrandTotal = src.isXGrandTotal;
130
                isYGrandTotal = src.isYGrandTotal;
131
                xFieldName = src.xFieldName;
132
                yFieldName = src.yFieldName;
133
                measureName = src.measureName;
134
                x = src.x;
135
                y = src.y;
136
            }
137
        }
138

139
        /// <inheritdoc/>
140
        public override void Serialize(FRWriter writer)
141
        {
142
            CrossViewCellDescriptor c = writer.DiffObject as CrossViewCellDescriptor;
143
            base.Serialize(writer);
144
            writer.ItemName = "Cell";
145
            if (IsXTotal != c.IsXTotal)
146
                writer.WriteBool("IsXTotal", IsXTotal);
147
            if (IsYTotal != c.IsYTotal)
148
                writer.WriteBool("IsYTotal", IsYTotal);
149
            if (IsXGrandTotal != c.IsXGrandTotal)
150
                writer.WriteBool("IsXGrandTotal", IsXGrandTotal);
151
            if (IsYGrandTotal != c.IsYGrandTotal)
152
                writer.WriteBool("IsYGrandTotal", IsYGrandTotal);
153
            if (XFieldName != c.XFieldName)
154
                writer.WriteStr("XFieldName", XFieldName);
155
            if (YFieldName != c.YFieldName)
156
                writer.WriteStr("YFieldName", YFieldName);
157
            if (MeasureName != c.MeasureName)
158
                writer.WriteStr("MeasureName", MeasureName);
159
            if (X != c.X)
160
                writer.WriteInt("X", X);
161
            if (Y != c.Y)
162
                writer.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>
176
        public CrossViewCellDescriptor(string xFieldName, string yFieldName, string measureName, bool isXTotal, bool isYTotal, bool isXGrandTotal, bool isYGrandTotal)
177
        {
178
            this.isXGrandTotal = isXGrandTotal;
179
            this.isYGrandTotal = isYGrandTotal;
180
            this.measureName = measureName;
181
            if (isXGrandTotal)
182
            {
183
                this.xFieldName = "";
184
                this.isXTotal = false;
185
            }
186
            else
187
            {
188
                this.xFieldName = xFieldName;
189
                this.isXTotal = isXTotal;
190
            }
191
            if (isYGrandTotal)
192
            {
193
                this.yFieldName = "";
194
                this.isYTotal = false;
195
            }
196
            else
197
            {
198
                this.yFieldName = yFieldName;
199
                this.isYTotal = isYTotal;
200
            }
201
        }
202
        /// <summary>
203
        /// Initializes a new instance of the <see cref="CrossViewCellDescriptor"/> class
204
        /// </summary>
205
        public CrossViewCellDescriptor()
206
            : this("", "", "", false, false, false, false)
207
        {
208
        }
209
    }
210
}
211

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.