using System.Collections.Generic; using Consulenza.ReportWriter.Business.OBJ_PDF; using Consulenza.ReportWriter.Business.Entity; using ceTe.DynamicPDF; namespace Consulenza.ReportWriter.Business.CUSTOM_PDF.ConsulenzaUnica { /// /// Oggetto custom che disegna l'intestazione del capitolo per ConsulenzaUnica. /// E' formato da 2 rettangoli rossi, un testo bianco (Title) e un testo introduttivo (Subtitle). /// public class SectionHeadingPDF : CompositePDF { private readonly FontFamily _fontfamily; /// /// Imposta o recupera il testo principale. [FontSize = 14] /// public string Title { get; set; } /// /// Imposta o recupera il testo secondario. [FontSize = 8] /// public string Subtitle { get; set; } /// /// Imposta o recupera la X del documento su cui disegnare il rettangolo. /// public float X { get; set; } /// /// Imposta o recupera la Y del documento su cui disegnare il rettangolo. /// public float Y { get; set; } /// /// Recupera il FontFamily. /// public FontFamily FontFamily { get { return _fontfamily; } } /// /// Costruttore /// public SectionHeadingPDF() { ObjectType = ObjectTypePdf.COMPOSITE; Title = string.Empty; Subtitle = string.Empty; Elements = new List(); } /// /// Costruttore /// /// titolo /// x /// y /// font family public SectionHeadingPDF(string title, float x, float y, FontFamily fontfamily) : this() { Title = title; X = x; Y = y; _fontfamily = fontfamily; } /// /// Costruttore /// /// titolo /// sottotitolo /// x /// y /// font family public SectionHeadingPDF(string title, string subtitle, float x, float y, FontFamily fontfamily) : this(title, x, y, fontfamily) { Subtitle = subtitle; } /// /// Definizione dell'oggetto ChapterHeading. /// /// public new ObjectPDF ToElement() { var ftaTitle = new FormattedTextAreaPDF(Title, X + 2, 425) { Y = Y - 1, FontSize = 10, FontBold = true, FontColor = ColorPDF.Bianco, AutoIncrementYWritable = true, AbsolutePosition = true }; ftaTitle.GetAndSetHeight(_fontfamily, ftaTitle.FontBold); #region Rettangoli rossi Elements.Add(new RectanglePDF(X, Y, 0.4F, 522, ColorPDF.ConsulenzaUnica_Rosso) { AutoIncrementYWritable = false }); // Rosso Elements.Add(new RectanglePDF(X, Y, ftaTitle.Height, 450, ColorPDF.ConsulenzaUnica_Rosso) { AutoIncrementYWritable = false }); // Rosso #endregion #region Titolo Elements.Add(ftaTitle); #endregion #region Sottotitolo if (Subtitle.Trim().Length <= 0) return this; Elements.Add(new SpacePDF(20)); Elements.Add(new FormattedTextAreaPDF(Subtitle, X) { FontSize = 7, AutoIncrementYWritable = true, TextHorizontalAlign = TextAlign.Justify }); Elements.Add(new SpacePDF(15)); #endregion return this; } } }