Browse Source

Cleanup DataPageBuilder.cs

reports
Peter Forstmeier 12 years ago
parent
commit
d3ffbf32b9
  1. 3
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/BasePageBuilder.cs
  2. 9
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/Converter/ContainerConverter.cs
  3. 93
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/DataPageBuilder.cs

3
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/BasePageBuilder.cs

@ -40,7 +40,6 @@ namespace ICSharpCode.Reporting.PageBuilder @@ -40,7 +40,6 @@ namespace ICSharpCode.Reporting.PageBuilder
ReportModel = reportModel;
Pages = new Collection<ExportPage>();
Graphics = CreateGraphics.FromSize(reportModel.ReportSettings.PageSize);
// ExpressionVisitor = new ExpressionVisitor(ReportModel.ReportSettings,null);
}
#region create Report Sections
@ -112,7 +111,7 @@ namespace ICSharpCode.Reporting.PageBuilder @@ -112,7 +111,7 @@ namespace ICSharpCode.Reporting.PageBuilder
protected IExportContainer CreateSection(IReportContainer container,Point location)
{
var containerConverter = new ContainerConverter(Graphics, location);
var containerConverter = new ContainerConverter(location);
var convertedContainer = containerConverter.ConvertToExportContainer(container);
var list = containerConverter.CreateConvertedList(container.Items);

9
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/Converter/ContainerConverter.cs

@ -22,12 +22,8 @@ namespace ICSharpCode.Reporting.PageBuilder.Converter @@ -22,12 +22,8 @@ namespace ICSharpCode.Reporting.PageBuilder.Converter
/// </summary>
class ContainerConverter : IContainerConverter
{
public ContainerConverter(Graphics graphics, Point currentLocation)
public ContainerConverter(Point currentLocation)
{
if (graphics == null) {
throw new ArgumentNullException("graphics");
}
Graphics = graphics;
CurrentLocation = currentLocation;
}
@ -63,9 +59,6 @@ namespace ICSharpCode.Reporting.PageBuilder.Converter @@ -63,9 +59,6 @@ namespace ICSharpCode.Reporting.PageBuilder.Converter
}
}
protected Point CurrentLocation { get; set; }
internal Graphics Graphics {get;private set;}
}
}

93
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/DataPageBuilder.cs

