예제 #1
0
        public async void setTextOnTextBock(string city)
        {
            RESTClient rest = new RESTClient();
            string     response;

            try
            {
                response = rest.getWeatherForLocation(city);
            }
            catch (HttpRequestException e)
            {
                String        dialogStr = String.Format("City \"{0}\" doesn't exists", city).ToString();
                MessageDialog dialog    = new MessageDialog(dialogStr);
                await dialog.ShowAsync();

                return;
            }
            WeatherInfo weatherInfo = JsonConvert.DeserializeObject <WeatherInfo>(response);

            tbCityValue.Text        = weatherInfo.city;
            tbWeatherValue.Text     = weatherInfo.getWeatherDescription();
            tbTemperatureValue.Text = weatherInfo.getTemperatureAsString();
            tbHumidityValue.Text    = weatherInfo.getHumidityAsString();
            tbWindValue.Text        = weatherInfo.getWindAsString();

            LastCitiesManager.getInst().AddCity(new LastCity(city, DateTime.Now));
        }
예제 #2
0
 public WeatherPage()
 {
     this.InitializeComponent();
     this.navigationHelper            = new NavigationHelper(this);
     this.navigationHelper.LoadState += navigationHelper_LoadState;
     this.navigationHelper.SaveState += navigationHelper_SaveState;
     lvLastUsedCities.ItemsSource     = LastCitiesManager.getInst().cities;
 }