Repository navigation
Expand file tree
/
Copy pathReportEngine.ProcessAt.cs
More file actions
232 lines (186 loc) · 6.52 KB
/
Copy pathReportEngine.ProcessAt.cs
File metadata and controls
232 lines (186 loc) · 6.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
using FastReport.Utils;
using System.Collections.Generic;
namespace FastReport.Engine
{
internal enum EngineState
{
ReportStarted,
ReportFinished,
ReportPageStarted,
ReportPageFinished,
PageStarted,
PageFinished,
ColumnStarted,
ColumnFinished,
BlockStarted,
BlockFinished,
GroupStarted,
GroupFinished
}
internal class EngineStateChangedEventArgs
{
#region Fields
private ReportEngine engine;
private EngineState state;
#endregion Fields
#region Properties
public ReportEngine Engine
{
get { return engine; }
}
public EngineState State
{
get { return state; }
}
#endregion Properties
#region Constructors
internal EngineStateChangedEventArgs(ReportEngine engine, EngineState state)
{
this.engine = engine;
this.state = state;
}
#endregion Constructors
}
internal delegate void EngineStateChangedEventHandler(object sender, EngineStateChangedEventArgs e);
internal class ProcessInfo
{
#region Fields
private TextObject textObject;
private XmlItem xmlItem;
#endregion Fields
#region Properties
public TextObjectBase TextObject
{
get { return textObject; }
}
#endregion Properties
#region Constructors
public ProcessInfo(TextObject obj, XmlItem item)
{
textObject = obj;
xmlItem = item;
}
#endregion Constructors
#region Public Methods
public void Process()
{
textObject.SaveState();
try
{
textObject.GetData();
string fill_clr = textObject.FillColor.IsNamedColor ? textObject.FillColor.Name :
"#" + textObject.FillColor.Name;
string txt_clr = textObject.TextColor.IsNamedColor ? textObject.TextColor.Name :
"#" + textObject.TextColor.Name;
xmlItem.SetProp("x", textObject.Text);
xmlItem.SetProp("Fill.Color", fill_clr);
xmlItem.SetProp("TextFill.Color", txt_clr);
xmlItem.SetProp("Font.Name", textObject.Font.Name);
}
finally
{
textObject.RestoreState();
}
}
public bool Process(object sender, EngineState state)
{
ProcessAt processAt = textObject.ProcessAt;
bool canProcess = false;
if ((processAt == ProcessAt.DataFinished && state == EngineState.BlockFinished) ||
(processAt == ProcessAt.GroupFinished && state == EngineState.GroupFinished))
{
// check which data is finished
BandBase topParentBand = textObject.Band;
if (topParentBand is ChildBand)
topParentBand = (topParentBand as ChildBand).GetTopParentBand;
if (processAt == ProcessAt.DataFinished && state == EngineState.BlockFinished)
{
// total can be printed on the same data header, or on its parent data band
DataBand senderBand = sender as DataBand;
canProcess = true;
if (topParentBand is DataHeaderBand && (topParentBand.Parent != sender))
canProcess = false;
if (topParentBand is DataBand && senderBand.Parent != topParentBand)
canProcess = false;
}
else
{
// total can be printed on the same group header
canProcess = sender == topParentBand;
}
}
else
{
canProcess = (processAt == ProcessAt.ReportFinished && state == EngineState.ReportFinished) ||
(processAt == ProcessAt.ReportPageFinished && state == EngineState.ReportPageFinished) ||
(processAt == ProcessAt.PageFinished && state == EngineState.PageFinished) ||
(processAt == ProcessAt.ColumnFinished && state == EngineState.ColumnFinished);
}
if (canProcess)
{
Process();
return true;
}
else
return false;
}
#endregion Public Methods
}
public partial class ReportEngine
{
#region Fields
private List<ProcessInfo> objectsToProcess;
#endregion Fields
#region Events
internal event EngineStateChangedEventHandler StateChanged;
#endregion Events
#region Private Methods
private void ProcessObjects(object sender, EngineState state)
{
for (int i = 0; i < objectsToProcess.Count; i++)
{
ProcessInfo info = objectsToProcess[i];
if (info.Process(sender, state))
{
objectsToProcess.RemoveAt(i);
i--;
}
}
}
private void OnStateChanged(object sender, EngineState state)
{
ProcessObjects(sender, state);
if (StateChanged != null)
StateChanged(sender, new EngineStateChangedEventArgs(this, state));
}
#endregion Private Methods
#region Internal Methods
internal void AddObjectToProcess(Base obj, XmlItem item)
{
TextObject textObj = obj as TextObject;
if (textObj == null || textObj.ProcessAt == ProcessAt.Default)
return;
objectsToProcess.Add(new ProcessInfo(textObj, item));
}
#endregion Internal Methods
#region Public Methods
/// <summary>
/// Processes the specified text object which <b>ProcessAt</b> property is set to <b>Custom</b>.
/// </summary>
/// <param name="obj">The text object to process.</param>
public void ProcessObject(TextObjectBase obj)
{
for (int i = 0; i < objectsToProcess.Count; i++)
{
ProcessInfo info = objectsToProcess[i];
if (info.TextObject == obj)
{
info.Process();
objectsToProcess.RemoveAt(i);
break;
}
}
}
#endregion Public Methods
}
}