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 MainWindow() { try { StartWindow StWindow = new StartWindow(); StWindow.ShowDialog(); wr = new Weather(); InitializeComponent(); InitializeDezign(); SetWeatherData(wr); ReadSettingsDataXML(); searchflyout.SetMainWnd(this); GetWeatherXmlCity(); settingsflyout.Wetspeed.LowerSlider.Minimum = 0; settingsflyout.Wetspeed.UpperSlider.Minimum = 0; } 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); } }
public void SetWeatherData(Weather wr) { LbWindCityName.Content = wr.City + " " + wr.Country; DataBox.LbState.Content = String.Format("Состояние: {0} ", wr.Sky); DataBox.LbWindSpeed.Content = String.Format("Ветер: {0} м/с", wr.WindSpeed); DataBox.LbMinTemperature.Content = String.Format("Tmin: {0} °C", wr.MinTemperature); DataBox.LbMaxTemperature.Content = String.Format("Tmax: {0} °C", wr.MaxTemperature); DataBox.LbHumidity.Content = String.Format("Влажность: {0} ", wr.Humidity); DataBox.LbSunrise.Content = String.Format("Рассвет: {0} ", wr.Sunrise); DataBox.LbSunset.Content = String.Format("Закат: {0} ", wr.Sunset); DataBox.LbTemperature.Content = String.Format("Температура: {0} °C", wr.Temperature); DataBox.LbPressure.Content = String.Format("Давление: {0} ", wr.Pressure); DataBox.LbCurrentDate.Content = String.Format("{0}", wr.Date); }
private void LboxSearchCities_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { try { Weather wtp = new Weather(); string location = LboxSearchCities.SelectedValue.ToString(); LboxSearchCities.Items.Clear(); TboxCityNotification.Clear(); TboxCityNotification.Text = location; } catch (Exception ex) { ShowInfo sg = new ShowInfo("Ошибка", ex.ToString()); sg.ShowDialog(); } }