Beispiel #1
0
 void AddSubcategory(SubCategoryStat sstats, CategoryStats parent)
 {
     foreach (PercentualStat ostats in sstats.OptionStats)
     {
         StatsWidget w = new StatsWidget(ostats, parent, sstats, subcatsMaxSize);
         subcats.Add(w);
         cstatsbox.PackStart(w, false, true, 0);
     }
 }
Beispiel #2
0
        void AddCategory(CategoryStats cstats)
        {
            Widget w = new StatsWidget(cstats, null, null, catsMaxSize);

            cats.Add(w);
            cstatsbox.PackStart(w, false, true, 0);

            foreach (SubCategoryStat stats in cstats.SubcategoriesStats)
            {
                AddSubcategory(stats, cstats);
            }
            cstatsbox.PackStart(new HSeparator(), false, false, 0);
        }
Beispiel #3
0
        public void LoadStats(CategoryStats stats)
        {
            homeLabel.Text = HomeName;
            awayLabel.Text = AwayName;

            alltagger.LoadFieldCoordinates(stats.FieldCoordinates);
            alltagger.LoadHalfFieldCoordinates(stats.HalfFieldCoordinates);
            alltagger.LoadGoalCoordinates(stats.GoalCoordinates);
            alltagger.CoordinatesSensitive = false;
            allframe.Visible = stats.FieldCoordinates.Count + stats.HalfFieldCoordinates.Count +
                               stats.GoalCoordinates.Count != 0;

            hometagger.LoadFieldCoordinates(stats.HomeFieldCoordinates);
            hometagger.LoadHalfFieldCoordinates(stats.HomeHalfFieldCoordinates);
            hometagger.LoadGoalCoordinates(stats.HomeGoalCoordinates);
            hometagger.CoordinatesSensitive = false;
            homeframe.Visible = stats.HomeFieldCoordinates.Count + stats.HomeHalfFieldCoordinates.Count +
                                stats.HomeGoalCoordinates.Count != 0;

            awaytagger.LoadFieldCoordinates(stats.AwayFieldCoordinates);
            awaytagger.LoadHalfFieldCoordinates(stats.AwayHalfFieldCoordinates);
            awaytagger.LoadGoalCoordinates(stats.AwayGoalCoordinates);
            awaytagger.CoordinatesSensitive = false;
            awayframe.Visible = stats.AwayFieldCoordinates.Count + stats.AwayHalfFieldCoordinates.Count +
                                stats.AwayGoalCoordinates.Count != 0;

            foreach (Widget child in vbox1.AllChildren)
            {
                if (child is SubCategoryViewer || child is HSeparator)
                {
                    vbox1.Remove(child);
                }
            }
            subcatViewers       = new List <SubCategoryViewer>();
            nodatalabel.Visible = stats.SubcategoriesStats.Count == 0;
            foreach (SubCategoryStat st in stats.SubcategoriesStats)
            {
                SubCategoryViewer subcatviewer = new SubCategoryViewer();
                subcatviewer.LoadStats(st, HomeName, AwayName);
                subcatViewers.Add(subcatviewer);
                vbox1.PackStart(subcatviewer);
                vbox1.PackStart(new HSeparator());
                subcatviewer.Show();
            }
        }
Beispiel #4
0
        private void RefreshCategories()
        {
            categoriesListView.Items.Clear();
            Dictionary <string, CategoryStats> stats = new Dictionary <string, CategoryStats>();
            double totalShareOfAll = 0;
            double centerNom       = 0;
            double centerDen       = 0;

            foreach (var summary in ActivityTracker.SelectedLog.Activities)
            {
                int k = 0;
                foreach (var entry in summary.Entries)
                {
                    string category = RuleManager.MatchCategory(entry);
                    if (stats.ContainsKey(category) == false)
                    {
                        stats[category] = new CategoryStats();
                    }
                    stats[category].TotalActiveTime += Parameters.LogTimeUnit * entry.Share / 100.0;
                    if (k++ == 0)
                    {
                        stats[category].TotalPresentTime += Parameters.LogTimeUnit;
                    }
                    stats[category].ShareSum += entry.Share;
                    totalShareOfAll          += entry.Share;
                }
                centerNom += summary.TimePoint.TimeOfDay.TotalMinutes * summary.TotalShare;
                centerDen += summary.TotalShare;
            }
            TimeSpan center = TimeSpan.FromMinutes(centerNom / (centerDen + 0.01));

            TimeSpan totalSpan;
            var      list = ActivityTracker.SelectedLog.Activities;

            if (list.Count == 0)
            {
                totalSpan = TimeSpan.Zero;
            }
            else
            {
                totalSpan = list.Last().TimePoint - list.First().TimePoint;
            }

            List <KeyValuePair <string, CategoryStats> > statsList = stats.ToList();

            statsList.Sort((a, b) => (int)(1000 * (b.Value.ShareSum - a.Value.ShareSum)));

            TimeSpan totalActiveTime  = TimeSpan.Zero;
            TimeSpan totalPresentTime = TimeSpan.Zero;

            foreach (var skv in statsList)
            {
                string        name        = skv.Key;
                CategoryStats cs          = skv.Value;
                TimeSpan      activeTime  = TimeSpan.FromSeconds(cs.TotalActiveTime);
                TimeSpan      presentTime = TimeSpan.FromSeconds(cs.TotalPresentTime);
                string[]      content     = new string[]
                {
                    name,
                    activeTime.ToString(),
                    presentTime.ToString(),
                    (100.0 * cs.ShareSum / totalShareOfAll).ToString("F1")
                };
                ListViewItem item = new ListViewItem(content);
                categoriesListView.Items.Add(item);

                totalActiveTime  += activeTime;
                totalPresentTime += presentTime;
            }

            {
                string[] content = new string[]
                {
                    "Total Time",
                    totalActiveTime.ToString(),
                    totalPresentTime.ToString(),
                    "100.0"
                };
                ListViewItem item = new ListViewItem(content);
                item.Font = boldFont;
                categoriesListView.Items.Add(item);
            }
            {
                double intensityActive =
                    totalSpan.TotalSeconds >= 1 ? (100.0 * totalActiveTime.TotalSeconds / totalSpan.TotalSeconds) : 0;
                double intensityPresent =
                    totalSpan.TotalSeconds >= 1 ? (100.0 * totalPresentTime.TotalSeconds / totalSpan.TotalSeconds) : 0;

                string[] content = new string[]
                {
                    "Intensity",
                    intensityActive.ToString("F2"),
                    intensityPresent.ToString("F2")
                };
                ListViewItem item = new ListViewItem(content);
                item.Font = boldFont;
                categoriesListView.Items.Add(item);
            }
            {
                string[] content = new string[]
                {
                    "Total Span",
                    totalSpan.ToString()
                };
                ListViewItem item = new ListViewItem(content);
                item.Font = boldFont;
                categoriesListView.Items.Add(item);
            }
            {
                string[] content = new string[]
                {
                    "Intensity Center",
                    center.ToString(@"hh\:mm\:ss")
                };
                ListViewItem item = new ListViewItem(content);
                item.Font = boldFont;
                categoriesListView.Items.Add(item);
            }
        }
 public async Task UpdateCategoryStat(CategoryStats stat)
 {
     await _database.UpdateAsync(stat);
 }
 public async Task InsertCategoryStat(CategoryStats stat)
 {
     await _database.InsertAsync(stat);
 }