Esempio n. 1
0
        private void Download(object userstate)
        {
            CallbackClass cc          = (CallbackClass)userstate;
            Uri           uri         = new Uri(cc.url);
            string        strFilePath = CreateStructure(Application.CommonAppDataPath + "\\" + uri.LocalPath.Replace("/", "\\"));
            WebClient     wc          = new WebClient();
            ListViewItem  lvi2;

            this.Invoke((MethodInvoker) delegate
            {
                lvi2 = FindListViewItem(cc.url);
                if (lvi2 != null)
                {
                    lvi2.SubItems[6].Text = strFilePath;
                }
            });
            wc.DownloadProgressChanged += (a, b) =>
            {
                this.Invoke((MethodInvoker) delegate
                {
                    lvi2 = FindListViewItem(cc.url);
                    if (lvi2 != null)
                    {
                        //lvi2.SubItems[2].Text = b.BytesReceived.ToString();
                        lvi2.SubItems[5].Text = b.ProgressPercentage.ToString() + "%";
                        lvi2.SubItems[4].Text = (b.TotalBytesToReceive / 1024).ToString() + "kb";
                    }
                });
            };
            wc.DownloadFileCompleted += (a, b) =>
            {
                this.Invoke((MethodInvoker) delegate { });
            };
            wc.DownloadFileAsync(uri, strFilePath);
        }
Esempio n. 2
0
 private void downloadToolStripMenuItem_Click(object sender, EventArgs e)
 {
     foreach (ListViewItem lvi in listView1.SelectedItems)
     {
         string        url = lvi.SubItems[3].Text;
         CallbackClass obj = new CallbackClass(url);
         ThreadPool.QueueUserWorkItem((WaitCallback)Download, obj);
     }
 }
Esempio n. 3
0
        private void GetRSS(object userstate)
        {
            CallbackClass obj = (CallbackClass)userstate;
            string        p   = obj.url;
            XmlDocument   xd  = new XmlDocument();

            xd.Load(p);
            foreach (XmlNode xn in xd.SelectNodes("//channel/item"))
            {
                bool bAdded = AddToArrayList(xn);
                if (bAdded)
                {
                    NewItemsFlag(p);
                }
            }
        }
Esempio n. 4
0
 private void downloadToolStripMenuItem_Click(object sender, EventArgs e)
 {
     foreach (ListViewItem lvi in listView1.SelectedItems)
     {
         string url = lvi.SubItems[3].Text;
         CallbackClass obj = new CallbackClass(url);
         ThreadPool.QueueUserWorkItem((WaitCallback)Download, obj);
     }
 }