Exemplo n.º 1
0
        public static void DrawString(Graphics graphics, string text,
                                      ICSharpCode.Reports.Core.Exporter.TextStyleDecorator decorator)
        {
            if (graphics == null)
            {
                throw new ArgumentNullException("graphics");
            }
            if (decorator == null)
            {
                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(formattedString, decorator.Font,
                                new SolidBrush(decorator.ForeColor),
                                new Rectangle(decorator.Location.X,
                                              decorator.Location.Y,
                                              decorator.Size.Width,
                                              decorator.Size.Height),
                                stringFormat);
        }
Exemplo n.º 2
0
        public static string FormatOutput(string valueToFormat, string format,
                                          string dataType, string nullValue)
        {
            TypeCode typeCode = TypeCodeFromString(dataType);

            return(StandardFormatter.FormatItem(valueToFormat, format,
                                                typeCode, nullValue));
        }