Skip to content
This repository has been archived by the owner on Oct 16, 2020. It is now read-only.

Commit

Permalink
Cleanup in BaseConverter.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterForstmeier committed Oct 6, 2010
1 parent 4155ddd commit d724ce4
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 80 deletions.
Expand Up @@ -53,7 +53,6 @@ public class BaseConverter:IBaseConverter
}



#region PageBreak

protected void BuildNewPage(ExporterCollection myList,BaseSection section)
Expand All @@ -69,6 +68,7 @@ protected void FirePageFull (ExporterCollection items)
EventHelper.Raise<NewPageEventArgs>(PageFull,this,new NewPageEventArgs(items));
}


#endregion


Expand Down Expand Up @@ -105,6 +105,17 @@ protected static ExporterCollection ConvertItems (ISimpleContainer row,Point of
}


#region Grouping

protected Point ConvertGroupChilds(ExporterCollection mylist, BaseSection section, ISimpleContainer simpleContainer, int defaultLeftPos, Point currentPosition)
{
PrepareContainerForConverting(section,simpleContainer);
Point curPos = BaseConverter.BaseConvert(mylist,simpleContainer,defaultLeftPos,currentPosition);
AfterConverting (mylist);
return curPos;
}

#endregion

#region IBaseConverter

Expand Down Expand Up @@ -140,6 +151,8 @@ public virtual ExporterCollection Convert(BaseReportItem parent, BaseReportItem
public Graphics Graphics {get;set;}
#endregion



protected void SaveSize(Size size)
{
this.saveSize = size;
Expand All @@ -158,13 +171,6 @@ protected IExpressionEvaluatorFacade Evaluator
}


protected void FillRow (ISimpleContainer row)
{
DataNavigator.Fill(row.Items);
}



protected void PrepareContainerForConverting(BaseSection section,ISimpleContainer simpleContainer)
{
if (section != null) {
Expand All @@ -174,17 +180,41 @@ protected void PrepareContainerForConverting(BaseSection section,ISimpleContaine
}


private void LayoutRow (ISimpleContainer row)
protected void AfterConverting (ExporterCollection convertedList)
{
PrintHelper.SetLayoutForRow(Graphics,Layouter,row);
StandardPrinter.EvaluateRow(Evaluator,convertedList);
// section.Items[0].Size = base.RestoreSize;
// section.SectionOffset += section.Size.Height + 3 * GlobalValues.GapBetweenContainer;
}



protected Point ConvertStandardRow(ExporterCollection mylist, BaseSection section, ISimpleContainer simpleContainer, int defaultLeftPos, Point currentPosition)
{
FillRow(simpleContainer);
PrepareContainerForConverting(section,simpleContainer);
Point curPos = BaseConverter.BaseConvert(mylist,simpleContainer,defaultLeftPos,currentPosition);
AfterConverting (mylist);
return curPos;
}


protected static Point BaseConvert(ExporterCollection myList,ISimpleContainer container,int leftPos,Point curPos)
{
ExporterCollection ml = BaseConverter.ConvertItems (container, curPos);
myList.AddRange(ml);
return new Point (leftPos,curPos.Y + container.Size.Height + (3 *GlobalValues.GapBetweenContainer));
}


private void FillRow (ISimpleContainer row)
{
DataNavigator.Fill(row.Items);
}


private void LayoutRow (ISimpleContainer row)
{
PrintHelper.SetLayoutForRow(Graphics,Layouter,row);
}
}
}
Expand Up @@ -22,8 +22,8 @@ public class GroupedRowConverter:BaseConverter
private BaseReportItem parent;

public GroupedRowConverter(IDataNavigator dataNavigator,
ExporterPage singlePage, ILayouter layouter):base(dataNavigator,singlePage,layouter)
{
ExporterPage singlePage, ILayouter layouter):base(dataNavigator,singlePage,layouter)
{
}

public override ExporterCollection Convert(BaseReportItem parent, BaseReportItem item)
Expand All @@ -45,7 +45,7 @@ public override ExporterCollection Convert(BaseReportItem parent, BaseReportItem
ExporterCollection myList = new ExporterCollection();

BaseConverter.BaseConvert (myList,simpleContainer,parent.Location.X,
new Point(base.SectionBounds.DetailStart.X,base.SectionBounds.DetailStart.Y));
new Point(base.SectionBounds.DetailStart.X,base.SectionBounds.DetailStart.Y));

return myList;
} else {
Expand All @@ -63,7 +63,7 @@ private ExporterCollection ConvertDataRow (ISimpleContainer simpleContainer)
int defaultLeftPos = parent.Location.X;

Rectangle pageBreakRect = Rectangle.Empty;

do {

PrintHelper.AdjustSectionLocation (section);
Expand All @@ -85,9 +85,9 @@ private ExporterCollection ConvertDataRow (ISimpleContainer simpleContainer)
childNavigator.MoveNext();

//Convert children
if (childNavigator != null) {
if (childNavigator != null) {
StandardPrinter.AdjustBackColor(simpleContainer,GlobalValues.DefaultBackColor);

do {
childNavigator.Fill(simpleContainer.Items);

Expand Down Expand Up @@ -173,41 +173,14 @@ private Point ConvertGroupHeader(ExporterCollection exportList,BaseSection secti
StandardPrinter.EvaluateRow(base.Evaluator,list);

exportList.AddRange(list);
AfterConverting (section,list);
AfterConverting (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;
}


private Point ConvertGroupChilds(ExporterCollection mylist, BaseSection section, ISimpleContainer simpleContainer, int defaultLeftPos, Point currentPosition)
{
PrepareContainerForConverting(section,simpleContainer);
Point curPos = BaseConverter.BaseConvert(mylist,simpleContainer,defaultLeftPos,currentPosition);
AfterConverting (section,mylist);
return curPos;
}


private Point ConvertStandardRow(ExporterCollection mylist, BaseSection section, ISimpleContainer simpleContainer, int defaultLeftPos, Point currentPosition)
{
base.FillRow(simpleContainer);
PrepareContainerForConverting(section,simpleContainer);
Point curPos = BaseConverter.BaseConvert(mylist,simpleContainer,defaultLeftPos,currentPosition);
AfterConverting (section,mylist);
return curPos;
}


private void AfterConverting (BaseSection section,ExporterCollection mylist)
{
StandardPrinter.EvaluateRow(base.Evaluator,mylist);
section.Items[0].Size = base.RestoreSize;
section.SectionOffset += section.Size.Height + 3 * GlobalValues.GapBetweenContainer;
}



private static void ShouldDrawBorder (BaseSection section,ExporterCollection list)
{
Expand Down
Expand Up @@ -46,6 +46,8 @@ public override ExporterCollection Convert (BaseReportItem parent,BaseReportItem
private ExporterCollection ConvertInternal(ExporterCollection exporterCollection)
{

BaseSection section = table.Parent as BaseSection;

Point currentPosition = new Point(PrintHelper.DrawingAreaRelativeToParent(this.table.Parent,this.table).Location.X,
base.SectionBounds.DetailStart.Y);

Expand Down Expand Up @@ -89,7 +91,7 @@ private ExporterCollection ConvertInternal(ExporterCollection exporterCollection
base.Evaluator.SinglePage.IDataNavigator = childNavigator;
// Convert Grouping Header

currentPosition = ConvertGroupHeader(exporterCollection,(BaseSection)table.Parent,defaultLeftPos,currentPosition);
currentPosition = ConvertGroupHeader(exporterCollection,section,defaultLeftPos,currentPosition);

childNavigator.Reset();
childNavigator.MoveNext();
Expand All @@ -103,7 +105,8 @@ private ExporterCollection ConvertInternal(ExporterCollection exporterCollection

childNavigator.Fill(simpleContainer.Items);

currentPosition = ConvertGroupChilds (exporterCollection,(BaseSection)table.Parent,
currentPosition = ConvertGroupChilds (exporterCollection,
section,
simpleContainer,defaultLeftPos,currentPosition);

}
Expand All @@ -119,14 +122,11 @@ private ExporterCollection ConvertInternal(ExporterCollection exporterCollection
{
// No Grouping at all

// DataRegion

base.SaveSize(simpleContainer.Size);
simpleContainer = table.Items[1] as ISimpleContainer;

do {
//
BaseSection section = this.table.Parent as BaseSection;

PrintHelper.AdjustSectionLocation(section);

pageBreakRect = PrintHelper.CalculatePageBreakRectangle((BaseReportItem)simpleContainer,currentPosition);
Expand Down Expand Up @@ -160,6 +160,7 @@ private ExporterCollection ConvertInternal(ExporterCollection exporterCollection


//Copy from GroupedRow

private Point ConvertGroupHeader(ExporterCollection exportList,BaseSection section,int leftPos,Point offset)
{
var retVal = Point.Empty;
Expand All @@ -176,39 +177,14 @@ private Point ConvertGroupHeader(ExporterCollection exportList,BaseSection secti
StandardPrinter.EvaluateRow(base.Evaluator,list);

exportList.AddRange(list);
AfterConverting (section,list);
AfterConverting (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;
}


private Point ConvertGroupChilds(ExporterCollection mylist, BaseSection section, ISimpleContainer simpleContainer, int defaultLeftPos, Point currentPosition)
{
PrepareContainerForConverting(section,simpleContainer);
Point curPos = BaseConverter.BaseConvert(mylist,simpleContainer,defaultLeftPos,currentPosition);
AfterConverting (section,mylist);
return curPos;
}

private void AfterConverting (BaseSection section,ExporterCollection mylist)
{
Console.WriteLine("AfterConverting");
StandardPrinter.EvaluateRow(base.Evaluator,mylist);
// section.Items[0].Size = base.RestoreSize;
// section.SectionOffset += section.Size.Height + 3 * GlobalValues.GapBetweenContainer;
}

private Point ConvertStandardRow(ExporterCollection mylist, BaseSection section, ISimpleContainer simpleContainer, int defaultLeftPos, Point currentPosition)
{
base.FillRow(simpleContainer);
PrepareContainerForConverting(section,simpleContainer);
Point curPos = BaseConverter.BaseConvert(mylist,simpleContainer,defaultLeftPos,currentPosition);
AfterConverting (section,mylist);
return curPos;
}
}
}

Expand Up @@ -78,7 +78,7 @@ private ExporterCollection ConvertInternal(ExporterCollection mylist)
BaseSection section = this.baseTable.Parent as BaseSection;
PrintHelper.AdjustSectionLocation(section);

base.FillRow(simpleContainer);
// base.FillRow(simpleContainer);

StandardPrinter.EvaluateRow(base.Evaluator,mylist);

Expand Down Expand Up @@ -154,7 +154,7 @@ private ExporterCollection old_ConvertInternal(ExporterCollection mylist)
BaseSection section = this.baseTable.Parent as BaseSection;
PrintHelper.AdjustSectionLocation(section);

base.FillRow(simpleContainer);
// base.FillRow(simpleContainer);

StandardPrinter.EvaluateRow(base.Evaluator,mylist);

Expand Down

0 comments on commit d724ce4

Please sign in to comment.