• 大小: 4.98MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-10-31
  • 语言: 其他
  • 标签: 雅虎  天气API  调用  

资源简介

雅虎天气API调用 http://blog.csdn.net/a497785609/article/details/16808123

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.Regularexpressions;
using System.Threading;
using System.Windows.Forms;
using System.xml.Linq;
using Whir.Software.WeatherForecast.Library;

namespace Whir.Software.WeatherForecast
{
    public partial class MainForm : Form
    {
        public static readonly string CityFilePath = Path.Combine(AppDomain.CurrentDomain.baseDirectory
                                                                  “Data\\cities.txt“);

        private readonly DataTable _table = new DataTable();

        public MainForm()
        {
            InitializeComponent();
        }

        private void MainForm_Load(object sender EventArgs e)
        {
            LblStatus.Text = “鼠标左键双击左侧城市,以查看天气“;
            progressBar.Visible = false;

            _table.Columns.Add(“iso“);
            _table.Columns.Add(“name“);
            _table.Columns.Add(“woeId“);
            _table.Columns.Add(“longitude“);
            _table.Columns.Add(“latitude“);
            _table.Columns.Add(“country“);
            _table.Columns.Add(“province“);

            List list = FileHelper.ReadFileLines(CityFilePath);
            foreach (string s in list)
            {
                string city = s;
                Invoke(new MethodInvoker(() =>
                    {
                        var item = new ListViewItem();
                        item.SubItems[0].Text = city;
                        ListCities.Items.Add(item);
                    }));

                DataRow row = _table.NewRow();
                row[“name“] = city;
                _table.Rows.Add(row);
            }
        }

        public void SetButtonEnabled(Control container bool enabled)
        {
            foreach (object control in container.Controls)
            {
                if (((Control)control).Controls.Count > 0)
                {
                    SetButtonEnabled((Control)control enabled);
                }
                else
                {
                    if (control.GetType() == typeof(Button))
                    {
                        ((Button)control).Enabled = enabled;
                    }
                }
            }
        }

        public void SetButtonEnabled(bool enabled)
        {
            SetButtonEnabled(this enabled);
        }

