Exemple #1
0
        private Task DiscussionBackground()
        {
            var bgUrl = Background.getDiscussionBackgroundUrl(_discussion);

            var tcs = new TaskCompletionSource <int>();

            new WebScreenshoter(
                bgUrl,
                pathName =>
            {
                var section = _document.LastSection;
                //Section section = _document.AddSection();
                //PdfTools2.SectionHeader(section.AddParagraph("Discussion Background"));

                var slices = PdfTools2.SliceImage(pathName);
                foreach (var slice in slices)
                {
                    section   = _document.AddSection();
                    var img   = section.AddImage(slice);
                    img.Width = PdfTools2.PAGE_WIDTH;
                    img.RelativeHorizontal = RelativeHorizontal.Page;
                    img.RelativeVertical   = RelativeVertical.Page;
                }

                tcs.SetResult(0);         //ok, done
            },
                1300
                );
            return(tcs.Task);
        }
Exemple #2
0
        private void AddLinkOrClusterImg(Section s, byte[] image)
        {
            var imgPara = s.AddParagraph();

            imgPara.AlignWithTable();
            var pathName = PdfTools2.ImageBytesToFile(image, _images);
            var img      = imgPara.AddImage(pathName);

            var bmp = new Bitmap(pathName);
            int w   = bmp.Width;
            int h   = bmp.Height;

            bmp.Dispose();

            var maxHeight = 0.3 * _document.DefaultPageSetup.PageHeight;

            if (h > maxHeight)
            {
                img.Height = maxHeight;
                w          = (int)maxHeight * w / h;
                h          = (int)maxHeight;
            }

            var maxWidth = 0.5 * ContentWidth();

            if (w > maxWidth)
            {
                img.Width  = maxWidth;
                img.Height = maxWidth * h / w;
            }
        }
Exemple #3
0
        private void CoverPage()
        {
            Section section = _document.AddSection();

            //blue background
            PdfTools2.AddPageBg(section, _document, 0x2C, 0xA1, 0xCF);

            var p0 = section.AddParagraph("Tohoku University");

            p0.SubsectionStyle();
            p0.Format.SpaceBefore = Unit.FromPoint(40);

            var p = section.AddParagraph("Discussion Support System");

            p.Format.Alignment   = ParagraphAlignment.Center;
            p.Format.Font.Color  = Colors.White;
            p.Format.Font.Size   = 40;
            p.Format.SpaceBefore = Unit.FromPoint(210);

            var p2 = section.AddParagraph("Topic report");

            p2.SubsectionStyle();

            var p3 = section.AddParagraph(DateTime.Now.Date.ToShortDateString());

            p3.Format.Alignment   = ParagraphAlignment.Center;
            p3.Format.Font.Color  = Colors.White;
            p3.Format.SpaceBefore = Unit.FromPoint(280);
        }
Exemple #4
0
        private void AllArgPoints()
        {
            var s = _document.AddSection();

            PdfTools2.SectionHeader(s.AddParagraph("Argument points"));

            foreach (var pers in _session.Person)
            {
                if (pers == null)
                {
                    MessageDlg.Show("skipping a null person in session");
                    continue;
                }

                bool     personValid = true;
                ArgPoint invalidAp   = null;
                foreach (var ap in pers.ArgPoint)
                {
                    if (ap.Topic == null)
                    {
                        personValid = false;
                        invalidAp   = ap;
                    }
                }

                if (!personValid)
                {
                    MessageDlg.Show(
                        string.Format(
                            "{0}'s arg.point \"{1}\" has null (undefined) topic. Skipping the arg.point in report",
                            pers.Name, invalidAp.Point));
                    continue;
                }

                var para = s.AddParagraph().AddBold("Argument points of " + pers.Name);

                var argPointsOf = DaoUtils.ArgPointsOf(pers, _discussion, _topic);
                if (argPointsOf.Count() > 0)
                {
                    foreach (var ap in argPointsOf)
                    {
                        if (!ap.SharedToPublic)
                        {
                            continue;
                        }

                        ArgPointNode(s, ap);
                        s.AddParagraph("\n\n");
                    }
                }
                else
                {
                    s.AddParagraph("<No arguments>\n\n");
                }
            }
        }
Exemple #5
0
        private void Summary(ReportCollector hardReport)
        {
            //var s = _document.AddSection();
            var s = _document.LastSection;

            s.AddParagraph();
            PdfTools2.SectionHeader(s.AddParagraph("Summary information"));

            SummaryTable(s, hardReport);
        }
Exemple #6
0
        private async Task FinalScene()
        {
            //var s = _document.AddSection();
            var s = _document.LastSection;

            s.AddParagraph();
            PdfTools2.SectionHeader(s.AddParagraph("Final Public Dashboard"));
            var screenshots = await _finalScene;
            var imgPara     = s.AddParagraph();
            var pathName    = PdfTools2.ImageBytesToFile(screenshots[-1], _images);
            var img         = imgPara.AddImage(pathName);

            img.Width = ContentWidth();
        }
Exemple #7
0
        private async void ClusterInformation(ReportCollector hardReport)
        {
            var s = _document.AddSection();

            PdfTools2.SectionHeader(s.AddParagraph("Cluster information"));

            if (hardReport.ClusterReports.Count > 0)
            {
                var screenshots = await _finalScene;
                foreach (var clusterReport in hardReport.ClusterReports)
                {
                    ClusterTable(s, clusterReport, screenshots[clusterReport.clusterShId]);
                    s.AddParagraph();
                }
            }
            else
            {
                s.AddParagraph("<No clusters>\n\n");
            }
        }
Exemple #8
0
        private async void LinkInformation(ReportCollector hardReport)
        {
            var s = _document.AddSection();

            PdfTools2.SectionHeader(s.AddParagraph("Link information"));

            if (hardReport.LinkReports.Count > 0)
            {
                var screenshots = await _finalScene;

                foreach (var linkReport in hardReport.LinkReports)
                {
                    LinkTable(s, linkReport, screenshots[linkReport.linkShId]);
                    s.AddParagraph();
                }
            }
            else
            {
                s.AddParagraph("<No links>\n\n");
            }
        }
Exemple #9
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);
                }
            }
        }