private void LoadSettings() { _listLocations.Clear(); using (Profile.Settings xmlreader = new Profile.MPSettings()) { _locationCode = xmlreader.GetValueAsString("weather", "location", string.Empty); _temperatureFarenheit = xmlreader.GetValueAsString("weather", "temperature", "C"); int loadWind = xmlreader.GetValueAsInt("weather", "speed", 0); switch (loadWind) { case 0: _currentWindUnit = WindUnit.Kmh; break; case 1: _currentWindUnit = WindUnit.mph; break; case 2: _currentWindUnit = WindUnit.ms; break; case 3: _currentWindUnit = WindUnit.Kn; break; case 4: _currentWindUnit = WindUnit.Bft; break; default: _currentWindUnit = WindUnit.Bft; break; } _refreshIntercal = xmlreader.GetValueAsInt("weather", "refresh", 60); _lastRefreshTime = DateTime.Now.AddMinutes(-(_refreshIntercal + 1)); _skipConnectionTest = xmlreader.GetValueAsBool("weather", "skipconnectiontest", false); Log.Info("GUIWindowWeather: SkipConnectionTest: {0}", _skipConnectionTest); bool bFound = false; for (int i = 0; i < VirtualDirectory.MaxSharesCount; i++) { string cityTag = String.Format("city{0}", i); string strCodeTag = String.Format("code{0}", i); string strSatUrlTag = String.Format("sat{0}", i); string strTempUrlTag = String.Format("temp{0}", i); string strUVUrlTag = String.Format("uv{0}", i); string strWindsUrlTag = String.Format("winds{0}", i); string strHumidUrlTag = String.Format("humid{0}", i); string strPrecipUrlTag = String.Format("precip{0}", i); string city = xmlreader.GetValueAsString("weather", cityTag, string.Empty); string strCode = xmlreader.GetValueAsString("weather", strCodeTag, string.Empty); string strSatURL = xmlreader.GetValueAsString("weather", strSatUrlTag, string.Empty); string strTempURL = xmlreader.GetValueAsString("weather", strTempUrlTag, string.Empty); string strUVURL = xmlreader.GetValueAsString("weather", strUVUrlTag, string.Empty); string strWindsURL = xmlreader.GetValueAsString("weather", strWindsUrlTag, string.Empty); string strHumidURL = xmlreader.GetValueAsString("weather", strHumidUrlTag, string.Empty); string strPrecipURL = xmlreader.GetValueAsString("weather", strPrecipUrlTag, string.Empty); if (city.Length > 0 && strCode.Length > 0) { if (strSatURL.Length == 0) { //strSatURL = "http://www.heute.de/CMO/frontend/subsystem_we/WeShowPicture/0,6008,161,00.gif"; //strSatURL = @"http://images.intellicast.com/WeatherImg/SatelliteLoop/hieusat_None_anim.gif"; //strSatURL = @"http://www.sat24.com/image.ashx?country=eu&type=loop&sat=vis"; strSatURL = @"http://www.sat24.com/image.ashx?country=eu"; } LocationInfo loc = new LocationInfo(); loc.City = city; loc.CityCode = strCode; loc.UrlSattelite = strSatURL; loc.UrlTemperature = strTempURL; loc.UrlUvIndex = strUVURL; loc.UrlWinds = strWindsURL; loc.UrlHumidity = strHumidURL; loc.UrlPrecip = strPrecipURL; _listLocations.Add(loc); if (String.Compare(_locationCode, strCode, true) == 0) { bFound = true; } } } if (!bFound) { if (_listLocations.Count > 0) { _locationCode = ((LocationInfo)_listLocations[0]).CityCode; } } } }
public Wind(double value, WindUnit unit) : base(value, StringEnum.GetStringValue(unit)) { }
/// <summary> /// Loads weather settings from MediaPortal.xml /// </summary> public override void LoadSettings() { using (Settings xmlreader = new MPSettings()) { int loadWind = xmlreader.GetValueAsInt("weather", "speed", 4); switch (loadWind) { case 0: selectedWindUnit = WindUnit.Kmh; windSpeedComboBox.Text = "kilometers / hour"; break; case 1: selectedWindUnit = WindUnit.mph; windSpeedComboBox.Text = "miles / hour"; break; case 2: selectedWindUnit = WindUnit.ms; windSpeedComboBox.Text = "meters / second"; break; case 3: selectedWindUnit = WindUnit.Kn; windSpeedComboBox.Text = "Knots"; break; case 4: selectedWindUnit = WindUnit.Bft; windSpeedComboBox.Text = "Beaufort"; break; default: selectedWindUnit = WindUnit.Bft; windSpeedComboBox.Text = "Beaufort"; break; } // Get temperature measurement type string temperature = xmlreader.GetValueAsString("weather", "temperature", "C"); if (temperature.Equals("C")) { temperatureComboBox.Text = "Celsius"; } else if (temperature.Equals("F")) { temperatureComboBox.Text = "Fahrenheit"; } // Get refresh interval setting intervalTextBox.Text = Convert.ToString(xmlreader.GetValueAsInt("weather", "refresh", 60)); // Get number of cities and city information for (int index = 0; index < MaximumCities; index++) { string cityName = String.Format("city{0}", index); string cityCode = String.Format("code{0}", index); string citySat = String.Format("sat{0}", index); string cityTemp = String.Format("temp{0}", index); string cityUV = String.Format("uv{0}", index); string cityWinds = String.Format("winds{0}", index); string cityHumid = String.Format("humid{0}", index); string cityPrecip = String.Format("precip{0}", index); //Read city information from index string cityNameData = xmlreader.GetValueAsString("weather", cityName, ""); string cityCodeData = xmlreader.GetValueAsString("weather", cityCode, ""); string citySatData = xmlreader.GetValueAsString("weather", citySat, ""); string cityTempData = xmlreader.GetValueAsString("weather", cityTemp, ""); string cityUVData = xmlreader.GetValueAsString("weather", cityUV, ""); string cityWindsData = xmlreader.GetValueAsString("weather", cityWinds, ""); string cityHumidData = xmlreader.GetValueAsString("weather", cityHumid, ""); string cityPrecipData = xmlreader.GetValueAsString("weather", cityPrecip, ""); if (cityNameData.Length > 0 && cityCodeData.Length > 0) { citiesListView.Items.Add( new ListViewItem(new string[] { cityNameData, cityCodeData, citySatData, cityTempData, cityUVData, cityWindsData, cityHumidData, cityPrecipData })); } } } }
public override void SaveSettings() { using (Settings xmlwriter = new MPSettings()) { if (windSpeedComboBox.Text.Equals("kilometers / hour")) { selectedWindUnit = WindUnit.Kmh; } else if (windSpeedComboBox.Text.Equals("miles / hour")) { selectedWindUnit = WindUnit.mph; } else if (windSpeedComboBox.Text.Equals("meters / second")) { selectedWindUnit = WindUnit.ms; } else if (windSpeedComboBox.Text.Equals("Knots")) { selectedWindUnit = WindUnit.Kn; } else if (windSpeedComboBox.Text.Equals("Beaufort")) { selectedWindUnit = WindUnit.Bft; } // Write the speed units xmlwriter.SetValue("weather", "speed", (int)selectedWindUnit); // Define the temperature measurement string temperature = string.Empty; if (temperatureComboBox.Text.Equals("Celsius")) { temperature = "C"; } else if (temperatureComboBox.Text.Equals("Fahrenheit")) { temperature = "F"; } xmlwriter.SetValue("weather", "temperature", temperature); // Define the interval time between weather updates xmlwriter.SetValue("weather", "refresh", intervalTextBox.Text); // Save city information for (int index = 0; index < MaximumCities; index++) { string cityName = String.Format("city{0}", index); string cityCode = String.Format("code{0}", index); string citySat = String.Format("sat{0}", index); string cityTemp = String.Format("temp{0}", index); string cityUV = String.Format("uv{0}", index); string cityWinds = String.Format("winds{0}", index); string cityHumid = String.Format("humid{0}", index); string cityPrecip = String.Format("precip{0}", index); string cityNameData = string.Empty; string cityCodeData = string.Empty; string citySatData = string.Empty; string cityTempData = string.Empty; string cityUVData = string.Empty; string cityWindsData = string.Empty; string cityHumidData = string.Empty; string cityPrecipData = string.Empty; if (citiesListView.Items != null && citiesListView.Items.Count > index) { cityNameData = citiesListView.Items[index].SubItems[0].Text; cityCodeData = citiesListView.Items[index].SubItems[1].Text; citySatData = citiesListView.Items[index].SubItems[2].Text; cityTempData = citiesListView.Items[index].SubItems[3].Text; cityUVData = citiesListView.Items[index].SubItems[4].Text; cityWindsData = citiesListView.Items[index].SubItems[5].Text; cityHumidData = citiesListView.Items[index].SubItems[6].Text; cityPrecipData = citiesListView.Items[index].SubItems[7].Text; } xmlwriter.SetValue("weather", cityName, cityNameData); xmlwriter.SetValue("weather", cityCode, cityCodeData); xmlwriter.SetValue("weather", citySat, citySatData); xmlwriter.SetValue("weather", cityTemp, cityTempData); xmlwriter.SetValue("weather", cityUV, cityUVData); xmlwriter.SetValue("weather", cityWinds, cityWindsData); xmlwriter.SetValue("weather", cityHumid, cityHumidData); xmlwriter.SetValue("weather", cityPrecip, cityPrecipData); } } }