using System;
using System.Collections.Generic;
using System.Linq;
using Consulenza.ExternalServices;
using Consulenza.ReportWriter.Business;
using Consulenza.ReportWriter.Business.OBJ_PDF;
using System.Data;
using Consulenza.ReportWriter.Business.CHART_PDF;
using Consulenza.ReportCommon;
using Consulenza.ReportWriter.Business.Entity;
using System.Text;

namespace Consulenza.ReportWriter.Manager.Section.Immobiliare.Monitoraggio
{
    /// <summary>
    /// Scheda 12 Glossatrio
    /// </summary>
    public class S12 : Entity.Section
    {

        public S12(EnvironmentFacade environmentFacade, int idSection)
            : base(environmentFacade, idSection)
        {
            try
            {
                Draw();
            }
            catch (Exception ex)
            {
                SectionLogger.Write("S12", ex.Message, SectionLoggerMessageLevel.E, EnvironmentFacade.ReportEnvironment);
            }
        }

        /// <summary>
        /// Scheda2. Patrimonio immobiliare –Sintesi (distribuzione del patrimonio complessivo del cliente diviso per tipologia e cointestatari)
        /// </summary>
        protected override sealed void Draw()
        {
            int oldIdReport = EnvironmentFacade.ReportEnvironment.ReportId;
            int oldIdSection = IdSection;
            IdSection = 148;
            EnvironmentFacade.ReportEnvironment.ReportId = 10;
            var testi = GetText();
            EnvironmentFacade.ReportEnvironment.ReportId = oldIdReport;
            IdSection = oldIdSection;
            var fontColor = ColorPDF.Immobiliare_Grigio_TestoStandard;
            const float fontSize = 8.5F;

            int xSx = 35;
            AddElement(new SpacePDF(30)); //45
            //AddElement(new ImagePDF(EnvironmentFacade.RendererFacade.XLeftLimit, 0.20F, "glossario2.png") { AutoIncrementYWritable = false }); //Immagine

            /*************************** Fix Adeguamento della Formattazione del titolo alle altre pagine 31/07/2020 Pino *********************************************************/
            AddElement(new FormattedTextAreaPDF(testi.Rows[0]["testo1"].ToString(), xSx, 600) { FontSize = 10, FontColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo, AutoIncrementYWritable = true, Width = 740, FixedHeight = 20 }); // Titolo
                                                                                                                                                                                                                                       //AddElement(new FormattedTextAreaPDF(testi.Rows[0]["testo1"].ToString(), xSx, 600) { FontSize = 9, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard}); // Titolo  --- Originale
                                                                                                                                                                                                                                       /**********************************************************************************************************************************************************************/

            #region Colonna Sinistra
            /*************************************** Modifica per parti statiche Semestrale 10/2020 - Pino ********************************/
            //AddElement(new ResetterYPDF(85));
            AddElement(new ResetterYPDF(70));
            /******************************************************************************************************************************/

            // Colonna Sinistra
            for (int i = 2; i < 9; i++)
            {
                var campo = string.Format("testo{0}", i);

                /************** FIX Giustificare i testi presenti nelle due colonne 31/07/2020 Pino *************************************/
            AddElement(new FormattedTextAreaPDF(testi.Rows[0][campo].ToString(), xSx, 340,ceTe.DynamicPDF.TextAlign.Justify)
                {
                    FontSize = fontSize,
                    FontColor = fontColor,
                    AbsolutePosition = true
                });
                /************************************************************************************************************************/
                AddElement(new SpacePDF(8));
            }

            #endregion

            #region Colonna Destra
            /*************************************** Modifica per parti statiche Semestrale 10/2020 - Pino ********************************/
            //AddElement(new ResetterYPDF(85));
            AddElement(new ResetterYPDF(70));
            /******************************************************************************************************************************/

            // Colonna Destra
            for (int i = 9; i <= 16; i++)
            {
                var campo = string.Format("testo{0}", i);

                /************** FIX Giustificare i testi presenti nelle due colonne 31/07/2020 Pino *************************************/
                AddElement(new FormattedTextAreaPDF(testi.Rows[0][campo].ToString(), xSx + 375, 340, ceTe.DynamicPDF.TextAlign.Justify)
                {
                    FontSize = fontSize,
                    FontColor = fontColor,
                    AbsolutePosition = true
                });
                /************************************************************************************************************************/
                AddElement(new SpacePDF(8));
            }

            #endregion 
        }

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

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