Example #1
0
        private static Section GetUniversitySection()
        {
            //Now starting with the real example
            var mainSec  = new Section($"Report for: {John.Name}");
            var persInfo = new Section("Personal Information", 2);

            mainSec.AddSection(persInfo);
            //Adding a pic with an external link (should works the same with an offline path)
            persInfo.Add(new Image("https://i.stack.imgur.com/l60Hf.png", "This should be a real pic", "Student photo", 100, 80));
            persInfo.AddParagraph();
            persInfo.AddQuote($"This is the profile pic of {John.Name}");
            //A paragraph with a on-a-fly italic word
            persInfo.AddParagraph("This personal information is automatically mapped in the List reading the properties of the " + TextFormat.Ital("Student") + " class");
            //Creating and auto-populating the Letterlist
            var autoLetterList = new NumberListAutoMap <Student>();

            autoLetterList.SetItem(John);
            //autoLetterList.Type = LetterType.LOWERCASE;
            persInfo.Add(autoLetterList);

            //Now to the auto-parsed Exams summary table
            var examsSummarySec = new Section("Exams summary", 2);

            mainSec.AddSection(examsSummarySec);
            examsSummarySec.AddParagraph("The following table is automatically mapped from the list of " + TextFormat.Ital("Exam"));
            var tableExams = new TableAutoMap <Exam>(Exams.ToArray()); //this table will auto detect property names

            tableExams.SetAlignement(TableAlignment.CENTER);           //this will set center for all the columns, you can set it for each every column
            examsSummarySec.Add(tableExams);

            //Last section: exams detail
            var examDetailsSec = new Section("Exams Detail", 2);

            mainSec.AddSection(examDetailsSec);
            examDetailsSec.AddParagraph("In this section we iterate over the list of exams and build a subsection of heading level 3 to have some details for each exam. I have also put an horizontal line between them.");
            var descTemplate = TemplateFromYaml.ReadFromYaml(EXAM_DETAIL_DESC_YAML);

            descTemplate.RenderMode = TemplateRenderMode.SINGLE;
            for (int i = 0; i < Exams.Count; i++)
            {
                var detailSec = new Section(Exams[i].Argument, 3);          //create subsection
                detailSec.AddParagraph("Chapters:");                        //adding a simple paragraph
                var chapList = new RomanList();                             //adding the chapter list
                foreach (string chapter in ExamsDetails[i].Chapters)
                {
                    chapList.AddItem(chapter);
                }
                detailSec.Add(chapList);
                descTemplate.ResultSingleID = Exams[i].Argument;    //choose the correct ID for the Result of the template
                detailSec.AddParagraph(descTemplate.Render());      //adding the rendered template as parahraph
                examDetailsSec.AddSection(detailSec);               //adding the subsection of level 3 to level 2
            }
            return(mainSec);
        }