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

Commit

Permalink
Rows can be used as StackPanel.Orientation=horizontal, PageHeader can…
Browse files Browse the repository at this point in the history
… display a List of rows
  • Loading branch information
PeterForstmeier committed Mar 2, 2011
1 parent 42bf8d4 commit 0da20d9
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 41 deletions.
Expand Up @@ -16,14 +16,25 @@ namespace ICSharpCode.Reports.Core.BaseClasses.Printing


internal sealed class LayoutHelper internal sealed class LayoutHelper
{ {
public static Rectangle FixSectionLayout(Graphics graphics,BaseSection section) public static Rectangle CalculateSectionLayout(Graphics graphics,BaseSection section)
{ {
ILayouter layouter = (ILayouter)ServiceContainer.GetService(typeof(ILayouter)); ILayouter layouter = (ILayouter)ServiceContainer.GetService(typeof(ILayouter));
var desiredRectangle = layouter.Layout(graphics, section); var desiredRectangle = layouter.Layout(graphics, section);
return desiredRectangle; return desiredRectangle;
} }




public static void FixSectionLayout(Rectangle desiredRectangle, BaseSection section)
{
Rectangle sectionRectangle = new Rectangle(section.Location, section.Size);
if (!sectionRectangle.Contains(desiredRectangle)) {
section.Size = new Size(section.Size.Width,
desiredRectangle.Size.Height + GlobalValues.ControlMargins.Top + GlobalValues.ControlMargins.Bottom);
}
}



public static void SetLayoutForRow (Graphics graphics, ILayouter layouter,ISimpleContainer row) public static void SetLayoutForRow (Graphics graphics, ILayouter layouter,ISimpleContainer row)
{ {
Rectangle textRect = layouter.Layout(graphics,row); Rectangle textRect = layouter.Layout(graphics,row);
Expand Down
Expand Up @@ -32,7 +32,7 @@ public Rectangle Layout(Graphics graphics,ISimpleContainer container)
} }


// Console.WriteLine("\tlayouter for container <{0}>",container.ToString()); // Console.WriteLine("\tlayouter for container <{0}>",container.ToString());
Console.WriteLine("\tLayouter for Container"); // Console.WriteLine("\tLayouter for Container");
Rectangle desiredContainerRectangle = new Rectangle (container.Location,container.Size); Rectangle desiredContainerRectangle = new Rectangle (container.Location,container.Size);


System.Collections.Generic.IEnumerable<BaseReportItem> canGrowShrinkCollection = from bt in container.Items where bt.CanGrow == true select bt; System.Collections.Generic.IEnumerable<BaseReportItem> canGrowShrinkCollection = from bt in container.Items where bt.CanGrow == true select bt;
Expand Down Expand Up @@ -71,7 +71,7 @@ public Rectangle Layout(Graphics graphics,BaseSection section)
} }


// Console.WriteLine("\tLayouter for Container");Console.WriteLine("\tlayouter for section <{0}>",section.Name); // Console.WriteLine("\tLayouter for Container");Console.WriteLine("\tlayouter for section <{0}>",section.Name);
Console.WriteLine("\tLayouter for Section"); // Console.WriteLine("\tLayouter for Section");
IEnumerable<BaseReportItem> canGrowShrinkCollection = from bt in section.Items where bt.CanGrow == true select bt; IEnumerable<BaseReportItem> canGrowShrinkCollection = from bt in section.Items where bt.CanGrow == true select bt;


Rectangle desiredSectionRectangle = new Rectangle(section.Location.X, Rectangle desiredSectionRectangle = new Rectangle(section.Location.X,
Expand Down
Expand Up @@ -224,7 +224,9 @@ public static ExportContainer ConvertToContainer (ISimpleContainer container,Poi
lineItem.StyleDecorator.Size); lineItem.StyleDecorator.Size);


AdjustBackColor (container); AdjustBackColor (container);
return lineItem; Console.WriteLine("\tstart container at {0}",lineItem.StyleDecorator.Location);
return lineItem;

} }
return null; return null;
} }
Expand Down
Expand Up @@ -96,7 +96,7 @@ public void MeasurePageHeader (IReportItem section)
throw new ArgumentNullException("section"); throw new ArgumentNullException("section");
} }


