Browse Source

Modified samples

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1531 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Peter Forstmeier 19 years ago
parent
commit
79831637b7
  1. 34
      samples/SharpReport/ReportSamples/MainForm.Designer.cs
  2. 64
      samples/SharpReport/ReportSamples/MainForm.cs
  3. 104
      samples/SharpReport/ReportSamples/MultipageUnboundPullModel.cs
  4. 2
      samples/SharpReport/ReportSamples/ReportSamples.csproj
  5. 98
      samples/SharpReport/ReportSamples/SimpleUnboundPullModel.cs
  6. 1
      samples/SharpReport/Unbound/MultiPageUnboundPullModel.srd
  7. 1
      samples/SharpReport/Unbound/UnboundPullModel.srd
  8. 11
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractRenderer.cs
  9. 2
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs
  10. 46
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderFormSheetReport.cs
  11. 1
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/ReportDocument.cs

34
samples/SharpReport/ReportSamples/MainForm.Designer.cs generated

@ -46,9 +46,11 @@ namespace ReportSamples @@ -46,9 +46,11 @@ namespace ReportSamples
this.missingConnectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.pushModelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.emlpoyeesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.errorProvider1 = new System.Windows.Forms.ErrorProvider(this.components);
this.unboundToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.unboundToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.unboundPullModelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.errorProvider1 = new System.Windows.Forms.ErrorProvider(this.components);
this.multipageUnboundPullModelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.errorProvider1)).BeginInit();
this.SuspendLayout();
@ -127,14 +129,12 @@ namespace ReportSamples @@ -127,14 +129,12 @@ namespace ReportSamples
this.emlpoyeesToolStripMenuItem.Text = "Employees-Push";
this.emlpoyeesToolStripMenuItem.Click += new System.EventHandler(this.EmployeesPushClick);
//
// errorProvider1
//
this.errorProvider1.ContainerControl = this;
//
// unboundToolStripMenuItem
//
this.unboundToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.unboundToolStripMenuItem1});
this.unboundToolStripMenuItem1,
this.unboundPullModelToolStripMenuItem,
this.multipageUnboundPullModelToolStripMenuItem});
this.unboundToolStripMenuItem.Name = "unboundToolStripMenuItem";
this.unboundToolStripMenuItem.Size = new System.Drawing.Size(62, 20);
this.unboundToolStripMenuItem.Text = "Unbound";
@ -142,10 +142,28 @@ namespace ReportSamples @@ -142,10 +142,28 @@ namespace ReportSamples
// unboundToolStripMenuItem1
//
this.unboundToolStripMenuItem1.Name = "unboundToolStripMenuItem1";
this.unboundToolStripMenuItem1.Size = new System.Drawing.Size(152, 22);
this.unboundToolStripMenuItem1.Size = new System.Drawing.Size(218, 22);
this.unboundToolStripMenuItem1.Text = "Unbound";
this.unboundToolStripMenuItem1.Click += new System.EventHandler(this.UnboundToolStripMenuItem1Click);
//
// unboundPullModelToolStripMenuItem
//
this.unboundPullModelToolStripMenuItem.Name = "unboundPullModelToolStripMenuItem";
this.unboundPullModelToolStripMenuItem.Size = new System.Drawing.Size(218, 22);
this.unboundPullModelToolStripMenuItem.Text = "UnboundPullModel";
this.unboundPullModelToolStripMenuItem.Click += new System.EventHandler(this.UnboundPullModelToolStripMenuItemClick);
//
// errorProvider1
//
this.errorProvider1.ContainerControl = this;
//
// multipageUnboundPullModelToolStripMenuItem
//
this.multipageUnboundPullModelToolStripMenuItem.Name = "multipageUnboundPullModelToolStripMenuItem";
this.multipageUnboundPullModelToolStripMenuItem.Size = new System.Drawing.Size(218, 22);
this.multipageUnboundPullModelToolStripMenuItem.Text = "MultipageUnboundPullModel";
this.multipageUnboundPullModelToolStripMenuItem.Click += new System.EventHandler(this.MultipageUnboundPullModelToolStripMenuItemClick);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -161,6 +179,8 @@ namespace ReportSamples @@ -161,6 +179,8 @@ namespace ReportSamples
this.ResumeLayout(false);
this.PerformLayout();
}
private System.Windows.Forms.ToolStripMenuItem multipageUnboundPullModelToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem unboundPullModelToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem unboundToolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem unboundToolStripMenuItem;
private System.Windows.Forms.ErrorProvider errorProvider1;

