コード例 #1
0
        private void BtnFiveDays_By_Hours_Click(object sender, EventArgs e)
        {
            Size = new System.Drawing.Size(600, 630);
            btnNext.Show();
            btnPrev.Show();
            WeatherModel.Last = (int)LastFunc.FIVEH;
            WeatherModel.TommorowShowIndex = 5; // 5-12
            WeatherModel.FiveDaysShowIndex = 1; // 1-5
            WeatherModel.IndexFiveDays     = 0;

            using (WebClient wc = new WebClient())
            {
                wc.Encoding = Encoding.UTF8;
                if (txtCityName.Text.Any())
                {
                    try
                    {
                        RadioButtonsUnitSet();
                        WeatherModel.City = txtCityName.Text;

                        WeatherModel.MinTemperature = 99999;
                        WeatherModel.MaxTemperature = -99999;
                        WeatherPresenter.FiveDaysHWeatherSet();
                        WeatherFiveDaysByHours();
                    }
                    catch {
                        txtRes.Text    = null;
                        txtResult.Text = "Incorrect city name";
                    }
                }
                else
                {
                    txtResult.Text = "Enter city name";
                }

                try
                {
                    txtResult.Text  = Translating.TranslateResult(txtResult.Text);
                    txtRes.Text     = Translating.TranslateResult(txtRes.Text);
                    txtCityDay.Text = Translating.TranslateResult(txtCityDay.Text);
                }
                catch { }
            }
        }
コード例 #2
0
        private void BtnTomorrowWeather_Click(object sender, EventArgs e)
        {
            Size = new System.Drawing.Size(500, 400);

            txtRes.Text = "";
            btnNext.Show();
            btnPrev.Show();
            WeatherModel.Last = (int)LastFunc.TOMORROW;
            WeatherModel.FiveDaysShowIndex  = 1; // 1-5
            WeatherModel.FiveDaysHShowIndex = 1; // 1-5
            WeatherModel.IndexFiveDays      = 0;
            WeatherModel.Index = 0;

            if (txtCityName.Text.Any())
            {
                try
                {
                    RadioButtonsUnitSet();
                    WeatherModel.City = txtCityName.Text;

                    WeatherModel.MinTemperature = 99999;
                    WeatherModel.MaxTemperature = -99999;
                    WeatherPresenter.TommorowWeatherSet();
                    WeatherTomorrow();
                }
                catch {
                    txtRes.Text    = null;
                    txtResult.Text = "Incorrect city name";
                }
            }
            else
            {
                txtResult.Text = "Enter city name";
            }

            try
            {
                txtResult.Text  = Translating.TranslateResult(txtResult.Text);
                txtRes.Text     = Translating.TranslateResult(txtRes.Text);
                txtCityDay.Text = Translating.TranslateResult(txtCityDay.Text);
            }
            catch { }
        }
コード例 #3
0
        private void BtnTodayWeather_Click(object sender, EventArgs e)
        {
            Size        = new System.Drawing.Size(500, 460);
            txtRes.Text = "";

            WeatherModel.Last = (int)LastFunc.TODAY;
            WeatherModel.TommorowShowIndex  = 5; // 5-12
            WeatherModel.FiveDaysShowIndex  = 1; // 1-5
            WeatherModel.FiveDaysHShowIndex = 1; // 1-5
            WeatherModel.IndexFiveDays      = 0;
            WeatherModel.Index = 0;

            if (txtCityName.Text.Any())
            {
                try
                {
                    RadioButtonsUnitSet();
                    WeatherModel.City = txtCityName.Text;

                    WeatherPresenter.TodayWeatherSet();
                    WeatherToday();
                }
                catch
                {
                    txtRes.Text    = null;
                    txtResult.Text = "Некорректное название города";
                }
            }
            else
            {
                txtResult.Text = "Введите название города";
            }

            try
            {
                txtResult.Text  = Translating.TranslateResult(txtResult.Text);
                txtRes.Text     = Translating.TranslateResult(txtRes.Text);
                txtCityDay.Text = Translating.TranslateResult(txtCityDay.Text);
            }
            catch { }
        }