Esempio n. 1
0
 public override void Visit(ExportText exportColumn)
 {
     if (!String.IsNullOrEmpty(exportColumn.FormatString))
     {
         StandardFormatter.FormatOutput(exportColumn);
     }
 }
Esempio n. 2
0
        public void NegativeTimeSpan_HH_mm_ss()
        {
            string toFormat = "-5:50:10";
            string format   = "H:mm:ss";
            var    result   = StandardFormatter.FormatOutput(toFormat, format, dateTimetype, nullValue);

            Assert.That(result, Is.EqualTo("-5:50:10"));
        }
Esempio n. 3
0
        public void TypeDateTimeOfResultIsString()
        {
            string toFormat = "2012/02/12";
            string format   = "dd.MM.yy";
            var    result   = StandardFormatter.FormatOutput(toFormat, format, dateTimetype, nullValue);

            Assert.That(result, Is.TypeOf(typeof(string)));
        }
Esempio n. 4
0
        public void DateTime_dd_MM_YY()
        {
            string toFormat = "2012/02/12";
            string format   = "dd.MM.yy";
            var    result   = StandardFormatter.FormatOutput(toFormat, format, dateTimetype, nullValue);

            Assert.That(result, Is.EqualTo("12.02.12"));
        }
Esempio n. 5
0
        public void Empty_Input_Returns_NullValue()
        {
            string toFormat = string.Empty;;
            string format   = "dd/MM/yy";
            var    result   = StandardFormatter.FormatOutput(toFormat, format, stringType, nullValue);

            Assert.That(result, Is.EqualTo(nullValue));
        }
Esempio n. 6
0
        public void String_Is_Not_Formatted()
        {
            string toFormat = "Hello World";
            string format   = "dd/MM/yy";
            var    result   = StandardFormatter.FormatOutput(toFormat, format, stringType, nullValue);

            Assert.That(result, Is.EqualTo(toFormat));
        }
Esempio n. 7
0
        public void TypeOfTimeSpanResultIsString()
        {
            string toFormat = "5,50,10";
            string format   = "H:mm:ss";
            var    result   = StandardFormatter.FormatOutput(toFormat, format, dateTimetype, nullValue);

            Assert.That(result, Is.TypeOf(typeof(string)));
        }
Esempio n. 8
0
        public void TimeSpan_HH_mm()
        {
            string toFormat = "5:50:10";
            string format   = "HH:mm";
            var    result   = StandardFormatter.FormatOutput(toFormat, format, dateTimetype, nullValue);

            Assert.That(result, Is.EqualTo("05:50"));
        }
Esempio n. 9
0
 public override void Visit(ExportText exportColumn)
 {
     Console.WriteLine(exportColumn.Text);
     if (!String.IsNullOrEmpty(exportColumn.FormatString))
     {
         StandardFormatter.FormatOutput(exportColumn);
     }
 }
Esempio n. 10
0
        public override void DrawItem(PdfWriter pdfWriter,
                                      ICSharpCode.Reports.Core.Exporter.ExportRenderer.PdfUnitConverter converter)
        {
            if (pdfWriter == null)
            {
                throw new ArgumentNullException("pdfWriter");
            }
            if (converter == null)
            {
                throw new ArgumentNullException("converter");
            }
            base.DrawItem(pdfWriter, converter);

            iTextSharp.text.Font font = null;

            if (this.StyleDecorator.Font.Unit == GraphicsUnit.Point)
            {
                font = FontFactory.GetFont(this.StyleDecorator.Font.FontFamily.Name,
                                           BaseFont.IDENTITY_H,
                                           this.StyleDecorator.Font.Size,
                                           (int)this.StyleDecorator.Font.Style,
                                           this.StyleDecorator.PdfForeColor);
            }
            else
            {
                font = FontFactory.GetFont(this.StyleDecorator.Font.FontFamily.Name,
                                           BaseFont.IDENTITY_H,
                                           UnitConverter.FromPixel(this.StyleDecorator.Font.Size).Point,
                                           (int)this.StyleDecorator.Font.Style,
                                           this.StyleDecorator.PdfForeColor);
            }

            base.Decorate();

            PdfContentByte contentByte = base.PdfWriter.DirectContent;

            CalculatePdfFormat pdfFormat = new CalculatePdfFormat(this.StyleDecorator, font);

            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 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();
        }
Esempio n. 11
0
        public void FormatTimeSpanfromTime()
        {
            var ti = new BaseTextItem();

            ti.DataType     = "System.TimeSpan";
            ti.FormatString = "hh:mm:ss";
            ti.Text         = new TimeSpan(7, 17, 20).ToString();
            var exportColumn = (ExportText)ti.CreateExportColumn();

            StandardFormatter.FormatOutput(exportColumn);
            Assert.That(ti.Text, Is.EqualTo("07:17:20"));
        }
Esempio n. 12
0
        public void ConvertResultToDateTime()
        {
            DateTime date;
            string   toFormat = "2012/02/12";
            string   format   = "dd.MM.yy";
            var      result   = StandardFormatter.FormatOutput(toFormat, format, dateTimetype, nullValue);


            bool valid = DateTime.TryParse(toFormat, out date);

            Assert.That(valid, Is.True);
            Assert.That(date, Is.EqualTo(new DateTime(2012, 02, 12)));
        }
