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

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

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

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

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

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

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

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

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

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

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

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

@ -70,93 +70,77 @@ namespace SharpReportCore { @@ -70,93 +70,77 @@ namespace SharpReportCore {
// 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 Draw the different report Sections
private PointF DoReportHeader (ReportPageEventArgs rpea){
System.Console.WriteLine("DoReportHeader");
PointF endAt = base.MeasureReportHeader (rpea);
this.AddSectionEvents();
base.RenderSection (base.CurrentSection,rpea);
base.RenderSection (rpea);
base.DoItems(rpea);
this.RemoveSectionEvents();
// if (base.CheckPageBreakAfter()) {
// base.PageBreak(rpea);
// base.CurrentSection.PageBreakAfter = false;
// return new PointF();
// }
return endAt;
}
private PointF DoPageHeader (PointF startAt,ReportPageEventArgs rpea){
PointF endAt = base.MeasurePageHeader (startAt,rpea);
this.AddSectionEvents();
base.RenderSection (base.CurrentSection,rpea);
base.RenderSection (rpea);
base.DoItems(rpea);
this.RemoveSectionEvents();
return endAt;
}
private void DoPageEnd (ReportPageEventArgs rpea){
System.Console.WriteLine("DoPageEnd");
base.PrintPageEnd(this,rpea);
// System.Console.WriteLine("DataRenderer:DoPageEnd");
base.MeasurePageEnd (rpea);
this.AddSectionEvents();
base.RenderSection (base.CurrentSection,rpea);
base.RenderSection (rpea);
base.DoItems(rpea);
this.RemoveSectionEvents();
}
//TODO how should we handle ReportFooter, print it on an seperate page ????
private void DoReportFooter (PointF startAt,ReportPageEventArgs rpea){
// System.Console.WriteLine("DoReportFooter");
base.MeasureReportFooter(rpea);
this.AddSectionEvents();
base.RenderSection (base.CurrentSection,rpea);
base.RenderSection (rpea);
base.DoItems(rpea);
this.RemoveSectionEvents();
}
#endregion
#region test
protected override void BuildReportHeader (object sender, ReportPageEventArgs e) {
base.BuildReportHeader (sender,e);
protected override void PrintReportHeader (object sender, ReportPageEventArgs e) {
base.PrintReportHeader (sender,e);
this.currentPoint = DoReportHeader (e);
base.RemoveSectionEvents();
}
protected override void BuildPageHeader (object sender, ReportPageEventArgs e) {
base.BuildPageHeader (sender,e);
protected override void PrintPageHeader (object sender, ReportPageEventArgs e) {
base.PrintPageHeader (sender,e);
this.currentPoint = DoPageHeader (this.currentPoint,e);
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
@ -170,7 +154,8 @@ namespace SharpReportCore { @@ -170,7 +154,8 @@ namespace SharpReportCore {
}
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.DataManager.ListChanged += new EventHandler<ListChangedEventArgs> (OnListChanged);
dataNavigator = base.DataManager.GetNavigator;
@ -179,15 +164,23 @@ namespace SharpReportCore { @@ -179,15 +164,23 @@ namespace SharpReportCore {
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.DetailStart.Y);
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));
// no loop if there is no data
@ -197,12 +190,15 @@ namespace SharpReportCore { @@ -197,12 +190,15 @@ namespace SharpReportCore {
}
// first element
if (this.dataNavigator.MoveNext()){
if (rpea.PageNumber == 1) {
this.dataNavigator.MoveNext();
}
do {
this.dataNavigator.Fill (base.CurrentSection.Items);
base.RenderSection (base.CurrentSection,rpea);
base.RenderSection (rpea);
if (!firstOnPage) {
base.CurrentSection.SectionOffset = base.CurrentSection.SectionOffset + base.CurrentSection.Size.Height + 2 * AbstractRenderer.Gap;
@ -234,29 +230,19 @@ namespace SharpReportCore { @@ -234,29 +230,19 @@ namespace SharpReportCore {
}
}
while (this.dataNavigator.MoveNext());
this.RemoveSectionEvents();
}
DoReportFooter (new PointF(0,base.CurrentSection.SectionOffset + base.CurrentSection.Size.Height),
rpea);
rpea.PrintPageEventArgs.HasMorePages = false;
}
protected override void PrintBodyEnd(object sender, ReportPageEventArgs rpea) {
protected override void OnBodyEnd(object sender, ReportPageEventArgs rpea) {
// 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

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

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

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

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

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

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

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

@ -45,6 +45,16 @@ namespace SharpReportCore { @@ -45,6 +45,16 @@ namespace SharpReportCore {
public event EventHandler <SharpReportEventArgs> NoData;
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() {
if (SharpReportCore.GlobalValues.IsValidPrinter() == false) {
@ -124,7 +134,7 @@ namespace SharpReportCore { @@ -124,7 +134,7 @@ namespace SharpReportCore {
}
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.CommandText != null) {
try {
@ -207,6 +217,8 @@ namespace SharpReportCore { @@ -207,6 +217,8 @@ namespace SharpReportCore {
default:
throw new SharpReportException ("SharpReportmanager:SetupRenderer -> Unknown Reporttype");
}
abstr.SectionRendering += new EventHandler<SectionRenderEventArgs>(OnSectionPrinting);
abstr.SectionRendered +=new EventHandler<SectionRenderEventArgs>(OnSectionPrinted);
return abstr;
} catch (Exception) {
throw;
@ -214,6 +226,17 @@ namespace SharpReportCore { @@ -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,
DataTable dataTable) {
@ -321,6 +344,10 @@ namespace SharpReportCore { @@ -321,6 +344,10 @@ namespace SharpReportCore {
model = ModelFromFile (fileName);
if (CheckReportParameters (model,reportParameters)) {
renderer = SetupStandartRenderer (model);
//
// renderer.SectionRendering += new EventHandler<SectionPrintingEventArgs>(OnTestPrinting);
// System.Console.WriteLine("Event should be set");
if (renderer != null) {
PreviewControl.ShowPreview(renderer,1.5,false);
}
@ -328,8 +355,10 @@ namespace SharpReportCore { @@ -328,8 +355,10 @@ namespace SharpReportCore {
} catch (Exception) {
throw;
}
}
/// <summary>
/// Preview a "PushModel - Report"
/// </summary>

Loading…
Cancel
Save