-
Notifications
You must be signed in to change notification settings - Fork 201
/
Copy pathTableCtl.cs
441 lines (405 loc) · 15.3 KB
/
TableCtl.cs
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
/* ====================================================================
Copyright (C) 2004-2008 fyiReporting Software, LLC
Copyright (C) 2011 Peter Gill <peter@majorsilence.com>
This file is part of the fyiReporting RDL project.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
For additional information, email info@fyireporting.com or visit
the website www.fyiReporting.com.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Xml;
using fyiReporting.RdlDesign.Resources;
namespace fyiReporting.RdlDesign
{
/// <summary>
/// Summary description for ReportCtl.
/// </summary>
internal class TableCtl : System.Windows.Forms.UserControl, IProperty
{
private List<XmlNode> _ReportItems;
private DesignXmlDraw _Draw;
bool fDataSet, fPBBefore, fPBAfter, fNoRows;
bool fDetailElementName, fDetailCollectionName, fRenderDetails;
bool fCheckRows;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.ComboBox cbDataSet;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.CheckBox chkPBBefore;
private System.Windows.Forms.CheckBox chkPBAfter;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox tbNoRows;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.CheckBox chkRenderDetails;
private System.Windows.Forms.TextBox tbDetailElementName;
private System.Windows.Forms.TextBox tbDetailCollectionName;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.CheckBox chkDetails;
private System.Windows.Forms.CheckBox chkHeaderRows;
private System.Windows.Forms.CheckBox chkFooterRows;
private CheckBox chkFooterRepeat;
private CheckBox chkHeaderRepeat;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
internal TableCtl(DesignXmlDraw dxDraw, List<XmlNode> ris)
{
_ReportItems = ris;
_Draw = dxDraw;
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
// Initialize form using the style node values
InitValues();
}
private void InitValues()
{
XmlNode riNode = _ReportItems[0];
tbNoRows.Text = _Draw.GetElementValue(riNode, "NoRows", "");
cbDataSet.Items.AddRange(_Draw.DataSetNames);
cbDataSet.Text = _Draw.GetDataSetNameValue(riNode);
if (_Draw.GetReportItemDataRegionContainer(riNode) != null)
cbDataSet.Enabled = false;
chkPBBefore.Checked = _Draw.GetElementValue(riNode, "PageBreakAtStart", "false").ToLower()=="true"? true:false;
chkPBAfter.Checked = _Draw.GetElementValue(riNode, "PageBreakAtEnd", "false").ToLower()=="true"? true:false;
this.chkRenderDetails.Checked = _Draw.GetElementValue(riNode, "DetailDataElementOutput", "output").ToLower() == "output";
this.tbDetailElementName.Text = _Draw.GetElementValue(riNode, "DetailDataElementName", "Details");
this.tbDetailCollectionName.Text = _Draw.GetElementValue(riNode, "DetailDataCollectionName", "Details_Collection");
this.chkDetails.Checked = _Draw.GetNamedChildNode(riNode, "Details") != null;
XmlNode fNode = _Draw.GetNamedChildNode(riNode, "Footer");
this.chkFooterRows.Checked = fNode != null;
if (fNode != null)
{
chkFooterRepeat.Checked = _Draw.GetElementValue(fNode, "RepeatOnNewPage", "false").ToLower() == "true" ? true : false;
}
else
chkFooterRepeat.Enabled = false;
XmlNode hNode = _Draw.GetNamedChildNode(riNode, "Header");
this.chkHeaderRows.Checked = hNode != null;
if (hNode != null)
{
chkHeaderRepeat.Checked = _Draw.GetElementValue(hNode, "RepeatOnNewPage", "false").ToLower() == "true" ? true : false;
}
else
chkHeaderRepeat.Enabled = false;
fNoRows = fDataSet = fPBBefore = fPBAfter =
fDetailElementName = fDetailCollectionName = fRenderDetails =
fCheckRows = false;
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TableCtl));
this.label2 = new System.Windows.Forms.Label();
this.cbDataSet = new System.Windows.Forms.ComboBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.chkPBAfter = new System.Windows.Forms.CheckBox();
this.chkPBBefore = new System.Windows.Forms.CheckBox();
this.label1 = new System.Windows.Forms.Label();
this.tbNoRows = new System.Windows.Forms.TextBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.tbDetailCollectionName = new System.Windows.Forms.TextBox();
this.tbDetailElementName = new System.Windows.Forms.TextBox();
this.chkRenderDetails = new System.Windows.Forms.CheckBox();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.chkFooterRepeat = new System.Windows.Forms.CheckBox();
this.chkHeaderRepeat = new System.Windows.Forms.CheckBox();
this.chkFooterRows = new System.Windows.Forms.CheckBox();
this.chkHeaderRows = new System.Windows.Forms.CheckBox();
this.chkDetails = new System.Windows.Forms.CheckBox();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.SuspendLayout();
//
// label2
//
resources.ApplyResources(this.label2, "label2");
this.label2.Name = "label2";
//
// cbDataSet
//
resources.ApplyResources(this.cbDataSet, "cbDataSet");
this.cbDataSet.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbDataSet.Name = "cbDataSet";
this.cbDataSet.SelectedIndexChanged += new System.EventHandler(this.cbDataSet_SelectedIndexChanged);
//
// groupBox1
//
resources.ApplyResources(this.groupBox1, "groupBox1");
this.groupBox1.Controls.Add(this.chkPBAfter);
this.groupBox1.Controls.Add(this.chkPBBefore);
this.groupBox1.Name = "groupBox1";
this.groupBox1.TabStop = false;
//
// chkPBAfter
//
resources.ApplyResources(this.chkPBAfter, "chkPBAfter");
this.chkPBAfter.Name = "chkPBAfter";
this.chkPBAfter.CheckedChanged += new System.EventHandler(this.chkPBAfter_CheckedChanged);
//
// chkPBBefore
//
resources.ApplyResources(this.chkPBBefore, "chkPBBefore");
this.chkPBBefore.Name = "chkPBBefore";
this.chkPBBefore.CheckedChanged += new System.EventHandler(this.chkPBBefore_CheckedChanged);
//
// label1
//
resources.ApplyResources(this.label1, "label1");
this.label1.Name = "label1";
//
// tbNoRows
//
resources.ApplyResources(this.tbNoRows, "tbNoRows");
this.tbNoRows.Name = "tbNoRows";
this.tbNoRows.TextChanged += new System.EventHandler(this.tbNoRows_TextChanged);
//
// groupBox2
//
resources.ApplyResources(this.groupBox2, "groupBox2");
this.groupBox2.Controls.Add(this.tbDetailCollectionName);
this.groupBox2.Controls.Add(this.tbDetailElementName);
this.groupBox2.Controls.Add(this.chkRenderDetails);
this.groupBox2.Controls.Add(this.label4);
this.groupBox2.Controls.Add(this.label3);
this.groupBox2.Name = "groupBox2";
this.groupBox2.TabStop = false;
//
// tbDetailCollectionName
//
resources.ApplyResources(this.tbDetailCollectionName, "tbDetailCollectionName");
this.tbDetailCollectionName.Name = "tbDetailCollectionName";
this.tbDetailCollectionName.TextChanged += new System.EventHandler(this.tbDetailCollectionName_TextChanged);
//
// tbDetailElementName
//
resources.ApplyResources(this.tbDetailElementName, "tbDetailElementName");
this.tbDetailElementName.Name = "tbDetailElementName";
this.tbDetailElementName.TextChanged += new System.EventHandler(this.tbDetailElementName_TextChanged);
//
// chkRenderDetails
//
resources.ApplyResources(this.chkRenderDetails, "chkRenderDetails");
this.chkRenderDetails.Name = "chkRenderDetails";
this.chkRenderDetails.CheckedChanged += new System.EventHandler(this.chkRenderDetails_CheckedChanged);
//
// label4
//
resources.ApplyResources(this.label4, "label4");
this.label4.Name = "label4";
//
// label3
//
resources.ApplyResources(this.label3, "label3");
this.label3.Name = "label3";
//
// groupBox3
//
resources.ApplyResources(this.groupBox3, "groupBox3");
this.groupBox3.Controls.Add(this.chkFooterRepeat);
this.groupBox3.Controls.Add(this.chkHeaderRepeat);
this.groupBox3.Controls.Add(this.chkFooterRows);
this.groupBox3.Controls.Add(this.chkHeaderRows);
this.groupBox3.Controls.Add(this.chkDetails);
this.groupBox3.Name = "groupBox3";
this.groupBox3.TabStop = false;
//
// chkFooterRepeat
//
resources.ApplyResources(this.chkFooterRepeat, "chkFooterRepeat");
this.chkFooterRepeat.Name = "chkFooterRepeat";
this.chkFooterRepeat.CheckedChanged += new System.EventHandler(this.chkRows_CheckedChanged);
//
// chkHeaderRepeat
//
resources.ApplyResources(this.chkHeaderRepeat, "chkHeaderRepeat");
this.chkHeaderRepeat.Name = "chkHeaderRepeat";
this.chkHeaderRepeat.CheckedChanged += new System.EventHandler(this.chkRows_CheckedChanged);
//
// chkFooterRows
//
resources.ApplyResources(this.chkFooterRows, "chkFooterRows");
this.chkFooterRows.Name = "chkFooterRows";
this.chkFooterRows.CheckedChanged += new System.EventHandler(this.chkRows_CheckedChanged);
//
// chkHeaderRows
//
resources.ApplyResources(this.chkHeaderRows, "chkHeaderRows");
this.chkHeaderRows.Name = "chkHeaderRows";
this.chkHeaderRows.CheckedChanged += new System.EventHandler(this.chkRows_CheckedChanged);
//
// chkDetails
//
resources.ApplyResources(this.chkDetails, "chkDetails");
this.chkDetails.Name = "chkDetails";
this.chkDetails.CheckedChanged += new System.EventHandler(this.chkRows_CheckedChanged);
//
// TableCtl
//
resources.ApplyResources(this, "$this");
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.tbNoRows);
this.Controls.Add(this.label1);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.cbDataSet);
this.Controls.Add(this.label2);
this.Name = "TableCtl";
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox3.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
public bool IsValid()
{
if (chkDetails.Checked || chkFooterRows.Checked || chkHeaderRows.Checked)
return true;
MessageBox.Show(Strings.TableCtl_Show_TableMustHaveRegions, Strings.TableCtl_Show_Table);
return false;
}
public void Apply()
{
// take information in control and apply to all the style nodes
// Only change information that has been marked as modified;
// this way when group is selected it is possible to change just
// the items you want and keep the rest the same.
foreach (XmlNode riNode in this._ReportItems)
ApplyChanges(riNode);
// No more changes
fNoRows = fDataSet = fPBBefore = fPBAfter =
fDetailElementName = fDetailCollectionName = fRenderDetails =
fCheckRows = false;
}
public void ApplyChanges(XmlNode node)
{
if (fNoRows)
_Draw.SetElement(node, "NoRows", this.tbNoRows.Text);
if (fDataSet)
_Draw.SetElement(node, "DataSetName", this.cbDataSet.Text);
if (fPBBefore)
_Draw.SetElement(node, "PageBreakAtStart", this.chkPBBefore.Checked? "true":"false");
if (fPBAfter)
_Draw.SetElement(node, "PageBreakAtEnd", this.chkPBAfter.Checked? "true":"false");
if (fCheckRows)
{
if (this.chkDetails.Checked)
CreateTableRow(node, "Details", false);
else
_Draw.RemoveElement(node, "Details");
if (this.chkHeaderRows.Checked)
CreateTableRow(node, "Header", chkHeaderRepeat.Checked);
else
_Draw.RemoveElement(node, "Header");
if (this.chkFooterRows.Checked)
CreateTableRow(node, "Footer", chkFooterRepeat.Checked);
else
_Draw.RemoveElement(node, "Footer");
}
if (fRenderDetails)
_Draw.SetElement(node, "DetailDataElementOutput", this.chkRenderDetails.Checked? "Output":"NoOutput");
if (this.fDetailElementName)
{
if (this.tbDetailElementName.Text.Length > 0)
_Draw.SetElement(node, "DetailDataElementName", this.tbDetailElementName.Text);
else
_Draw.RemoveElement(node, "DetailDataElementName");
}
if (this.fDetailCollectionName)
{
if (this.tbDetailCollectionName.Text.Length > 0)
_Draw.SetElement(node, "DetailDataCollectionName", this.tbDetailCollectionName.Text);
else
_Draw.RemoveElement(node, "DetailDataCollectionName");
}
}
private void CreateTableRow(XmlNode tblNode, string elementName, bool bRepeatOnNewPage)
{
XmlNode node = _Draw.GetNamedChildNode(tblNode, elementName);
if (node == null)
{
node = _Draw.CreateElement(tblNode, elementName, null);
XmlNode tblRows = _Draw.CreateElement(node, "TableRows", null);
_Draw.InsertTableRow(tblRows);
}
if (bRepeatOnNewPage)
_Draw.SetElement(node, "RepeatOnNewPage", "true");
else
_Draw.RemoveElement(node, "RepeatOnNewPage");
return;
}
private void cbDataSet_SelectedIndexChanged(object sender, System.EventArgs e)
{
fDataSet = true;
}
private void chkPBBefore_CheckedChanged(object sender, System.EventArgs e)
{
fPBBefore = true;
}
private void chkPBAfter_CheckedChanged(object sender, System.EventArgs e)
{
fPBAfter = true;
}
private void tbNoRows_TextChanged(object sender, System.EventArgs e)
{
fNoRows = true;
}
private void chkRows_CheckedChanged(object sender, System.EventArgs e)
{
this.fCheckRows = true;
chkFooterRepeat.Enabled = chkFooterRows.Checked;
chkHeaderRepeat.Enabled = chkHeaderRows.Checked;
}
private void chkRenderDetails_CheckedChanged(object sender, System.EventArgs e)
{
fRenderDetails = true;
}
private void tbDetailElementName_TextChanged(object sender, System.EventArgs e)
{
fDetailElementName = true;
}
private void tbDetailCollectionName_TextChanged(object sender, System.EventArgs e)
{
fDetailCollectionName = true;
}
}
}