Example #1
0
        private object GetProvinceList(string country)
        {
            string        province_data = CovidHelper.GetProvinceList4mCountry(country);
            List <string> province_list = province_data.Split(new char[] { '\n' }).ToList();

            return(province_list);
        }
Example #2
0
        private void country_dd_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string country_name = country_dd.SelectedItem.ToString();

                if (country_name != country_not_available)
                {
                    SetConnectionStatus(true);
                }

                if (country_dd.SelectedItem == global_countries)
                {
                    CovidGetGlobalData();
                }
                else
                {
                    var    province_list = GetProvinceList(country_name);
                    string country_code  = CovidHelper.GetCountryCode4mName(country_name);

                    //Get province data.
                    province_dd.DataSource = province_list;
                    CovidGetCountryData(country_name);

                    //Load the flag.
                    string flags_url = CovidHelper.GetFlagsURL(country_code);
                    country_flag_picbox.Load(flags_url);
                }
            }
            catch (NullReferenceException ex)
            {
                ShowError("Internet connection lost");
                confirm_txt_box.Text = fatal_txt_box.Text = recovered_txt_box.Text = "NAN";
                SetConnectionStatus(false);
            }

            catch (Exception ex)
            {
                if (ex.Message.Contains("(404) Not Found"))
                {
                    country_flag_picbox.Load(CovidHelper.country_error_url);
                }
                else
                {
                    ShowError(ex.Message);
                }
            }
        }
Example #3
0
        static void CovidLoadData(CountriesInfo country_info, List <CovidDataList> covid_data_list, string filter_option, int display_size = 6)
        {
            try
            {
                Label[]      countries_label     = { country_info.country_1, country_info.country_2, country_info.country_3, country_info.country_4, country_info.country_5, country_info.country_6 };
                Label[]      countries_active    = { country_info.country_1_active, country_info.country_2_active, country_info.country_3_active, country_info.country_4_active, country_info.country_5_active, country_info.country_6_active };
                Label[]      countries_fatal     = { country_info.country_1_fatal, country_info.country_2_fatal, country_info.country_3_fatal, country_info.country_4_fatal, country_info.country_5_fatal, country_info.country_6_fatal };
                Label[]      countries_recovered = { country_info.country_1_recovered, country_info.country_2_recovered, country_info.country_3_recovered, country_info.country_4_recovered, country_info.country_5_recovered, country_info.country_6_recovered };
                PictureBox[] countries_flags_pb  = { country_info.country_1_picbox, country_info.country_2_picbox, country_info.country_3_picbox, country_info.country_4_picbox, country_info.country_5_picbox, country_info.country_6_picbox };

                if (filter_option == ACTIVE_CASE)
                {
                    covid_data_list         = covid_data_list.OrderByDescending(cd_list => ulong.Parse(cd_list.active_cases)).ToList();
                    country_info.title.Text = "Countries Info by Active cases";
                }
                else if (filter_option == FATAL_CASE)
                {
                    covid_data_list         = covid_data_list.OrderByDescending(cd_list => ulong.Parse(cd_list.fatal_cases)).ToList();
                    country_info.title.Text = "Countries Info by Fatal cases";
                }
                else if (filter_option == RECOVERED_CASE)
                {
                    //covid_data_list = covid_data_list.OrderByDescending(cd_list => ulong.Parse(cd_list.recovered_cases)).ToList();
                    country_info.title.Text = "Countries Info by Recovered cases";
                    ShowWarning("Recovered cases has problem right now correct information is not displayed");
                }

                //Reset previous data.
                for (int index = 0; index < display_size; ++index)
                {
                    countries_active[index].Text    = "NAN";
                    countries_fatal[index].Text     = "NAN";
                    countries_recovered[index].Text = "NAN";
                }

                //Load the data on information page.
                string active_cases = null, fatal_cases = null, recovered_cases = null;
                for (int index = 0; index < display_size; ++index)
                {
                    string country = covid_data_list[index].country;
                    active_cases    = covid_data_list[index].active_cases;
                    fatal_cases     = covid_data_list[index].fatal_cases;
                    recovered_cases = covid_data_list[index].recovered_cases;

                    countries_label[index].Text = country;

                    if (filter_option == ACTIVE_CASE)
                    {
                        countries_active[index].Text = active_cases;
                    }
                    else if (filter_option == FATAL_CASE)
                    {
                        countries_fatal[index].Text = fatal_cases;
                    }
                    else if (filter_option == RECOVERED_CASE)
                    {
                        countries_recovered[index].Text = recovered_cases;
                    }

                    //Load the flag.
                    if (connection_status)
                    {
                        string country_code = CovidHelper.GetCountryCode4mName(country);
                        string flags_url    = CovidHelper.GetFlagsURL(country_code);
                        countries_flags_pb[index].Load(flags_url);
                    }
                }
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
Example #4
0
 void CovidGetProvinceData(string province_name)
 {
     confirm_txt_box.Text   = CovidHelper.FromCountryProvinceConfirmed(province_name);
     fatal_txt_box.Text     = CovidHelper.FromCountryProvinceDeaths(province_name);
     recovered_txt_box.Text = CovidHelper.FromCountryProvinceRecovered(province_name);
 }