Source code of wp7 Weather Forecast (binary serialization of Google data) released source code download address

Source: Internet
Author: User

This application has been introduced in the previous article.

Article Source: http://www.cnblogs.com/wildfeng/archive/2012/03/21/2410504.html

Due to too much code and complicated front-end page effects Code, there is no way to explain it in the blog, and many netizens asked me to publish the source code project. At the bottom of the article, I provide the source code.

Author: QQ: 29992379

This weather forecast uses Google's API. I specially wrote a tool class to serialize the returned data. This article mainly introduces this tool class.

The Code is as follows:

Using System; using System. linq; using System. xml. linq; namespace GoogleWeather {public static class GoogleWeatherHelper {// <summary> // obtain the city and province /// </summary> /// <param name = "xmlWeather"> xml data </param> /// <returns> </returns> public static string GetCity (XElement xmlWeather) {XElement forecast_information = xmlWeather. descendants ("forecast_information "). first (); return forecast_information.Element ("city "). attribute ("data "). value ;} /// <summary> /// obtain the Chinese city name /// </summary> /// <param name = "xmlWeather"> </param> /// <returns> </returns> public static string GetPostalCode (XElement xmlWeather) {XElement forecast_information = xmlWeather. descendants ("forecast_information "). first (); return forecast_information.Element ("postal_code "). attribute ("data "). value ;} /// <summary> /// obtain the forecast date /// </summary> /// <param name = "xmlWeather"> </param> /// <returns> </returns> public static string GetForecastDate (XElement xmlWeather) {XElement forecast_information = xmlWeather. descendants ("forecast_information "). first (); return forecast_information.Element ("forecast_date "). attribute ("data "). value ;} /// <summary> /// obtain humidity /// </summary> /// <param name = "xmlWeather"> </param> /// <returns> </returns> public static string GetHumidity (XElement xmlWeather) {XElement forecast_information = xmlWeather. descendants ("current_conditions "). first (); return forecast_information.Element ("humidity "). attribute ("data "). value ;} /// <summary> /// obtain the wind direction /// </summary> /// <param name = "xmlWeather"> </param> /// <returns> </returns> public static string GetWindCondition (XElement xmlWeather) {XElement forecast_information = xmlWeather. descendants ("current_conditions "). first (); return forecast_information.Element ("wind_condition "). attribute ("data "). value ;} /// <summary> /// obtain today's week // </summary> /// <param name = "xmlWeather"> </param> /// <returns> </returns> public static string GetTodayWeek (XElement xmlWeather) {XElement forecast_information = xmlWeather. descendants ("forecast_conditions "). first (); return forecast_information.Element ("day_of_week "). attribute ("data "). value ;} /// <summary> /// obtain the minimum temperature today /// </summary> /// <param name = "xmlWeather"> </param> /// <returns> </returns> public static string GetTodayLow (XElement xmlWeather) {XElement forecast_information = xmlWeather. descendants ("forecast_conditions "). first (); return forecast_information.Element ("low "). attribute ("data "). value ;} /// <summary> /// obtain the maximum temperature today /// </summary> /// <param name = "xmlWeather"> </param> /// <returns> </returns> public static string GetTodayHight (XElement xmlWeather) {XElement forecast_information = xmlWeather. descendants ("forecast_conditions "). first (); return forecast_information.Element ("high "). attribute ("data "). value ;} /// <summary> /// obtain the today's weather icon /// </summary> /// <param name = "xmlWeather"> </param> /// <returns> </returns> public static string GetTodayIcon (XElement xmlWeather) {XElement forecast_information = xmlWeather. descendants ("forecast_conditions "). first (); return ExtractFileName (forecast_information.Element ("icon "). attribute ("data "). value );} /// <summary> /// obtain today's weather conditions /// </summary> /// <param name = "xmlWeather"> </param> /// <returns> </returns> public static string GetTodayCondition (XElement xmlWeather) {XElement forecast_information = xmlWeather. descendants ("forecast_conditions "). first (); return forecast_information.Element ("condition "). attribute ("data "). value ;} /// <summary> /// obtain tomorrow's week // </summary> /// <param name = "xmlWeather"> </param> /// <returns> </returns> public static string GetTomorrowWeek (XElement xmlWeather) {XElement forecast_information = xmlWeather. descendants ("forecast_conditions "). elementAt (1); return forecast_information.Element ("day_of_week "). attribute ("data "). value ;} /// <summary> /// obtain the minimum tomorrow temperature // </summary> /// <param name = "xmlWeather"> </param> /// <returns> </returns> public static string GetTomorrowLow (XElement xmlWeather) {XElement forecast_information = xmlWeather. descendants ("forecast_conditions "). elementAt (1); return forecast_information.Element ("low "). attribute ("data "). value ;} /// <summary> /// obtain the maximum temperature for tomorrow /// </summary> /// <param name = "xmlWeather"> </param> /// <returns> </returns> public static string GetTomorrowHight (XElement xmlWeather) {XElement forecast_information = xmlWeather. descendants ("forecast_conditions "). elementAt (1); return forecast_information.Element ("high "). attribute ("data "). value ;} /// <summary> /// get tomorrow's weather icon /// </summary> /// <param name = "xmlWeather"> </param> /// <returns> </returns> public static string GetTomorrowIcon (XElement xmlWeather) {XElement forecast_information = xmlWeather. descendants ("forecast_conditions "). elementAt (1); return ExtractFileName (forecast_information.Element ("icon "). attribute ("data "). value );} /// <summary> /// obtain tomorrow's weather conditions /// </summary> /// <param name = "xmlWeather"> </param> /// <returns> </returns> public static string GetTomorrowCondition (XElement xmlWeather) {XElement forecast_information = xmlWeather. descendants ("forecast_conditions "). elementAt (1); return forecast_information.Element ("condition "). attribute ("data "). value ;} /// <summary> /// obtain the week after tomorrow /// </summary> /// <param name = "xmlWeather"> </param> /// <returns> </returns> public static string GetHouTianWeek (XElement xmlWeather) {XElement forecast_information = xmlWeather. descendants ("forecast_conditions "). elementAt (2); return forecast_information.Element ("day_of_week "). attribute ("data "). value ;} /// <summary> /// obtain the minimum temperature of the day after tomorrow /// </summary> /// <param name = "xmlWeather"> </param> /// <returns> </returns> public static string GetHouTianLow (XElement xmlWeather) {XElement forecast_information = xmlWeather. descendants ("forecast_conditions "). elementAt (2); return forecast_information.Element ("low "). attribute ("data "). value ;} /// <summary> /// obtain the maximum temperature of the day after tomorrow /// </summary> /// <param name = "xmlWeather"> </param> /// <returns> </returns> public static string GetHouTianHight (XElement xmlWeather) {XElement forecast_information = xmlWeather. descendants ("forecast_conditions "). elementAt (2); return forecast_information.Element ("high "). attribute ("data "). value ;} /// <summary> /// obtain the acquired weather icon /// </summary> /// <param name = "xmlWeather"> </param> /// <returns> </returns> public static string GetHouTianIcon (XElement xmlWeather) {XElement forecast_information = xmlWeather. descendants ("forecast_conditions "). elementAt (2); return ExtractFileName (forecast_information.Element ("icon "). attribute ("data "). value );} /// <summary> /// obtain the weather condition of the day after tomorrow /// </summary> /// <param name = "xmlWeather"> </param> /// <returns> </returns> public static string GetHouTianCondition (XElement xmlWeather) {XElement forecast_information = xmlWeather. descendants ("forecast_conditions "). elementAt (2); return forecast_information.Element ("condition "). attribute ("data "). value ;} /// <summary> /// obtain the day after tomorrow. /// </summary> /// <param name = "xmlWeather"> </param> /// <returns> </returns> public static string GetDaHouTianWeek (XElement xmlWeather) {XElement forecast_information = xmlWeather. descendants ("forecast_conditions "). elementAt (3); return forecast_information.Element ("day_of_week "). attribute ("data "). value ;} /// <summary> /// obtain the minimum temperature of the day after tomorrow /// </summary> /// <param name = "xmlWeather"> </param> /// <returns> </returns> public static string GetDaHouTianLow (XElement xmlWeather) {XElement forecast_information = xmlWeather. descendants ("forecast_conditions "). elementAt (3); return forecast_information.Element ("low "). attribute ("data "). value ;} /// <summary> /// obtain the maximum temperature of the day after tomorrow /// </summary> /// <param name = "xmlWeather"> </param> /// <returns> </returns> public static string GetDaHouTianHight (XElement xmlWeather) {XElement forecast_information = xmlWeather. descendants ("forecast_conditions "). elementAt (3); return forecast_information.Element ("high "). attribute ("data "). value ;} /// <summary> /// obtain the big data weather icon /// </summary> /// <param name = "xmlWeather"> </param> /// <returns> </returns> public static string GetDaHouTianIcon (XElement xmlWeather) {XElement forecast_information = xmlWeather. descendants ("forecast_conditions "). elementAt (3); return ExtractFileName (forecast_information.Element ("icon "). attribute ("data "). value );} /// <summary> /// obtain the weather conditions of the day after tomorrow /// </summary> /// <param name = "xmlWeather"> </param> /// <returns> </returns> public static string GetDaHouTianCondition (XElement xmlWeather) {XElement forecast_information = xmlWeather. descendants ("forecast_conditions "). elementAt (3); return forecast_information.Element ("condition "). attribute ("data "). value;} private static string ExtractFileName (string fullFileName) {string str = fullFileName. substring (fullFileName. lastIndexOf ('/') + 1); return str. substring (0, str. lastIndexOf ('. ')). replace ("cn _","");}}}

 

The entire weather forecast project source code: http://download.csdn.net/detail/wildfeng04/4168595

In future blog posts, I will explain in detail the implementation of this application UI. After all, this application highlights all over the UI. I personally understand this because the functional code is not very difficult and the UI effect is dazzling. I used Storyboard to achieve some results.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.