示例#1
0
        public async Task UpdateDataAsync()
        {
            if (weatherData.Count != 0)
            {
                Weather w = weatherData.Find(e => e.City == selectedCity);
                await Task.Run(() =>
                {
                    w.Update();
                });

                view.ShowWeather(w);
            }
        }
示例#2
0
        public void AddCity(string cityName)
        {
            byte[] tempBytes = Encoding.GetEncoding("ISO-8859-8").GetBytes(cityName);
            string asciiStr  = Encoding.UTF8.GetString(tempBytes);

            Weather city = new Weather(asciiStr);

            city.Update();
            if (!weatherData.Any(c => c.City == city.City))
            {
                view.ShowWeather(city);
                weatherData.Add(city);
                view.AddCityToList(city.City);
                selectedCity = city.City;
                if (!Properties.Settings.Default.Cities.Contains(city.City))
                {
                    Properties.Settings.Default.Cities.Add(city.City);
                    Properties.Settings.Default.Save();
                }
            }
        }