public SelectTownViewModel(CityTown selectedCity) { XmlCityTownRepository countryRepository = new XmlCityTownRepository(); SelectedCity = selectedCity; ListItemsSource = countryRepository.GetTownList(selectedCity); }
public TileUpdateWorker() { IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings; if (!settings.Contains("forecastCity") || !settings.Contains("forecastTown")) { return; } mForecastCity = (CityTown)settings["forecastCity"]; mForecastTown = (CityTown)settings["forecastTown"]; if (settings.Contains("lastLaunchTime")) mLastLaunchTime = (DateTime)settings["lastLaunchTime"]; }
public System.Collections.Generic.IList <CityTown> GetTownList(CityTown selectedCity) { DateTime startTime = DateTime.Now; //XmlReader reader = XmlReader.Create("Model/CityTownSp.xml"); //countryList = ((CityTown)Utils.deserialize(reader, typeof(CityTown))).Cities; XDocument loadedGT_Town368Data = XDocument.Load("Model/GT_Town368Data.xml"); var town368Data = from query in loadedGT_Town368Data.Descendants("Area") select new Town368Data { ID = (string)query.Attribute("AreaID").Value, Longitude = (string)query.Attribute("lon").Value, Latitude = (string)query.Attribute("lat").Value }; XDocument loadedData = XDocument.Load("Model/CityTownSp.xml"); var cityData = from query in loadedData.Descendants("City") where query.Attribute("COUN_ID").Value == selectedCity.ID select query; var townData = from c1 in cityData.Descendants("Town") join c2 in town368Data on c1.Attribute("TOWN_ID").Value equals c2.ID select new CityTown { ID = (string)c1.Attribute("TOWN_ID").Value, Name = (string)c1.Attribute("TOWN_NA").Value, Latitude = c2.Latitude, Longitude = c2.Longitude }; List <CityTown> countryList = townData.ToList(); DateTime stopTime = DateTime.Now; System.Diagnostics.Debug.WriteLine("Elapsed: {0}", (stopTime - startTime).TotalMilliseconds); return(countryList); }
public System.Collections.Generic.IList<CityTown> GetTownList(CityTown selectedCity) { DateTime startTime = DateTime.Now; //XmlReader reader = XmlReader.Create("Model/CityTownSp.xml"); //countryList = ((CityTown)Utils.deserialize(reader, typeof(CityTown))).Cities; XDocument loadedGT_Town368Data = XDocument.Load("Model/GT_Town368Data.xml"); var town368Data = from query in loadedGT_Town368Data.Descendants("Area") select new Town368Data { ID = (string)query.Attribute("AreaID").Value, Longitude = (string)query.Attribute("lon").Value, Latitude = (string)query.Attribute("lat").Value }; XDocument loadedData = XDocument.Load("Model/CityTownSp.xml"); var cityData = from query in loadedData.Descendants("City") where query.Attribute("COUN_ID").Value == selectedCity.ID select query; var townData = from c1 in cityData.Descendants("Town") join c2 in town368Data on c1.Attribute("TOWN_ID").Value equals c2.ID select new CityTown { ID = (string)c1.Attribute("TOWN_ID").Value, Name = (string)c1.Attribute("TOWN_NA").Value, Latitude = c2.Latitude, Longitude = c2.Longitude }; List<CityTown> countryList = townData.ToList(); DateTime stopTime = DateTime.Now; System.Diagnostics.Debug.WriteLine("Elapsed: {0}", (stopTime - startTime).TotalMilliseconds); return countryList; }
public static String GetXmlFileName(CityTown forecastCity, string postfix) { String fileName = ""; string forecastCityID = forecastCity.ID; if (forecastCityID.StartsWith("630") || forecastCityID.StartsWith("640")) fileName = forecastCityID.Substring(0, forecastCityID.Length - 4) + "00" + postfix; else fileName = forecastCityID.Substring(0, forecastCityID.Length - 2) + postfix; return fileName; }
public WeekDayViewModel() { mForecastCity = Navigation.ForecastCity; //GetWeekdayForecastItemsSource(); }
public MainPageViewModel() { if (DesignerProperties.IsInDesignTool) { ForecastCity = new CityTown { Name = "天龍國" }; ForecastTown = new CityTown { Name = "天龍區" }; DateText = " 2013/02/23 星期六"; } BackgroundImage = "Weather01.bmp"; }