        private void BtnGetCode_Click(object sender EventArgs e)
        {

            if (_table != null)
            {
                if (_table.Rows.Count > 0)
                {
                    var threadDelegate = new ThreadStart(delegate
                        {
                            Invoke(new MethodInvoker(() => SetButtonEnabled(false)));
                            DataTable tb = _table.Copy();
                            _table.Rows.Clear();

                         

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       4603  2013-11-18 19:43  15.Whir.Software.WeatherForecast\Whir.Software.WeatherForecast\bin\Debug\Data\cities.txt

     文件     200704  2013-11-18 19:23  15.Whir.Software.WeatherForecast\Whir.Software.WeatherForecast\bin\Debug\ICSharpCode.SharpZipLib.dll

     文件     379392  2013-11-18 19:23  15.Whir.Software.WeatherForecast\Whir.Software.WeatherForecast\bin\Debug\ICSharpCode.TextEditor.dll

     文件      57344  2013-11-18 19:23  15.Whir.Software.WeatherForecast\Whir.Software.WeatherForecast\bin\Debug\Newtonsoft.Json.dll

     文件    1624064  2013-11-18 20:39  15.Whir.Software.WeatherForecast\Whir.Software.WeatherForecast\bin\Debug\NPOI.dll

     文件     387072  2013-11-18 19:23  15.Whir.Software.WeatherForecast\Whir.Software.WeatherForecast\bin\Debug\NPOI.OOxml.dll

     文件      79872  2013-11-18 19:23  15.Whir.Software.WeatherForecast\Whir.Software.WeatherForecast\bin\Debug\NPOI.Openxml4Net.dll

     文件    1316864  2013-11-18 19:23  15.Whir.Software.WeatherForecast\Whir.Software.WeatherForecast\bin\Debug\NPOI.OpenxmlFormats.dll

     文件     839680  2013-11-18 19:23  15.Whir.Software.WeatherForecast\Whir.Software.WeatherForecast\bin\Debug\System.Data.SQLite.dll

     文件      23552  2013-11-19 09:29  15.Whir.Software.WeatherForecast\Whir.Software.WeatherForecast\bin\Debug\Whir.Software.WeatherForecast.exe

     文件      16896  2013-11-19 09:13  15.Whir.Software.WeatherForecast\Whir.Software.WeatherForecast\bin\Debug\Whir.Software.WeatherForecast.Library.dll

     文件      40448  2013-11-19 09:13  15.Whir.Software.WeatherForecast\Whir.Software.WeatherForecast\bin\Debug\Whir.Software.WeatherForecast.Library.pdb

     文件      50688  2013-11-19 09:29  15.Whir.Software.WeatherForecast\Whir.Software.WeatherForecast\bin\Debug\Whir.Software.WeatherForecast.pdb

     文件      11608  2013-11-19 09:29  15.Whir.Software.WeatherForecast\Whir.Software.WeatherForecast\bin\Debug\Whir.Software.WeatherForecast.vshost.exe

     文件        490  2010-03-17 22:39  15.Whir.Software.WeatherForecast\Whir.Software.WeatherForecast\bin\Debug\Whir.Software.WeatherForecast.vshost.exe.manifest

     文件      16506  2013-11-19 09:28  15.Whir.Software.WeatherForecast\Whir.Software.WeatherForecast\MainForm.cs

     文件      14992  2013-11-19 09:28  15.Whir.Software.WeatherForecast\Whir.Software.WeatherForecast\MainForm.Designer.cs

     文件       6190  2013-11-19 09:28  15.Whir.Software.WeatherForecast\Whir.Software.WeatherForecast\MainForm.resx

     文件        789  2013-11-18 19:07  15.Whir.Software.WeatherForecast\Whir.Software.WeatherForecast\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       9024  2013-11-19 09:29  15.Whir.Software.WeatherForecast\Whir.Software.WeatherForecast\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件      35153  2013-11-19 09:13  15.Whir.Software.WeatherForecast\Whir.Software.WeatherForecast\obj\x86\Debug\ResolveAssemblyReference.cache

     文件       5011  2013-11-19 09:29  15.Whir.Software.WeatherForecast\Whir.Software.WeatherForecast\obj\x86\Debug\Whir.Software.WeatherForecast.csproj.FileListAbsolute.txt

     文件        850  2013-11-18 21:24  15.Whir.Software.WeatherForecast\Whir.Software.WeatherForecast\obj\x86\Debug\Whir.Software.WeatherForecast.csproj.GenerateResource.Cache

     文件      40853  2013-11-18 20:51  15.Whir.Software.WeatherForecast\Whir.Software.WeatherForecast\obj\x86\Debug\Whir.Software.WeatherForecast.csprojResolveAssemblyReference.cache

     文件      23552  2013-11-19 09:29  15.Whir.Software.WeatherForecast\Whir.Software.WeatherForecast\obj\x86\Debug\Whir.Software.WeatherForecast.exe

     文件        180  2013-11-19 09:29  15.Whir.Software.WeatherForecast\Whir.Software.WeatherForecast\obj\x86\Debug\Whir.Software.WeatherForecast.MainForm.resources

     文件      50688  2013-11-19 09:29  15.Whir.Software.WeatherForecast\Whir.Software.WeatherForecast\obj\x86\Debug\Whir.Software.WeatherForecast.pdb

     文件        180  2013-11-19 09:29  15.Whir.Software.WeatherForecast\Whir.Software.WeatherForecast\obj\x86\Debug\Whir.Software.WeatherForecast.Properties.Resources.resources

     文件        513  2013-11-18 19:23  15.Whir.Software.WeatherForecast\Whir.Software.WeatherForecast\Program.cs

     文件       1408  2013-11-18 19:06  15.Whir.Software.WeatherForecast\Whir.Software.WeatherForecast\Properties\AssemblyInfo.cs

............此处省略281个文件信息

评论

共有 条评论