Beispiel #1
0
        private void InitPredictionCheckboxes()
        {
            var predictionTypes = Enum.GetValues(typeof(PredictionType));

            var heightStep = 20;
            var height     = 0;

            foreach (PredictionType type in predictionTypes)
            {
                var attribute = type.GetAttributeOfType <IsDefaultSelectedAttribute>();

                var checkbox = new CheckBox();
                checkbox.Text      = type.ToString();
                checkbox.Width     = 300;
                checkbox.Top       = height;
                checkbox.Checked   = attribute?.Selected ?? false;
                checkbox.ForeColor = BasePrediction.GetBorderColor(type) ?? Color.Black;

                height += heightStep;

                Controls.Add(checkbox);

                PredictionSettings.Init(type, checkbox);
            }
        }
Beispiel #2
0
        public Color?GetPredictionBorderColor()
        {
            var groups = AllVisiblePredictions.GroupBy(p => p.Type).OrderBy(g => (int)g.Key);
            var colors = groups
                         .Where(g => PredictionSettings.GetVisible(g.Key))
                         .Select(g => g.First().GetBorderColor()).ToList();

            return(colors.FirstOrDefault());
        }
Beispiel #3
0
        public List <Note> GetPredictionNotes()
        {
            var groups = AllPredictions.GroupBy(p => p.Type).OrderBy(g => (int)g.Key);
            var result = groups
                         .Where(g => PredictionSettings.GetVisible(g.Key))
                         .Select(g =>
            {
                return(new Note(g.Min(p => p.Depth), g.First().GetTextColor()));
            }).ToList();

            return(result);
        }
        public IActionResult Index(TimeSeriesType timeSeriesType = TimeSeriesType.Confirmed, string countries = "Ukraine", CountrySearchType countrySearchType = CountrySearchType.Inside, string viewType = "graph")
        {
            var predictionSettings = new PredictionSettings
            {
                TimeSeriesType    = timeSeriesType,
                Countries         = countries,
                CountrySearchType = countrySearchType,
                ViewType          = viewType
            };

            var predictionOutput = this.predictionService.CreatePredictionTimeSeries(new PredictionInputModel {
                Settings = predictionSettings
            });

            return(viewType == "table" ? this.View("Table", predictionOutput) : this.View("Graph", predictionOutput));
        }
Beispiel #5
0
        public List <Note> GetPredictionNotes()
        {
            var groups = AllVisiblePredictions.GroupBy(p => p.Type).OrderBy(g => (int)g.Key);
            var result = groups
                         .Where(g => PredictionSettings.GetVisible(g.Key))
                         .Select(g =>
            {
                return(new Note(g.Min(p => p.Depth), g.First().GetTextColor()));
            }).ToList();


            var mySelectedKillPredictionNote = MySelectedKillPredictions
                                               .OrderBy(x => x.Depth)
                                               .Select(x => new Note(x.Depth, x.GetTextColor()))
                                               .FirstOrDefault();

            if (mySelectedKillPredictionNote != null)
            {
                result.Insert(0, mySelectedKillPredictionNote);
            }

            return(result);
        }
        private TimeSeriesByLocation FilterSelectedCounties(TimeSeriesByLocation countryTimeSeriesByLocation, PredictionSettings settings)
        {
            var locations = countryTimeSeriesByLocation.LocationsWithDayData.Where(location => settings.Countries.Contains(location.Country)).ToList();

            return(new TimeSeriesByLocation {
                LocationsWithDayData = locations
            });
        }
        private TimeSeriesByDay AggregateTimeSeries(TimeSeriesByDay countriesTimeSeriesByDay, PredictionSettings predictionSettings)
        {
            var aggregatedTimeSeries = new TimeSeriesByDay();

            foreach (var day in countriesTimeSeriesByDay.DaysWithLocationData)
            {
                var aggregatedTimeSeriesDay = new DayWithLocationsData
                {
                    DayNumber = day.DayNumber,
                    Date      = day.Date
                };

                foreach (var locationData in day.LocationsData)
                {
                    switch (predictionSettings.CountrySearchType)
                    {
                    case CountrySearchType.Inside when !string.IsNullOrEmpty(locationData.Country) && predictionSettings.Countries.Contains(locationData.Country):
                    case CountrySearchType.Outside when string.IsNullOrEmpty(locationData.Country) || !predictionSettings.Countries.Contains(locationData.Country):
                        aggregatedTimeSeriesDay.TotalCases += locationData.TotalCases;

                        break;
                    }
                }

                aggregatedTimeSeries.DaysWithLocationData.Add(aggregatedTimeSeriesDay);
            }

            this.AdjustRealDaysData(aggregatedTimeSeries);

            return(aggregatedTimeSeries);
        }