Exemplo n.º 1
0
 public static weatherDataObject.weatherWebObj GetWeatherByCityWebServices(string cityName)
 {
     if (!string.IsNullOrEmpty(cityName))
     {
         sLocateName = cityName;
     }
     try
     {
         weatherDataObject.weatherWebObj     weathObj    = new weatherDataObject.weatherWebObj();
         cn.com.webxml.www.WeatherWebService weatherInfo = new cn.com.webxml.www.WeatherWebService();
         string[] s = new string[23];//声明string数组存放返回结果
         s = weatherInfo.getWeatherbyCityName(cityName);
         if (s[8] == "")
         {
             System.Windows.Forms.MessageBox.Show("暂时不支持您查询的城市");
         }
         else
         {
             weathObj.temp       = s[5];
             weathObj.tempDetail = s[6];
             weathObj.note       = s[10];
         }
         return(weathObj);
     }
     catch
     {
         return(null);
     }
 }
Exemplo n.º 2
0
 private void GetWeatherInfo(string sCity)
 {
     if (!string.IsNullOrEmpty(sCity))
     {
         objWeather = weatherUtils.GetWeatherByCityWebServices(sCity);
         if (objWeather != null)
         {
             lblWeather.Text = objWeather.tempDetail + " " + objWeather.temp;
         }
     }
 }
Exemplo n.º 3
0
        private void lblWeather_MouseEnter(object sender, EventArgs e)
        {
            //显示tips
            weatherDataObject.weatherWebObj objWeatherOld = objWeather;
            var thread = new System.Threading.Thread(new System.Threading.ThreadStart(()
                                                                                      =>
            {
                getWeatherMethodRefresh();
            }))
            {
                IsBackground = true
            };

            thread.Start();
            if (objWeather == null)
            {
                objWeather = objWeatherOld;
            }

            toolinfo = new ToolTipControllerShowEventArgs();
            if (objWeather != null)
            {
                toolinfo.AllowHtmlText = DefaultBoolean.True;
                toolinfo.ToolTip       = objWeather.note;
                toolinfo.Rounded       = true; //圆角
                toolinfo.RoundRadius   = 7;    //圆角率
                toolinfo.ToolTipType   = ToolTipType.Standard;
                SetToolTipsSetting(toolinfo, pubDefines.toolTipsType.type_Weather);
                if (toolinfo.Title != "" || toolinfo.ToolTip != "")
                {
                    Point pLocate = new Point(lblWeather.Location.X, lblWeather.Location.Y); // 0,0 是左上角
                    pLocate = lblWeather.PointToScreen(pLocate);                             // p.X, p.Y 是控件左上角在屏幕上的坐标
                    SetToolTipsControllerSetting(toolTipController1, pubDefines.toolTipsType.type_Weather);
                    toolTipController1.ShowHint(toolinfo, pLocate);
                }
            }
        }