@ -55,31 +55,30 @@ namespace ICSharpCode.Reporting.PageBuilder @@ -55,31 +55,30 @@ namespace ICSharpCode.Reporting.PageBuilder
CurrentSection = ReportModel.DetailSection;
if(DataSourceContainsData()) {
CurrentLocation = DetailStart;
var converter = new ContainerConverter(DetailStart);
if (IsGrouped()) {
BuildGroupedDetails();
BuildGroupedDetails(converter,DetailStart);
} else {
BuildSortedDetails();
BuildSortedDetails(converter,DetailStart);
}
}
}
void BuildGroupedDetails () {
void BuildGroupedDetails (IContainerConverter converter,Point startPosition) {
var exportRows = new List<IExportContainer>();
var converter = new ContainerConverter(base.Graphics, CurrentLocation);
var pagePosition = DetailStart;
var pagePosition = startPosition;
var sectionPosition = pagePosition;
foreach (IGrouping<object, object> grouping in DataSource.GroupedList) {
var groupHeader = (BaseRowItem)CurrentSection.Items.Where(p => p.GetType() == typeof(GroupHeader)).FirstOrDefault();
var sectionContainer = CreateContainerForSection(CurrentPage, pagePosition);
DataSource.Fill(groupHeader.Items,grouping.FirstOrDefault());
var sectionContainer = CreateContainerForSection(CurrentPage, pagePosition);
// Console.WriteLine("Page Position {0}",pagePosition);
var headerRow = converter.ConvertToExportContainer(groupHeader);
headerRow.Location = new Point(headerRow.Location.X,groupHeader.Location.Y);
@ -102,30 +101,47 @@ namespace ICSharpCode.Reporting.PageBuilder @@ -102,30 +101,47 @@ namespace ICSharpCode.Reporting.PageBuilder
foreach (var child in grouping) {
var dataItems = CurrentSection.Items.Where(p => p.GetType() == typeof(BaseDataItem)).ToList();
DataSource.Fill(dataItems,child);
var convertedItems = converter.CreateConvertedList(dataItems.ToList());
List<IExportColumn> convertedItems = FillAndConvert(sectionContainer, child, dataItems, converter);
AdjustLocationInSection(sectionPosition, convertedItems);
// Console.WriteLine("section height {0} Bottom {1}",sectionContainer.Size,convertedItems[0].DisplayRectangle.Bottom);
converter.SetParent(sectionContainer, convertedItems);
/*
if (PageFull(sectionContainer)) {
InsertExportRows(exportRows);
exportRows.Clear();
PerformPageBreak();
// pagePosition = DetailStart;
// sectionContainer.Location = pagePosition;
}
*/
sectionContainer.ExportedItems.AddRange(convertedItems);
MeasureAndArrangeContainer(sectionContainer);
exportRows.Add(sectionContainer);
sectionPosition = new Point(CurrentSection.Location.X, sectionPosition.Y + 25);
sectionContainer.Size = new Size(sectionContainer.Size.Width,convertedItems[0].Location.Y + 40);
sectionPosition = new Point(CurrentSection.Location.X, sectionPosition.Y + convertedItems[0].DisplayRectangle.Size.Height + 5);
sectionContainer.Size = new Size(sectionContainer.Size.Width,convertedItems[0].Location.Y + convertedItems[0].DisplayRectangle.Size.Height * 2);
}
MeasureAndArrangeContainer(sectionContainer);
pagePosition = new Point(pagePosition.X,sectionContainer.DisplayRectangle.Bottom + 1);
}
InsertExportRows(exportRows);
}
void AdjustLocationInSection(Point sectionPosition,List<IExportColumn> convertedItems)
List<IExportColumn> FillAndConvert(ExportContainer parent, object current, List<IPrintableObject> dataItems, IContainerConverter converter)
{
DataSource.Fill(dataItems, current);
var convertedItems = converter.CreateConvertedList(dataItems.ToList());
converter.SetParent(parent, convertedItems);
return convertedItems;
}
static void AdjustLocationInSection(Point sectionPosition,List<IExportColumn> convertedItems)
{
foreach (var element in convertedItems) {
element.Location = new Point(element.Location.X, sectionPosition.Y);
@ -133,19 +149,13 @@ namespace ICSharpCode.Reporting.PageBuilder @@ -133,19 +149,13 @@ namespace ICSharpCode.Reporting.PageBuilder
}
void BuildSortedDetails(){
void BuildSortedDetails(IContainerConverter converter,Point startPosition){
var exportRows = new List<IExportContainer>();
var converter = new ContainerConverter(base.Graphics, CurrentLocation);
var pagePosition = DetailStart;
var pagePosition = startPosition;
foreach (var element in DataSource.SortedList) {
var sectionContainer = CreateContainerForSection(CurrentPage, pagePosition);
DataSource.Fill(CurrentSection.Items,element);
var convertedItems = converter.CreateConvertedList(ReportModel.DetailSection.Items);
converter.SetParent(sectionContainer, convertedItems);
var convertedItems = FillAndConvert(sectionContainer,element,ReportModel.DetailSection.Items,converter);
if (PageFull(sectionContainer)) {
InsertExportRows(exportRows);
@ -165,39 +175,6 @@ namespace ICSharpCode.Reporting.PageBuilder @@ -165,39 +175,6 @@ namespace ICSharpCode.Reporting.PageBuilder
InsertExportRows(exportRows);
}
/*
void old_BuildSortedDetails(){
var exportRows = new List<IExportContainer>();
var converter = new ContainerConverter(base.Graphics, CurrentLocation);
var position = DetailStart;
do {
var row = CreateContainerForSection(CurrentPage, position);
DataSource.Fill(CurrentSection.Items);
var convertedItems = converter.CreateConvertedList(ReportModel.DetailSection.Items);
converter.SetParent(row, convertedItems);
if (PageFull(row)) {
InsertExportRows(exportRows);
exportRows.Clear();
PerformPageBreak();
position = DetailStart;
row.Location = position;
}
MeasureAndArrangeContainer(row);
row.ExportedItems.AddRange(convertedItems);
exportRows.Add(row);
position = new Point(CurrentSection.Location.X, position.Y + row.DesiredSize.Height + 1);
} while (DataSource.MoveNext());
InsertExportRows(exportRows);
}
*/
void PerformPageBreak(){
CurrentPage.PageInfo.PageNumber = Pages.Count + 1;

Loading…
Cancel
Save