Пример #1
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGridView1.CurrentCell.ColumnIndex == 1 | dataGridView1.CurrentCell.ColumnIndex == 2 | dataGridView1.CurrentCell.ColumnIndex == 3 | dataGridView1.CurrentCell.ColumnIndex == 4)
            {
                return;
            }

            user_cities.RemoveAt(dataGridView1.CurrentCell.RowIndex);

            IProxyWeather     proxy     = new ProxyWeather();
            TotalCDegrees     degrees   = new TotalCDegrees();
            FDegreesConverter converter = new FDegreesConverter(degrees);

            dataGridView1.Rows.Clear();

            foreach (var i in user_cities)
            {
                var weather = proxy.Weather(i);
                converter.ConvertFDegreees(weather.main.temp);
                double temp = converter.GetCDegrees();
                converter.ConvertFDegreees(weather.main.temp_max);
                double temp_max = converter.GetCDegrees();
                converter.ConvertFDegreees(weather.main.temp_min);
                double      temp_min = converter.GetCDegrees();
                DisplayCity c        = new DisplayCity {
                    Name = i, Temp = temp, TempMax = temp_max, TempMin = temp_min
                };
                datagrid_cities.Add(c);
            }

            BindingSource source = new BindingSource();

            source.DataSource        = datagrid_cities;
            dataGridView1.DataSource = source;
        }
Пример #2
0
        private void button4_Click(object sender, EventArgs e)
        {
            string city = user_cities[dataGridView1.CurrentCell.RowIndex];

            selected_city.Text = city;

            IProxyWeather     proxy     = new ProxyWeather();
            TotalCDegrees     degrees   = new TotalCDegrees();
            FDegreesConverter converter = new FDegreesConverter(degrees);

            var forecast = proxy.Forecast(city);

            converter.ConvertFDegreees(forecast.list[0].main.temp);
            double temp = converter.GetCDegrees();

            today_w.Text = "" + temp;
            converter.ConvertFDegreees(forecast.list[1].main.temp);
            temp        = converter.GetCDegrees();
            day1_w.Text = "" + temp;
            converter.ConvertFDegreees(forecast.list[2].main.temp);
            temp        = converter.GetCDegrees();
            day2_w.Text = "" + temp;
            converter.ConvertFDegreees(forecast.list[3].main.temp);
            temp        = converter.GetCDegrees();
            day3_w.Text = "" + temp;
            converter.ConvertFDegreees(forecast.list[4].main.temp);
            temp        = converter.GetCDegrees();
            day4_w.Text = "" + temp;
            converter.ConvertFDegreees(forecast.list[5].main.temp);
            temp        = converter.GetCDegrees();
            day5_w.Text = "" + temp;

            panel4.Visible = false;
        }
Пример #3
0
        private void home_button_Click(object sender, EventArgs e)
        {
            IProxyWeather     proxy     = new ProxyWeather();
            TotalCDegrees     degrees   = new TotalCDegrees();
            FDegreesConverter converter = new FDegreesConverter(degrees);

            dataGridView1.Rows.Clear();

            foreach (var i in user_cities)
            {
                var weather = proxy.Weather(i);
                if (weather.main != null)
                {
                    converter.ConvertFDegreees(weather.main.temp);
                    double temp = converter.GetCDegrees();
                    converter.ConvertFDegreees(weather.main.temp_max);
                    double temp_max = converter.GetCDegrees();
                    converter.ConvertFDegreees(weather.main.temp_min);
                    double      temp_min = converter.GetCDegrees();
                    DisplayCity c        = new DisplayCity {
                        Name = i, Temp = temp, TempMax = temp_max, TempMin = temp_min
                    };
                    datagrid_cities.Add(c);
                }
            }

            BindingSource source = new BindingSource();

            source.DataSource        = datagrid_cities;
            dataGridView1.DataSource = source;

            panel_add.Visible = false;
            panel4.Visible    = true;
        }