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

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterForstmeier committed Jul 26, 2011
1 parent e80c438 commit 1828a8d
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 136 deletions.
Expand Up @@ -64,12 +64,8 @@ protected void DrawControl (Graphics graphics,Rectangle borderRectangle)
Description("Draw a Border around the Item")]
public bool DrawBorder {get;set;}


protected new Size DefaultSize {get;set;}




public bool VisibleInReport {get;set;}

#endregion
Expand Down
Expand Up @@ -110,7 +110,7 @@ protected virtual Rectangle DisplayRectangle


#region Properties
// public bool Visible {get;set;}
public bool Visible {get;set;}

public bool VisibleInReport {get;set;}

Expand Down
Expand Up @@ -148,11 +148,11 @@ public Size MeasureOverride (Size availableSize)

// resultSize.Width = double.IsPositiveInfinity(availableSize.Width) ?
// resultSize.Width : availableSize.Width;
//
//
// resultSize.Height = double.IsPositiveInfinity(availableSize.Height) ?
// resultSize.Height : availableSize.Height;

resultSize.Width = double.IsPositiveInfinity(availableSize.Width) ?
resultSize.Width = double.IsPositiveInfinity(availableSize.Width) ?
resultSize.Width : availableSize.Width;
var b = double.IsPositiveInfinity(availableSize.Height);
resultSize.Height = double.IsPositiveInfinity(availableSize.Height) ?
Expand Down
Expand Up @@ -200,6 +200,8 @@ public override void Bind()

#endregion


#region Fill

public override void Fill(int position,ReportItemCollection collection)
{
Expand All @@ -210,6 +212,11 @@ public override void Fill(int position,ReportItemCollection collection)
}
}

public override void Fill(IDataItem item)
{
FillInternal(Current,item);
}


private void FillInternal(object fillFrom,IDataItem item)
{
Expand Down Expand Up @@ -248,67 +255,6 @@ private void FillInternal(object fillFrom,IDataItem item)
}
}

/*
private void FillInternal(object fillFrom,IDataItem item)
{
if (item is BaseDataItem)
{
var retVal = FollowPropertyPath(fillFrom,item.ColumnName);
if (retVal != null) {
item.DBValue = retVal.ToString();
} else {
item.DBValue = String.Empty;
}
}
else
{
//image processing from IList
BaseImageItem baseImageItem = item as BaseImageItem;
if (baseImageItem != null) {
PropertyDescriptor p = this.listProperties.Find(baseImageItem.ColumnName, true);
if (p != null) {
baseImageItem.Image = p.GetValue(this.Current) as System.Drawing.Image;
}
return;
}
}
}
*/

public override void Fill(IDataItem item)
{
FillInternal(Current,item);
}

#region PropertyPath from StackOverflow

//http://stackoverflow.com/questions/366332/best-way-to-get-sub-properties-using-getproperty

/*
private static object FollowPropertyPath(object value, string path)
{
Type currentType = value.GetType();
foreach (string propertyName in path.Split('.'))
{
PropertyInfo property = currentType.GetProperty(propertyName);
if (property != null) {
value = property.GetValue(value, null);
currentType = property.PropertyType;
} else {
return WrongColumnName(path);
}
}
return value;
}
*/

#endregion

static string WrongColumnName(string propertyName)
Expand Down
Expand Up @@ -64,8 +64,6 @@ protected void InitNewPage ()

