Browse Source

Unbound Reports, values of ReportItems can be changed at runtime

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1504 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Peter Forstmeier 19 years ago
parent
commit
5db171f825
  1. 4
      src/AddIns/Misc/SharpReport/SharpReport/SharpReportManager.cs
  2. 17
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseSection.cs
  3. 4
      src/AddIns/Misc/SharpReport/SharpReportCore/Events/PrintEventArgs.cs
  4. 2
      src/AddIns/Misc/SharpReport/SharpReportCore/Events/ReportPageEventArgs.cs
  5. 52
      src/AddIns/Misc/SharpReport/SharpReportCore/Events/SectionRenderEventArgs.cs
  6. 18
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractDataRenderer.cs
  7. 128
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractRenderer.cs
  8. 130
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs
  9. 80
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderFormSheetReport.cs
  10. 33
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/ReportDocument.cs
  11. 1
      src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj
  12. 33
      src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportEngine.cs

4
src/AddIns/Misc/SharpReport/SharpReport/SharpReportManager.cs

@ -196,6 +196,7 @@ namespace SharpReport{
try { try {
AbstractRenderer abstr = this.BuildStandartRenderer (model); AbstractRenderer abstr = this.BuildStandartRenderer (model);
if (abstr != null) { if (abstr != null) {
PreviewControl.ShowPreview (abstr,1.5,standAlone); PreviewControl.ShowPreview (abstr,1.5,standAlone);
} }
@ -205,6 +206,8 @@ namespace SharpReport{
} }
} }
private AbstractRenderer BuildStandartRenderer (ReportModel model) { private AbstractRenderer BuildStandartRenderer (ReportModel model) {
System.Console.WriteLine("Manager:BuildStandartRenderr"); System.Console.WriteLine("Manager:BuildStandartRenderr");
@ -242,7 +245,6 @@ namespace SharpReport{
try { try {
AbstractRenderer abstr = GetRendererForPushDataReports (model,dataSet); AbstractRenderer abstr = GetRendererForPushDataReports (model,dataSet);
if (abstr != null) { if (abstr != null) {
PreviewControl.ShowPreview (abstr,1.5,standAlone); PreviewControl.ShowPreview (abstr,1.5,standAlone);
} }

17
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseSection.cs

@ -26,14 +26,13 @@ namespace SharpReportCore {
private ReportItemCollection items; private ReportItemCollection items;
public event EventHandler<SectionPrintingEventArgs> SectionPrinting; public event EventHandler<SectionEventArgs> SectionPrinting;
public event EventHandler<SectionPrintingEventArgs> SectionPrinted; public event EventHandler<SectionEventArgs> SectionPrinted;
#region Constructors #region Constructors
public BaseSection(): base() { public BaseSection(): base() {
// this.Name = String.Empty;
base.Name = String.Empty; base.Name = String.Empty;
} }
@ -43,24 +42,24 @@ namespace SharpReportCore {
#endregion #endregion
#region Rendering
public override void Render(ReportPageEventArgs rpea){ public override void Render(ReportPageEventArgs rpea){
this.NotifyPrinting(); this.NotifyPrinting();
base.Render(rpea); base.Render(rpea);
this.NotifyPrinted(); this.NotifyPrinted();
} }
#region Events private void NotifyPrinting () {
public void NotifyPrinting () {
if (this.SectionPrinting != null) { if (this.SectionPrinting != null) {
SectionPrintingEventArgs ea = new SectionPrintingEventArgs (this); SectionEventArgs ea = new SectionEventArgs (this);
SectionPrinting (this,ea); SectionPrinting (this,ea);
} }
} }
public void NotifyPrinted () { private void NotifyPrinted () {
if (this.SectionPrinted != null) { if (this.SectionPrinted != null) {
SectionPrintingEventArgs ea = new SectionPrintingEventArgs (this); SectionEventArgs ea = new SectionEventArgs (this);
SectionPrinted (this,ea); SectionPrinted (this,ea);
} }
} }

4
src/AddIns/Misc/SharpReport/SharpReportCore/Events/PrintEventArgs.cs

@ -23,10 +23,10 @@ using System.Drawing;
namespace SharpReportCore { namespace SharpReportCore {
public class SectionPrintingEventArgs : System.EventArgs { public class SectionEventArgs : System.EventArgs {
BaseSection section; BaseSection section;
public SectionPrintingEventArgs(BaseSection section){ public SectionEventArgs(BaseSection section){
this.section = section; this.section = section;
} }

2
src/AddIns/Misc/SharpReport/SharpReportCore/Events/ReportPageEventArgs.cs

@ -50,6 +50,8 @@ namespace SharpReportCore {
return pageNumber; return pageNumber;
} }
} }
public PrintPageEventArgs PrintPageEventArgs { public PrintPageEventArgs PrintPageEventArgs {
get { get {
return printEventArgs; return printEventArgs;

52
src/AddIns/Misc/SharpReport/SharpReportCore/Events/SectionRenderEventArgs.cs

@ -0,0 +1,52 @@
/*
* Created by SharpDevelop.
* User: Forstmeier Helmut
* Date: 20.06.2006
* Time: 13:07
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
namespace SharpReportCore {
/// <summary>
/// Description of SectionRenderEventArgs.
/// </summary>
public class SectionRenderEventArgs:SectionEventArgs{
private int pageNumber;
private int rowNumber;
private GlobalEnums.enmSection currentSection;
public SectionRenderEventArgs(BaseSection section,
int pageNumber,int rowNumber,
GlobalEnums.enmSection currentSection):base(section){
this.pageNumber = pageNumber;
this.currentSection = currentSection;
this.rowNumber = rowNumber;
}
public int PageNumber {
get {
return pageNumber;
}
}
public int RowNumber {
get {
return rowNumber;
}
}
public SharpReportCore.GlobalEnums.enmSection CurrentSection {
get {
return currentSection;
}
}
}
}

18
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractDataRenderer.cs

@ -16,8 +16,7 @@ namespace SharpReportCore{
/// </summary> /// </summary>
public class AbstractDataRenderer : AbstractRenderer{ public class AbstractDataRenderer : AbstractRenderer{
DataManager dataManager; DataManager dataManager;
DataNavigator navigator; DataNavigator dataNavigator;
public AbstractDataRenderer(ReportModel model,DataManager dataManager):base(model){ public AbstractDataRenderer(ReportModel model,DataManager dataManager):base(model){
if (dataManager == null) { if (dataManager == null) {
@ -32,9 +31,11 @@ namespace SharpReportCore{
} }
protected override int RenderSection(BaseSection section, ReportPageEventArgs rpea){
protected override int RenderSection(ReportPageEventArgs rpea){
return 0; return 0;
} }
#endregion #endregion
protected int DoItems (ReportPageEventArgs rpea) { protected int DoItems (ReportPageEventArgs rpea) {
IContainerItem container = null; IContainerItem container = null;
@ -49,7 +50,7 @@ namespace SharpReportCore{
if (hasContainer) { if (hasContainer) {
return DoContainerControl(this.CurrentSection,container,rpea); return DoContainerControl(this.CurrentSection,container,rpea);
} else { } else {
return base.RenderSection(this.CurrentSection, rpea); return base.RenderSection(rpea);
} }
} }
@ -93,8 +94,8 @@ namespace SharpReportCore{
} }
protected DataNavigator DataNavigator{ protected DataNavigator DataNavigator{
get {return this.navigator;} get {return this.dataNavigator;}
set {this.navigator = value;} set {this.dataNavigator = value;}
} }
#endregion #endregion
@ -102,13 +103,12 @@ namespace SharpReportCore{
#region IDisposable #region IDisposable
public new void Dispose(){ public new void Dispose(){
try { try {
System.Console.WriteLine("Abstarct:Dispose");
if (this.dataManager != null) { if (this.dataManager != null) {
this.dataManager.Dispose(); this.dataManager.Dispose();
this.dataManager = null; this.dataManager = null;
} }
if (this.navigator != null) { if (this.dataNavigator != null) {
this.navigator= null; this.dataNavigator= null;
} }
} finally { } finally {
base.Dispose(); base.Dispose();

128
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractRenderer.cs

@ -40,6 +40,8 @@ namespace SharpReportCore {
private DefaultFormatter defaultFormatter; private DefaultFormatter defaultFormatter;
private bool cancel; private bool cancel;
public event EventHandler<SectionRenderEventArgs> SectionRendering;
public event EventHandler<SectionRenderEventArgs> SectionRendered;
protected AbstractRenderer(ReportModel model){ protected AbstractRenderer(ReportModel model){
if (model == null) { if (model == null) {
@ -57,36 +59,93 @@ namespace SharpReportCore {
void Init() { void Init() {
reportDocument = new SharpReportCore.ReportDocument(); reportDocument = new SharpReportCore.ReportDocument();
reportDocument.DocumentName = reportSettings.ReportName;
// Events from ReportDocument // Events from ReportDocument
reportDocument.QueryPageSettings += new QueryPageSettingsEventHandler (ReportQueryPage); reportDocument.QueryPageSettings += new QueryPageSettingsEventHandler (ReportQueryPage);
reportDocument.BeginPrint += new PrintEventHandler(ReportBegin); reportDocument.BeginPrint += new PrintEventHandler(ReportBegin);
reportDocument.EndPrint += new PrintEventHandler(ReportEnd); reportDocument.EndPrint += new PrintEventHandler(ReportEnd);
// homemade events // homemade events
reportDocument.PrintPageBodyStart += new EventHandler<ReportPageEventArgs> (PrintBodyStart); reportDocument.PrintPageBodyStart += new EventHandler<ReportPageEventArgs> (BodyStart);
reportDocument.PrintPageBodyEnd += new EventHandler<ReportPageEventArgs> (PrintBodyEnd);
reportDocument.PrintPageEnd += new EventHandler<ReportPageEventArgs> (PrintPageEnd);
reportDocument.DocumentName = reportSettings.ReportName; reportDocument.PrintPageBodyEnd += new EventHandler<ReportPageEventArgs> (OnBodyEnd);
// //
reportDocument.RenderReportHeader += new EventHandler<ReportPageEventArgs> (BuildReportHeader); reportDocument.RenderReportHeader += new EventHandler<ReportPageEventArgs> (PrintReportHeader);
reportDocument.RenderPageHeader += new EventHandler<ReportPageEventArgs> (BuildPageHeader); reportDocument.RenderPageHeader += new EventHandler<ReportPageEventArgs> (PrintPageHeader);
reportDocument.RenderDetails += new EventHandler<ReportPageEventArgs> (PrintDetail);
reportDocument.RenderPageEnd += new EventHandler<ReportPageEventArgs> (PrintPageEnd);
reportDocument.RenderReportEnd += new EventHandler<ReportPageEventArgs> (PrintReportFooter);
} }
#region Event handling for SectionRendering
#region test protected void AddSectionEvents () {
protected virtual void BuildReportHeader (object sender, ReportPageEventArgs e) { this.CurrentSection.SectionPrinting += new EventHandler<SectionEventArgs>(OnSectionPrinting);
SectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportPageHeader, this.CurrentSection.SectionPrinted += new EventHandler<SectionEventArgs>(OnSectionPrinted);
}
protected void RemoveSectionEvents () {
this.CurrentSection.SectionPrinting -= new EventHandler<SectionEventArgs>(OnSectionPrinting);
this.CurrentSection.SectionPrinted -= new EventHandler<SectionEventArgs>(OnSectionPrinted);
}
private void OnSectionPrinting (object sender,SectionEventArgs e) {
if (this.SectionRendering != null) {
SectionRenderEventArgs ea = new SectionRenderEventArgs (e.Section,
this.reportDocument.PageNumber,0,
(GlobalEnums.enmSection)this.sectionInUse);
this.SectionRendering(this,ea);
}
}
private void OnSectionPrinted (object sender,SectionEventArgs e) {
if (this.SectionRendered != null) {
SectionRenderEventArgs ea = new SectionRenderEventArgs (e.Section,
this.reportDocument.PageNumber,0,
(GlobalEnums.enmSection)this.sectionInUse);
this.SectionRendered(this,ea);
}
}
#endregion
protected virtual void PrintReportHeader (object sender, ReportPageEventArgs e) {
SectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportHeader,
CultureInfo.InvariantCulture); CultureInfo.InvariantCulture);
this.AddSectionEvents();
} }
protected virtual void BuildPageHeader (object sender, ReportPageEventArgs e) { protected virtual void PrintPageHeader (object sender, ReportPageEventArgs e) {
SectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportPageHeader, SectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportPageHeader,
CultureInfo.InvariantCulture); CultureInfo.InvariantCulture);
this.AddSectionEvents();
}
protected virtual void PrintDetail (object sender,ReportPageEventArgs rpea) {
SectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportDetail,
CultureInfo.InvariantCulture);
this.AddSectionEvents();
// System.Console.WriteLine("\tAbstract - PrintDetail");
}
protected virtual void PrintPageEnd (object sender,ReportPageEventArgs rpea) {
SectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportPageFooter,
CultureInfo.InvariantCulture);
// System.Console.WriteLine("\tAbstract:PrintPageEnd");
this.AddSectionEvents();
}
protected virtual void PrintReportFooter (object sender,ReportPageEventArgs rpea) {
SectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportFooter,
CultureInfo.InvariantCulture);
// System.Console.WriteLine("\tAbstract:PrintReportFooter");
this.AddSectionEvents();
} }
#endregion
protected static void PageBreak(ReportPageEventArgs pea) { protected static void PageBreak(ReportPageEventArgs pea) {
if (pea == null) { if (pea == null) {
throw new ArgumentNullException("pea"); throw new ArgumentNullException("pea");
@ -206,28 +265,26 @@ namespace SharpReportCore {
return new PointF(0,this.CurrentSection.SectionOffset + this.CurrentSection.Size.Height); return new PointF(0,this.CurrentSection.SectionOffset + this.CurrentSection.Size.Height);
} }
protected virtual int RenderSection (ReportPageEventArgs rpea) {
protected virtual int RenderSection (BaseSection section,ReportPageEventArgs rpea) {
Point drawPoint = new Point(0,0); Point drawPoint = new Point(0,0);
if (section.Visible){
section.Render (rpea);
foreach (BaseReportItem item in section.Items) { if (this.CurrentSection.Visible){
this.CurrentSection.Render (rpea);
foreach (BaseReportItem item in this.CurrentSection.Items) {
if (item.Parent == null) { if (item.Parent == null) {
item.Parent = section; item.Parent = this.CurrentSection;
} }
item.SectionOffset = section.SectionOffset; item.SectionOffset = this.CurrentSection.SectionOffset;
this.DrawSingleItem (rpea,item); this.DrawSingleItem (rpea,item);
drawPoint.Y = section.SectionOffset + section.Size.Height; drawPoint.Y = this.CurrentSection.SectionOffset + this.CurrentSection.Size.Height;
rpea.LocationAfterDraw = new PointF (rpea.LocationAfterDraw.X,section.SectionOffset + section.Size.Height); rpea.LocationAfterDraw = new PointF (rpea.LocationAfterDraw.X,this.CurrentSection.SectionOffset + this.CurrentSection.Size.Height);
} }
if ((section.CanGrow == false)&& (section.CanShrink == false)) { if ((this.CurrentSection.CanGrow == false)&& (this.CurrentSection.CanShrink == false)) {
return section.Size.Height; return this.CurrentSection.Size.Height;
} }
return drawPoint.Y; return drawPoint.Y;
@ -291,7 +348,6 @@ namespace SharpReportCore {
} }
} }
} }
private static void AdjustSection (BaseSection section,ReportPageEventArgs e){ private static void AdjustSection (BaseSection section,ReportPageEventArgs e){
@ -349,6 +405,7 @@ namespace SharpReportCore {
} }
#endregion #endregion
#region virtuals #region virtuals
protected virtual void ReportQueryPage (object sender,QueryPageSettingsEventArgs qpea) { protected virtual void ReportQueryPage (object sender,QueryPageSettingsEventArgs qpea) {
@ -361,28 +418,23 @@ namespace SharpReportCore {
} }
protected virtual void PrintBodyStart (object sender,ReportPageEventArgs rpea) { protected virtual void BodyStart (object sender,ReportPageEventArgs rpea) {
// System.Console.WriteLine("\tAbstract - PrintBodyStart"); // System.Console.WriteLine("\tAbstract - PrintBodyStart");
this.SectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportDetail, this.SectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportDetail,
CultureInfo.InvariantCulture); CultureInfo.InvariantCulture);
} }
protected virtual void PrintBodyEnd (object sender,ReportPageEventArgs rpea) {
// System.Console.WriteLine("\tAbstarct - PrintBodyEnd");
}
protected virtual void PrintPageEnd (object sender,ReportPageEventArgs rpea) {
// System.Console.WriteLine("\tAbstract - PrintPageEnd"); protected virtual void OnBodyEnd (object sender,ReportPageEventArgs rpea) {
// BaseSection section = null; // System.Console.WriteLine("\tAbstarct - PrintBodyEnd");
// section = CurrentSection; this.SectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportFooter,
// section.SectionOffset = reportSettings.PageSettings.Bounds.Height - reportSettings.DefaultMargins.Top - reportSettings.DefaultMargins.Bottom; CultureInfo.InvariantCulture);
// FitSectionToItems (section,e);
// RenderSection (section,e);
} }
protected virtual void ReportEnd (object sender,PrintEventArgs e) { protected virtual void ReportEnd (object sender,PrintEventArgs e) {
// System.Console.WriteLine("Abstract - ReportEnd"); // System.Console.WriteLine("\tAbstract - ReportEnd");
} }
#endregion #endregion

130
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs

@ -70,93 +70,77 @@ namespace SharpReportCore {
// e.ListChangedType); // e.ListChangedType);
} }
private void OnSectionPrinting (object sender,SectionPrintingEventArgs e) {
// System.Console.WriteLine("");
// System.Console.WriteLine("Begin Print <{0}> with <{1}> Items ",e.Section.Name,
// e.Section.Items.Count);
}
private void OnSectionPrinted (object sender,SectionPrintingEventArgs e) {
// System.Console.WriteLine("Section Printed <{0}> ",e.Section.Name);
}
private void AddSectionEvents () {
base.CurrentSection.SectionPrinting += new EventHandler<SectionPrintingEventArgs>(OnSectionPrinting);
base.CurrentSection.SectionPrinted += new EventHandler<SectionPrintingEventArgs>(OnSectionPrinted);
}
private void RemoveSectionEvents () {
base.CurrentSection.SectionPrinting -= new EventHandler<SectionPrintingEventArgs>(OnSectionPrinting);
base.CurrentSection.SectionPrinted -= new EventHandler<SectionPrintingEventArgs>(OnSectionPrinted);
}
#region overrides #region overrides
#region Draw the different report Sections #region Draw the different report Sections
private PointF DoReportHeader (ReportPageEventArgs rpea){ private PointF DoReportHeader (ReportPageEventArgs rpea){
System.Console.WriteLine("DoReportHeader");
PointF endAt = base.MeasureReportHeader (rpea); PointF endAt = base.MeasureReportHeader (rpea);
base.RenderSection (rpea);
this.AddSectionEvents();
base.RenderSection (base.CurrentSection,rpea);
base.DoItems(rpea); base.DoItems(rpea);
this.RemoveSectionEvents();
// if (base.CheckPageBreakAfter()) {
// base.PageBreak(rpea);
// base.CurrentSection.PageBreakAfter = false;
// return new PointF();
// }
return endAt; return endAt;
} }
private PointF DoPageHeader (PointF startAt,ReportPageEventArgs rpea){ private PointF DoPageHeader (PointF startAt,ReportPageEventArgs rpea){
PointF endAt = base.MeasurePageHeader (startAt,rpea); PointF endAt = base.MeasurePageHeader (startAt,rpea);
this.AddSectionEvents(); base.RenderSection (rpea);
base.RenderSection (base.CurrentSection,rpea);
base.DoItems(rpea); base.DoItems(rpea);
this.RemoveSectionEvents();
return endAt; return endAt;
} }
private void DoPageEnd (ReportPageEventArgs rpea){ private void DoPageEnd (ReportPageEventArgs rpea){
System.Console.WriteLine("DoPageEnd"); // System.Console.WriteLine("DataRenderer:DoPageEnd");
base.PrintPageEnd(this,rpea);
base.MeasurePageEnd (rpea); base.MeasurePageEnd (rpea);
base.RenderSection (rpea);
this.AddSectionEvents();
base.RenderSection (base.CurrentSection,rpea);
base.DoItems(rpea); base.DoItems(rpea);
this.RemoveSectionEvents();
} }
//TODO how should we handle ReportFooter, print it on an seperate page ???? //TODO how should we handle ReportFooter, print it on an seperate page ????
private void DoReportFooter (PointF startAt,ReportPageEventArgs rpea){ private void DoReportFooter (PointF startAt,ReportPageEventArgs rpea){
// System.Console.WriteLine("DoReportFooter");
base.MeasureReportFooter(rpea); base.MeasureReportFooter(rpea);
this.AddSectionEvents(); base.RenderSection (rpea);
base.RenderSection (base.CurrentSection,rpea);
base.DoItems(rpea); base.DoItems(rpea);
this.RemoveSectionEvents();
} }
#endregion #endregion
#region test #region test
protected override void BuildReportHeader (object sender, ReportPageEventArgs e) { protected override void PrintReportHeader (object sender, ReportPageEventArgs e) {
base.BuildReportHeader (sender,e); base.PrintReportHeader (sender,e);
this.currentPoint = DoReportHeader (e); this.currentPoint = DoReportHeader (e);
base.RemoveSectionEvents();
} }
protected override void BuildPageHeader (object sender, ReportPageEventArgs e) { protected override void PrintPageHeader (object sender, ReportPageEventArgs e) {
base.BuildPageHeader (sender,e); base.PrintPageHeader (sender,e);
this.currentPoint = DoPageHeader (this.currentPoint,e); this.currentPoint = DoPageHeader (this.currentPoint,e);
base.DetailStart = new Point ((int)currentPoint.X,(int)currentPoint.Y +1); base.DetailStart = new Point ((int)currentPoint.X,(int)currentPoint.Y +1);
base.RemoveSectionEvents();
}
protected override void PrintPageEnd(object sender, ReportPageEventArgs rpea) {
// System.Console.WriteLine("DataRenderer:PrintPageEnd");
base.PrintPageEnd(sender,rpea);
this.DoPageEnd (rpea);
base.RemoveSectionEvents();
}
protected override void PrintReportFooter(object sender, ReportPageEventArgs rpea){
System.Console.WriteLine("DataRenderer:PrintReportFooter");
base.PrintReportFooter(sender, rpea);
DoReportFooter (new PointF(0,base.CurrentSection.SectionOffset + base.CurrentSection.Size.Height),
rpea);
base.RemoveSectionEvents();
}
protected override void ReportEnd(object sender, PrintEventArgs e){
// System.Console.WriteLine("DataRenderer:ReportEnd");
base.ReportEnd(sender, e);
} }
#endregion #endregion
@ -170,7 +154,8 @@ namespace SharpReportCore {
} }
protected override void ReportBegin(object sender, PrintEventArgs pea) { protected override void ReportBegin(object sender, PrintEventArgs pea) {
System.Console.WriteLine("ReportBegin (BeginPrint)"); // System.Console.WriteLine("");
// System.Console.WriteLine("ReportBegin (BeginPrint)");
base.ReportBegin (sender,pea); base.ReportBegin (sender,pea);
base.DataManager.ListChanged += new EventHandler<ListChangedEventArgs> (OnListChanged); base.DataManager.ListChanged += new EventHandler<ListChangedEventArgs> (OnListChanged);
dataNavigator = base.DataManager.GetNavigator; dataNavigator = base.DataManager.GetNavigator;
@ -179,15 +164,23 @@ namespace SharpReportCore {
base.DataNavigator = dataNavigator; base.DataNavigator = dataNavigator;
} }
protected override void PrintBodyStart(object sender, ReportPageEventArgs rpea) {
Rectangle sectionRect;
bool firstOnPage = true;
base.PrintBodyStart (sender,rpea);
protected override void BodyStart(object sender, ReportPageEventArgs rpea) {
// System.Console.WriteLine("DataRenderer:PrintBodyStart");
base.BodyStart (sender,rpea);
this.currentPoint = new PointF (base.CurrentSection.Location.X, this.currentPoint = new PointF (base.CurrentSection.Location.X,
this.DetailStart.Y); this.DetailStart.Y);
base.CurrentSection.SectionOffset = (int)this.DetailStart.Y + AbstractRenderer.Gap; base.CurrentSection.SectionOffset = (int)this.DetailStart.Y + AbstractRenderer.Gap;
}
protected override void PrintDetail(object sender, ReportPageEventArgs rpea){
Rectangle sectionRect;
bool firstOnPage = true;
// System.Console.WriteLine("RenderDataReport:PrintDetail");
base.PrintDetail(sender, rpea);
// base.DebugRectangle(rpea,base.DetailRectangle(rpea)); // base.DebugRectangle(rpea,base.DetailRectangle(rpea));
// no loop if there is no data // no loop if there is no data
@ -197,12 +190,15 @@ namespace SharpReportCore {
} }
// first element // first element
if (this.dataNavigator.MoveNext()){ if (rpea.PageNumber == 1) {
this.dataNavigator.MoveNext();
}
do { do {
this.dataNavigator.Fill (base.CurrentSection.Items); this.dataNavigator.Fill (base.CurrentSection.Items);
base.RenderSection (base.CurrentSection,rpea); base.RenderSection (rpea);
if (!firstOnPage) { if (!firstOnPage) {
base.CurrentSection.SectionOffset = base.CurrentSection.SectionOffset + base.CurrentSection.Size.Height + 2 * AbstractRenderer.Gap; base.CurrentSection.SectionOffset = base.CurrentSection.SectionOffset + base.CurrentSection.Size.Height + 2 * AbstractRenderer.Gap;
@ -234,29 +230,19 @@ namespace SharpReportCore {
} }
} }
while (this.dataNavigator.MoveNext()); while (this.dataNavigator.MoveNext());
this.RemoveSectionEvents();
} }
DoReportFooter (new PointF(0,base.CurrentSection.SectionOffset + base.CurrentSection.Size.Height), protected override void OnBodyEnd(object sender, ReportPageEventArgs rpea) {
rpea);
rpea.PrintPageEventArgs.HasMorePages = false;
}
protected override void PrintBodyEnd(object sender, ReportPageEventArgs rpea) {
// System.Console.WriteLine("PrintBodyEnd ????"); // System.Console.WriteLine("PrintBodyEnd ????");
base.PrintBodyEnd (sender,rpea); base.OnBodyEnd (sender,rpea);
// DoReportFooter (new PointF(0,base.CurrentSection.SectionOffset + base.CurrentSection.Size.Height),
// rpea);
rpea.PrintPageEventArgs.HasMorePages = false;
} }
protected override void PrintPageEnd(object sender, ReportPageEventArgs rpea) {
System.Console.WriteLine("Page End");
this.DoPageEnd (rpea);
}
protected override void ReportEnd(object sender, PrintEventArgs e){
base.ReportEnd(sender, e);
}
#endregion #endregion

80
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderFormSheetReport.cs

@ -46,36 +46,11 @@ namespace SharpReportCore {
} }
private void OnSectionPrinting (object sender,SectionPrintingEventArgs e) {
System.Console.WriteLine("");
System.Console.WriteLine("Begin Print <{0}> with <{1}> Items ",e.Section.Name,
e.Section.Items.Count);
}
private void OnSectionPrinted (object sender,SectionPrintingEventArgs e) {
System.Console.WriteLine("Section Printed {0} ",e.Section.Name);
}
private void AddSectionEvents () {
base.CurrentSection.SectionPrinting += new EventHandler<SectionPrintingEventArgs>(OnSectionPrinting);
base.CurrentSection.SectionPrinted += new EventHandler<SectionPrintingEventArgs>(OnSectionPrinted);
}
private void RemoveSectionEvents () {
base.CurrentSection.SectionPrinting -= new EventHandler<SectionPrintingEventArgs>(OnSectionPrinting);
base.CurrentSection.SectionPrinted -= new EventHandler<SectionPrintingEventArgs>(OnSectionPrinted);
}
#region Draw the different report Sections #region Draw the different report Sections
private PointF DoReportHeader (ReportPageEventArgs rpea){ private PointF DoReportHeader (ReportPageEventArgs rpea){
PointF endAt = base.MeasureReportHeader (rpea); PointF endAt = base.MeasureReportHeader (rpea);
base.RenderSection (rpea);
this.AddSectionEvents();
base.RenderSection (base.CurrentSection,rpea);
this.RemoveSectionEvents();
if (base.CheckPageBreakAfter()) { if (base.CheckPageBreakAfter()) {
AbstractRenderer.PageBreak(rpea); AbstractRenderer.PageBreak(rpea);
@ -88,29 +63,21 @@ namespace SharpReportCore {
private PointF DoPageHeader (PointF startAt,ReportPageEventArgs rpea){ private PointF DoPageHeader (PointF startAt,ReportPageEventArgs rpea){
PointF endAt = base.MeasurePageHeader (startAt,rpea); PointF endAt = base.MeasurePageHeader (startAt,rpea);
base.RenderSection (rpea);
this.AddSectionEvents();
base.RenderSection (base.CurrentSection,rpea);
this.RemoveSectionEvents();
return endAt; return endAt;
} }
private void DoPageEnd (ReportPageEventArgs rpea){ private void DoPageEnd (ReportPageEventArgs rpea){
base.PrintPageEnd(this,rpea); base.PrintPageEnd(this,rpea);
base.MeasurePageEnd (rpea); base.MeasurePageEnd (rpea);
base.RenderSection (rpea);
this.AddSectionEvents();
base.RenderSection (base.CurrentSection,rpea);
this.RemoveSectionEvents();
} }
//TODO how should we handle ReportFooter, print it on an seperate page ???? //TODO how should we handle ReportFooter, print it on an seperate page ????
private void DoReportFooter (PointF startAt,ReportPageEventArgs rpea){ private void DoReportFooter (PointF startAt,ReportPageEventArgs rpea){
base.MeasureReportFooter(rpea); base.MeasureReportFooter(rpea);
base.RenderSection (rpea);
this.AddSectionEvents();
base.RenderSection (base.CurrentSection,rpea);
this.RemoveSectionEvents(); this.RemoveSectionEvents();
} }
@ -118,35 +85,21 @@ namespace SharpReportCore {
#region test #region test
protected override void BuildReportHeader (object sender, ReportPageEventArgs e) { protected override void PrintReportHeader (object sender, ReportPageEventArgs e) {
System.Console.WriteLine("!!!!"); base.PrintReportHeader (sender,e);
System.Console.WriteLine("testReportStart");
base.BuildReportHeader (sender,e);
this.currentPoint = DoReportHeader (e); this.currentPoint = DoReportHeader (e);
System.Console.WriteLine("");
} }
protected override void BuildPageHeader (object sender, ReportPageEventArgs e) { protected override void PrintPageHeader (object sender, ReportPageEventArgs e) {
base.PrintPageHeader (sender,e);
System.Console.WriteLine("!!!!");
System.Console.WriteLine("testPrintheader");
base.BuildPageHeader (sender,e);
this.currentPoint = DoPageHeader (this.currentPoint,e); this.currentPoint = DoPageHeader (this.currentPoint,e);
base.DetailStart = new Point ((int)currentPoint.X,(int)currentPoint.Y); base.DetailStart = new Point ((int)currentPoint.X,(int)currentPoint.Y);
System.Console.WriteLine("");
} }
#endregion #endregion
#region event's
// protected override void ReportQueryPage (object sender,QueryPageSettingsEventArgs qpea) {
// base.ReportQueryPage (sender,qpea);
// }
// protected override void ReportBegin (object sender,PrintEventArgs rpea) { #region event's
// base.ReportBegin (sender,rpea);
// }
/// <summary> /// <summary>
@ -154,18 +107,13 @@ namespace SharpReportCore {
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
protected override void PrintBodyStart (object sender,ReportPageEventArgs rpea) { protected override void BodyStart (object sender,ReportPageEventArgs rpea) {
base.PrintBodyStart (sender,rpea); base.BodyStart (sender,rpea);
// BaseSection section = base.CurrentSection;
base.CurrentSection.SectionOffset = (int)this.currentPoint.Y + AbstractRenderer.Gap; base.CurrentSection.SectionOffset = (int)this.currentPoint.Y + AbstractRenderer.Gap;
FitSectionToItems (base.CurrentSection,rpea); FitSectionToItems (base.CurrentSection,rpea);
base.RenderSection (rpea);
this.AddSectionEvents();
base.RenderSection (base.CurrentSection,rpea);
this.RemoveSectionEvents();
} }
/// <summary> /// <summary>
/// Print the PageFooter /// Print the PageFooter
@ -178,9 +126,9 @@ namespace SharpReportCore {
protected override void PrintBodyEnd (object sender,ReportPageEventArgs rpea) { protected override void OnBodyEnd (object sender,ReportPageEventArgs rpea) {
base.PrintBodyEnd (sender,rpea); base.OnBodyEnd (sender,rpea);
this.DoReportFooter (new PointF(0,base.CurrentSection.SectionOffset + base.CurrentSection.Size.Height), this.DoReportFooter (new PointF(0,base.CurrentSection.SectionOffset + base.CurrentSection.Size.Height),
rpea); rpea);
} }

33
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/ReportDocument.cs

@ -20,13 +20,16 @@ namespace SharpReportCore {
public class ReportDocument : PrintDocument { public class ReportDocument : PrintDocument {
public event EventHandler<ReportPageEventArgs> PrintPageBodyStart; public event EventHandler<ReportPageEventArgs> PrintPageBodyStart;
public event EventHandler<ReportPageEventArgs> PrintPageBodyEnd; public event EventHandler<ReportPageEventArgs> PrintPageBodyEnd;
public event EventHandler<ReportPageEventArgs> PrintPageEnd;
public event EventHandler<ReportPageEventArgs> RenderReportHeader; public event EventHandler<ReportPageEventArgs> RenderReportHeader;
public event EventHandler<ReportPageEventArgs> RenderPageHeader; public event EventHandler<ReportPageEventArgs> RenderPageHeader;
public event EventHandler<ReportPageEventArgs> RenderDetails;
public event EventHandler<ReportPageEventArgs> RenderPageEnd;
public event EventHandler<ReportPageEventArgs> RenderReportEnd;
int pageNumber; int pageNumber;
public ReportDocument():base() { public ReportDocument():base() {
@ -49,12 +52,16 @@ namespace SharpReportCore {
base.OnPrintPage(e); base.OnPrintPage(e);
pageNumber ++; pageNumber ++;
ReportPageEventArgs pea = new ReportPageEventArgs (e,pageNumber,false,new PointF (0,0)); ReportPageEventArgs pea = new ReportPageEventArgs (e,pageNumber,
false,new PointF (0,0));
GeneratePage (pea); GeneratePage (pea);
if (pea.PrintPageEventArgs.HasMorePages == false) { if (pea.PrintPageEventArgs.HasMorePages == false) {
this.OnEndPrint (new PrintEventArgs()); if (this.RenderReportEnd != null) {
this.RenderReportEnd(this,pea);
}
// this.OnEndPrint (new PrintEventArgs());
} }
} }
@ -76,16 +83,11 @@ namespace SharpReportCore {
this.RenderPageHeader (this,page); this.RenderPageHeader (this,page);
} }
/*
if (page.ForceNewPage == true) {
page.PrintPageEventArgs.HasMorePages = true;
return;
}
*/
// print PageFooter before DetailSection // print PageFooter before DetailSection
//so it's much easyer to calculate size of DetailSection //so it's much easyer to calculate size of DetailSection
if (PrintPageEnd != null) { if (RenderPageEnd != null) {
PrintPageEnd (this,page); RenderPageEnd (this,page);
} }
@ -93,11 +95,18 @@ namespace SharpReportCore {
PrintPageBodyStart (this,page); PrintPageBodyStart (this,page);
} }
if (this.RenderDetails != null) {
this.RenderDetails(this,page);
}
if (page.PrintPageEventArgs.HasMorePages == false) {
if (PrintPageBodyEnd != null) { if (PrintPageBodyEnd != null) {
PrintPageBodyEnd (this,page); PrintPageBodyEnd (this,page);
} }
} }
}
#region Property's #region Property's

1
src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj

@ -131,6 +131,7 @@
<Compile Include="Events\PrintEventArgs.cs" /> <Compile Include="Events\PrintEventArgs.cs" />
<Compile Include="BaseItems\TableItem.cs" /> <Compile Include="BaseItems\TableItem.cs" />
<Compile Include="Exceptions\IllegalQueryException.cs" /> <Compile Include="Exceptions\IllegalQueryException.cs" />
<Compile Include="Events\SectionRenderEventArgs.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="BaseItems" /> <Folder Include="BaseItems" />

33
src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportEngine.cs

@ -45,6 +45,16 @@ namespace SharpReportCore {
public event EventHandler <SharpReportEventArgs> NoData; public event EventHandler <SharpReportEventArgs> NoData;
public event EventHandler <SharpReportParametersEventArgs> ParametersRequest; public event EventHandler <SharpReportParametersEventArgs> ParametersRequest;
/// <summary>
/// This event is fired before a Section is Rendered, you can use
/// it to modify items to be printed
/// </summary>
public event EventHandler<SectionRenderEventArgs> SectionRendering;
/// <summary>
/// This event is fired after a section's output is done
/// </summary>
public event EventHandler<SectionRenderEventArgs> SectionRendered;
public SharpReportEngine() { public SharpReportEngine() {
if (SharpReportCore.GlobalValues.IsValidPrinter() == false) { if (SharpReportCore.GlobalValues.IsValidPrinter() == false) {
@ -124,7 +134,7 @@ namespace SharpReportCore {
} }
private void InitDataContainer (ReportSettings settings) { private void InitDataContainer (ReportSettings settings) {
System.Console.WriteLine("Engine:InitDataContainer eortType {0}",settings.ReportType); System.Console.WriteLine("Engine:InitDataContainer ReportType <{0}>",settings.ReportType);
if (settings.ReportType == GlobalEnums.enmReportType.DataReport) { if (settings.ReportType == GlobalEnums.enmReportType.DataReport) {
if (settings.CommandText != null) { if (settings.CommandText != null) {
try { try {
@ -207,6 +217,8 @@ namespace SharpReportCore {
default: default:
throw new SharpReportException ("SharpReportmanager:SetupRenderer -> Unknown Reporttype"); throw new SharpReportException ("SharpReportmanager:SetupRenderer -> Unknown Reporttype");
} }
abstr.SectionRendering += new EventHandler<SectionRenderEventArgs>(OnSectionPrinting);
abstr.SectionRendered +=new EventHandler<SectionRenderEventArgs>(OnSectionPrinted);
return abstr; return abstr;
} catch (Exception) { } catch (Exception) {
throw; throw;
@ -214,6 +226,17 @@ namespace SharpReportCore {
} }
private void OnSectionPrinting (object sender,SectionRenderEventArgs e) {
if (this.SectionRendering != null) {
this.SectionRendering(this,e);
}
}
private void OnSectionPrinted (object sender,SectionRenderEventArgs e) {
if (this.SectionRendered != null) {
this.SectionRendered (this,e);
}
}
protected SharpReportCore.AbstractRenderer SetupPushDataRenderer (ReportModel model, protected SharpReportCore.AbstractRenderer SetupPushDataRenderer (ReportModel model,
DataTable dataTable) { DataTable dataTable) {
@ -321,6 +344,10 @@ namespace SharpReportCore {
model = ModelFromFile (fileName); model = ModelFromFile (fileName);
if (CheckReportParameters (model,reportParameters)) { if (CheckReportParameters (model,reportParameters)) {
renderer = SetupStandartRenderer (model); renderer = SetupStandartRenderer (model);
//
// renderer.SectionRendering += new EventHandler<SectionPrintingEventArgs>(OnTestPrinting);
// System.Console.WriteLine("Event should be set");
if (renderer != null) { if (renderer != null) {
PreviewControl.ShowPreview(renderer,1.5,false); PreviewControl.ShowPreview(renderer,1.5,false);
} }
@ -328,8 +355,10 @@ namespace SharpReportCore {
} catch (Exception) { } catch (Exception) {
throw; throw;
} }
} }
/// <summary> /// <summary>
/// Preview a "PushModel - Report" /// Preview a "PushModel - Report"
/// </summary> /// </summary>

Loading…
Cancel
Save