Exemple #1
0
        /// <summary>
        /// Changes the active tab and statistics to match selected country
        /// </summary>
        /// <returns>Generated tab page</returns>
        public void OnClick(CountryInfoEx country)
        {
            UpdateChart(country);

            TabControl parent = _tabPage.Parent as TabControl;

            parent.SelectedIndex = 2;
        }
Exemple #2
0
 public void OnClick(CountryInfoEx country)
 {
     System.Console.WriteLine(country.CountryCode);
 }
Exemple #3
0
        /// <summary>
        /// This method will be called every time a new country is choosed from global View
        /// </summary>
        /// <param name="country"></param>
        private void UpdateChart(CountryInfoEx country)
        {
            foreach (DayInfo day in country.DaysInfo)
            {
                int index = (day.Date.ToDateTime() - _startDate).Days;
                if (index < 0)
                { // skip info from days that are before the chosen start date
                    continue;
                }
                _confirmed[index] = day.Confirmed - day.Deaths - day.Recovered;
                _deaths[index]    = day.Deaths;
                _recovered[index] = day.Recovered;
            }

            _stackedAreaDead.Values      = GetRegionChartValues(_deaths, _startDate);
            _stackedAreaRecovered.Values = GetRegionChartValues(_recovered, _startDate);
            _stackedAreaConfirmed.Values = GetRegionChartValues(_confirmed, _startDate);

            _solidGaugeInfectionRage.Value = Math.Log(country.Confirmed);
            _solidGaugeDeathRate.Value     = Math.Log(country.Deaths);
            _solidGaugeRecoveryRate.Value  = Math.Log(country.Recovered);

            _solidGaugeInfectionRage.LabelFormatter = value =>
            {
                value = Math.Exp(value);
                if (value > 1000000)
                {
                    return($"  {Math.Round(value / 1000000.0, 2)}M \n infected");
                }
                else
                if (value > 1000)
                {
                    return($"  {Math.Round(value / 1000.0, 2)}K \n infected");
                }
                else
                {
                    return($"    {value}\n infected");
                }
            };

            _solidGaugeRecoveryRate.LabelFormatter = value =>
            {
                value = Math.Exp(value);
                if (value > 1000000)
                {
                    return($"  {Math.Round(value / 1000000.0, 2)}M \nrecovred");
                }
                else
                if (value > 1000)
                {
                    return($"  {Math.Round(value / 1000.0, 2)}K \nrecovered");
                }
                else
                {
                    return($"     {value}\nrecovered");
                }
            };

            _solidGaugeDeathRate.LabelFormatter = value =>
            {
                value = Math.Exp(value);
                if (value > 1000000)
                {
                    return($"  {Math.Round(value / 1000000.0, 2)}M \n deaths");
                }
                else
                if (value > 1000)
                {
                    return($"  {Math.Round(value / 1000.0, 2)}K \n deaths");
                }
                else
                {
                    return($"     {value}\n deaths");
                }
            };

            _labelTitle.Text = country.Name;
        }