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

Commit

Permalink
PageBreakOnGroupChange
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterForstmeier committed Sep 30, 2010
1 parent 2ce0cd7 commit d680730
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 49 deletions.
Expand Up @@ -27,7 +27,8 @@ public BaseGroupedRow()
TypeDescriptor.AddProvider(new GroupedRowTypeProvider(), typeof(BaseGroupedRow));
}


[Category("Behavior")]
public bool PageBreakOnGroupChange {get;set;}
}


Expand Down Expand Up @@ -83,16 +84,17 @@ public override PropertyDescriptorCollection GetProperties(Attribute[] attribute

prop = props.Find("Controls",true);
allProperties.Add(prop);
/*
prop = props.Find("Padding",true);
allProperties.Add(prop);
*/

prop = props.Find("AlternateBackColor",true);
allProperties.Add(prop);

prop = props.Find("ChangeBackColorEveryNRow",true);
allProperties.Add(prop);

prop = props.Find("PageBreakOnGroupChange",true);
allProperties.Add(prop);


return new PropertyDescriptorCollection(allProperties.ToArray());
}
}
Expand Down
Expand Up @@ -91,10 +91,8 @@ public override void Draw(Graphics graphics)
[Browsable(true),
Category("Appearance"),
Description("String to format Number's Date's etc")]

[DefaultValue("entry1")]

[TypeConverter(typeof(FormatStringConverter))]
[TypeConverter(typeof(FormatStringConverter))]

public string FormatString {
get { return formatString; }
Expand Down
Expand Up @@ -17,7 +17,8 @@ public class BaseGroupedRow:BaseRowItem
{
public BaseGroupedRow():base()
{
Console.WriteLine("Constr baseGroupedrow");
}

public bool PageBreakOnGroupChange {get;set;}
}
}
Expand Up @@ -49,7 +49,8 @@ public CurrentItemsCollection GetDataRow()

public bool HasMoreData {
get {
if (this.CurrentRow < this.Count -1 ){
if (this.CurrentRow < store.IndexList.Count +1 ){
// if (this.CurrentRow < this.Count -1 ){
return true;
} else {
return false;
Expand All @@ -68,6 +69,7 @@ public CurrentItemsCollection GetDataRow()

public bool IsSorted {get {return this.store.IsSorted;}}


public bool IsGrouped {get {return this.store.IsGrouped;}}


Expand Down Expand Up @@ -110,33 +112,6 @@ public bool HasChildren
}
}


/*
public int ChildListCount
{
get {
return BuildChildList().Count;
}
}
*/


// at the moment only tables are working
/*
public void FillChild (ReportItemCollection collection)
{
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);
CurrentItem s = currentItemsCollection.FirstOrDefault(x => x.ColumnName == dataItem.ColumnName);
dataItem.DBValue = s.Value.ToString();
}
}
}
*/

private IndexList BuildChildList()
{
Expand Down
Expand Up @@ -104,10 +104,10 @@ public override void Sort()
public override void Group ()
{
base.Group();
IndexList gl = new IndexList("group");
gl = this.BuildSortIndex (ReportSettings.GroupColumnsCollection);
ShowIndexList(gl);
BuildGroup(gl);
IndexList sortedIndexList = new IndexList("group");
sortedIndexList = this.BuildSortIndex (ReportSettings.GroupColumnsCollection);
ShowIndexList(sortedIndexList);
BuildGroup(sortedIndexList);

}

Expand Down
Expand Up @@ -102,12 +102,24 @@ private ExporterCollection ConvertDataRow (ISimpleContainer simpleContainer)
pageBreakRect = PrintHelper.CalculatePageBreakRectangle((BaseReportItem)section.Items[1],currentPosition);

if (PrintHelper.IsPageFull(pageBreakRect,base.SectionBounds )) {
base.BuildNewPage(exporterCollection,section);
ForcePagePreak (exporterCollection,section);
// base.BuildNewPage(exporterCollection,section);
currentPosition = CalculateStartPosition ();
}


}

while ( childNavigator.MoveNext());
if (PageBreakAfterGroupChange(section) ) {
var b = base.DataNavigator.HasMoreData;
Console.WriteLine("datanav {0}",b);
ForcePagePreak (exporterCollection,section);
Console.WriteLine ("PageBreakaftrer");

currentPosition = CalculateStartPosition ();
}

var groupedRow = new Collection<BaseGroupedRow>(section.Items.OfType<BaseGroupedRow>().ToList());
base.Evaluator.SinglePage.IDataNavigator = base.DataNavigator;
}
}
Expand All @@ -119,12 +131,13 @@ private ExporterCollection ConvertDataRow (ISimpleContainer simpleContainer)

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

ShouldDrawBorder (section,exporterCollection);


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

Expand All @@ -136,30 +149,47 @@ private ExporterCollection ConvertDataRow (ISimpleContainer simpleContainer)
}



void ForcePagePreak(ExporterCollection exporterCollection, BaseSection section)
{
base.BuildNewPage(exporterCollection,section);
}


bool PageBreakAfterGroupChange(BaseSection section)
{
var groupedRowCollection = new Collection<BaseGroupedRow>(section.Items.OfType<BaseGroupedRow>().ToList());
var groupedRow = groupedRowCollection[0];
Console.WriteLine(base.DataNavigator.HasMoreData);

return groupedRow.PageBreakOnGroupChange;
}


private Point CalculateStartPosition()
{
return new Point(base.SectionBounds.PageHeaderRectangle.X,base.SectionBounds.PageHeaderRectangle.Y);
}


private Point ConvertGroupHeader(ExporterCollection mylist,BaseSection section,ISimpleContainer simpleContainer,int leftPos,Point offset)
private Point ConvertGroupHeader(ExporterCollection exportList,BaseSection section,ISimpleContainer simpleContainer,int leftPos,Point offset)
{
Point retVal = Point.Empty;
ReportItemCollection groupCollection = null;
var grh = new Collection<BaseGroupedRow>(section.Items.OfType<BaseGroupedRow>().ToList());
if (grh.Count == 0) {
var groupedRow = new Collection<BaseGroupedRow>(section.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);

mylist.AddRange(list);
exportList.AddRange(list);
AfterConverting (section,list);
retVal = new Point (leftPos,offset.Y + groupCollection[0].Size.Height + 20 + (3 *GlobalValues.GapBetweenContainer));
} else {
retVal = ConvertStandardRow(mylist,section,grh[0],leftPos,offset);
retVal = ConvertStandardRow(exportList,section,groupedRow[0],leftPos,offset);
}
return retVal;
}
Expand Down

0 comments on commit d680730

Please sign in to comment.