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

namespace Consulenza.ReportWriter.Manager.Section.Unica.Diagnosi
{
    /// <summary>
    /// Scheda 74 - Glossario idSezione = 117
    /// </summary>
    public class S74 : Unica.S74
    {
        
            public S74(EnvironmentFacade environmentFacade, int idSection)
                : base(environmentFacade, idSection)
            {
                try
                {
                    //Draw();
                }
                catch (Exception ex)
                {
                    SectionLogger.Write("S74", ex.Message, SectionLoggerMessageLevel.E, EnvironmentFacade.ReportEnvironment);
                }
              
            }
            protected override void Draw()
            {
                var testi = GetText();
                var listaOggettiDaRipetere = new List<ObjectPDF>();
                listaOggettiDaRipetere.Add(new SpacePDF(20));

                var cliente = datiSeiUnico.clienteUnit().anagrafica;
                bool profiloProfessionale;
                bool profiloAggressivo;
                bool profiloProfessionaleAggressivo;
                var profiler = new Profiler(cliente);

                profiloProfessionale = profiler.ProfiloProfessionale;
                profiloAggressivo = profiler.ProfiloAggressivo;
                profiloProfessionaleAggressivo = profiler.ProfiloProfessionaleAggressivo;    

                AddElement(new RepeaterPDF(listaOggettiDaRipetere));
                AddElement(new SpacePDF(20));
                AddElement(new FormattedTextAreaPDF(testi.Rows[0]["Testo1"].ToString(), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 7,TextHorizontalAlign = TextAlign.Justify });
                AddElement(new SpacePDF(9));
                AddElement(new FormattedTextAreaPDF(testi.Rows[0]["Testo2"].ToString(), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 7,TextHorizontalAlign = TextAlign.Justify });

                var stringheElencoPuntato = new List<string> { testi.Rows[0]["Testo3"].ToString(), testi.Rows[0]["Testo4"].ToString(), testi.Rows[0]["Testo5"].ToString(), testi.Rows[0]["Testo6"].ToString(), testi.Rows[0]["Testo7"].ToString(), testi.Rows[0]["Testo8"].ToString() };

                var elencoPuntato = new UnorderedListPDF(EnvironmentFacade.RendererFacade.XLeftLimit, stringheElencoPuntato) { FontSize = 7};
                AddElement(elencoPuntato);
              
                int fine = testi.Columns.Count - 8;
                for (int i = 9; i <= fine; i++)
                {
                    if (profiloProfessionale)
                    {
                        if (i != 11 && i != 13 && i != 20)
                        {
                            AddElement(new SpacePDF(9));
                            string campo = "Testo" + i.ToString();
                            AddElement(new FormattedTextAreaPDF(testi.Rows[0][campo].ToString(), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 7, TextHorizontalAlign = TextAlign.Justify });
                        }
                    }
                    else
                    {
                        AddElement(new SpacePDF(9));
                        string campo = "Testo" + i.ToString();
                        AddElement(new FormattedTextAreaPDF(testi.Rows[0][campo].ToString(), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 7, TextHorizontalAlign = TextAlign.Justify });
                    }
                }
            }

        
       
    }
}
