120 lines
3.9 KiB
C#
120 lines
3.9 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// 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).
|
|
/// </summary>
|
|
public class SectionHeadingPDF : CompositePDF
|
|
{
|
|
private readonly FontFamily _fontfamily;
|
|
|
|
/// <summary>
|
|
/// Imposta o recupera il testo principale. [FontSize = 14]
|
|
/// </summary>
|
|
public string Title { get; set; }
|
|
|
|
/// <summary>
|
|
/// Imposta o recupera il testo secondario. [FontSize = 8]
|
|
/// </summary>
|
|
public string Subtitle { get; set; }
|
|
|
|
/// <summary>
|
|
/// Imposta o recupera la X del documento su cui disegnare il rettangolo.
|
|
/// </summary>
|
|
public float X { get; set; }
|
|
|
|
/// <summary>
|
|
/// Imposta o recupera la Y del documento su cui disegnare il rettangolo.
|
|
/// </summary>
|
|
public float Y { get; set; }
|
|
|
|
/// <summary>
|
|
/// Recupera il FontFamily.
|
|
/// </summary>
|
|
public FontFamily FontFamily
|
|
{
|
|
get { return _fontfamily; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Costruttore
|
|
/// </summary>
|
|
public SectionHeadingPDF()
|
|
{
|
|
ObjectType = ObjectTypePdf.COMPOSITE;
|
|
Title = string.Empty;
|
|
Subtitle = string.Empty;
|
|
Elements = new List<ObjectPDF>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Costruttore
|
|
/// </summary>
|
|
/// <param name="title">titolo</param>
|
|
/// <param name="x">x</param>
|
|
/// <param name="y">y</param>
|
|
/// <param name="fontfamily">font family</param>
|
|
public SectionHeadingPDF(string title, float x, float y, FontFamily fontfamily)
|
|
: this()
|
|
{
|
|
Title = title;
|
|
X = x;
|
|
Y = y;
|
|
_fontfamily = fontfamily;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Costruttore
|
|
/// </summary>
|
|
/// <param name="title">titolo</param>
|
|
/// <param name="subtitle">sottotitolo</param>
|
|
/// <param name="x">x</param>
|
|
/// <param name="y">y</param>
|
|
/// <param name="fontfamily">font family</param>
|
|
public SectionHeadingPDF(string title, string subtitle, float x, float y, FontFamily fontfamily)
|
|
: this(title, x, y, fontfamily)
|
|
{
|
|
Subtitle = subtitle;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Definizione dell'oggetto ChapterHeading.
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
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;
|
|
}
|
|
}
|
|
}
|