码迷,mamicode.com
首页 > Windows程序 > 详细

C#作业总结 (4)

时间:2014-12-14 00:40:47      阅读:270      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   ar   color   sp   for   on   div   

时间关系,先总结一下天气信息获取部分,给出详细的步骤

.bubuko.com,布布扣

bubuko.com,布布扣

bubuko.com,布布扣

bubuko.com,布布扣

在URL里面输入  http://www.webxml.com.cn/WebServices/WeatherWebService.asmx ,添加引用就行 。

准备工作已经做好,下面给出我里面大部分的代码

        private void GetWeather()
        {
            string city = "西安";
            try
            {
                cn.com.webxml.www.WeatherWebService wws = new cn.com.webxml.www.WeatherWebService();       //实例化
                string[] wwsArray = wws.getWeatherbyCityName(city);            //获取信息  
                string[] info = wwsArray[10].Split(new char[] {  });       //分割  注意 这里的 ;  不是 ;   
                m_WeatherAllInfo[0] = info[0].Substring(info[0].LastIndexOf() + 1, info[0].Length - info[0].LastIndexOf());      //气温 注意零下的气温 
                m_WeatherAllInfo[1] = wwsArray[6].Substring(wwsArray[6].LastIndexOf( ) + 1);     //云状况
                m_WeatherAllInfo[2] = info[1].Substring(info[1].IndexOf() + 1);    //风向
                m_WeatherAllInfo[3] = info[2].Substring(info[2].IndexOf() + 1);    //湿度
                m_WeatherAllInfo[4] = info[4].Substring(info[4].IndexOf() + 1);    //紫外线强度
                m_WeatherAllInfo[5] = wwsArray[5];                                     //当天气温
                m_WeatherAllInfo[6] = @".\Image\Weather\SmallWeather\b_" + wwsArray[8];      //图片信息  
                m_WeatherAllInfo[7] = wwsArray[12];
                m_WeatherAllInfo[8] = @".\Image\Weather\SmallWeather\b_" + wwsArray[15];
                m_WeatherAllInfo[9] = wwsArray[17];
                m_WeatherAllInfo[10] = @".\Image\Weather\SmallWeather\b_" + wwsArray[20];
                string tmp = wwsArray[8].Substring(0, wwsArray[8].IndexOf(.));
                pictureWeather.Image = Image.FromFile(string.Format(@".\Image\Weather\BigWeather\a_{0}.ico", tmp));
                m_SuccessWeather = true;
            }
            catch
            {
                m_SuccessWeather=false; 
            }
        }

 

 

上面大部分是操作字符串的代码,给出天气图标素材资源的下载 http://download.csdn.net/detail/zhoupeng39/8257009

具体的程序就不发了,发一张截图

bubuko.com,布布扣

 

洗洗睡了

C#作业总结 (4)

标签:style   blog   http   ar   color   sp   for   on   div   

原文地址:http://www.cnblogs.com/fightfuture/p/4162089.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!