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 @@ -17,12 +17,12 @@ namespace ICSharpCode.Reports.Core
private DataTypeHelper () {
}
internal static TypeCode TypeCodeFromString (string type) {
if (String.IsNullOrEmpty(type)) {
throw new ArgumentNullException("type");
}
return Type.GetTypeCode( Type.GetType(type));
}
// internal static TypeCode TypeCodeFromString (string type) {
// if (String.IsNullOrEmpty(type)) {
// throw new ArgumentNullException("type");
// }
// return Type.GetTypeCode( Type.GetType(type));
// }
/*
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 @@ -18,10 +18,18 @@ namespace ICSharpCode.Reports.Core.BaseClasses.Printing
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,
string dataType, string nullValue )
{
TypeCode typeCode = DataTypeHelper.TypeCodeFromString(dataType);
TypeCode typeCode = TypeCodeFromString(dataType);
return StandardFormatter.FormatItem(valueToFormat,format,
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 @@ -54,9 +54,17 @@ namespace ICSharpCode.Reports.Core.BaseClasses.Printing
throw new ArgumentNullException("decorator");
}
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.DrawString (text,decorator.Font,
graphics.DrawString (formattedString,decorator.Font,
new SolidBrush(decorator.ForeColor),
new Rectangle(decorator.Location.X,
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 { @@ -70,11 +70,15 @@ namespace ICSharpCode.Reports.Core.Exporter {
ColumnText columnText = new ColumnText(contentByte);
iTextSharp.text.Rectangle r = base.ConvertToPdfRectangle();
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,
this.StyleDecorator.DataType,String.Empty);
Console.WriteLine("--- {0}",formated);
Chunk chunk = new Chunk(formated,font);
string formatedText = this.text;
if (!String.IsNullOrEmpty(StyleDecorator.FormatString)) {
formatedText = StandardFormatter.FormatOutput(this.text,this.StyleDecorator.FormatString,
this.StyleDecorator.DataType,String.Empty);
}
Chunk chunk = new Chunk(formatedText,font);
columnText.AddText(chunk);
columnText.Go();

Loading…
Cancel
Save