64
samples/SharpReport/ReportSamples/MainForm.cs

@ -85,6 +85,7 @@ namespace ReportSamples @@ -85,6 +85,7 @@ namespace ReportSamples
}
}
#region unbound
private void OpenUnbound() {
try{
OpenFileDialog dg = new OpenFileDialog();
@ -92,8 +93,8 @@ namespace ReportSamples @@ -92,8 +93,8 @@ namespace ReportSamples
dg.Title = "Select a report file: ";
if (dg.ShowDialog() == DialogResult.OK){
SharpReportCore.SharpReportEngine mn = new SharpReportCore.SharpReportEngine();
mn.SectionRendering += new EventHandler<SectionRenderEventArgs>(OnTestPrinting);
mn.SectionRendered += new EventHandler<SectionRenderEventArgs>(OnTestPrinted);
mn.SectionRendering += new EventHandler<SectionRenderEventArgs>(UnboundPrinting);
mn.SectionRendered += new EventHandler<SectionRenderEventArgs>(UnboundPrinted);
mn.PreviewStandartReport(dg.FileName.ToString());
}
@ -103,18 +104,19 @@ namespace ReportSamples @@ -103,18 +104,19 @@ namespace ReportSamples
}
}
private void OnTestPrinting (object sender,SectionRenderEventArgs e) {
System.Console.WriteLine("");
System.Console.WriteLine("--------------");
System.Console.WriteLine("MainForm:OnTestPrinting on PageNr <{0}>",e.PageNumber);
System.Console.WriteLine("\t SectionInUse <{0}>",e.CurrentSection);
System.Console.WriteLine("\t <{0}> Items",e.Section.Items.Count);
private void UnboundPrinting (object sender,SectionRenderEventArgs e) {
// System.Console.WriteLine("");
// System.Console.WriteLine("--------------");
// System.Console.WriteLine("MainForm:OnTestPrinting <{0}> for PageNr <{1}>",e.CurrentSection,e.PageNumber);
// System.Console.WriteLine("\t <{0}> Items",e.Section.Items.Count);
//
//
switch (e.CurrentSection) {
case GlobalEnums.enmSection.ReportHeader:
System.Console.WriteLine("I found the ReportHeader");
System.Console.WriteLine("\tI found the ReportHeader");
break;
case GlobalEnums.enmSection.ReportPageHeader:
BaseTextItem t = (BaseTextItem)e.Section.Items.Find("reportTextItem1");
@ -131,13 +133,23 @@ namespace ReportSamples @@ -131,13 +133,23 @@ namespace ReportSamples
bb.DbValue = "Hello World";
}
System.Console.WriteLine("I found the Pageheader");
System.Console.WriteLine("\tI found the Pageheader");
break;
case GlobalEnums.enmSection.ReportDetail:
System.Console.WriteLine("I found the ReportDetail");
System.Console.WriteLine("\tI found the ReportDetail");
BaseDataItem bdi = (BaseDataItem)e.Section.Items.Find("reportDbTextItem1");
if (bdi != null) {
bdi.BackColor = Color.LightGray;
bdi.Location = new Point(200,5);
bdi.DbValue = "Unbound Field in DetailSection";
}
break;
case GlobalEnums.enmSection.ReportPageFooter:
System.Console.WriteLine("I found the PageFooter");
System.Console.WriteLine("\tI found the PageFooter");
BaseReportItem b = (BaseReportItem)e.Section.Items.Find("pageNumber1");
if (b != null) {
b.BackColor = Color.AliceBlue;
@ -146,21 +158,26 @@ namespace ReportSamples @@ -146,21 +158,26 @@ namespace ReportSamples
MessageBox.Show (s);
}
break;
case GlobalEnums.enmSection.ReportFooter:
System.Console.WriteLine("I found the ReportFooter");
System.Console.WriteLine("\tI found the ReportFooter");
break;
default:
default:
break;
}
System.Console.WriteLine("");
}
private void OnTestPrinted (object sender,SectionRenderEventArgs e) {
System.Console.WriteLine("MainForm:OnTestPrinted for <{0}>",e.CurrentSection);
private void UnboundPrinted (object sender,SectionRenderEventArgs e) {
// System.Console.WriteLine("MainForm:Rendering done for <{0}>",e.CurrentSection);
System.Console.WriteLine("----------");
}
#endregion
///<summary>Preferd Method to initialise the <see cref="SharpReportCore.ConnectionObject"></see>
/// hav a look to
/// <http://msdn2.microsoft.com/en-us/library/system.data.oledb.oledbconnectionstringbuilder(VS.80).aspx>
@ -275,5 +292,16 @@ namespace ReportSamples @@ -275,5 +292,16 @@ namespace ReportSamples
{
this.OpenUnbound();
}
void UnboundPullModelToolStripMenuItemClick(object sender, System.EventArgs e){
SimpleUnboundPullModel sm = new SimpleUnboundPullModel();
sm.Run();
}
void MultipageUnboundPullModelToolStripMenuItemClick(object sender, System.EventArgs e)
{
MultiPageUnboundPullModel mp = new MultiPageUnboundPullModel();
mp.Run();
}
}
}

