Browse Source

cleanup, remove dublicate code

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@5558 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Peter Forstmeier 16 years ago
parent
commit
0aac9e7333
  1. 3
      src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/BaseItems/BaseTableItem.cs
  2. 6
      src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/Events/SectionRenderEventArgs.cs
  3. 2
      src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/Exporter/BasePager.cs
  4. 2
      src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/Exporter/Converters/BaseConverter.cs
  5. 191
      src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/Printing/AbstractRenderer.cs
  6. 2
      src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/Printing/RenderDataReport.cs
  7. 2
      src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/ReportViewer/ReportViewer.cs

3
src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/BaseItems/BaseTableItem.cs

@ -86,8 +86,7 @@ namespace ICSharpCode.Reports.Core { @@ -86,8 +86,7 @@ namespace ICSharpCode.Reports.Core {
}
//
Point saveLocation = this.Location;
// Point currentPosition = new Point(this.SectionBounds.DetailStart.X,rpea.LocationAfterDraw.Y);
Point currentPosition = new Point(this.startSection.Location.X,rpea.LocationAfterDraw.Y);
Point currentPosition = new Point(this.startSection.Location.X,this.startSection.Location.Y);
Point tableStart = currentPosition;
base.Render(rpea);
int defaultLeftPos = PrintHelper.DrawingAreaRelativeToParent(this.Parent,this).Left;

6
src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/Events/SectionRenderEventArgs.cs

@ -15,11 +15,11 @@ namespace ICSharpCode.Reports.Core { @@ -15,11 +15,11 @@ namespace ICSharpCode.Reports.Core {
public class SectionRenderEventArgs:SectionEventArgs{
private int pageNumber;
private int rowNumber;
private GlobalEnums.ReportSection currentSection;
private BaseSection currentSection;
public SectionRenderEventArgs(BaseSection section,
int pageNumber,int rowNumber,
GlobalEnums.ReportSection currentSection):base(section){
BaseSection currentSection):base(section){
this.pageNumber = pageNumber;
this.currentSection = currentSection;
@ -40,7 +40,7 @@ namespace ICSharpCode.Reports.Core { @@ -40,7 +40,7 @@ namespace ICSharpCode.Reports.Core {
}
public GlobalEnums.ReportSection CurrentSection {
public BaseSection CurrentSection {
get {
return currentSection;
}

2
src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/Exporter/BasePager.cs

@ -233,7 +233,7 @@ namespace ICSharpCode.Reports.Core.Exporter @@ -233,7 +233,7 @@ namespace ICSharpCode.Reports.Core.Exporter
new SectionRenderEventArgs(section,
pages.Count,
currentRow,
(GlobalEnums.ReportSection)GlobalEnums.ReportSection.Parse(typeof(GlobalEnums.ReportSection),section.Name));
section);
EventHelper.Raise<SectionRenderEventArgs>(SectionRendering,this,ea);
}

2
src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/Exporter/Converters/BaseConverter.cs

@ -66,7 +66,7 @@ namespace ICSharpCode.Reports.Core.Exporter @@ -66,7 +66,7 @@ namespace ICSharpCode.Reports.Core.Exporter
SectionRenderEventArgs srea = new SectionRenderEventArgs(section,
this.SinglePage.PageNumber,
this.dataNavigator.CurrentRow,
(GlobalEnums.ReportSection)GlobalEnums.ReportSection.Parse(typeof(GlobalEnums.ReportSection),section.Name));
section);
EventHelper.Raise<SectionRenderEventArgs>(SectionRendering,this,srea);
}

191
src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/Printing/AbstractRenderer.cs

@ -33,20 +33,19 @@ namespace ICSharpCode.Reports.Core @@ -33,20 +33,19 @@ namespace ICSharpCode.Reports.Core
private ReportSectionCollection sections;
private ReportSettings reportSettings;
private int sectionInUse;
private int currentRow;
private int currentPageNumber;
private int currentPageNumber;
private SectionBounds sectionBounds;
private bool cancel;
private IExpressionEvaluatorFacade expressionFassade;
private ILayouter layout;
private IReportModel reportModel;
public event EventHandler<SectionRenderEventArgs> Rendering;
public event EventHandler<SectionRenderEventArgs> SectionRendered;
private ILayouter layout;
protected AbstractRenderer(IReportModel model,ReportDocument reportDocument,ILayouter layout)
protected AbstractRenderer(IReportModel reportModel,ReportDocument reportDocument,ILayouter layout)
{
if (model == null) {
if (reportModel == null) {
throw new MissingModelException();
}
if (reportDocument == null) {
@ -55,22 +54,27 @@ namespace ICSharpCode.Reports.Core @@ -55,22 +54,27 @@ namespace ICSharpCode.Reports.Core
if (layout == null) {
throw new ArgumentNullException("layout");
}
this.reportSettings = model.ReportSettings;
this.reportModel = reportModel;
this.reportSettings = reportModel.ReportSettings;
this.reportDocument = reportDocument;
this.layout = layout;
this.sections = model.SectionCollection;
this.sections = reportModel.SectionCollection;
Init();
}
void Init()
private void Init()
{
this.reportDocument.DocumentName = reportSettings.ReportName;
// Events from ReportDocument
this.reportDocument.QueryPageSettings += new QueryPageSettingsEventHandler (ReportQueryPage);
this.reportDocument.BeginPrint += new PrintEventHandler(ReportBegin);
this.reportDocument.PrintPage += new PrintPageEventHandler(ReportPageStart);
this.reportDocument.PrintPage += delegate(object sender,PrintPageEventArgs e){
this.CalculatePageBounds ();
};
this.reportDocument.EndPrint += new PrintEventHandler(ReportEnd);
// homemade events
@ -109,21 +113,20 @@ namespace ICSharpCode.Reports.Core @@ -109,21 +113,20 @@ namespace ICSharpCode.Reports.Core
if (this.Rendering != null) {
SectionRenderEventArgs ea = new SectionRenderEventArgs (e.Section,
this.currentPageNumber,
this.currentRow,
(GlobalEnums.ReportSection)this.sectionInUse);
this.CurrentRow,
this.CurrentSection);
this.Rendering(this,ea);
}
}
}
private void OnSectionPrinted (object sender,SectionEventArgs e)
private void OnSectionPrinted (object sender,SectionEventArgs e)
{
if (this.SectionRendered != null) {
SectionRenderEventArgs ea = new SectionRenderEventArgs (e.Section,
this.currentPageNumber,
this.currentRow,
(GlobalEnums.ReportSection)this.sectionInUse);
this.CurrentRow,
this.CurrentSection);
this.SectionRendered(this,ea);
}
}
@ -135,59 +138,53 @@ namespace ICSharpCode.Reports.Core @@ -135,59 +138,53 @@ namespace ICSharpCode.Reports.Core
internal virtual void PrintReportHeader (object sender, ReportPageEventArgs rpea)
{
SectionInUse = Convert.ToInt16(GlobalEnums.ReportSection.ReportHeader,
CultureInfo.InvariantCulture);
this.CurrentSection = this.reportModel.ReportHeader;
this.AddSectionEvents();
}
internal virtual void PrintPageHeader (object sender, ReportPageEventArgs rpea)
{
SectionInUse = Convert.ToInt16(GlobalEnums.ReportSection.ReportPageHeader,
CultureInfo.InvariantCulture);
this.CurrentSection = this.reportModel.PageHeader;
this.AddSectionEvents();
}
internal virtual void BodyStart (object sender,ReportPageEventArgs rpea)
{
this.SectionInUse = Convert.ToInt16(GlobalEnums.ReportSection.ReportDetail,
CultureInfo.InvariantCulture);
this.CurrentSection = this.reportModel.DetailSection;
}
internal virtual void PrintDetail (object sender,ReportPageEventArgs rpea)
{
SectionInUse = Convert.ToInt16(GlobalEnums.ReportSection.ReportDetail,
CultureInfo.InvariantCulture);
this.CurrentSection = this.reportModel.DetailSection;
this.AddSectionEvents();
}
internal virtual void BodyEnd (object sender,ReportPageEventArgs rpea)
{
this.SectionInUse = Convert.ToInt16(GlobalEnums.ReportSection.ReportFooter,
CultureInfo.InvariantCulture);
this.CurrentSection = this.reportModel.ReportFooter;
}
internal virtual void PrintPageEnd (object sender,ReportPageEventArgs rpea)
{
SectionInUse = Convert.ToInt16(GlobalEnums.ReportSection.ReportPageFooter,
CultureInfo.InvariantCulture);
this.CurrentSection = this.reportModel.ReportFooter;
this.AddSectionEvents();
}
internal virtual void PrintReportFooter (object sender,ReportPageEventArgs rpea)
{
SectionInUse = Convert.ToInt16(GlobalEnums.ReportSection.ReportFooter,
CultureInfo.InvariantCulture);
this.CurrentSection = this.reportModel.ReportFooter;
this.AddSectionEvents();
}
#endregion
public static void PageBreak(ReportPageEventArgs pea)
public static void PageBreak(ReportPageEventArgs pea)
{
if (pea == null) {
throw new ArgumentNullException("pea");
@ -203,9 +200,9 @@ namespace ICSharpCode.Reports.Core @@ -203,9 +200,9 @@ namespace ICSharpCode.Reports.Core
throw new ArgumentNullException("e");
}
e.Graphics.DrawString(this.reportSettings.NoDataMessage,
this.ReportSettings.DefaultFont,
new SolidBrush(Color.Black),
sectionBounds.DetailArea);
this.ReportSettings.DefaultFont,
new SolidBrush(Color.Black),
this.SectionBounds.DetailArea);
}
@ -265,47 +262,12 @@ namespace ICSharpCode.Reports.Core @@ -265,47 +262,12 @@ namespace ICSharpCode.Reports.Core
private void CalculatePageBounds ()
{
sectionInUse = Convert.ToInt16(GlobalEnums.ReportSection.ReportHeader,
CultureInfo.InvariantCulture);
sectionBounds.MeasureReportHeader(this.CurrentSection);
//PageHeader
sectionInUse = Convert.ToInt16(GlobalEnums.ReportSection.ReportPageHeader,
CultureInfo.InvariantCulture);
this.sectionBounds.MeasurePageHeader(this.CurrentSection);
//Detail
sectionInUse = Convert.ToInt16(GlobalEnums.ReportSection.ReportDetail,
CultureInfo.InvariantCulture);
sectionBounds.DetailSectionRectangle = new Rectangle(this.CurrentSection.Location,this.CurrentSection.Size);
//PageFooter
sectionInUse = Convert.ToInt16(GlobalEnums.ReportSection.ReportPageFooter,
CultureInfo.InvariantCulture);
this.sectionBounds.MeasurePageFooter (this.CurrentSection);
//ReportFooter
sectionInUse = Convert.ToInt16(GlobalEnums.ReportSection.ReportFooter,
CultureInfo.InvariantCulture);
this.sectionBounds.MeasureReportFooter(this.CurrentSection);
this.sectionBounds.MeasureDetailArea();
}
private void ReportPageStart (object sender, PrintPageEventArgs ppea)
{
System.Diagnostics.Trace.WriteLine("ReportPageStart");
if (this.sectionBounds == null) {
throw new ArgumentException("page");
}
this.CalculatePageBounds ();
this.SinglePage.CalculatePageBounds(this.reportModel);
}
internal virtual void ReportQueryPage (object sender,QueryPageSettingsEventArgs qpea)
{
qpea.PageSettings.Margins = new Margins(reportSettings.LeftMargin,reportSettings.RightMargin,reportSettings.TopMargin,reportSettings.BottomMargin);
bool firstPage;
if (this.currentPageNumber == 0) {
@ -313,9 +275,8 @@ namespace ICSharpCode.Reports.Core @@ -313,9 +275,8 @@ namespace ICSharpCode.Reports.Core
} else {
firstPage = false;
}
this.sectionBounds = new SectionBounds (reportSettings,firstPage);
this.currentPageNumber ++;
ISinglePage sp = new SinglePage(this.sectionBounds,0);
ISinglePage sp = new SinglePage(new SectionBounds (reportSettings,firstPage),0);
PrintHelper.InitPage(sp,this.reportSettings);
sp.PageNumber = this.currentPageNumber;
reportDocument.SinglePage = sp;
@ -334,90 +295,36 @@ namespace ICSharpCode.Reports.Core @@ -334,90 +295,36 @@ namespace ICSharpCode.Reports.Core
#endregion
#region property's
public ReportDocument ReportDocument
{
get {
return reportDocument;
}
}
public ReportDocument ReportDocument {get {return this.reportDocument;}}
public ReportSettings ReportSettings
{
get {
return reportSettings;
}
}
public ReportSettings ReportSettings {get {return reportSettings;}}
public ReportSectionCollection Sections
{
get {
return sections;
}
}
public ReportSectionCollection Sections {get {return this.sections;}}
public bool Cancel
{
get {
return cancel;
}
set {
cancel = value;
}
}
public ISinglePage SinglePage {
get { return this.reportDocument.SinglePage; }
}
public bool Cancel {get;set;}
protected int SectionInUse
{
get {
return sectionInUse;
}
set {
sectionInUse = value;
}
}
public ISinglePage SinglePage {get { return this.reportDocument.SinglePage; }}
protected int CurrentRow {get;set;}
protected int CurrentRow {
get { return currentRow; }
set { currentRow = value; }
}
protected BaseSection CurrentSection {get;set;}
protected BaseSection CurrentSection
{
get {
return (BaseSection)sections[sectionInUse];
}
}
protected SectionBounds SectionBounds { get {return this.SinglePage.SectionBounds;}}
protected SectionBounds SectionBounds
{
get {
return sectionBounds;
}
set {
sectionBounds = value;
}
}
protected IExpressionEvaluatorFacade ExpressionFassade {
get { return expressionFassade; }
}
protected IExpressionEvaluatorFacade ExpressionFassade {get { return expressionFassade; }}
protected ILayouter Layout
{get {return this.layout;}}
protected ILayouter Layout {get {return this.layout;}}
#endregion

2
src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/Printing/RenderDataReport.cs

@ -160,7 +160,7 @@ namespace ICSharpCode.Reports.Core { @@ -160,7 +160,7 @@ namespace ICSharpCode.Reports.Core {
if (rpea.SinglePage.PageNumber == 1) {
tableContainer.StartLayoutAt(base.Sections[2]);
} else {
tableContainer.StartLayoutAt(base.Sections[1]);
tableContainer.StartLayoutAt(base.Sections[0]);
}
tableContainer.RenderTable(base.CurrentSection,this.SectionBounds,rpea,this.Layout);

2
src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/ReportViewer/ReportViewer.cs

@ -233,7 +233,7 @@ namespace ICSharpCode.Reports.Core.ReportViewer @@ -233,7 +233,7 @@ namespace ICSharpCode.Reports.Core.ReportViewer
}
private void PushPrinting (object sender, SectionRenderEventArgs e ) {
// Console.WriteLine ("ReportViewer - SectionRenderEventargs from <{0}> with {1} items ",e.Section.Name,e.Section.Items.Count);
Console.WriteLine ("ReportViewer - SectionRenderEventargs from <{0}> with {1} item ",e.Section.Name,e.Section.Items.Count);
EventHelper.Raise<SectionRenderEventArgs>(SectionRendering,this,e);
}

Loading…
Cancel
Save