private void LboxSearchCities_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { try { Weather wtp = new Weather(); string location = LboxSearchCities.SelectedValue.ToString(); string city, country; int comaIndex = location.IndexOf(','); country = location.Substring(comaIndex + 1); city = location.Remove(comaIndex); City cityFound = Cities.CityList.FirstOrDefault<City>(c => c.name == city | c.country == country); wtp.GetWeatherById(cityFound._id); Mw.SetWeatherData(wtp); TbCitySearch.Clear(); CloseTextBoxvoxFl(); } catch (Exception ex) { ShowInfo sg = new ShowInfo("Ошибка", ex.ToString()); sg.ShowDialog(); } }
public void GetWeatherXmlCity() { if (System.IO.File.Exists("userSettings.xml")) { var path = "userSettings.xml"; XDocument doc = XDocument.Load(path); var doccity = doc.Element("settings").Element("location").Element("city").Value; Weather wtp = new Weather(); string location = doccity; string city, country; int comaIndex = location.IndexOf(','); country = location.Substring(comaIndex + 1); city = location.Remove(comaIndex); City cityFound = Cities.CityList.FirstOrDefault<City>(c => c.name == city | c.country == country); wtp.GetWeatherById(cityFound._id); SetWeatherData(wtp); } }