Browse Source

Added SectionPrinting and SectionPrinted Event to BaseSection.cs

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1274 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Peter Forstmeier 20 years ago
parent
commit
174e374ccb
  1. 2
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseDataItem.cs
  2. 21
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportItem.cs
  3. 18
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportObject.cs
  4. 26
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseSection.cs
  5. 2
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/RowItem.cs
  6. 16
      src/AddIns/Misc/SharpReport/SharpReportCore/Events/PrintEventArgs.cs
  7. 5
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractDataRenderer.cs
  8. 92
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractRenderer.cs
  9. 102
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs
  10. 24
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderFormSheetReport.cs
  11. 3
      src/AddIns/Misc/SharpReport/SharpReportCore/Visitors/LoadModelVisitor.cs

2
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseDataItem.cs

@ -64,7 +64,7 @@ namespace SharpReportCore { @@ -64,7 +64,7 @@ namespace SharpReportCore {
string toPrint = CheckForNullValue();
string formattedString = base.FireFormatOutput(toPrint,this.FormatString,"");
// System.Console.WriteLine("\t\tBaseDataItem:Render {0} ",formattedString);
RectangleF rect = base.PrepareRectangle (rpea,formattedString);
base.PrintTheStuff (rpea,formattedString,rect);
base.NotiyfyAfterPrint (rpea.LocationAfterDraw);

21
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportItem.cs

@ -28,7 +28,10 @@ namespace SharpReportCore { @@ -28,7 +28,10 @@ namespace SharpReportCore {
private Color foreColor;
private Font font;
public event EventHandler<BeforePrintEventArgs> BeforePrinting;
public event EventHandler<AfterPrintEventArgs> AfterPrinting;
public event EventHandler <FormatOutputEventArgs> FormatOutput;
public event EventHandler Disposed;
@ -57,6 +60,22 @@ namespace SharpReportCore { @@ -57,6 +60,22 @@ namespace SharpReportCore {
#endregion
#region EventHandling
public void NotiyfyAfterPrint (PointF afterPrintLocation) {
if (this.AfterPrinting != null) {
AfterPrintEventArgs rea = new AfterPrintEventArgs (afterPrintLocation);
AfterPrinting(this, rea);
}
}
public void NotifyBeforePrint () {
if (this.BeforePrinting != null) {
BeforePrintEventArgs ea = new BeforePrintEventArgs ();
BeforePrinting (this,ea);
}
}
#endregion
#region virtual method's
protected RectangleF DrawingRectangle (ReportPageEventArgs e,SizeF measureSize) {

18
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportObject.cs

@ -41,9 +41,6 @@ namespace SharpReportCore { @@ -41,9 +41,6 @@ namespace SharpReportCore {
private Color backColor;
private int sectionOffset;
public event EventHandler<BeforePrintEventArgs> BeforePrinting;
public event EventHandler<AfterPrintEventArgs> AfterPrinting;
#region SharpReportCore.IPropertyChange interface implementation
@ -196,22 +193,7 @@ namespace SharpReportCore { @@ -196,22 +193,7 @@ namespace SharpReportCore {
}
#endregion
#region EventHandling
public void NotiyfyAfterPrint (PointF afterPrintLocation) {
if (this.AfterPrinting != null) {
AfterPrintEventArgs rea = new AfterPrintEventArgs (afterPrintLocation);
AfterPrinting(this, rea);
}
}
public void NotifyBeforePrint () {
if (this.BeforePrinting != null) {
BeforePrintEventArgs ea = new BeforePrintEventArgs ();
BeforePrinting (this,ea);
}
}
#endregion
#region SharpReportCore.IBaseRenderer interface implementation
public virtual void Render(ReportPageEventArgs rpea) {

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

@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
//------------------------------------------------------------------------------
using System;
using System.ComponentModel;
//using System.Windows.Forms;
using System.Xml.Serialization;
/// <summary>
@ -24,7 +24,12 @@ namespace SharpReportCore { @@ -24,7 +24,12 @@ namespace SharpReportCore {
private ReportItemCollection items;
public event EventHandler<SectionPrintingEventArgs> SectionPrinting;
public event EventHandler<SectionPrintingEventArgs> SectionPrinted;
#region Constructors
public BaseSection(): base() {
this.Name = String.Empty;
}
@ -35,11 +40,28 @@ namespace SharpReportCore { @@ -35,11 +40,28 @@ namespace SharpReportCore {
#endregion
public override void Render(ReportPageEventArgs rpea){
this.NotifyPrinting();
base.Render(rpea);
this.NotifyPrinted();
}
#region properties
public void NotifyPrinting () {
if (this.SectionPrinting != null) {
SectionPrintingEventArgs ea = new SectionPrintingEventArgs (this);
SectionPrinting (this,ea);
}
}
public void NotifyPrinted () {
if (this.SectionPrinted != null) {
SectionPrintingEventArgs ea = new SectionPrintingEventArgs (this);
SectionPrinted (this,ea);
}
}
public int SectionMargin {
get {
return this.sectionMargin;

2
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/RowItem.cs

@ -59,7 +59,7 @@ namespace SharpReportCore{ @@ -59,7 +59,7 @@ namespace SharpReportCore{
public override void Render(ReportPageEventArgs rpea){
System.Console.WriteLine("Render RowItem");
// System.Console.WriteLine("Render RowItem");
if (rpea == null) {
throw new ArgumentNullException("rpea");
}

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

@ -23,6 +23,22 @@ using System.Drawing; @@ -23,6 +23,22 @@ using System.Drawing;
namespace SharpReportCore {
public class SectionPrintingEventArgs : System.EventArgs {
BaseSection section;
public SectionPrintingEventArgs(BaseSection section){
this.section = section;
}
public BaseSection Section {
get {
return section;
}
}
}
///<summary>
/// This event is fired just bevore an Item is printed
/// Use this event for formatting etc.

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

@ -17,6 +17,8 @@ namespace SharpReportCore{ @@ -17,6 +17,8 @@ namespace SharpReportCore{
public class AbstractDataRenderer : AbstractRenderer{
DataManager dataManager;
DataNavigator navigator;
public AbstractDataRenderer(ReportModel model,DataManager dataManager):base(model){
if (dataManager == null) {
throw new ArgumentNullException("dataManager");
@ -24,8 +26,7 @@ namespace SharpReportCore{ @@ -24,8 +26,7 @@ namespace SharpReportCore{
this.dataManager = dataManager;
}
protected override void ReportBegin(object sender, ReportPageEventArgs e)
{
protected override void ReportBegin(object sender, ReportPageEventArgs e){
base.ReportBegin(sender, e);
}

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

@ -113,7 +113,7 @@ namespace SharpReportCore { @@ -113,7 +113,7 @@ namespace SharpReportCore {
throw new ArgumentNullException("rpea");
}
System.Console.WriteLine("Debug Rectangle {0}",rectangle);
// System.Console.WriteLine("Debug Rectangle {0}",rectangle);
rpea.PrintPageEventArgs.Graphics.DrawRectangle (Pens.Black,rectangle);
}
@ -132,54 +132,65 @@ namespace SharpReportCore { @@ -132,54 +132,65 @@ namespace SharpReportCore {
return rect;
}
///<summary>
/// Prints the ReportHader printjob is the same in all Types of reportz
///</summary>
/// <param name="e">ReportpageEventArgs</param>
///
protected PointF DrawReportHeader (ReportPageEventArgs e) {
float offset = 0;
BaseSection section = null;
protected PointF MeasureReportHeader (ReportPageEventArgs e) {
PointF endAt = new PointF();
if (e.PageNumber == 1) {
sectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportHeader,CultureInfo.InvariantCulture);
sectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportHeader,
CultureInfo.InvariantCulture);
if (this.CurrentSection.Items.Count > 0) {
this.CurrentSection.SectionOffset = reportSettings.DefaultMargins.Top;
FitSectionToItems (this.CurrentSection,e);
endAt = new PointF (0,
reportSettings.DefaultMargins.Top + this.CurrentSection.Size.Height + Gap);
} else {
endAt = new PointF(0,reportSettings.DefaultMargins.Top);
}
section = CurrentSection;
section.SectionOffset = reportSettings.DefaultMargins.Top;
FitSectionToItems (section,e);
offset = RenderSection (section,e);
}
return new PointF (0,offset + reportSettings.DefaultMargins.Top + Gap);
return endAt;
}
///<summary>
/// Prints the PageHeader printjob is the same in all Types of reportz
///</summary>
/// <param name="startAt">Section start at this PointF</param>
/// <param name="e">ReportPageEventArgs</param>
protected PointF DrawPageHeader (PointF startat,ReportPageEventArgs e) {
float offset = 0F;
BaseSection section = null;
sectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportPageHeader,CultureInfo.InvariantCulture);
section = CurrentSection;
protected PointF MeasurePageHeader (PointF startat,ReportPageEventArgs e) {
sectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportPageHeader,
CultureInfo.InvariantCulture);
if (e.PageNumber == 1) {
section.SectionOffset = (int)startat.Y + Gap;
this.CurrentSection.SectionOffset = (int)startat.Y + Gap;
} else {
section.SectionOffset = reportSettings.DefaultMargins.Top;
this.CurrentSection.SectionOffset = reportSettings.DefaultMargins.Top;
}
FitSectionToItems (section,e);
offset = RenderSection (section,e);
return new PointF (0,section.SectionOffset + offset + Gap);
FitSectionToItems (this.CurrentSection,e);
return new PointF (0,
this.CurrentSection.SectionOffset + this.CurrentSection.Size.Height + Gap);
}
protected PointF MeasurePageEnd (ReportPageEventArgs e) {
sectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportPageFooter,
CultureInfo.InvariantCulture);
this.CurrentSection.SectionOffset = reportSettings.PageSettings.Bounds.Height - reportSettings.DefaultMargins.Top - reportSettings.DefaultMargins.Bottom;
FitSectionToItems (this.CurrentSection,e);
this.DetailEnds = new Point (0,this.CurrentSection.SectionOffset);
return new PointF(0,this.CurrentSection.SectionOffset);
}
protected PointF MeasureReportFooter (ReportPageEventArgs e) {
sectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportFooter,
CultureInfo.InvariantCulture);
FitSectionToItems (this.CurrentSection,e);
return new PointF(0,this.CurrentSection.SectionOffset + this.CurrentSection.Size.Height);
}
protected virtual int RenderSection (BaseSection section,ReportPageEventArgs rpea) {
Point drawPoint = new Point(0,0);
if (section.Visible){
section.Render (rpea);
@ -204,7 +215,7 @@ namespace SharpReportCore { @@ -204,7 +215,7 @@ namespace SharpReportCore {
}
return drawPoint.Y;
}
protected void DrawSingleItem (ReportPageEventArgs rpea,BaseReportItem item){
item.SuspendLayout();
@ -216,12 +227,12 @@ namespace SharpReportCore { @@ -216,12 +227,12 @@ namespace SharpReportCore {
// Called by FormatOutPutEvent of the BaseReportItem
void FormatBaseReportItem (object sender, FormatOutputEventArgs rpea) {
System.Console.WriteLine("FormatBaseReportItem");
// System.Console.WriteLine("FormatBaseReportItem");
BaseDataItem baseDataItem = sender as BaseDataItem;
if (baseDataItem != null) {
if (!String.IsNullOrEmpty(baseDataItem.FormatString)) {
rpea.FormatedValue = defaultFormatter.FormatItem (baseDataItem);
System.Console.WriteLine("\tFormated Value = {0}",rpea.FormatedValue);
// System.Console.WriteLine("\tFormated Value = {0}",rpea.FormatedValue);
} else {
rpea.FormatedValue = rpea.ValueToFormat;
}
@ -333,7 +344,8 @@ namespace SharpReportCore { @@ -333,7 +344,8 @@ namespace SharpReportCore {
}
protected virtual void PrintBodyStart (object sender,ReportPageEventArgs e) {
this.SectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportDetail,
CultureInfo.InvariantCulture);
}
@ -341,12 +353,12 @@ namespace SharpReportCore { @@ -341,12 +353,12 @@ namespace SharpReportCore {
}
protected virtual void PrintPageEnd (object sender,ReportPageEventArgs e) {
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 PrintPageEnd (object sender,ReportPageEventArgs e) {
// BaseSection section = null;
// section = CurrentSection;
// section.SectionOffset = reportSettings.PageSettings.Bounds.Height - reportSettings.DefaultMargins.Top - reportSettings.DefaultMargins.Bottom;
// FitSectionToItems (section,e);
// RenderSection (section,e);
}
#endregion

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

@ -68,8 +68,76 @@ namespace SharpReportCore { @@ -68,8 +68,76 @@ 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){
PointF endAt = base.MeasureReportHeader (rpea);
this.AddSectionEvents();
base.RenderSection (base.CurrentSection,rpea);
this.RemoveSectionEvents();
if (base.CurrentSection.PageBreakAfter) {
base.PageBreak(rpea,base.CurrentSection);
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);
this.RemoveSectionEvents();
return endAt;
}
private void DoPageEnd (ReportPageEventArgs rpea){
base.PrintPageEnd(this,rpea);
base.MeasurePageEnd (rpea);
this.AddSectionEvents();
base.RenderSection (base.CurrentSection,rpea);
this.RemoveSectionEvents();
}
//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);
this.RemoveSectionEvents();
}
#endregion
protected override void ReportQueryPage(object sender, QueryPageSettingsEventArgs e) {
base.ReportQueryPage (sender,e);
@ -90,27 +158,29 @@ namespace SharpReportCore { @@ -90,27 +158,29 @@ namespace SharpReportCore {
if (rpea == null) {
throw new ArgumentNullException("rpea");
}
base.BeginPrintPage (sender,rpea);
//Draw ReportHeader
currentPoint = base.DrawReportHeader (rpea);
if (base.CurrentSection.PageBreakAfter) {
base.PageBreak(rpea,base.CurrentSection);
base.CurrentSection.PageBreakAfter = false;
return;
if (rpea.PageNumber == 1) {
//Draw ReportHeader
this.currentPoint = DoReportHeader (rpea);
}
//Draw Pageheader
currentPoint = base.DrawPageHeader (currentPoint,rpea);
this.currentPoint = DoPageHeader (this.currentPoint,rpea);
base.DetailStart = new Point ((int)currentPoint.X,(int)currentPoint.Y);
}
protected override void PrintBodyStart(object sender, ReportPageEventArgs e) {
Rectangle sectionRect;
Rectangle detailRect;
// System.Console.WriteLine("PrintBodyStart");
base.PrintBodyStart (sender,e);
base.SectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportDetail,CultureInfo.InvariantCulture);
BaseSection section = base.CurrentSection;
section.SectionOffset = (int)this.currentPoint.Y + base.Gap;
@ -145,12 +215,16 @@ namespace SharpReportCore { @@ -145,12 +215,16 @@ namespace SharpReportCore {
section.Size.Height);
if (!detailRect.Contains(sectionRect)) {
// System.Console.WriteLine("--------- Page Break ----------");
base.PageBreak(e,section);
return;
}
}
DoReportFooter (new PointF(0,section.SectionOffset + section.Size.Height),
e);
e.PrintPageEventArgs.HasMorePages = false;
//Did we have a pagebreak
@ -163,15 +237,13 @@ namespace SharpReportCore { @@ -163,15 +237,13 @@ namespace SharpReportCore {
protected override void PrintBodyEnd(object sender, ReportPageEventArgs e) {
// System.Console.WriteLine("PrintBodyEnd");
base.PrintBodyEnd (sender,e);
}
protected override void PrintPageEnd(object sender, ReportPageEventArgs e) {
base.SectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportPageFooter,
CultureInfo.InvariantCulture);
base.PrintPageEnd (sender,e);
base.DetailEnds = new Point (0,base.CurrentSection.SectionOffset);
protected override void PrintPageEnd(object sender, ReportPageEventArgs rpea) {
this.DoPageEnd (rpea);
}
public override string ToString() {

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

@ -46,6 +46,16 @@ namespace SharpReportCore { @@ -46,6 +46,16 @@ 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);
}
#region event's
protected override void ReportQueryPage (object sender,QueryPageSettingsEventArgs e) {
@ -63,19 +73,21 @@ namespace SharpReportCore { @@ -63,19 +73,21 @@ namespace SharpReportCore {
/// <param name="sender"></param>
/// <param name="e"></param>
///
protected override void BeginPrintPage (object sender,ReportPageEventArgs e) {
base.BeginPrintPage (sender,e);
protected override void BeginPrintPage (object sender,ReportPageEventArgs rpea) {
base.BeginPrintPage (sender,rpea);
//Draw ReportHeader
currentPoint = base.DrawReportHeader (e);
currentPoint = base.MeasureReportHeader(rpea);
base.RenderSection (base.CurrentSection,rpea);
if (base.CurrentSection.PageBreakAfter) {
base.PageBreak(e,base.CurrentSection);
base.PageBreak(rpea,base.CurrentSection);
base.CurrentSection.PageBreakAfter = false;
return;
}
//Draw Pageheader
currentPoint = base.DrawPageHeader (currentPoint,e);
currentPoint = base.MeasurePageHeader(currentPoint,rpea);
base.RenderSection (base.CurrentSection,rpea);
base.DetailStart = new Point ((int)currentPoint.X,(int)currentPoint.Y);
}
@ -88,8 +100,6 @@ namespace SharpReportCore { @@ -88,8 +100,6 @@ namespace SharpReportCore {
protected override void PrintBodyStart (object sender,ReportPageEventArgs e) {
base.PrintBodyStart (sender,e);
base.SectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportDetail,
CultureInfo.InvariantCulture);
BaseSection section = base.CurrentSection;
section.SectionOffset = (int)this.currentPoint.Y + base.Gap;

3
src/AddIns/Misc/SharpReport/SharpReportCore/Visitors/LoadModelVisitor.cs

@ -68,6 +68,7 @@ namespace SharpReportCore { @@ -68,6 +68,7 @@ namespace SharpReportCore {
if (node is XmlElement) {
XmlElement sectionElem = (XmlElement)node;
baseSection = (BaseSection)model.SectionCollection.Find(sectionElem.GetAttribute("name"));
baseSection.SuspendLayout();
if (baseSection != null) {
XmlHelper.SetSectionValues (xmlFormReader,sectionElem,baseSection);
XmlNodeList ctrlList = sectionElem.SelectNodes ("controls/control");
@ -85,7 +86,7 @@ namespace SharpReportCore { @@ -85,7 +86,7 @@ namespace SharpReportCore {
baseSection.Items.Add (rpt);
XmlHelper.BuildControl (xmlFormReader,ctrlElem,rpt);
rpt.Visible = true;
rpt.ResumeLayout();
// rpt.ResumeLayout();
} else {
String str = String.Format("< {0}>",ctrlElem.GetAttribute("basetype"));
throw new UnkownItemException(str);

Loading…
Cancel
Save