Ejemplo n.º 1
0
        public SelectTownViewModel(CityTown selectedCity)
        {
            XmlCityTownRepository countryRepository = new XmlCityTownRepository();

            SelectedCity = selectedCity;

            ListItemsSource = countryRepository.GetTownList(selectedCity);
        }
Ejemplo n.º 2
0
        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"];
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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;
        }
Ejemplo n.º 5
0
        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;
        }
Ejemplo n.º 6
0
        public WeekDayViewModel()
        {
            mForecastCity = Navigation.ForecastCity;

            //GetWeekdayForecastItemsSource();
        }
Ejemplo n.º 7
0
        public MainPageViewModel()
        {
            if (DesignerProperties.IsInDesignTool)
            {
                ForecastCity = new CityTown
                {
                    Name = "天龍國"
                };

                ForecastTown = new CityTown
                {
                    Name = "天龍區"
                };

                DateText = "    2013/02/23 星期六";
            }

            BackgroundImage = "Weather01.bmp";
        }