using System;
using Consulenza.ReportWriter.Business;
using Consulenza.ReportWriter.Business.OBJ_PDF;
using System.Data;

namespace Consulenza.ReportWriter.Manager.Section.Immobiliare.Diagnosi
{
    /// <summary>
    /// Glossario (id 42)
    /// </summary>
    public class S10 : Entity.Section
    {
        public S10(EnvironmentFacade environmentFacade, int idSection)
            : base(environmentFacade, idSection)
        {
            try
            {
                Draw();
            }
            catch (Exception ex)
            {
                SectionLogger.Write("S10", ex.Message, SectionLoggerMessageLevel.E, EnvironmentFacade.ReportEnvironment);
            }
        }

        /// <summary>
        /// Scheda10. Glossario
        /// </summary>
        protected override sealed void Draw()
        {
            var testi = GetText();
            var fontColor = ColorPDF.Immobiliare_Grigio_TestoStandard;
            const float fontSize = 8.5F;

            AddElement(new SpacePDF(15));

            AddElement(new ImagePDF(EnvironmentFacade.RendererFacade.XLeftLimit, 0.20F, "Glossario.png") { AutoIncrementYWritable = false }); //Immagine
            AddElement(new FormattedTextAreaPDF(testi.Rows[0]["testo1"].ToString(), 82, 600) { FontSize = 10, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, DeltaY = 5 }); // Titolo

            #region Colonna Sinistra

            AddElement(new ResetterYPDF(115));

            // Colonna Sinistra
            for (int i = 2; i < 9; i++)
            {
                var campo = string.Format("testo{0}", i);
                AddElement(new FormattedTextAreaPDF(testi.Rows[0][campo].ToString(), EnvironmentFacade.RendererFacade.XLeftLimit, 350)
                {
                    FontSize = fontSize,
                    FontColor = fontColor,
                    AbsolutePosition = true
                });

                AddElement(new SpacePDF(8));
            }

            #endregion

            #region Colonna Destra

            AddElement(new ResetterYPDF(115));

            // Colonna Destra
            for (int i = 9; i <= 16; i++)
            {
                var campo = string.Format("testo{0}", i);
                AddElement(new FormattedTextAreaPDF(testi.Rows[0][campo].ToString(), EnvironmentFacade.RendererFacade.XLeftLimit + 400, 350)
                {
                    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 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;
        }
    }
}
