1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
6
using ICSharpCode.Reports.Core.Exporter;
7
using ICSharpCode.Reports.Core.Globals;
8
using ICSharpCode.Reports.Core.Interfaces;
9
using ICSharpCode.Reports.Expressions.ReportingLanguage;
11
namespace ICSharpCode.Reports.Core.BaseClasses.Printing
14
/// Description of StandardPrinter.
18
internal sealed class StandardPrinter
20
public StandardPrinter()
25
public static void AdjustBackColor (ISimpleContainer container)
27
foreach (var item in container.Items)
29
item.BackColor = container.BackColor;
34
public static void FillBackground (Graphics graphics,BaseStyleDecorator decorator)
36
if (decorator.BackColor != GlobalValues.DefaultBackColor) {
38
RectangleShape backgroundShape = new RectangleShape();
40
backgroundShape.FillShape(graphics,
41
new SolidFillPattern(decorator.BackColor),
42
decorator.DisplayRectangle);
47
public static void DrawBorder (Graphics graphics,BaseStyleDecorator decorator)
49
if (decorator.DrawBorder)
51
if (decorator.FrameColor == Color.Empty)
53
decorator.FrameColor = decorator.ForeColor;
55
Border border = new Border(new BaseLine (decorator.FrameColor,System.Drawing.Drawing2D.DashStyle.Solid,1));
56
border.DrawBorder(graphics,decorator.DisplayRectangle);
61
#region Render/Convert SimpleItem
64
/// Convert a single item, Location is calculated as follows
66
/// <param name="offset"> only Y value is used, gives the offset to Items location.Y </param>
67
/// <param name="item">Item to convert</param>
68
/// <returns></returns>
71
private static void RenderLineItem (BaseReportItem item, Point offset,IExpressionEvaluatorFacade evaluator,ReportPageEventArgs rpea)
74
Point saveLocation = new Point (item.Location.X,item.Location.Y);
76
PrintHelper.AdjustChildLocation(item,offset);
78
IReportExpression epr = item as IReportExpression;
80
string evaluatedValue = String.Empty;
84
if (!String.IsNullOrEmpty(epr.Expression))
86
evaluatedValue = evaluator.Evaluate(epr.Expression);
90
evaluatedValue = evaluator.Evaluate(epr.Text);
92
epr.Text = evaluatedValue;
94
} catch (UnknownFunctionException ufe) {
96
epr.Text = GlobalValues.UnkownFunctionMessage(ufe.Message);
101
item.Location = saveLocation;
108
#region Render Collection
110
public static Rectangle RenderPlainCollection (BaseReportItem parent,
111
ReportItemCollection items,
112
IExpressionEvaluatorFacade evaluator,
114
ReportPageEventArgs rpea)
117
if (items.Count > 0) {
118
foreach (BaseReportItem child in items) {
119
child.Parent = parent;
120
StandardPrinter.RenderLineItem (child,offset,evaluator,rpea);
123
return new Rectangle(offset,parent.Size);
131
public static Rectangle RenderContainer (ISimpleContainer simpleContainer,IExpressionEvaluatorFacade evaluator,Point offset,ReportPageEventArgs rpea)
134
BaseReportItem item = simpleContainer as BaseReportItem;
135
Rectangle retVal = new Rectangle(offset,item.Size);
136
Point saveLocation = item.Location;
137
PrintHelper.AdjustChildLocation(item,offset);
142
if (simpleContainer.Items != null) {
143
retVal = StandardPrinter.RenderPlainCollection(item,simpleContainer.Items,evaluator,offset,rpea);
146
retVal = new Rectangle (retVal.X,retVal.Y,
147
retVal.X + item.Size.Width,
148
item.Size.Height + 3 * GlobalValues.GapBetweenContainer);
149
item.Location = saveLocation;