Exemple #1
0
        private void BasicInfo()
        {
            var s = _document.AddSection();

            PdfTools2.SectionHeader(s.AddParagraph("Basic information")).AddBookmark("BasicInfo");

            var t = PdfTools2.TableDefaults(s.AddTable());

            var c0 = t.AddColumn(0.5 * ContentWidth());
            var c1 = t.AddColumn(0.5 * ContentWidth());

            var r0 = t.AddRow();

            r0.Cells[0].AddParagraph("Discussion");
            r0.Cells[1].AddParagraph(_discussion.Subject);

            var r1 = t.AddRow();

            r1.Cells[0].AddParagraph("Topic");
            r1.Cells[1].AddParagraph(_topic.Name);

            //session
            if (_person.Session != null)
            {
                var r2 = t.AddRow();
                r2.Cells[0].AddParagraph("Session");
                r2.Cells[1].AddParagraph(_person.Session.Name);

                var r3 = t.AddRow();
                r3.Cells[0].AddParagraph("Date and time");
                r3.Cells[1].AddParagraph(_person.Session.EstimatedDateTime.ToString());
            }
            else
            {
                s.AddParagraph("Session: no session for " + _person.Name);
            }

            var r4 = t.AddRow();

            r4.Cells[0].AddParagraph("Total time (one topic)");
            var cumulativeDuration = TimeSpan.FromSeconds(_topic.CumulativeDuration).ToString();

            r4.Cells[1].AddParagraph(cumulativeDuration);

            //session participants
            if (_person.Session != null)
            {
                s.AddParagraph();
                s.AddParagraph("Participants");

                var partTbl = s.AddTable();
                partTbl.Borders.Color = Colors.Transparent;
                partTbl.Borders.Width = Unit.FromPoint(1);

                var participants = DaoUtils.Participants(_topic, _person.Session);

                c0 = partTbl.AddColumn(0.5 * ContentWidth());
                c1 = partTbl.AddColumn(0.5 * ContentWidth());

                Row row        = null;
                var enumerator = participants.GetEnumerator();
                for (int i = 0; i < participants.Count(); i++)
                {
                    if (i % 2 == 0)
                    {
                        row = partTbl.AddRow();
                    }

                    enumerator.MoveNext();
                    var p = row.Cells[i % 2].AddParagraph(enumerator.Current.Name);
                    p.Format.Shading.Color = new MigraDoc.DocumentObjectModel.Color((uint)enumerator.Current.Color);
                }
            }
        }