Пример #1
0
 internal static void CovidDisplayData(CountriesInfo country_info, string filter_option)
 {
     try
     {
         //Sort the data as per filter option.
         var covid_data_list = CovidGetDataList();
         CovidLoadData(country_info, covid_data_list, filter_option);
     }
     catch (Exception ex)
     {
         ShowError(ex.Message);
     }
 }
Пример #2
0
        private void display_data_btn_Click(object sender, EventArgs e)
        {
            CountriesInfo country_info = new CountriesInfo();

            country_info.ShowDialog();
        }
Пример #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);
            }
        }