1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
5
using System.ComponentModel;
8
using System.Xml.Serialization;
10
using ICSharpCode.Reports.Core.Interfaces;
13
/// This Class is the BaseClass for <see cref="ReportSection"></see>
17
namespace ICSharpCode.Reports.Core
19
public class BaseSection : BaseReportItem,ISimpleContainer
22
private ReportItemCollection items;
24
public event EventHandler<SectionEventArgs> SectionPrinting;
25
public event EventHandler<SectionEventArgs> SectionPrinted;
30
public BaseSection(): base()
32
base.Name = String.Empty;
35
public BaseSection (string sectionName) :base()
37
base.Name = sectionName;
44
public override void Render(ReportPageEventArgs rpea)
46
this.NotifyPrinting();
52
protected override Rectangle DisplayRectangle {
54
return new Rectangle(Location.X , this.Location.Y ,
55
this.Size.Width,this.Size.Height);
60
private void NotifyPrinting ()
62
if (this.SectionPrinting != null) {
63
SectionEventArgs ea = new SectionEventArgs (this);
64
SectionPrinting (this,ea);
69
private void NotifyPrinted ()
71
if (this.SectionPrinted != null) {
72
SectionEventArgs ea = new SectionEventArgs (this);
73
SectionPrinted (this,ea);
81
private BaseReportItem FindRec (ReportItemCollection items, string name)
83
foreach(BaseReportItem item in items)
85
ISimpleContainer cont = item as ISimpleContainer;
87
return FindRec(cont.Items,name);
89
var query = from bt in items where bt.Name == name select bt;
90
if (query.Count() >0) {
91
return query.FirstOrDefault();
100
public BaseReportItem FindItem (string itemName)
102
foreach (BaseReportItem item in items)
104
ISimpleContainer cont = item as ISimpleContainer;
106
return FindRec (cont.Items,itemName);
108
return FindRec(this.items,itemName);
118
public int SectionMargin {get;set;}
120
// public virtual int SectionOffset {get;set;}
123
public ReportItemCollection Items
126
if (this.items == null) {
127
items = new ReportItemCollection();
134
public virtual bool PageBreakAfter {get;set;}
139
public Size MeasureOverride (Size availableSize)
141
Size resultSize = new Size(0,0);
142
// Console.WriteLine("MeasureOverride");
143
foreach (var item in Items) {
144
// Console.WriteLine("{0} - {1}",item.Location,item.Size);
145
resultSize.Width = Math.Max(resultSize.Width, item.Size.Width);
146
resultSize.Height = Math.Max(resultSize.Height, item.Size.Height);
149
// resultSize.Width = double.IsPositiveInfinity(availableSize.Width) ?
150
// resultSize.Width : availableSize.Width;
152
// resultSize.Height = double.IsPositiveInfinity(availableSize.Height) ?
153
// resultSize.Height : availableSize.Height;
155
resultSize.Width = double.IsPositiveInfinity(availableSize.Width) ?
156
resultSize.Width : availableSize.Width;
157
var b = double.IsPositiveInfinity(availableSize.Height);
158
resultSize.Height = double.IsPositiveInfinity(availableSize.Height) ?
159
resultSize.Height : availableSize.Height;
164
#region System.IDisposable interface implementation
166
protected override void Dispose(bool disposing)
170
if (this.items != null) {
176
base.Dispose(disposing);