104
samples/SharpReport/ReportSamples/MultipageUnboundPullModel.cs

@ -0,0 +1,104 @@ @@ -0,0 +1,104 @@
/*
* Created by SharpDevelop.
* User: Forstmeier Helmut
* Date: 29.06.2006
* Time: 13:02
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Windows.Forms;
using SharpReportCore;
namespace ReportSamples{
/// <summary>
/// Description of MultipageUnboundPullModel.
/// </summary>
public class MultiPageUnboundPullModel{
int rowNr;
int rowsPerPage;
int pageNr;
public MultiPageUnboundPullModel(){
}
public void Run() {
try{
OpenFileDialog dg = new OpenFileDialog();
dg.Filter = "SharpReport files|*.srd";
dg.Title = "Select a report file: ";
if (dg.ShowDialog() == DialogResult.OK){
SharpReportCore.SharpReportEngine mn = new SharpReportCore.SharpReportEngine();
mn.SectionRendering += new EventHandler<SectionRenderEventArgs>(MultipagePrinting);
mn.SectionRendered += new EventHandler<SectionRenderEventArgs>(MultipagePrinted);
mn.PreviewStandartReport(dg.FileName.ToString());
}
}
catch(Exception er){
MessageBox.Show(er.ToString(),"MainForm");
}
}
private void MultipagePrinting (object sender,SectionRenderEventArgs e) {
System.Console.WriteLine("UnboundPullPrinting");
CheckItems(e.Section.Items);
switch (e.CurrentSection) {
case GlobalEnums.enmSection.ReportHeader:
System.Console.WriteLine("\tI found the ReportHeader");
break;
case GlobalEnums.enmSection.ReportPageHeader:
System.Console.WriteLine("\tI found the Pageheader");
this.rowsPerPage = 0;
break;
case GlobalEnums.enmSection.ReportDetail:
System.Console.WriteLine("\tI found the ReportDetail");
this.rowNr ++;
this.rowsPerPage ++;
RowItem ri = e.Section.Items[0] as RowItem;
if (ri != null) {
if (this.rowNr %2 == 0) {
ri.DrawBorder = true;
} else {
ri.DrawBorder = false;
}
}
break;
case GlobalEnums.enmSection.ReportPageFooter:
System.Console.WriteLine("\tI found the PageFooter");
BaseDataItem bdi = e.Section.Items.Find("ItemsPerPage") as BaseDataItem;
if (bdi != null) {
bdi.DbValue = this.rowsPerPage.ToString();
}
break;
case GlobalEnums.enmSection.ReportFooter:
System.Console.WriteLine("\tI found the ReportFooter");
break;
default:
break;
}
}
private void MultipagePrinted (object sender,SectionRenderEventArgs e) {
//// System.Console.WriteLine("MainForm:Rendering done for <{0}>",e.CurrentSection);
// System.Console.WriteLine("----------");
}
private void CheckItems (ReportItemCollection items) {
System.Console.WriteLine("\t<{0}> Items",items.Count );
foreach (BaseReportItem i in items) {
IContainerItem container = i as IContainerItem;
if (container != null) {
System.Console.WriteLine("\t\tContainer found");
CheckItems (container.Items);
}
}
}
}
}

2
samples/SharpReport/ReportSamples/ReportSamples.csproj

@ -48,6 +48,8 @@ @@ -48,6 +48,8 @@
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
<Compile Include="SimpleUnboundPullModel.cs" />
<Compile Include="MultipageUnboundPullModel.cs" />
</ItemGroup>
<ItemGroup>
<COMReference Include="Microsoft ActiveX Data Objects 2.7 Library">

98
samples/SharpReport/ReportSamples/SimpleUnboundPullModel.cs

@ -0,0 +1,98 @@ @@ -0,0 +1,98 @@
/*
* Created by SharpDevelop.
* User: Forstmeier Helmut
* Date: 29.06.2006
* Time: 09:21
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Drawing;
using System.Windows.Forms;
using SharpReportCore;
namespace ReportSamples
{
/// <summary>
/// Description of SimpleUnboundPullModel.
/// </summary>
public class SimpleUnboundPullModel{
int rowNr;
public SimpleUnboundPullModel(){
}
public void Run() {
try{
OpenFileDialog dg = new OpenFileDialog();
dg.Filter = "SharpReport files|*.srd";
dg.Title = "Select a report file: ";
if (dg.ShowDialog() == DialogResult.OK){
SharpReportCore.SharpReportEngine mn = new SharpReportCore.SharpReportEngine();
mn.SectionRendering += new EventHandler<SectionRenderEventArgs>(SimplePullPrinting);
mn.SectionRendered += new EventHandler<SectionRenderEventArgs>(SimplePullPrinted);
mn.PreviewStandartReport(dg.FileName.ToString());
}
}
catch(Exception er){
MessageBox.Show(er.ToString(),"MainForm");
}
}
private void SimplePullPrinting (object sender,SectionRenderEventArgs e) {
System.Console.WriteLine("UnboundPullPrinting");
CheckItems(e.Section.Items);
switch (e.CurrentSection) {
case GlobalEnums.enmSection.ReportHeader:
System.Console.WriteLine("\tI found the ReportHeader");
break;
case GlobalEnums.enmSection.ReportPageHeader:
System.Console.WriteLine("\tI found the Pageheader");
break;
case GlobalEnums.enmSection.ReportDetail:
System.Console.WriteLine("\tI found the ReportDetail");
this.rowNr ++;
RowItem ri = e.Section.Items[0] as RowItem;
if (ri != null) {
if (this.rowNr %2 == 0) {
ri.DrawBorder = true;
} else {
ri.DrawBorder = false;
}
}
break;
case GlobalEnums.enmSection.ReportPageFooter:
System.Console.WriteLine("\tI found the PageFooter");
break;
case GlobalEnums.enmSection.ReportFooter:
System.Console.WriteLine("\tI found the ReportFooter");
break;
default:
break;
}
}
private void SimplePullPrinted (object sender,SectionRenderEventArgs e) {
//// System.Console.WriteLine("MainForm:Rendering done for <{0}>",e.CurrentSection);
// System.Console.WriteLine("----------");
}
private void CheckItems (ReportItemCollection items) {
System.Console.WriteLine("\t<{0}> Items",items.Count );
foreach (BaseReportItem i in items) {
IContainerItem container = i as IContainerItem;
if (container != null) {
System.Console.WriteLine("\t\tContainer found");
CheckItems (container.Items);
}
}
}
}
}

1
samples/SharpReport/Unbound/MultiPageUnboundPullModel.srd

File diff suppressed because one or more lines are too long

1
samples/SharpReport/Unbound/UnboundPullModel.srd

File diff suppressed because one or more lines are too long

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

@ -65,7 +65,7 @@ namespace SharpReportCore { @@ -65,7 +65,7 @@ namespace SharpReportCore {
reportDocument.QueryPageSettings += new QueryPageSettingsEventHandler (ReportQueryPage);
reportDocument.BeginPrint += new PrintEventHandler(ReportBegin);
reportDocument.EndPrint += new PrintEventHandler(ReportEnd);
reportDocument.PrintPage += new PrintPageEventHandler(testPageStart);
// homemade events
reportDocument.PrintPageBodyStart += new EventHandler<ReportPageEventArgs> (BodyStart);
@ -234,6 +234,7 @@ namespace SharpReportCore { @@ -234,6 +234,7 @@ namespace SharpReportCore {
if (rpea == null) {
throw new ArgumentNullException("rpea");
}
System.Console.WriteLine("MeasurePageHeader");
sectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportPageHeader,
CultureInfo.InvariantCulture);
@ -248,13 +249,15 @@ namespace SharpReportCore { @@ -248,13 +249,15 @@ namespace SharpReportCore {
this.CurrentSection.SectionOffset + this.CurrentSection.Size.Height + Gap);
}
protected PointF MeasurePageEnd (ReportPageEventArgs e) {
protected PointF MeasurePageFooter (ReportPageEventArgs e) {
System.Console.WriteLine("MeasurePageFooter");
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);
// return this.DetailEnds;
}
@ -382,7 +385,9 @@ namespace SharpReportCore { @@ -382,7 +385,9 @@ namespace SharpReportCore {
#region virtuals
protected virtual void testPageStart (object sender, PrintPageEventArgs e) {
System.Console.WriteLine("PAGESTART");
}
protected virtual void ReportQueryPage (object sender,QueryPageSettingsEventArgs qpea) {
qpea.PageSettings.Margins = reportSettings.DefaultMargins;
}

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

@ -93,7 +93,7 @@ namespace SharpReportCore { @@ -93,7 +93,7 @@ namespace SharpReportCore {
private void DoPageEnd (ReportPageEventArgs rpea){
// System.Console.WriteLine("DataRenderer:DoPageEnd");
base.MeasurePageEnd (rpea);
base.MeasurePageFooter (rpea);
base.RenderSection (rpea);
base.DoItems(rpea);
}

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

@ -49,6 +49,7 @@ namespace SharpReportCore { @@ -49,6 +49,7 @@ namespace SharpReportCore {
#region Draw the different report Sections
private PointF DoReportHeader (ReportPageEventArgs rpea){
System.Console.WriteLine("\t ReportHeader");
PointF endAt = base.MeasureReportHeader (rpea);
base.RenderSection (rpea);
@ -61,21 +62,24 @@ namespace SharpReportCore { @@ -61,21 +62,24 @@ namespace SharpReportCore {
}
private PointF DoPageHeader (PointF startAt,ReportPageEventArgs rpea){
System.Console.WriteLine("\t PageHeader");
PointF endAt = base.MeasurePageHeader (startAt,rpea);
base.RenderSection (rpea);
return endAt;
}
private void DoPageEnd (ReportPageEventArgs rpea){
base.PrintPageEnd(this,rpea);
base.MeasurePageEnd (rpea);
base.MeasurePageFooter (rpea);
base.RenderSection (rpea);
}
//TODO how should we handle ReportFooter, print it on an seperate page ????
private void DoReportFooter (PointF startAt,ReportPageEventArgs rpea){
System.Console.WriteLine("\t ReportFooter");
base.MeasureReportFooter(rpea);
base.RenderSection (rpea);
this.RemoveSectionEvents();
@ -83,19 +87,44 @@ namespace SharpReportCore { @@ -83,19 +87,44 @@ namespace SharpReportCore {
#endregion
#region test
#region print all the sections
protected override void PrintReportHeader (object sender, ReportPageEventArgs e) {
System.Console.WriteLine("PRINT REPORTHEADER");
base.PrintReportHeader (sender,e);
this.currentPoint = DoReportHeader (e);
}
protected override void PrintPageHeader (object sender, ReportPageEventArgs e) {
System.Console.WriteLine("PRINT PAGEHEDER");
base.PrintPageHeader (sender,e);
this.currentPoint = DoPageHeader (this.currentPoint,e);
base.DetailStart = new Point ((int)currentPoint.X,(int)currentPoint.Y);
}
protected override void PrintDetail(object sender, ReportPageEventArgs rpea){
base.PrintDetail(sender, rpea);
System.Console.WriteLine("PRINT DETAIL");
base.RenderSection(rpea);
base.RemoveSectionEvents();
}
protected override void PrintReportFooter(object sender, ReportPageEventArgs rpea){
System.Console.WriteLine("PRINT REPORTFOOTER");
base.PrintReportFooter(sender, rpea);
base.RenderSection(rpea);
base.RemoveSectionEvents();
}
/// <summary>
/// Print the PageFooter
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected override void PrintPageEnd(object sender, ReportPageEventArgs rpea) {
System.Console.WriteLine("PRINTPAGEEND");
this.DoPageEnd (rpea);
}
#endregion
@ -115,15 +144,6 @@ namespace SharpReportCore { @@ -115,15 +144,6 @@ namespace SharpReportCore {
base.RenderSection (rpea);
}
/// <summary>
/// Print the PageFooter
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected override void PrintPageEnd(object sender, ReportPageEventArgs rpea) {
this.DoPageEnd (rpea);
}
protected override void OnBodyEnd (object sender,ReportPageEventArgs rpea) {

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

@ -65,6 +65,7 @@ namespace SharpReportCore { @@ -65,6 +65,7 @@ namespace SharpReportCore {
}
}
protected override void OnEndPrint(PrintEventArgs e){
base.OnEndPrint(e);
}

Loading…
Cancel
Save