Esempio n. 1
0
        private void Button_ClickWeather(object sender, RoutedEventArgs e)
        {
            var weather = _weatherServies.GetWeather(textBox.Text);

            if (weather != null)
            {
                this.DataContext = weather;
            }
        }
Esempio n. 2
0
 private void GetWeather(object sender, RoutedEventArgs e)
 {
     _root = _weatherService.GetWeather(cityTxtBox.Text);
     if (_root == null)
     {
         cityTxtBox.Text = "Такого города не существует";
     }
     else
     {
         _root.main.ConventToCelsius();
         this.DataContext        = _root;
         weatherPanel.Visibility = Visibility.Visible;
         btnDB.Visibility        = Visibility.Visible;
     }
 }
Esempio n. 3
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var weather = _weatherServies.GetWeather(txt.Text);
         if (weather != null)
         {
             this.DataContext = weather;
         }
         else
         {
             throw new Exception("Error");
         }
     }
     catch (Exception rx)
     {
         textbox3.Text = rx.Message;
     }
 }
Esempio n. 4
0
 private void BtnSearch(object sender, RoutedEventArgs e)
 {
     temp = _weatherService.GetWeather(txtBoxCity.Text);
     if (temp == null || temp.cod == 404)
     {
         panelInfo.Visibility = Visibility.Hidden;
         snackBarMsg.MessageQueue.Enqueue("city not found");
     }
     else
     if (temp.cod == 200)
     {
         panelInfo.Visibility = Visibility.Visible;
         txtBlkCity.Text      = temp.name;
         txtBlkCurTemp.Text   = Math.Round(temp.main.temp).ToString() + "°C";
         txtBlkDate.Text      = UnixTimestampToDateTime(temp.dt).ToString("MMM dd, ddd - HH:mm");
         txtBlkFeelsTemp.Text = "Feels like " + (int)temp.main.feels_like + "°C";
         txtBlkHumidity.Text  = "Humidity: " + temp.main.humidity + "%";
         txtBlkWind.Text      = "Wind: " + (int)temp.wind.speed + "m/s";
         txtBlkMinMax.Text    = "Min: " + (int)temp.main.temp_min + "°C / Max: " + (int)temp.main.temp_max + "°C";
     }
 }