Browse Source

Draw formatted String

pull/1/head
peterforstmeier 16 years ago
parent
commit
91fcce0a82
  1. 12
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/DataTypeHelper.cs
  2. 10
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/StandardFormatter.cs
  3. 10
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/TextDrawer.cs
  4. 14
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/ExportColumns/ExportText.cs

12
src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/DataTypeHelper.cs

@ -17,12 +17,12 @@ namespace ICSharpCode.Reports.Core
private DataTypeHelper () { private DataTypeHelper () {
} }
internal static TypeCode TypeCodeFromString (string type) { // internal static TypeCode TypeCodeFromString (string type) {
if (String.IsNullOrEmpty(type)) { // if (String.IsNullOrEmpty(type)) {
throw new ArgumentNullException("type"); // throw new ArgumentNullException("type");
} // }
return Type.GetTypeCode( Type.GetType(type)); // return Type.GetTypeCode( Type.GetType(type));
} // }
/* /*
internal static bool IsNumber(TypeCode tc){ internal static bool IsNumber(TypeCode tc){

10
src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/StandardFormatter.cs

@ -18,10 +18,18 @@ namespace ICSharpCode.Reports.Core.BaseClasses.Printing
internal static class StandardFormatter internal static class StandardFormatter
{ {
private static TypeCode TypeCodeFromString (string type) {
if (String.IsNullOrEmpty(type)) {
throw new ArgumentNullException("type");
}
return Type.GetTypeCode( Type.GetType(type));
}
public static string FormatOutput(string valueToFormat,string format, public static string FormatOutput(string valueToFormat,string format,
string dataType, string nullValue ) string dataType, string nullValue )
{ {
TypeCode typeCode = DataTypeHelper.TypeCodeFromString(dataType); TypeCode typeCode = TypeCodeFromString(dataType);
return StandardFormatter.FormatItem(valueToFormat,format, return StandardFormatter.FormatItem(valueToFormat,format,
typeCode,nullValue); typeCode,nullValue);
} }

10
src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/TextDrawer.cs

@ -54,9 +54,17 @@ namespace ICSharpCode.Reports.Core.BaseClasses.Printing
throw new ArgumentNullException("decorator"); throw new ArgumentNullException("decorator");
} }
StringFormat stringFormat = BuildStringFormat(decorator.StringTrimming,decorator.ContentAlignment); StringFormat stringFormat = BuildStringFormat(decorator.StringTrimming,decorator.ContentAlignment);
string formattedString = text;
if (! String.IsNullOrEmpty(decorator.FormatString)) {
formattedString = StandardFormatter.FormatOutput(text,decorator.FormatString,decorator.DataType,"yyy");
}
graphics.TextRenderingHint = TextRenderingHint.AntiAlias; graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
graphics.DrawString (text,decorator.Font, graphics.DrawString (formattedString,decorator.Font,
new SolidBrush(decorator.ForeColor), new SolidBrush(decorator.ForeColor),
new Rectangle(decorator.Location.X, new Rectangle(decorator.Location.X,
decorator.Location.Y, decorator.Location.Y,

14
src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/ExportColumns/ExportText.cs

@ -70,11 +70,15 @@ namespace ICSharpCode.Reports.Core.Exporter {
ColumnText columnText = new ColumnText(contentByte); ColumnText columnText = new ColumnText(contentByte);
iTextSharp.text.Rectangle r = base.ConvertToPdfRectangle(); iTextSharp.text.Rectangle r = base.ConvertToPdfRectangle();
columnText.SetSimpleColumn(r.Left, r.Top , r.Left + r.Width,r.Top - r.Height,pdfFormat.Leading,pdfFormat.Alignment); columnText.SetSimpleColumn(r.Left, r.Top , r.Left + r.Width,r.Top - r.Height,pdfFormat.Leading,pdfFormat.Alignment);
string formated = StandardFormatter.FormatOutput(this.text,this.StyleDecorator.FormatString, string formatedText = this.text;
this.StyleDecorator.DataType,String.Empty);
Console.WriteLine("--- {0}",formated); if (!String.IsNullOrEmpty(StyleDecorator.FormatString)) {
Chunk chunk = new Chunk(formated,font); formatedText = StandardFormatter.FormatOutput(this.text,this.StyleDecorator.FormatString,
this.StyleDecorator.DataType,String.Empty);
}
Chunk chunk = new Chunk(formatedText,font);
columnText.AddText(chunk); columnText.AddText(chunk);
columnText.Go(); columnText.Go();

Loading…
Cancel
Save