section.SectionOffset = this.reportHeaderRectangle.Bottom + + 3 * GlobalValues.GapBetweenContainer; section.SectionOffset = this.reportHeaderRectangle.Bottom + 3 * GlobalValues.GapBetweenContainer;
this.pageHeaderRectangle = new Rectangle (this.reportHeaderRectangle.Left, this.pageHeaderRectangle = new Rectangle (this.reportHeaderRectangle.Left,
section.SectionOffset, section.SectionOffset,
this.marginBounds.Width, this.marginBounds.Width,
Expand Down
Expand Up @@ -85,74 +85,74 @@ protected virtual void BuildNewPage ()


#region Converters #region Converters


//Point currentPosition = Point.Empty;
protected Point Offset {get;set;}


protected ExporterCollection ConvertSection (BaseSection section,int dataRow) protected ExporterCollection ConvertSection (BaseSection section,int dataRow)
{ {
FireSectionRenderEvent (section ,dataRow); FireSectionRenderEvent (section ,dataRow);

Console.WriteLine("");
Console.WriteLine("section {0}",section.Name);
PrintHelper.AdjustParent((BaseSection)section,section.Items); PrintHelper.AdjustParent((BaseSection)section,section.Items);


var list = new ExporterCollection(); var list = new ExporterCollection();
Offset = new Point(section.Location.X,section.SectionOffset);


if (section.Items.Count > 0) { if (section.Items.Count > 0) {


section.Items.SortByLocation(); section.Items.SortByLocation();


var offset = new Point(section.Location.X,section.SectionOffset); IExpressionEvaluatorFacade evaluator = EvaluationHelper.CreateEvaluator(this.SinglePage,this.SinglePage.IDataNavigator);
IExpressionEvaluatorFacade f = EvaluationHelper.CreateEvaluator(this.SinglePage,this.SinglePage.IDataNavigator);


Rectangle desiredRectangle = LayoutHelper.FixSectionLayout(this.Graphics,section); Rectangle desiredRectangle = LayoutHelper.CalculateSectionLayout(this.Graphics,section);

LayoutHelper.FixSectionLayout(desiredRectangle,section);
Setlayout( desiredRectangle, section);


foreach (BaseReportItem item in section.Items) { foreach (BaseReportItem item in section.Items)
{
ISimpleContainer simpleContainer = item as ISimpleContainer; ISimpleContainer simpleContainer = item as ISimpleContainer;



if (simpleContainer != null) if (simpleContainer != null)
{ {
foreach (BaseTextItem v in simpleContainer.Items) EvaluationHelper.EvaluateReportItems(evaluator,simpleContainer.Items);
{
string ss = f.Evaluate(v.Text);
v.Text = ss;
}
Size s = simpleContainer.Size; Size s = simpleContainer.Size;
var l = (ILayouter)ServiceContainer.GetService(typeof(ILayouter)); var l = (ILayouter)ServiceContainer.GetService(typeof(ILayouter));
LayoutHelper.SetLayoutForRow(Graphics,l, simpleContainer); LayoutHelper.SetLayoutForRow(Graphics,l, simpleContainer);


ExportContainer exportContainer = StandardPrinter.ConvertToContainer(simpleContainer,offset); ExportContainer exportContainer = StandardPrinter.ConvertToContainer(simpleContainer,Offset);
Console.WriteLine ("offset {0}",Offset);
Console.WriteLine("start exportContainer container at {0} with height {1}",exportContainer.StyleDecorator.Location,exportContainer.StyleDecorator.Size.Height);
s = simpleContainer.Size; s = simpleContainer.Size;
ExporterCollection clist = StandardPrinter.ConvertPlainCollection(simpleContainer.Items,exportContainer.StyleDecorator.Location); ExporterCollection clist = StandardPrinter.ConvertPlainCollection(simpleContainer.Items,exportContainer.StyleDecorator.Location);
exportContainer.Items.AddRange(clist); exportContainer.Items.AddRange(clist);
list.Add(exportContainer); list.Add(exportContainer);
offset = new Point(offset.X,offset.Y + simpleContainer.Size.Height + 4* GlobalValues.GapBetweenContainer); Offset = new Point(Offset.X,Offset.Y + exportContainer.StyleDecorator.Size.Height);

Console.WriteLine ("new offset {0}",Offset);



foreach (ExportText VARIABLE in clist) // foreach (ExportText VARIABLE in clist)
{ // {
Console.WriteLine("{0} - {1}",VARIABLE.Text,VARIABLE.StyleDecorator.Location); // Console.WriteLine("{0} - {1}",VARIABLE.Text,VARIABLE.StyleDecorator.Location);
} // }
Console.WriteLine("......."); // Console.WriteLine(".......");


} else {
list = StandardPrinter.ConvertPlainCollection(section.Items,offset);
} }
else
{
Console.WriteLine("start section {0} at {1}",section.Name,section.SectionOffset + section.Location.Y);
list = StandardPrinter.ConvertPlainCollection(section.Items,Offset);
Offset = new Point(Offset.X,Offset.Y + section.Size.Height);
}
section.Size = new Size(section.Size.Width,section.Size.Height);
} }
Console.WriteLine ("\toffset {0} sectionoffset {1}",Offset,section.SectionOffset);

} }
Console.WriteLine ("Cuurent location {0} section.botom {1}",Offset,section.Location.Y + section.Size.Height);
return list; return list;
} }



void Setlayout(Rectangle desiredRectangle, BaseSection section)
{
Rectangle sectionRectangle = new Rectangle(section.Location, section.Size);
if (!sectionRectangle.Contains(desiredRectangle)) {
section.Size = new Size(section.Size.Width,
desiredRectangle.Size.Height + GlobalValues.ControlMargins.Top + GlobalValues.ControlMargins.Bottom);
}
}



public static BaseRectangleItem CreateDebugItem (BaseReportItem item) public static BaseRectangleItem CreateDebugItem (BaseReportItem item)
{ {
Expand All @@ -164,7 +164,6 @@ public static BaseRectangleItem CreateDebugItem (BaseReportItem item)
return debugRectangle; return debugRectangle;
} }



#endregion #endregion




Expand Down
Expand Up @@ -78,9 +78,12 @@ protected override void BuildReportHeader ()
protected override void BuildPageHeader () protected override void BuildPageHeader ()
{ {
base.ReportModel.PageHeader.SectionOffset = base.AdjustPageHeader(); base.ReportModel.PageHeader.SectionOffset = base.AdjustPageHeader();

Console.WriteLine ("pageHeader {0}",base.ReportModel.PageHeader.Size);
ExporterCollection convertedList = base.ConvertSection (base.ReportModel.PageHeader,this.dataNavigator.CurrentRow); ExporterCollection convertedList = base.ConvertSection (base.ReportModel.PageHeader,this.dataNavigator.CurrentRow);
Console.WriteLine ("pageHeader {0}",base.ReportModel.PageHeader.Size);
// base.ReportModel.PageHeader.Size = new Size(base.ReportModel.PageHeader.Size.Width,base.Offset.Y);
base.SectionBounds.MeasurePageHeader(base.ReportModel.PageHeader); base.SectionBounds.MeasurePageHeader(base.ReportModel.PageHeader);
Console.WriteLine ("rect {0} detail {1}",base.SectionBounds.PageHeaderRectangle,base.SectionBounds.DetailStart);
base.SinglePage.Items.AddRange(convertedList); base.SinglePage.Items.AddRange(convertedList);
} }


Expand Down
Expand Up @@ -42,6 +42,24 @@ public static IExpressionEvaluatorFacade CreateEvaluator (ISinglePage singlePag
} }




public static void EvaluateReportItems (IExpressionEvaluatorFacade evaluator,ReportItemCollection items)
{
try {
foreach(BaseReportItem column in items) {
var container = column as ISimpleContainer ;
if (container != null) {
EvaluateReportItems(evaluator,container.Items);
}
BaseTextItem textItem = column as BaseTextItem;
if (textItem != null) {
textItem.Text = evaluator.Evaluate(textItem.Text);
}
}
} catch (Exception) {
throw ;
}
}

public static void EvaluateRow(IExpressionEvaluatorFacade evaluator,ExporterCollection row) public static void EvaluateRow(IExpressionEvaluatorFacade evaluator,ExporterCollection row)
{ {
try { try {
Expand Down

0 comments on commit 0da20d9

Please sign in to comment.