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

Commit

Permalink
Evaluation in grouped report
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterForstmeier committed Sep 15, 2010
1 parent 979315e commit 7dadb2c
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 148 deletions.
Expand Up @@ -37,7 +37,7 @@ internal class ExplorerTree:TreeView,INotifyPropertyChanged

private static int folderClosed = 0;
private static int folderOpen = 1;
private static int clearIcon = 2;
// private static int clearIcon = 2;

private static int ascendingIcon = 4;
private static int descendingIcon = 5;
Expand Down
Expand Up @@ -258,17 +258,20 @@ public static IExpressionEvaluatorFacade CreateEvaluator (ISinglePage singlePag
public static void EvaluateRow(IExpressionEvaluatorFacade evaluator,ExporterCollection row)
{
// Console.WriteLine("evaluate row with row:{0} ",evaluator.SinglePage.IDataNavigator.CurrentRow);
foreach (BaseExportColumn element in row) {
ExportText textItem = element as ExportText;

if (textItem != null) {

string s = evaluator.Evaluate(textItem.Text);
// Console.WriteLine("\teval {0} - {1} ",textItem.Text,s);
// textItem.Text = evaluator.Evaluate(textItem.Text);
textItem.Text = s;
try {
foreach (BaseExportColumn element in row) {
ExportText textItem = element as ExportText;
if (textItem != null) {
// string s = evaluator.Evaluate(textItem.Text);
// Console.WriteLine("\teval {0} - {1} ",textItem.Text,s);
textItem.Text = evaluator.Evaluate(textItem.Text);
// textItem.Text = s;
}
}
} catch (Exception e) {
throw e;
}

}

#endregion
Expand Down
Expand Up @@ -17,15 +17,15 @@ namespace ICSharpCode.Reports.Core
public class ChildNavigator:IDataNavigator
{
private IndexList indexList;
private IDataViewStrategy dataStore;
private IDataViewStrategy store;
private System.Collections.Generic.List<BaseComparer>.Enumerator ce;

public ChildNavigator(IDataViewStrategy dataStore,IndexList indexList)
{
if (dataStore == null) {
throw new ArgumentNullException("dataStore");
}
this.dataStore = dataStore;
this.store = dataStore;
this.indexList = indexList;
ce = this.indexList.GetEnumerator();
ce.MoveNext();
Expand All @@ -42,10 +42,10 @@ public ChildNavigator(IDataViewStrategy dataStore,IndexList indexList)
get {
IndexList ind = BuildChildList();
return ((ind != null) && (ind.Count > 0));
// return false;
}
}


public int ChildListCount {
get {
throw new NotImplementedException();
Expand All @@ -58,45 +58,49 @@ public ChildNavigator(IDataViewStrategy dataStore,IndexList indexList)
}
}


public bool IsGrouped {
get {
throw new NotImplementedException();
}
}

public int CurrentRow {
get {
throw new NotImplementedException();
}

public int CurrentRow
{
get {return this.indexList.CurrentPosition;}
}


public int Count {
get {
return this.indexList.Count;
}
}


public object Current {
get {
TableStrategy t = this.dataStore as TableStrategy;
TableStrategy t = this.store as TableStrategy;
return t.myCurrent(ce.Current.ListIndex);
// return ci;
}
}


public AvailableFieldsCollection AvailableFields {
get {
throw new NotImplementedException();
}
}


public void Fill(ReportItemCollection collection)
{
TableStrategy tableStrategy = dataStore as TableStrategy;
TableStrategy tableStrategy = store as TableStrategy;
foreach (var item in collection) {
IDataItem dataItem = item as IDataItem;
if (dataItem != null) {
CurrentItemsCollection currentItemsCollection = tableStrategy.FillDataRow(ce.Current.ListIndex);
CurrentItemsCollection currentItemsCollection = tableStrategy.FillDataRow(this.indexList[CurrentRow].ListIndex);
CurrentItem s = currentItemsCollection.FirstOrDefault(x => x.ColumnName == dataItem.ColumnName);
dataItem.DBValue = s.Value.ToString();
}
Expand All @@ -106,37 +110,31 @@ public void Fill(ReportItemCollection collection)

public bool MoveNext()
{
return this.ce.MoveNext();
this.indexList.CurrentPosition ++;
return this.indexList.CurrentPosition<this.indexList.Count;
}

public void Reset()
{
throw new NotImplementedException();
this.indexList.CurrentPosition = -1;
}

public CurrentItemsCollection GetDataRow()
{
throw new NotImplementedException();
var st= store as TableStrategy;
return st.FillDataRow(this.indexList[CurrentRow].ListIndex);
}


public IDataNavigator GetChildNavigator()
{
var i = BuildChildList();
if ((i == null) || (i.Count == 0)) {
return null;
}
return new ChildNavigator(this.dataStore,i);
}

public void SwitchGroup()
{
throw new NotImplementedException();
return new ChildNavigator(this.store,i);
}

public bool ChildMoveNext()
{
throw new NotImplementedException();
}

public void FillChild(ReportItemCollection collection)
{
Expand Down
Expand Up @@ -37,15 +37,6 @@ public CurrentItemsCollection GetDataRow()

#endregion

/*
private static Collection<BaseDataItem> ExtraxtDataItems (ReportItemCollection items)
{
Collection<BaseDataItem> inheritedReportItems = new Collection<BaseDataItem>(items.OfType<BaseDataItem>().ToList());
return inheritedReportItems;
}
*/


#region IDataNavigator implementation

Expand Down Expand Up @@ -122,14 +113,6 @@ public bool HasChildren
}
}


public void SwitchGroup()
{
this.childList = BuildChildList();
ce = childList.GetEnumerator();
ce.MoveNext();
}



public int ChildListCount
Expand All @@ -139,13 +122,6 @@ public int ChildListCount
}
}


public bool ChildMoveNext()
{
return ce.MoveNext();
}


// at the moment only tables are working

public void FillChild (ReportItemCollection collection)
Expand Down
Expand Up @@ -70,6 +70,8 @@ private ExporterCollection ConvertDataRow (ISimpleContainer simpleContainer)

Rectangle pageBreakRect = Rectangle.Empty;

Console.WriteLine("datanav currentrow {0}",base.DataNavigator.CurrentRow);

do {

PrintHelper.AdjustSectionLocation (section);
Expand All @@ -78,94 +80,37 @@ private ExporterCollection ConvertDataRow (ISimpleContainer simpleContainer)

// did we have GroupedItems at all
if (section.Items.IsGrouped) {
// Convert Grouping Header
currentPosition = ConvertGroupHeader(exporterCollection,section,simpleContainer,defaultLeftPos,currentPosition);

// GetType child navigator
IDataNavigator childNavigator = base.DataNavigator.GetChildNavigator();
Console.WriteLine("child has {0} items",childNavigator.Count);

//Convert children
if (childNavigator != null) {
StandardPrinter.AdjustBackColor(simpleContainer,GlobalValues.DefaultBackColor);
//base.DataNavigator.SwitchGroup();
do {
childNavigator.Fill(simpleContainer.Items);
currentPosition = ConvertGroupChilds (exporterCollection,section,simpleContainer,defaultLeftPos,currentPosition);
pageBreakRect = PrintHelper.CalculatePageBreakRectangle((BaseReportItem)section.Items[1],currentPosition);

if (PrintHelper.IsPageFull(pageBreakRect,base.SectionBounds )) {
base.BuildNewPage(exporterCollection,section);
currentPosition = CalculateStartPosition ();
}
}
while ( childNavigator.MoveNext());
}
}
else
{
// No Grouping at all
currentPosition = ConvertStandardRow (exporterCollection,section,simpleContainer,defaultLeftPos,currentPosition);
}

pageBreakRect = PrintHelper.CalculatePageBreakRectangle((BaseReportItem)section.Items[0],currentPosition);
if (PrintHelper.IsPageFull(pageBreakRect,base.SectionBounds)) {
base.BuildNewPage(exporterCollection,section);
currentPosition = CalculateStartPosition();
}

ShouldDrawBorder (section,exporterCollection);

}
while (base.DataNavigator.MoveNext());

SectionBounds.ReportFooterRectangle = new Rectangle(SectionBounds.ReportFooterRectangle.Left,
section.Location.Y + section.Size.Height,
SectionBounds.ReportFooterRectangle.Width,
SectionBounds.ReportFooterRectangle.Height);
return exporterCollection;
}


private ExporterCollection old_ConvertDataRow (ISimpleContainer simpleContainer)
{
ExporterCollection exporterCollection = new ExporterCollection();
Point currentPosition = new Point(base.SectionBounds.DetailStart.X,base.SectionBounds.DetailStart.Y);
BaseSection section = parent as BaseSection;

int defaultLeftPos = parent.Location.X;

Rectangle pageBreakRect = Rectangle.Empty;

do {

PrintHelper.AdjustSectionLocation (section);
section.Size = this.SectionBounds.DetailSectionRectangle.Size;
base.SaveSize(section.Items[0].Size);


if (section.Items.IsGrouped) {

base.Evaluator.SinglePage.IDataNavigator = childNavigator;
// Convert Grouping Header

currentPosition = ConvertGroupHeader(exporterCollection,section,simpleContainer,defaultLeftPos,currentPosition);

//Convert children
childNavigator.Reset();
childNavigator.MoveNext();

if (base.DataNavigator.HasChildren) {

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

do {
currentPosition = ConvertGroupChilds (exporterCollection,section,simpleContainer,defaultLeftPos,currentPosition);
childNavigator.Fill(simpleContainer.Items);

currentPosition = ConvertGroupChilds (exporterCollection,section,
simpleContainer,defaultLeftPos,currentPosition);
pageBreakRect = PrintHelper.CalculatePageBreakRectangle((BaseReportItem)section.Items[1],currentPosition);

if (PrintHelper.IsPageFull(pageBreakRect,base.SectionBounds )) {
base.BuildNewPage(exporterCollection,section);
currentPosition = CalculateStartPosition ();
}
}
while ( base.DataNavigator.ChildMoveNext());

while ( childNavigator.MoveNext());
base.Evaluator.SinglePage.IDataNavigator = base.DataNavigator;
}
}
else
Expand All @@ -192,7 +137,7 @@ private ExporterCollection old_ConvertDataRow (ISimpleContainer simpleContainer)
return exporterCollection;
}


private Point CalculateStartPosition()
{
return new Point(base.SectionBounds.PageHeaderRectangle.X,base.SectionBounds.PageHeaderRectangle.Y);
Expand All @@ -209,7 +154,9 @@ private Point ConvertGroupHeader(ExporterCollection mylist,BaseSection section,I
base.DataNavigator.Fill(groupCollection);
base.FireSectionRendering(section);
ExporterCollection list = StandardPrinter.ConvertPlainCollection(groupCollection,offset);

StandardPrinter.EvaluateRow(base.Evaluator,list);

mylist.AddRange(list);
AfterConverting (section,list);
retVal = new Point (leftPos,offset.Y + groupCollection[0].Size.Height + 20 + (3 *GlobalValues.GapBetweenContainer));
Expand All @@ -218,7 +165,6 @@ private Point ConvertGroupHeader(ExporterCollection mylist,BaseSection section,I
}
return retVal;
}



private Point old_ConvertGroupHeader(ExporterCollection mylist,BaseSection section,ISimpleContainer simpleContainer,int leftPos,Point offset)
Expand All @@ -227,7 +173,7 @@ private Point old_ConvertGroupHeader(ExporterCollection mylist,BaseSection secti
base.DataNavigator.Fill(groupCollection);
base.FireSectionRendering(section);
ExporterCollection list = StandardPrinter.ConvertPlainCollection(groupCollection,offset);
StandardPrinter.EvaluateRow(base.Evaluator,list);
// StandardPrinter.EvaluateRow(base.Evaluator,list);
mylist.AddRange(list);
AfterConverting (section,list);

Expand All @@ -237,7 +183,6 @@ private Point old_ConvertGroupHeader(ExporterCollection mylist,BaseSection secti

private Point ConvertGroupChilds(ExporterCollection mylist, BaseSection section, ISimpleContainer simpleContainer, int defaultLeftPos, Point currentPosition)
{
//base.DataNavigator.FillChild(simpleContainer.Items);
PrepareContainerForConverting(section,simpleContainer);
Point curPos = BaseConverter.BaseConvert(mylist,simpleContainer,defaultLeftPos,currentPosition);
AfterConverting (section,mylist);
Expand All @@ -249,17 +194,16 @@ private Point ConvertStandardRow(ExporterCollection mylist, BaseSection section
{
base.FillRow(simpleContainer);
PrepareContainerForConverting(section,simpleContainer);
// base.FireSectionRendering(section);
Point curPos = BaseConverter.BaseConvert(mylist,simpleContainer,defaultLeftPos,currentPosition);
// StandardPrinter.EvaluateRow(base.Evaluator,mylist);
StandardPrinter.EvaluateRow(base.Evaluator,mylist);
AfterConverting (section,mylist);
return curPos;
}


private void AfterConverting (BaseSection section,ExporterCollection mylist)
{
StandardPrinter.EvaluateRow(base.Evaluator,mylist);
// StandardPrinter.EvaluateRow(base.Evaluator,mylist);

section.Items[0].Size = base.RestoreSize;
section.SectionOffset += section.Size.Height + 3 * GlobalValues.GapBetweenContainer;
Expand Down

0 comments on commit 7dadb2c

Please sign in to comment.