38 changed files with 987 additions and 503 deletions
@ -0,0 +1,127 @@ |
|||||||
|
/* |
||||||
|
* Created by SharpDevelop. |
||||||
|
* User: Peter Forstmeier |
||||||
|
* Date: 03.10.2010 |
||||||
|
* Time: 17:26 |
||||||
|
* |
||||||
|
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||||
|
*/ |
||||||
|
|
||||||
|
using System; |
||||||
|
using ICSharpCode.Reports.Addin.ReportWizard; |
||||||
|
using ICSharpCode.Reports.Core; |
||||||
|
using NUnit.Framework; |
||||||
|
|
||||||
|
namespace ICSharpCode.Reports.Addin.Test.Wizard.Generators |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class GenertaeTableWithGroupFixture |
||||||
|
{ |
||||||
|
|
||||||
|
private const string reportName = "TableBasedReport"; |
||||||
|
private ReportModel reportModel; |
||||||
|
|
||||||
|
|
||||||
|
[Test] |
||||||
|
public void PageDetail_First_Item_Should_Table() |
||||||
|
{ |
||||||
|
ICSharpCode.Reports.Core.BaseSection s = this.reportModel.DetailSection; |
||||||
|
var item = s.Items[0]; |
||||||
|
Assert.That(item,Is.InstanceOf(typeof(ICSharpCode.Reports.Core.BaseTableItem))); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Table_Should_Contain_Three_Rows() |
||||||
|
{ |
||||||
|
ICSharpCode.Reports.Core.BaseSection s = this.reportModel.DetailSection; |
||||||
|
ICSharpCode.Reports.Core.BaseTableItem table = s.Items[0] as ICSharpCode.Reports.Core.BaseTableItem; |
||||||
|
Assert.That(table.Items.Count,Is.GreaterThanOrEqualTo(3)); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Table_FirstItem_Should_Row () |
||||||
|
{ |
||||||
|
ICSharpCode.Reports.Core.BaseSection s = this.reportModel.DetailSection; |
||||||
|
ICSharpCode.Reports.Core.BaseTableItem table = s.Items[0] as ICSharpCode.Reports.Core.BaseTableItem; |
||||||
|
var row = table.Items[0]; |
||||||
|
Assert.That(row,Is.InstanceOf(typeof(ICSharpCode.Reports.Core.BaseRowItem))); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Table_SecondItem_Should_GroupRow () |
||||||
|
{ |
||||||
|
ICSharpCode.Reports.Core.BaseSection s = this.reportModel.DetailSection; |
||||||
|
ICSharpCode.Reports.Core.BaseTableItem table = s.Items[0] as ICSharpCode.Reports.Core.BaseTableItem; |
||||||
|
var row = table.Items[1]; |
||||||
|
Assert.That(row,Is.InstanceOf(typeof(ICSharpCode.Reports.Core.BaseGroupedRow))); |
||||||
|
} |
||||||
|
|
||||||
|
#region setup / TearDown
|
||||||
|
|
||||||
|
[TestFixtureSetUp] |
||||||
|
public void Init() |
||||||
|
{ |
||||||
|
this.reportModel = CreateModel(reportName); |
||||||
|
} |
||||||
|
|
||||||
|
[TestFixtureTearDown] |
||||||
|
public void Dispose() |
||||||
|
{ |
||||||
|
// TODO: Add tear down code.
|
||||||
|
} |
||||||
|
|
||||||
|
private static ReportModel CreateModel (string reportName) |
||||||
|
{ |
||||||
|
|
||||||
|
ReportStructure structure = CreateReportStructure(reportName); |
||||||
|
|
||||||
|
AvailableFieldsCollection abstractColumns = new AvailableFieldsCollection(); |
||||||
|
AbstractColumn a1 = new AbstractColumn("Field1",typeof(System.String)); |
||||||
|
structure.AvailableFieldsCollection.Add(a1); |
||||||
|
|
||||||
|
ICSharpCode.Reports.Core.BaseDataItem bri = new ICSharpCode.Reports.Core.BaseDataItem(); |
||||||
|
bri.Name ="Field1"; |
||||||
|
structure.ReportItemCollection.Add(bri); |
||||||
|
|
||||||
|
structure.Grouping = "group"; |
||||||
|
|
||||||
|
ReportModel m = structure.CreateAndFillReportModel(); |
||||||
|
|
||||||
|
ICSharpCode.Core.Properties customizer = new ICSharpCode.Core.Properties(); |
||||||
|
|
||||||
|
customizer.Set("Generator", structure); |
||||||
|
customizer.Set("ReportLayout",GlobalEnums.ReportLayout.TableLayout); |
||||||
|
|
||||||
|
IReportGenerator generator = new GeneratePushDataReport(m,customizer); |
||||||
|
|
||||||
|
generator.GenerateReport(); |
||||||
|
|
||||||
|
ReportLoader rl = new ReportLoader(); |
||||||
|
object root = rl.Load(generator.XmlReport.DocumentElement); |
||||||
|
ReportModel model = root as ReportModel; |
||||||
|
if (model != null) { |
||||||
|
model.ReportSettings.FileName = GlobalValues.PlainFileName; |
||||||
|
FilePathConverter.AdjustReportName(model); |
||||||
|
} else { |
||||||
|
throw new InvalidReportModelException(); |
||||||
|
} |
||||||
|
return model; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private static ReportStructure CreateReportStructure (string reportName) |
||||||
|
{ |
||||||
|
ReportStructure structure = new ReportStructure(); |
||||||
|
structure.ReportName = reportName; |
||||||
|
structure.DataModel = GlobalEnums.PushPullModel.PushData; |
||||||
|
structure.ReportType = GlobalEnums.ReportType.DataReport; |
||||||
|
return structure; |
||||||
|
} |
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,203 @@ |
|||||||
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Collections.ObjectModel; |
||||||
|
using System.Drawing; |
||||||
|
using System.Linq; |
||||||
|
|
||||||
|
using ICSharpCode.Reports.Core.BaseClasses.Printing; |
||||||
|
using ICSharpCode.Reports.Core.Interfaces; |
||||||
|
|
||||||
|
namespace ICSharpCode.Reports.Core.Exporter |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Description of TableConverter.
|
||||||
|
/// </summary>
|
||||||
|
public class GroupedTableConverter:BaseConverter |
||||||
|
{ |
||||||
|
|
||||||
|
private ITableContainer table; |
||||||
|
|
||||||
|
public GroupedTableConverter(IDataNavigator dataNavigator, |
||||||
|
ExporterPage singlePage, ILayouter layouter ):base(dataNavigator,singlePage,layouter) |
||||||
|
|
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public override ExporterCollection Convert (BaseReportItem parent,BaseReportItem item) |
||||||
|
{ |
||||||
|
if (parent == null) { |
||||||
|
throw new ArgumentNullException("parent"); |
||||||
|
} |
||||||
|
if (item == null) { |
||||||
|
throw new ArgumentNullException("item"); |
||||||
|
} |
||||||
|
|
||||||
|
ExporterCollection mylist = base.Convert(parent,item); |
||||||
|
this.table = (BaseTableItem)item ; |
||||||
|
this.table.Parent = parent; |
||||||
|
this.table.DataNavigator = base.DataNavigator; |
||||||
|
return ConvertInternal(mylist); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private ExporterCollection ConvertInternal(ExporterCollection exporterCollection) |
||||||
|
{ |
||||||
|
|
||||||
|
BaseSection section = table.Parent as BaseSection; |
||||||
|
|
||||||
|
base.CurrentPosition = new Point(PrintHelper.DrawingAreaRelativeToParent(this.table.Parent,this.table).Location.X, |
||||||
|
base.SectionBounds.DetailStart.Y); |
||||||
|
int defaultLeftPos = base.CurrentPosition.X; |
||||||
|
|
||||||
|
Point dataAreaStart = new Point(table.Items[0].Location.X,table.Items[0].Location.Y + base.CurrentPosition.Y); |
||||||
|
|
||||||
|
ISimpleContainer headerRow = null; |
||||||
|
Rectangle pageBreakRect = Rectangle.Empty; |
||||||
|
this.table.Items.SortByLocation(); |
||||||
|
|
||||||
|
// Header
|
||||||
|
|
||||||
|
var simpleContainer = table.Items[0] as ISimpleContainer; |
||||||
|
|
||||||
|
if (simpleContainer.Items.Count > 0) |
||||||
|
{ |
||||||
|
simpleContainer.Location = new Point (simpleContainer.Location.X,simpleContainer.Location.Y); |
||||||
|
simpleContainer.Parent = (BaseReportItem)this.table; |
||||||
|
|
||||||
|
base.SaveSectionSize( new Size (simpleContainer.Size.Width,simpleContainer.Size.Height)); |
||||||
|
|
||||||
|
if (PrintHelper.IsTextOnlyRow(simpleContainer) ) { |
||||||
|
headerRow = simpleContainer; |
||||||
|
base.CurrentPosition = BaseConverter.BaseConvert(exporterCollection,headerRow,defaultLeftPos,base.CurrentPosition); |
||||||
|
} |
||||||
|
|
||||||
|
BaseGroupedRow row = table.Items[1] as BaseGroupedRow; |
||||||
|
|
||||||
|
if (row != null) { |
||||||
|
|
||||||
|
//grouped
|
||||||
|
do { |
||||||
|
|
||||||
|
// GetType child navigator
|
||||||
|
IDataNavigator childNavigator = base.DataNavigator.GetChildNavigator(); |
||||||
|
|
||||||
|
base.Evaluator.SinglePage.IDataNavigator = childNavigator; |
||||||
|
// Convert Grouping Header
|
||||||
|
|
||||||
|
base.CurrentPosition = ConvertGroupHeader(exporterCollection,section,defaultLeftPos,base.CurrentPosition); |
||||||
|
|
||||||
|
childNavigator.Reset(); |
||||||
|
childNavigator.MoveNext(); |
||||||
|
|
||||||
|
//Convert children
|
||||||
|
if (childNavigator != null) { |
||||||
|
do |
||||||
|
{ |
||||||
|
StandardPrinter.AdjustBackColor(simpleContainer,GlobalValues.DefaultBackColor); |
||||||
|
simpleContainer = table.Items[2] as ISimpleContainer; |
||||||
|
|
||||||
|
childNavigator.Fill(simpleContainer.Items); |
||||||
|
|
||||||
|
base.CurrentPosition = ConvertGroupChilds (exporterCollection, |
||||||
|
section, |
||||||
|
simpleContainer,defaultLeftPos,base.CurrentPosition); |
||||||
|
pageBreakRect = PrintHelper.CalculatePageBreakRectangle((BaseReportItem)simpleContainer,base.CurrentPosition); |
||||||
|
|
||||||
|
if (PrintHelper.IsPageFull(pageBreakRect,base.SectionBounds)) |
||||||
|
{ |
||||||
|
base.CurrentPosition = base.ForcePageBreak(exporterCollection,section); |
||||||
|
base.CurrentPosition = ConvertStandardRow (exporterCollection,section,headerRow,defaultLeftPos,base.CurrentPosition); |
||||||
|
} |
||||||
|
} |
||||||
|
while ( childNavigator.MoveNext()); |
||||||
|
|
||||||
|
if (PageBreakAfterGroupChange(table) ) |
||||||
|
{ |
||||||
|
if ( base.DataNavigator.HasMoreData) |
||||||
|
{ |
||||||
|
base.CurrentPosition = base.ForcePageBreak(exporterCollection,section); |
||||||
|
base.CurrentPosition = ConvertStandardRow (exporterCollection,section,headerRow,defaultLeftPos,base.CurrentPosition); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
base.Evaluator.SinglePage.IDataNavigator = base.DataNavigator; |
||||||
|
} |
||||||
|
} |
||||||
|
while (base.DataNavigator.MoveNext()); |
||||||
|
} |
||||||
|
|
||||||
|
else |
||||||
|
{ |
||||||
|
// No Grouping at all
|
||||||
|
|
||||||
|
base.SaveSectionSize(simpleContainer.Size); |
||||||
|
simpleContainer = table.Items[1] as ISimpleContainer; |
||||||
|
|
||||||
|
do { |
||||||
|
|
||||||
|
PrintHelper.AdjustSectionLocation(section); |
||||||
|
|
||||||
|
pageBreakRect = PrintHelper.CalculatePageBreakRectangle((BaseReportItem)simpleContainer,base.CurrentPosition); |
||||||
|
|
||||||
|
if (PrintHelper.IsPageFull(pageBreakRect,base.SectionBounds)) |
||||||
|
{ |
||||||
|
base.CurrentPosition = base.ForcePageBreak(exporterCollection,section); |
||||||
|
base.CurrentPosition = ConvertStandardRow (exporterCollection,section,headerRow,defaultLeftPos,base.CurrentPosition); |
||||||
|
} |
||||||
|
|
||||||
|
base.CurrentPosition = ConvertStandardRow (exporterCollection,section,simpleContainer,defaultLeftPos,base.CurrentPosition); |
||||||
|
|
||||||
|
simpleContainer.Size = base.RestoreSize; |
||||||
|
} |
||||||
|
while (base.DataNavigator.MoveNext()); |
||||||
|
|
||||||
|
base.DataNavigator.Reset(); |
||||||
|
base.DataNavigator.MoveNext(); |
||||||
|
SectionBounds.ReportFooterRectangle = new Rectangle(SectionBounds.ReportFooterRectangle.Left, |
||||||
|
base.CurrentPosition.Y, |
||||||
|
SectionBounds.ReportFooterRectangle.Width, |
||||||
|
SectionBounds.ReportFooterRectangle.Height); |
||||||
|
} |
||||||
|
} |
||||||
|
return exporterCollection; |
||||||
|
} |
||||||
|
|
||||||
|
protected override Point ForcePageBreak(ExporterCollection exporterCollection, BaseSection section) |
||||||
|
{ |
||||||
|
base.ForcePageBreak(exporterCollection, section); |
||||||
|
return base.SectionBounds.ReportHeaderRectangle.Location; |
||||||
|
} |
||||||
|
//Copy from GroupedRow
|
||||||
|
|
||||||
|
private Point ConvertGroupHeader(ExporterCollection exportList,BaseSection section,int leftPos,Point offset) |
||||||
|
{ |
||||||
|
var retVal = Point.Empty; |
||||||
|
ReportItemCollection groupCollection = null; |
||||||
|
|
||||||
|
var groupedRow = new Collection<BaseGroupedRow>(table.Items.OfType<BaseGroupedRow>().ToList()); |
||||||
|
|
||||||
|
if (groupedRow.Count == 0) { |
||||||
|
groupCollection = section.Items.ExtractGroupedColumns(); |
||||||
|
base.DataNavigator.Fill(groupCollection); |
||||||
|
base.FireSectionRendering(section); |
||||||
|
ExporterCollection list = StandardPrinter.ConvertPlainCollection(groupCollection,offset); |
||||||
|
|
||||||
|
StandardPrinter.EvaluateRow(base.Evaluator,list); |
||||||
|
|
||||||
|
exportList.AddRange(list); |
||||||
|
AfterConverting (section,list); |
||||||
|
retVal = new Point (leftPos,offset.Y + groupCollection[0].Size.Height + 20 + (3 *GlobalValues.GapBetweenContainer)); |
||||||
|
} else { |
||||||
|
retVal = ConvertStandardRow(exportList,section,groupedRow[0],leftPos,offset); |
||||||
|
} |
||||||
|
return retVal; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
@ -1,118 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Drawing; |
|
||||||
using ICSharpCode.Reports.Core.BaseClasses.Printing; |
|
||||||
using ICSharpCode.Reports.Core.Interfaces; |
|
||||||
|
|
||||||
namespace ICSharpCode.Reports.Core.Exporter |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Description of TableConverter.
|
|
||||||
/// </summary>
|
|
||||||
public class TableConverter:BaseConverter |
|
||||||
{ |
|
||||||
|
|
||||||
private ITableContainer baseTable; |
|
||||||
|
|
||||||
public TableConverter(IDataNavigator dataNavigator, |
|
||||||
ExporterPage singlePage, |
|
||||||
|
|
||||||
ILayouter layouter ):base(dataNavigator,singlePage,layouter) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
public override ExporterCollection Convert (BaseReportItem parent,BaseReportItem item) |
|
||||||
{ |
|
||||||
if (parent == null) { |
|
||||||
throw new ArgumentNullException("parent"); |
|
||||||
} |
|
||||||
if (item == null) { |
|
||||||
throw new ArgumentNullException("item"); |
|
||||||
} |
|
||||||
|
|
||||||
ExporterCollection mylist = base.Convert(parent,item); |
|
||||||
this.baseTable = (BaseTableItem)item ; |
|
||||||
this.baseTable.Parent = parent; |
|
||||||
this.baseTable.DataNavigator = base.DataNavigator; |
|
||||||
return ConvertInternal(mylist); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
private ExporterCollection ConvertInternal(ExporterCollection mylist) |
|
||||||
{ |
|
||||||
|
|
||||||
Point currentPosition = new Point(PrintHelper.DrawingAreaRelativeToParent(this.baseTable.Parent,this.baseTable).Location.X, |
|
||||||
base.SectionBounds.DetailStart.Y); |
|
||||||
|
|
||||||
int defaultLeftPos = currentPosition.X; |
|
||||||
|
|
||||||
Point dataAreaStart = new Point(baseTable.Items[0].Location.X,baseTable.Items[0].Location.Y + currentPosition.Y); |
|
||||||
|
|
||||||
ISimpleContainer headerContainer = null; |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.baseTable.Items.SortByLocation(); |
|
||||||
|
|
||||||
foreach (ISimpleContainer simpleContainer in this.baseTable.Items) |
|
||||||
{ |
|
||||||
if (simpleContainer.Items.Count > 0) { |
|
||||||
simpleContainer.Location = new Point (simpleContainer.Location.X,simpleContainer.Location.Y); |
|
||||||
simpleContainer.Parent = (BaseReportItem)this.baseTable; |
|
||||||
base.SaveSize( new Size (simpleContainer.Size.Width,simpleContainer.Size.Height)); |
|
||||||
// Header/FooterRow
|
|
||||||
|
|
||||||
if (PrintHelper.IsTextOnlyRow(simpleContainer) ) { |
|
||||||
headerContainer = simpleContainer; |
|
||||||
currentPosition = BaseConverter.BaseConvert(mylist,headerContainer,defaultLeftPos,currentPosition); |
|
||||||
} |
|
||||||
|
|
||||||
else |
|
||||||
{ |
|
||||||
// DataRegion
|
|
||||||
base.SaveSize(simpleContainer.Size); |
|
||||||
do { |
|
||||||
//
|
|
||||||
BaseSection section = this.baseTable.Parent as BaseSection; |
|
||||||
PrintHelper.AdjustSectionLocation(section); |
|
||||||
|
|
||||||
base.FillRow(simpleContainer); |
|
||||||
|
|
||||||
StandardPrinter.EvaluateRow(base.Evaluator,mylist); |
|
||||||
|
|
||||||
base.PrepareContainerForConverting(null,simpleContainer); |
|
||||||
|
|
||||||
Rectangle pageBreakRect = PrintHelper.CalculatePageBreakRectangle((BaseReportItem)simpleContainer,currentPosition); |
|
||||||
|
|
||||||
if (PrintHelper.IsPageFull(pageBreakRect,base.SectionBounds)) |
|
||||||
{ |
|
||||||
base.BuildNewPage(mylist,section); |
|
||||||
|
|
||||||
currentPosition = BaseConverter.BaseConvert(mylist,headerContainer, |
|
||||||
defaultLeftPos, |
|
||||||
base.SectionBounds.ReportHeaderRectangle.Location); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
currentPosition = BaseConverter.BaseConvert(mylist,simpleContainer,defaultLeftPos,currentPosition); |
|
||||||
|
|
||||||
simpleContainer.Size = base.RestoreSize; |
|
||||||
} |
|
||||||
while (base.DataNavigator.MoveNext()); |
|
||||||
//Allway's reset the DataNavigator
|
|
||||||
base.DataNavigator.Reset(); |
|
||||||
base.DataNavigator.MoveNext(); |
|
||||||
SectionBounds.ReportFooterRectangle = new Rectangle(SectionBounds.ReportFooterRectangle.Left, |
|
||||||
currentPosition.Y, |
|
||||||
SectionBounds.ReportFooterRectangle.Width, |
|
||||||
SectionBounds.ReportFooterRectangle.Height); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
return mylist; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -0,0 +1,230 @@ |
|||||||
|
/* |
||||||
|
* Created by SharpDevelop. |
||||||
|
* User: Peter Forstmeier |
||||||
|
* Date: 10.10.2010 |
||||||
|
* Time: 17:37 |
||||||
|
* |
||||||
|
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
using System.Drawing; |
||||||
|
using ICSharpCode.Reports.Core.BaseClasses.Printing; |
||||||
|
using ICSharpCode.Reports.Core.Interfaces; |
||||||
|
using ICSharpCode.Reports.Expressions.ReportingLanguage; |
||||||
|
|
||||||
|
namespace ICSharpCode.Reports.Core |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Description of RenderTable.
|
||||||
|
/// </summary>
|
||||||
|
public class RenderTable:IBaseRenderer |
||||||
|
{ |
||||||
|
|
||||||
|
IDataNavigator dataNavigator; |
||||||
|
Rectangle parentRectangle; |
||||||
|
ISinglePage singlePage; |
||||||
|
ILayouter layouter; |
||||||
|
ReportPageEventArgs reportPageEventArgs; |
||||||
|
BaseSection currentSection; |
||||||
|
|
||||||
|
public RenderTable(IDataNavigator datanavigator,Rectangle parentRectangle,ISinglePage singlePage,ILayouter layouter,BaseSection section) |
||||||
|
{ |
||||||
|
this.dataNavigator = datanavigator; |
||||||
|
|
||||||
|
this.parentRectangle = parentRectangle; |
||||||
|
this.singlePage = singlePage; |
||||||
|
this.layouter = layouter; |
||||||
|
this.currentSection = section; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public event EventHandler<ICSharpCode.Reports.Core.Events.NewPageEventArgs> PageFull; |
||||||
|
|
||||||
|
public event EventHandler<SectionRenderEventArgs> SectionRendering; |
||||||
|
|
||||||
|
|
||||||
|
public void Render (ISimpleContainer table,ReportPageEventArgs rpea,IExpressionEvaluatorFacade evaluator) |
||||||
|
{ |
||||||
|
if (this.dataNavigator.CurrentRow < 0 ) { |
||||||
|
this.dataNavigator.MoveNext(); |
||||||
|
} |
||||||
|
this.reportPageEventArgs = rpea; |
||||||
|
Point saveLocation = table.Location; |
||||||
|
Rectangle pageBreakRect = Rectangle.Empty; |
||||||
|
|
||||||
|
Point currentPosition = new Point(PrintHelper.DrawingAreaRelativeToParent(this.currentSection,table).Location.X, |
||||||
|
this.currentSection.Location.Y); |
||||||
|
table.Items.SortByLocation(); |
||||||
|
|
||||||
|
Size rs = Size.Empty; |
||||||
|
|
||||||
|
|
||||||
|
ISimpleContainer headerRow = null; |
||||||
|
|
||||||
|
var simpleContainer = table.Items[0] as ISimpleContainer; |
||||||
|
|
||||||
|
// foreach (BaseRowItem row in table.Items)
|
||||||
|
// {
|
||||||
|
rs = simpleContainer.Size; |
||||||
|
PrintHelper.AdjustParent(table as BaseReportItem,table.Items); |
||||||
|
|
||||||
|
// if (PrintHelper.IsTextOnlyRow(simpleContainer) )
|
||||||
|
// {
|
||||||
|
|
||||||
|
PrintHelper.SetLayoutForRow(ReportPageEventArgs.PrintPageEventArgs.Graphics,Layouter,simpleContainer); |
||||||
|
|
||||||
|
var r = StandardPrinter.RenderContainer(simpleContainer,evaluator,currentPosition,ReportPageEventArgs); |
||||||
|
|
||||||
|
currentPosition = PrintHelper.ConvertRectangleToCurentPosition (r); |
||||||
|
|
||||||
|
table.Location = saveLocation; |
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
//---------------
|
||||||
|
simpleContainer = table.Items[1] as ISimpleContainer; |
||||||
|
|
||||||
|
int adjust = simpleContainer.Location.Y - saveLocation.Y; |
||||||
|
simpleContainer.Location = new Point(simpleContainer.Location.X,simpleContainer.Location.Y - adjust - 3 * GlobalValues.GapBetweenContainer); |
||||||
|
rs = simpleContainer.Size; |
||||||
|
|
||||||
|
do { |
||||||
|
|
||||||
|
pageBreakRect = PrintHelper.CalculatePageBreakRectangle((BaseReportItem)table,currentPosition); |
||||||
|
|
||||||
|
if (PrintHelper.IsPageFull(pageBreakRect,this.SectionBounds)) { |
||||||
|
Console.WriteLine("PageBreak - PageFull"); |
||||||
|
table.Location = saveLocation; |
||||||
|
AbstractRenderer.PageBreak(ReportPageEventArgs); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
this.dataNavigator.Fill(simpleContainer.Items); |
||||||
|
|
||||||
|
PrintHelper.SetLayoutForRow(ReportPageEventArgs.PrintPageEventArgs.Graphics,Layouter,simpleContainer); |
||||||
|
|
||||||
|
r = StandardPrinter.RenderContainer(simpleContainer,evaluator,currentPosition,ReportPageEventArgs); |
||||||
|
|
||||||
|
currentPosition = PrintHelper.ConvertRectangleToCurentPosition (r); |
||||||
|
|
||||||
|
simpleContainer.Size = rs; |
||||||
|
} |
||||||
|
while (this.dataNavigator.MoveNext()); |
||||||
|
//-----
|
||||||
|
// }
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void old_Render (ISimpleContainer table,ReportPageEventArgs rpea,IExpressionEvaluatorFacade evaluator) |
||||||
|
{ |
||||||
|
if (this.dataNavigator.CurrentRow < 0 ) { |
||||||
|
this.dataNavigator.MoveNext(); |
||||||
|
} |
||||||
|
this.reportPageEventArgs = rpea; |
||||||
|
Point saveLocation = table.Location; |
||||||
|
Rectangle pageBreakRect = Rectangle.Empty; |
||||||
|
|
||||||
|
Point currentPosition = new Point(PrintHelper.DrawingAreaRelativeToParent(this.currentSection,table).Location.X, |
||||||
|
this.currentSection.Location.Y); |
||||||
|
table.Items.SortByLocation(); |
||||||
|
|
||||||
|
Size rs = Size.Empty; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
foreach (BaseRowItem row in table.Items) |
||||||
|
{ |
||||||
|
rs = row.Size; |
||||||
|
PrintHelper.AdjustParent(table as BaseReportItem,table.Items); |
||||||
|
|
||||||
|
if (PrintHelper.IsTextOnlyRow(row) ) |
||||||
|
{ |
||||||
|
|
||||||
|
PrintHelper.SetLayoutForRow(ReportPageEventArgs.PrintPageEventArgs.Graphics,Layouter,row); |
||||||
|
|
||||||
|
Rectangle r = StandardPrinter.RenderContainer(row,evaluator,currentPosition,ReportPageEventArgs); |
||||||
|
|
||||||
|
currentPosition = PrintHelper.ConvertRectangleToCurentPosition (r); |
||||||
|
|
||||||
|
table.Location = saveLocation; |
||||||
|
} |
||||||
|
else { |
||||||
|
int adjust = row.Location.Y - saveLocation.Y; |
||||||
|
row.Location = new Point(row.Location.X,row.Location.Y - adjust - 3 * GlobalValues.GapBetweenContainer); |
||||||
|
rs = row.Size; |
||||||
|
|
||||||
|
do { |
||||||
|
|
||||||
|
pageBreakRect = PrintHelper.CalculatePageBreakRectangle((BaseReportItem)table,currentPosition); |
||||||
|
|
||||||
|
if (PrintHelper.IsPageFull(parentRectangle,this.SectionBounds)) { |
||||||
|
Console.WriteLine("PageBreak - PageFull"); |
||||||
|
table.Location = saveLocation; |
||||||
|
AbstractRenderer.PageBreak(ReportPageEventArgs); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
this.dataNavigator.Fill(row.Items); |
||||||
|
|
||||||
|
PrintHelper.SetLayoutForRow(ReportPageEventArgs.PrintPageEventArgs.Graphics,Layouter,row); |
||||||
|
|
||||||
|
Rectangle r = StandardPrinter.RenderContainer(row,evaluator,currentPosition,ReportPageEventArgs); |
||||||
|
|
||||||
|
currentPosition = PrintHelper.ConvertRectangleToCurentPosition (r); |
||||||
|
|
||||||
|
row.Size = rs; |
||||||
|
} |
||||||
|
while (this.dataNavigator.MoveNext()); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
row.Size = rs; |
||||||
|
} |
||||||
|
// base.NotifyAfterPrint (rpea.LocationAfterDraw);
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public ICSharpCode.Reports.Core.BaseClasses.SectionBounds SectionBounds { |
||||||
|
get { |
||||||
|
return this.singlePage.SectionBounds; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public IDataNavigator DataNavigator { |
||||||
|
get { |
||||||
|
return this.dataNavigator; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public System.Drawing.Rectangle ParentRectangle { |
||||||
|
get { |
||||||
|
return this.parentRectangle; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public ISinglePage SinglePage { |
||||||
|
get { |
||||||
|
return this.singlePage; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public ILayouter Layouter { |
||||||
|
get { |
||||||
|
return this.layouter; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public System.Drawing.Graphics Graphics {get;set;} |
||||||
|
|
||||||
|
|
||||||
|
public ReportPageEventArgs ReportPageEventArgs { |
||||||
|
get { return reportPageEventArgs; } |
||||||
|
set { reportPageEventArgs = value; } |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,38 @@ |
|||||||
|
/* |
||||||
|
* Created by SharpDevelop. |
||||||
|
* User: Peter Forstmeier |
||||||
|
* Date: 10.10.2010 |
||||||
|
* Time: 17:28 |
||||||
|
* |
||||||
|
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
using System.Drawing; |
||||||
|
using ICSharpCode.Reports.Core.Interfaces; |
||||||
|
|
||||||
|
namespace ICSharpCode.Reports.Core |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Description of RendererFactory.
|
||||||
|
/// </summary>
|
||||||
|
public class PrintRendererFactory |
||||||
|
{ |
||||||
|
|
||||||
|
public static IBaseRenderer CreateRenderer (BaseReportItem itemToConvert,IDataNavigator dataNavigator, |
||||||
|
ISinglePage singlePage,ILayouter layouter,BaseSection section) |
||||||
|
{ |
||||||
|
|
||||||
|
Type t = itemToConvert.GetType(); |
||||||
|
if (t.Equals(typeof(BaseTableItem))) { |
||||||
|
Console.WriteLine("render Table"); |
||||||
|
return new RenderTable(dataNavigator,Rectangle.Empty,singlePage,layouter,section); |
||||||
|
} |
||||||
|
|
||||||
|
if (t.Equals(typeof(BaseRowItem))) { |
||||||
|
// return new GroupedRowConverter (dataNavigator,singlePage,layouter);
|
||||||
|
Console.WriteLine("render Row"); |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue