Ejemplo n.º 1
0
        private static ITextGraphDataCollection GetAggregateDayOfWeekDataCollection(IConversation conversation)
        {
            const int daysPerWeek = 7;

            int[] messagesExchangedPerDayOfWeek = new int[daysPerWeek];

            for (int i = 0; i < daysPerWeek; i++)
            {
                messagesExchangedPerDayOfWeek[i] = 0;
            }

            foreach (IConversationMessage message in conversation)
            {
                messagesExchangedPerDayOfWeek[(int)message.Timestamp.DayOfWeek]++;
            }

            TextGraphDataCollection dataCollection = new TextGraphDataCollection();

            for (int i = 0; i < daysPerWeek; i++)
            {
                TextGraphData graphData = new TextGraphData(NormalizedSunday.AddDays(i));
                graphData.MessagesTotal = messagesExchangedPerDayOfWeek[i];
                dataCollection.Add(graphData);
            }

            return(dataCollection);
        }
Ejemplo n.º 2
0
        private static ITextGraphDataCollection GetAggregateHourOfDayDataCollection(IConversation conversation)
        {
            const int hoursPerDay = 24;

            int[] messagesExchangedPerHour = new int[hoursPerDay];

            for (int i = 0; i < hoursPerDay; i++)
            {
                messagesExchangedPerHour[i] = 0;
            }

            foreach (IConversationMessage message in conversation)
            {
                messagesExchangedPerHour[message.Timestamp.Hour]++;
            }

            TextGraphDataCollection dataCollection = new TextGraphDataCollection();

            for (int i = 0; i < hoursPerDay; i++)
            {
                TextGraphData graphData = new TextGraphData(NormalizedSunday.AddHours(i));
                graphData.MessagesTotal = messagesExchangedPerHour[i];
                dataCollection.Add(graphData);
            }

            return(dataCollection);
        }
Ejemplo n.º 3
0
        public bool Equals(TextGraphData other)
        {
            if (Date != other.Date)
            {
                return(false);
            }

            if (MessagesTotal != other.MessagesTotal)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Workaround for known issue with WPF Toolkit DateTimeAxis. If only one datapoint appears on a datetime, the
        /// graph renders no datapoints.
        /// http://wpf.codeplex.com/workitem/15276
        ///
        /// Workaround: Add a datapoint immediately before and after the single datapoint.
        /// </summary>
        /// <param name="originalCollection"></param>
        /// <returns></returns>
        private static ITextGraphDataCollection AdjustGraphDataCollectionForWorkaround(TextGraphDataCollection originalCollection)
        {
            if (originalCollection.Count != 1)
            {
                return(AddMonthlyZeroesWorkaround(originalCollection));
            }

            TextGraphData graphData = null;

            foreach (TextGraphData tgd in originalCollection)
            {
                graphData = tgd;
            }

            int      month = graphData.Date.Month;
            DateTime prevDate;
            DateTime nextDate;

            if (month == 1)
            {
                prevDate = new DateTime(graphData.Date.Year - 1, 12, 1);
                nextDate = new DateTime(graphData.Date.Year, 2, 1);
            }
            else if (month == 12)
            {
                prevDate = new DateTime(graphData.Date.Year, 11, 1);
                nextDate = new DateTime(graphData.Date.Year + 1, 1, 1);
            }
            else
            {
                prevDate = new DateTime(graphData.Date.Year, month - 1, 1);
                nextDate = new DateTime(graphData.Date.Year, month + 1, 1);
            }

            TextGraphDataCollection adjustedCollection = new TextGraphDataCollection();

            adjustedCollection.Add(new TextGraphData(prevDate, 0));
            adjustedCollection.Add(graphData);
            adjustedCollection.Add(new TextGraphData(nextDate, 0));

            return(adjustedCollection);
        }