if (this.EvaluatorFacade == null)
{
Console.WriteLine ("");
Console.WriteLine ("InitNewPage create evaluator");
EvaluatorFacade = EvaluationHelper.CreateEvaluator(SinglePage,SinglePage.IDataNavigator);
}
EvaluatorFacade.SinglePage = this.SinglePage;
Expand Down Expand Up @@ -182,7 +180,6 @@ protected ExporterCollection old_ConvertSection (BaseSection section,int dataRow
if (section.Items.Count > 0)
{
Size sectionSize = section.Size;
Console.WriteLine ("BasePager-createEval for {0}",section.Name);
IExpressionEvaluatorFacade evaluator = EvaluationHelper.CreateEvaluator(this.SinglePage,this.SinglePage.IDataNavigator);

Rectangle desiredRectangle = LayoutHelper.CalculateSectionLayout(this.Graphics,section);
Expand Down Expand Up @@ -309,40 +306,15 @@ protected void FinishRendering (IDataNavigator dataNavigator)
if (this.Pages.Count == 0) {
return;
}
Console.WriteLine ("FinishRendereing create IExpressionEvaluatorFacade");

//IExpressionEvaluatorFacade evaluatorFacade = new ExpressionEvaluatorFacade(this.SinglePage);
//Evaluator.SinglePage = this.SinglePage;
foreach (ExporterPage page in this.pages)
{
page.TotalPages = this.Pages.Count;
// dataNavigator.Reset();
// dataNavigator.MoveNext();
page.IDataNavigator = dataNavigator;
EvaluatorFacade.SinglePage = page;
EvaluateRecursive(EvaluatorFacade,page.Items);
}
}

/*
protected void FinishRendering (IDataNavigator dataNavigator)
{
if (this.Pages.Count == 0) {
return;
}
Console.WriteLine ("FinishRendereing create IExpressionEvaluatorFacade");
IExpressionEvaluatorFacade evaluatorFacade = new ExpressionEvaluatorFacade(this.SinglePage);
foreach (ExporterPage p in this.pages)
{
p.TotalPages = this.Pages.Count;
p.IDataNavigator = dataNavigator;
evaluatorFacade.SinglePage = p;
EvaluateRecursive(evaluatorFacade,p.Items);
}
}
*/

private static void EvaluateRecursive (IExpressionEvaluatorFacade evaluatorFassade,ExporterCollection items)
{
Expand Down
Expand Up @@ -27,9 +27,6 @@ public void CalculateGapList (BaseSection section)
for (int i = 0; i < section.Items.Count; i++) {
GapBetweenItems[i] = CalculateGap(oldItem,section.Items[i]);
}
for (int i = 0; i < section.Items.Count; i++) {
Console.WriteLine(GapBetweenItems[i]);
}
GapBetweenItems[section.Items.Count] = CalculateLastGap(section);
}

Expand Down
Expand Up @@ -33,7 +33,6 @@ public static IExpressionEvaluatorFacade CreateEvaluator (ISinglePage singlePag

throw new ArgumentNullException("singlePage");
}
Console.WriteLine ("EvaluationHelper.CreateEvaluator");
singlePage.IDataNavigator = dataNavigator;
IExpressionEvaluatorFacade evaluatorFacade = new ExpressionEvaluatorFacade(singlePage);
return evaluatorFacade;
Expand Down
Expand Up @@ -23,7 +23,6 @@ public class ExpressionEvaluatorFacade:IExpressionEvaluatorFacade

public ExpressionEvaluatorFacade(IPageInfo pageInfo)
{
Console.WriteLine("Eval-fassade Constr");
compiler = new ReportingLanguageCompiler();
this.context = new ExpressionContext(null);
context.ResolveUnknownVariable += VariableStore;
Expand All @@ -36,18 +35,13 @@ public ExpressionEvaluatorFacade(IPageInfo pageInfo)
public string Evaluate (string expression)
{
try {

string s = EvaluationHelper.ExtractExpressionPart(expression);
string r = EvaluationHelper.ExtractResultPart(expression);
if (s.Length > 0) {
this.context.ContextObject = this.SinglePage ;
return EvaluateExpression (s);
}

// if (EvaluationHelper.CanEvaluate(expression)) {
// this.context.ContextObject = this.SinglePage;
// return EvaluateExpression(expression);
// }

} catch (Exception e) {
expression = e.Message;
WriteLogMessage(e);
Expand All @@ -72,22 +66,6 @@ public string Evaluate (string expression, object row)
return expression;
}

/*
public string Evaluate (string expression, object row)
{
try {
if (EvaluationHelper.CanEvaluate(expression)) {
this.context.ContextObject = row;
return EvaluateExpression (expression);
}
} catch (Exception e) {
expression = e.Message;
WriteLogMessage(e);
}
return expression;
}
*/

public void Evaluate (IReportExpression expressionItem)
{
Expand All @@ -100,15 +78,13 @@ public void Evaluate (IReportExpression expressionItem)
} else {
expr = expressionItem.Text;
}

expressionItem.Text = Evaluate(expr);
}



string EvaluateExpression(string expression)
{
IExpression compiled = compiler.CompileExpression<string>(expression);
IExpression compiled = compiler.CompileExpression<string>(expression);
if (compiled != null) {
return (compiled.Evaluate(context)).ToString();
}
Expand Down
Expand Up @@ -133,7 +133,9 @@ public ReportingLanguage():base(false)
LUnOp.Rule = Symbol("-")
| "!";

FunctionExpression.Rule = QualifiedName + LCb + ExprList.Q() + RCb;
FunctionExpression.Rule = QualifiedName + LCb + ExprList.Q() + RCb
| QualifiedName + LCb + BinExpr + RCb;


QualifiedName.Rule = identifier
| QualifiedName + dot + identifier
Expand Down
Expand Up @@ -54,15 +54,23 @@ string ExtractValueFromSinglePage(ref Variable variable, ISinglePage singlePage,
{
if (singlePage.IDataNavigator.CurrentRow > -1)
{
var dataRow = singlePage.IDataNavigator.GetDataRow;
var item = dataRow.Find(variable.VariableName);
if (item != null) {
retval = item.Value.ToString();
} else {
retval = GlobalValues.UnkownFunctionMessage(variable.VariableName);
WriteLogmessage(variable);
try {
var dataRow = singlePage.IDataNavigator.GetDataRow;
var item = dataRow.Find(variable.VariableName);

if (item != null) {
retval = item.Value.ToString();
} else {
retval = GlobalValues.UnkownFunctionMessage(variable.VariableName);
WriteLogmessage(variable);
}

return retval;
} catch (Exception e) {
Console.WriteLine ("Error in FieldReference.ExtractValueFromSinglePage");
Console.WriteLine("IDataNavigator currentrow = {0} count = {1}",singlePage.IDataNavigator.CurrentRow,singlePage.IDataNavigator.Count);
throw e;
}
return retval;
}
return variable.VariableName;
}
Expand Down
Expand Up @@ -29,7 +29,7 @@ public static class PrintRendererFactory

if (t.Equals(typeof(BaseRowItem))) {
// return new GroupedRowConverter (dataNavigator,singlePage,layouter);
Console.WriteLine("render Row");
// Console.WriteLine("render Row");
}
return null;
}
Expand Down

0 comments on commit 1828a8d

Please sign in to comment.