Ejemplo n.º 1
0
 private void UpdateQueueStatus(StreamBackgroundWorker worker, string text)
 {
     foreach (ListViewItem item in listViewQueue.Items)
     {
         if (item.Tag == worker)
         {
             item.SubItems[2].Text = text;
         }
     }
 }
Ejemplo n.º 2
0
        private void btnStartDownload_Click(object sender, EventArgs e)
        {
            if (_infoResult != null)
            {
                _tracker.SendEvent("Download " + _infoResult.Type, _infoResult.LongTitle, _infoResult.BaseUrl, _infoResult.Duration);

                var filename = txtOutputLocation.Text + @"\" + txtFilename.Text;
                if (File.Exists(filename))
                {
                    MessageBox.Show(this, "File already exists", "File exists", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return;
                }

                var worker = new StreamBackgroundWorker(_streamButtons.First(b => b.Key.Checked).Value,
                                                        txtOutputLocation.Text, txtFilename.Text);
                _workers.Add(worker);

                //Define
                var data = new [] { _infoResult.Title, _infoResult.Type.ToString(), "0 %" };
                var item = new ListViewItem(data)
                {
                    Tag = worker
                };
                listViewQueue.Items.Add(item);


                worker.RunWorkerCompleted += Worker_RunWorkerCompleted;
                worker.ProgressChanged    += Worker_ProgressChanged;

                if (!_workers.Any(w => w.IsBusy))
                {
                    worker.RunWorkerAsync();
                }
            }
        }