private StackPanel GetHeader(Person pers, string str)
        {
            var res = new TreeViewItem();
            var st  = new StackPanel();

            st.Orientation = Orientation.Horizontal;
            st.Children.Add(GetUser(pers));
            st.Children.Add(StatsUtils.WrapText(str));
            return(st);
        }
        private TextBlock GetAttachmentsSummary(ReportCollector report)
        {
            var txt = "<media summary>\r\n";

            txt += "No. of images " + report.NumImagesInSession + "\r\n";
            txt += "No. of PDF " + report.NumPdfInSession + "\r\n";
            txt += "No. of screenshots " + report.NumScreenshotsInSession + "\r\n";
            txt += "No. of videos " + report.NumYoutubeInSession;
            return(StatsUtils.WrapText(txt));
        }
        public void reportGenerated(ReportCollector sender, object args)
        {
            txtLastSync.Text = DateTime.Now.ToString();

            TreeViewItem topicsNode = null;
            TreeViewItem usersNode  = null;
            TreeViewItem eventsNode = null;

            if (args == leftReportTree)
            {
                _reportCollector1 = sender;
                topicsNode        = topicSection1;
                usersNode         = usersSection1;
                eventsNode        = eventSection1;
                reportHeader1.SetParticipants(sender.Participants);
            }
            else if (args == rightReportTree)
            {
                _reportCollector2 = sender;
                topicsNode        = topicSection2;
                usersNode         = usersSection2;
                eventsNode        = eventSection2;
                reportHeader2.SetParticipants(sender.Participants);
            }
            else
            {
                throw new NotSupportedException();
            }

            topicsNode.Items.Clear();
            foreach (var topicReport in sender.TopicReports)
            {
                topicsNode.Items.Add(GetTopicReport(topicReport, sender));
            }

            if (_reportCollector1 != null && _reportCollector2 != null)
            {
                var requiredUsers = StatsUtils.Union(reportHeader1.getReportParams(false).requiredUsers,
                                                     reportHeader2.getReportParams(false).requiredUsers);
                var totals = ReportCollector.GetTotalTopicsReports(_reportCollector1.TopicReports.First(),
                                                                   _reportCollector2.TopicReports.First(),
                                                                   requiredUsers);
                topicsNode.Items.Add(GetTotalTopicSummary(totals));
            }

            topicsNode.Items.Add(GetAttachmentsSummary(sender));

            topicsNode.Items.Add(StatsUtils.GetEventTotals(sender.EventTotals));

            usersNode.Items.Clear();
            foreach (var report in sender.ArgPointReports.Values)
            {
                EventUserReport eventReport = null;
                if (report.Count > 0)
                {
                    eventReport = sender.PerUserEventReportDict.ContainsKey(report.First().user.Id)
                                      ? sender.PerUserEventReportDict[report.First().user.Id]
                                      : null;
                }
                usersNode.Items.Add(GetUserSummary(report, eventReport));
            }

            eventsNode.Items.Clear();
            foreach (var ev in sender.StatsEvents)
            {
                eventsNode.Items.Add(GetEvent(ev, sender.GetCtx()));
            }
            usersNode.Items.Add(GetUserOneTopicSummary(sender.TotalArgPointReport, true));
        }
        private TextBlock GetUserEventTotals(EventUserReport eTotals)
        {
            var sb = new StringBuilder();

            sb.AppendLine("<user event totals>");

            sb.Append("no. arg.point topic changed ");
            sb.AppendLine(eTotals.TotalArgPointTopicChanged.ToString());

            sb.Append("no. badge created ");
            sb.AppendLine(eTotals.TotalBadgeCreated.ToString());

            sb.Append("no. badge edited ");
            sb.AppendLine(eTotals.TotalBadgeEdited.ToString());

            sb.Append("no. badge moved ");
            sb.AppendLine(eTotals.TotalBadgeMoved.ToString());

            sb.Append("no. badge zoom in ");
            sb.AppendLine(eTotals.TotalBadgeZoomIn.ToString());

            sb.Append("no. cluster created ");
            sb.AppendLine(eTotals.TotalClusterCreated.ToString());

            sb.Append("no. cluster deleted ");
            sb.AppendLine(eTotals.TotalClusterDeleted.ToString());

            sb.Append("no. cluster-in ");
            sb.AppendLine(eTotals.TotalClusterIn.ToString());

            sb.Append("no. cluster moved ");
            sb.AppendLine(eTotals.TotalClusterMoved.ToString());

            sb.Append("no. cluster-out ");
            sb.AppendLine(eTotals.TotalClusterOut.ToString());

            sb.Append("no. cluster titles added ");
            sb.AppendLine(eTotals.TotalClusterTitlesAdded.ToString());

            sb.Append("no. cluster titles edited ");
            sb.AppendLine(eTotals.TotalClusterTitlesEdited.ToString());

            sb.Append("no. cluster titles removed ");
            sb.AppendLine(eTotals.TotalClusterTitlesRemoved.ToString());

            sb.Append("no. comment added ");
            sb.AppendLine(eTotals.TotalCommentAdded.ToString());

            sb.Append("no. comment removed ");
            sb.AppendLine(eTotals.TotalCommentRemoved.ToString());

            sb.Append("no. free drawing created ");
            sb.AppendLine(eTotals.TotalFreeDrawingCreated.ToString());

            sb.Append("no. free drawing moved ");
            sb.AppendLine(eTotals.TotalFreeDrawingMoved.ToString());

            sb.Append("no. free drawing removed ");
            sb.AppendLine(eTotals.TotalFreeDrawingRemoved.ToString());

            sb.Append("no. free drawing resize ");
            sb.AppendLine(eTotals.TotalFreeDrawingResize.ToString());

            sb.Append("no. image added ");
            sb.AppendLine(eTotals.TotalImageAdded.ToString());

            sb.Append("no. image opened ");
            sb.AppendLine(eTotals.TotalImageOpened.ToString());

            sb.Append("no. image url added ");
            sb.AppendLine(eTotals.TotalImageUrlAdded.ToString());

            sb.Append("no. link created ");
            sb.AppendLine(eTotals.TotalLinkCreated.ToString());

            sb.Append("no. link removed ");
            sb.AppendLine(eTotals.TotalLinkRemoved.ToString());

            sb.Append("no. media removed ");
            sb.AppendLine(eTotals.TotalMediaRemoved.ToString());

            sb.Append("no. PDF added ");
            sb.AppendLine(eTotals.TotalPdfAdded.ToString());

            sb.Append("no. PDF opened ");
            sb.AppendLine(eTotals.TotalPdfOpened.ToString());

            sb.Append("no. PDF url added ");
            sb.AppendLine(eTotals.TotalPdfUrlAdded.ToString());

            sb.Append("no. source added ");
            sb.AppendLine(eTotals.TotalSourceAdded.ToString());

            sb.Append("no. source opened ");
            sb.AppendLine(eTotals.TotalSourceOpened.ToString());

            sb.Append("no. source removed ");
            sb.AppendLine(eTotals.TotalSourceRemoved.ToString());

            sb.Append("no. video opened ");
            sb.AppendLine(eTotals.TotalVideoOpened.ToString());

            sb.Append("no. video added ");
            sb.AppendLine(eTotals.TotalYoutubeAdded.ToString());

            sb.Append("no. scene zoom in ");
            sb.AppendLine(eTotals.TotalSceneZoomedIn.ToString());

            sb.Append("no. scene zoom out ");
            sb.AppendLine(eTotals.TotalSceneZoomedOut.ToString());

            sb.Append("no. screenshot added ");
            sb.AppendLine(eTotals.TotalScreenshotAdded.ToString());

            sb.Append("no. screenshot opened ");
            sb.AppendLine(eTotals.TotalScreenshotOpened.ToString());

            sb.Append("no. laser enabled ");
            sb.AppendLine(eTotals.TotalLaserEnabled.ToString());

            return(StatsUtils.WrapText(sb.ToString()));
        }