Esempio n. 13
0
        public void ConvertResultToTimeSpan()
        {
            TimeSpan time;
            string   toFormat = "5:50:10";
            string   format   = "H:mm:ss";
            var      result   = StandardFormatter.FormatOutput(toFormat, format, dateTimetype, nullValue);

            bool valid = TimeSpan.TryParseExact(result,
                                                "c",
                                                CultureInfo.CurrentCulture,
                                                out time);

            Assert.That(valid, Is.True);
            Assert.That(time, Is.EqualTo(new TimeSpan(5, 50, 10)));
        }
        public void NegativeTimeSpan_HH_mm_ss()
        {
            TimeSpan time;
            string   toFormat = "-5:50:10";
            string   format   = "H:mm:ss";
            var      result   = StandardFormatter.FormatOutput(toFormat, format, dateTimetype, nullValue);

            Assert.That(result, Is.EqualTo("-5:50:10"));
            bool valid = TimeSpan.TryParseExact(result,
                                                "c",
                                                CultureInfo.CurrentCulture,
                                                out time);

            Assert.That(valid, Is.True);
        }
Esempio n. 15
0
        public override void DrawItem(PdfWriter pdfWriter,
                                      ICSharpCode.Reports.Core.Exporter.ExportRenderer.PdfUnitConverter converter)
        {
            if (pdfWriter == null)
            {
                throw new ArgumentNullException("pdfWriter");
            }
            if (converter == null)
            {
                throw new ArgumentNullException("converter");
            }
            base.DrawItem(pdfWriter, converter);

            base.Decorate();

            PdfContentByte contentByte = base.PdfWriter.DirectContent;

            iTextSharp.text.Font font      = CreateFontFromFactory(this.StyleDecorator);
            CalculatePdfFormat   pdfFormat = new CalculatePdfFormat(this.StyleDecorator, font);

            ColumnText columnText = new ColumnText(contentByte);

            if (StyleDecorator.RightToLeft.ToString() == "Yes")
            {
                columnText.RunDirection = PdfWriter.RUN_DIRECTION_RTL;
            }

            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 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();
        }
Esempio n. 16
0
        public override void DrawItem(PdfWriter pdfWriter,
                                      ICSharpCode.Reports.Core.Exporter.ExportRenderer.PdfUnitConverter converter)
        {
            if (pdfWriter == null)
            {
                throw new ArgumentNullException("pdfWriter");
            }
            if (converter == null)
            {
                throw new ArgumentNullException("converter");
            }
            base.DrawItem(pdfWriter, converter);

            iTextSharp.text.Font font = null;

            if (this.StyleDecorator.Font.Unit == GraphicsUnit.Point)
            {
                font = FontFactory.GetFont(this.StyleDecorator.Font.FontFamily.Name,
                                           BaseFont.IDENTITY_H,
                                           this.StyleDecorator.Font.Size,
                                           (int)this.StyleDecorator.Font.Style,
                                           this.StyleDecorator.PdfForeColor);
            }
            else
            {
                font = FontFactory.GetFont(this.StyleDecorator.Font.FontFamily.Name,
                                           BaseFont.IDENTITY_H,
                                           UnitConverter.FromPixel(this.StyleDecorator.Font.Size).Point,
                                           (int)this.StyleDecorator.Font.Style,
                                           this.StyleDecorator.PdfForeColor);
            }
//
//			http://www.google.de/search?hl=de&q=itextsharp+%2B+measure+text&start=10&sa=N
//			http://www.mikesdotnetting.com/Article/82/iTextSharp-Adding-Text-with-Chunks-Phrases-and-Paragraphs
//			http://www.mikesdotnetting.com/Category/20

//	itextsharp + columntext + textheight
//itextsharp + columntext + rectangle

//itextsharp + simulate
//http://www.mail-archive.com/[email protected]/msg04747.html
            base.Decorate();
            PdfContentByte contentByte = base.PdfWriter.DirectContent;

            iTextSharp.text.Rectangle r = base.ConvertToPdfRectangle();
            ColumnText columnText       = new ColumnText(contentByte);
            PdfFormat  pdfFormat        = new PdfFormat(this.StyleDecorator, font);

            columnText.SetSimpleColumn(r.Left, r.Top, r.Left + r.Width, r.Height, pdfFormat.Leading, pdfFormat.Alignment);
//			int a = Convert.ToInt16((r.Height/font.Size) + 1);
//			columnText.SetSimpleColumn(r.Left, r.Top , r.Left + r.Width,r.Height,a,pdfFormat.Alignment);
            string formated = StandardFormatter.FormatOutput(this.text, this.StyleDecorator.FormatString,
                                                             this.StyleDecorator.DataType, String.Empty);

            Chunk chunk = new Chunk(formated, font);

            columnText.AddText(chunk);

            columnText.Go();
            int i = columnText.LinesWritten;

            if (i > 1)
            {
                Console.WriteLine("{0} - {1}", i, this.text);
                Console.WriteLine("dif {0}", r.Height / font.Size);
            }
        }