using System;
using Consulenza.ReportWriter.Business.OBJ_PDF;
using ceTe.DynamicPDF;
using Consulenza.ReportCommon;
using Consulenza.ReportWriter.Business;
using System.Data;

namespace Consulenza.ReportWriter.Manager.Section.Base.Proposta
{
    public class T1 : Entity.Section
    {
        public T1(EnvironmentFacade environmentFacade, int idSection)
            : base(environmentFacade, idSection)
        {
            try
            {
                Draw();
            }
            catch (Exception ex)
            {
                SectionLogger.Write("T1", ex.Message, SectionLoggerMessageLevel.E, EnvironmentFacade.ReportEnvironment);
            }
        }

        /// <summary>
        /// Disegna l'oggetto T1
        /// </summary>
        protected override sealed void Draw()
        {
            var dtT1 = GetText();

            if (dtT1.Rows.Count <= 0) return;

            var stringaTestoIntroduttivo = Helper.ReplaceVariables(EnvironmentFacade.ReportEnvironment.Proposta.EsitoAdeguatezza == TipologiaEsitoAdeguatezza.Adeguata ?
                dtT1.Rows[0]["Testo1"].ToString() :
                dtT1.Rows[0]["Testo2"].ToString(), EnvironmentFacade.ReportEnvironment);

            var bordoSuperiore = new LinePDF(EnvironmentFacade.RendererFacade.XLeftLimit, EnvironmentFacade.RendererFacade.XRightLimit)
            {
                AutoIncrementYWritable = false
            };
            var bordoSuperioreSinistro = new LinePDF(EnvironmentFacade.RendererFacade.XLeftLimit, EnvironmentFacade.RendererFacade.XLeftLimit)
            {
                DeltaY2ForVerticalLine = 10
            };
            var bordoSuperioreDestro = new LinePDF(EnvironmentFacade.RendererFacade.XRightLimit, EnvironmentFacade.RendererFacade.XRightLimit)
            {
                DeltaY2ForVerticalLine = 10
            };
            var testoIntroduttivo = new FormattedTextAreaPDF(stringaTestoIntroduttivo, EnvironmentFacade.RendererFacade.XLeftLimit + 5, 512)
            {
                TextHorizontalAlign = TextAlign.Justify
            };
            var bordoInferiore = new LinePDF(EnvironmentFacade.RendererFacade.XLeftLimit, EnvironmentFacade.RendererFacade.XRightLimit)
            {
                AutoIncrementYWritable = false
            };
            var bordoInferioreSinistro = new LinePDF(EnvironmentFacade.RendererFacade.XLeftLimit, EnvironmentFacade.RendererFacade.XLeftLimit)
            {
                AutoIncrementYWritable = false,
                DeltaY2ForVerticalLine = -10F
            };
            var bordoInferioreDestro = new LinePDF(EnvironmentFacade.RendererFacade.XRightLimit, EnvironmentFacade.RendererFacade.XRightLimit)
            {
                AutoIncrementYWritable = false,
                DeltaY2ForVerticalLine = -10F
            };

            AddElement(bordoSuperiore);
            AddElement(bordoSuperioreSinistro);
            AddElement(bordoSuperioreDestro);
            AddElement(testoIntroduttivo);
            AddElement(bordoInferiore);
            AddElement(bordoInferioreSinistro);
            AddElement(bordoInferioreDestro);
            AddElement(new SpacePDF(15));
        }

        /// <summary>
        /// Recupera i dati necessari alla Section restituendo un DataTable.
        /// </summary>
        /// <returns></returns>
        protected sealed override DataTable GetDataTable()
        {
            return null;
        }

        /// <summary>
        /// Recupera i dati necessari alla Section restituendo un DataSet.
        /// </summary>
        /// <returns></returns>
        protected sealed override DataSet GetDataSet()
        {
            return null;
        }
    }
}
