youtube downloader with multiple progressbar
I creating one application same as a youtubedownloader ! & want contains all the functionality that youtubedownloader have! i have a one listbox[glacial list controll],one text box & one add button ! now when i paste the url in to text box then click on add button,the urls are listed in the listview, i put the separate progressbar in each line to show a download progress & also put the button dynamically in each url row to download file, up to that part of coading is done but problem is when i click the download button it prompt me to save dialog box,that is also correct, but after clicking on save button the downloading start in last list url list.

i m understant it is difficult but hope u understand ! plz any help?

plz reply fast as possible!

Thank You,

    private void Add_Click(object sender, EventArgs e)
    {

        gi = new GLItem();
        pb = new ProgressBar();
        cb = new ColorFull_Button();
        wc = new WebClient();

        cb.Click += new EventHandler(this.cb_click);

        gi.SubItems[0].Text = txtUrl.Text;
        gi.SubItems[1].Control = pb;
        gi.SubItems[2].Control = cb;
       
        glacialList1.Items.Add(gi);

        _downloadUrls = new Queue<string>();
        IEnumerable<string> urls;

        for (int i = 0; i < glacialList1.Items.Count; i++)
        {
            foreach (var url in gi.SubItems[i].Text)
            {
                _downloadUrls.Enqueue(gi.SubItems[i].Text);
            }
        }

        txtUrl.Text = "";
        glacialList1.Refresh();
    }

    private void cb_click(Object sender, EventArgs e)
    {
     //   MessageBox.Show("Hello");

        filePath = null;
        lockGui();
        lblResult.Text = "Check video url..";
        lblResult.Refresh();

        for (int i = 0; i < glacialList1.Items.Count; i++)
        {
            if (glacialList1.Items[i].Selected == true)
            {
                url = glacialList1.Items[i].Text;

                if (url.StartsWith("https://")) url = "http://" + url.Substring(8);
                else if (!url.StartsWith("http://")) url = "http://" + url;

                url = url.Replace("youtu.be/", "youtube.com/watch?v=");
                url = url.Replace("www.youtube.com", "youtube.com");

                if (url.StartsWith("http://youtube.com/v/"))
                    url = url.Replace("youtube.com/v/", "youtube.com/watch?v=");
                else if (url.StartsWith("http://youtube.com/watch#"))
                    url = url.Replace("youtube.com/watch#", "youtube.com/watch?");

                if (!url.StartsWith("http://youtube.com/watch"))
                {
                    MessageBox.Show("Invalid youtube url!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    unlockGui();
                    return;
                }
                //string link = null;
                try
                {
                    yts = YouTubeService.Create(url);
                    title = yts.VideoTitle;
                    if ((_audio && yts.AvailableAudioFormat.Length == 0) ||
                         (!_audio && yts.AvailableVideoFormat.Length == 0)
                       )
                        throw new Exception("No videos found!");
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message, Application.ProductName + " error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    unlockGui();
                    return;
                }

                int format = 0;
                filePath = chooseFormat(out format);

                if (format == 0)
                {
                    unlockGui();
                    return;
                }

                if (_audio)		// audio only
                {
                    try
                    {
                        File.Create(filePath).Close();  //TODO: Close when end download and not here..
                    }
                    catch (Exception) { }
                    link = yts.AvailableAudioFormat[format - 1].VideoUrl;
                    dwnFile = Path.GetTempFileName();
                }
                else			// Video
                {
                    link = yts.AvailableVideoFormat[format - 1].VideoUrl;
                    dwnFile = filePath;
                }

                lblResult.Text = "Download file...";
                lblResult.Refresh();    

                try
                {
                    wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wc_DownloadProgressChanged);
                    wc.DownloadFileCompleted += new AsyncCompletedEventHandler(wc_DownloadFileCompleted);
                    lnkCancel.Enabled = true;

                    url = _downloadUrls.Dequeue();
                    wc.DownloadFileAsync(new Uri(this.link), dwnFile);
                    lblResult.Visible = false;
                }
                catch (Exception)
                {
                    MessageBox.Show("  Unexpected error occured.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    try { File.Delete(dwnFile); if (_audio) File.Delete(filePath); }
                    catch (Exception) { }
                    unlockGui();
                }
                lblResult.Text = "";
                break;
            }
        }

        
    }

    private void form1_Load(object sender, EventArgs e)
    {
        glacialList1.Columns.Add(new GLColumn("URL"));
        glacialList1.Columns.Add(new GLColumn("Progress"));
        glacialList1.Columns.Add(new GLColumn("Size"));

        txtUrl.Text = "";
    }

    private void button1_Click(object sender, EventArgs e)
    {
        // for Download Button

        //GLItem gi = new GLItem();
        //gi.SubItems[0].Text = "hi";
        //ProgressBar pb = new ProgressBar();
        //pb.Value = 0;
        //gi.SubItems[1].Control = pb;
        //glacialList1.Items.Add(gi);

        //glacialList1.Refresh();


    }

    private void colorFull_Button1_Click(object sender, EventArgs e)
    {
        for (int i = 0; i < glacialList1.Items.Count; i++)
        {
            //if (gi.SubItems[i].Selected == true)
            //{
            //    MessageBox.Show("Hello");
            //}

            if (glacialList1.Items[i].Selected == true)
            {
                MessageBox.Show("Hi");
                glacialList1.Refresh();
            }
        }
    }

    private void glacialList1_ColumnClickedEvent(object source, ClickEventArgs e)
    {
        for (int i = 0; i < glacialList1.Items.Count; i++)
        {
            if (gi.SubItems[i].Equals(colorFull_Button1))
            {
                MessageBox.Show("Hi");
            }
        }

    }
}

youtube downloader with multiple progressbar
===

I creating one application same as a youtubedownloader ! & want contains all the functionality that youtubedownloader have! i have a one listbox[glacial list controll],one text box & one add button ! now when i paste the url in to text box then click on add button,the urls are listed in the listview, i put the separate progressbar in each line to show a download progress & also put the button dynamically in each url row to download file, up to that part of coading is done but problem is when i click the download button it prompt me to save dialog box,that is also correct, but after clicking on save button the downloading start in last list url list.

i m understant it is difficult but hope u understand ! plz any help?

plz reply fast as possible!

Thank You,

    private void Add_Click(object sender, EventArgs e)
    {

        gi = new GLItem();
        pb = new ProgressBar();
        cb = new ColorFull_Button();
        wc = new WebClient();

        cb.Click += new EventHandler(this.cb_click);

        gi.SubItems[0].Text = txtUrl.Text;
        gi.SubItems[1].Control = pb;
        gi.SubItems[2].Control = cb;
       
        glacialList1.Items.Add(gi);

        _downloadUrls = new Queue<string>();
        IEnumerable<string> urls;

        for (int i = 0; i < glacialList1.Items.Count; i++)
        {
            foreach (var url in gi.SubItems[i].Text)
            {
                _downloadUrls.Enqueue(gi.SubItems[i].Text);
            }
        }

        txtUrl.Text = "";
        glacialList1.Refresh();
    }

    private void cb_click(Object sender, EventArgs e)
    {
     //   MessageBox.Show("Hello");

        filePath = null;
        lockGui();
        lblResult.Text = "Check video url..";
        lblResult.Refresh();

        for (int i = 0; i < glacialList1.Items.Count; i++)
        {
            if (glacialList1.Items[i].Selected == true)
            {
                url = glacialList1.Items[i].Text;

                if (url.StartsWith("https://")) url = "http://" + url.Substring(8);
                else if (!url.StartsWith("http://")) url = "http://" + url;

                url = url.Replace("youtu.be/", "youtube.com/watch?v=");
                url = url.Replace("www.youtube.com", "youtube.com");

                if (url.StartsWith("http://youtube.com/v/"))
                    url = url.Replace("youtube.com/v/", "youtube.com/watch?v=");
                else if (url.StartsWith("http://youtube.com/watch#"))
                    url = url.Replace("youtube.com/watch#", "youtube.com/watch?");

                if (!url.StartsWith("http://youtube.com/watch"))
                {
                    MessageBox.Show("Invalid youtube url!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    unlockGui();
                    return;
                }
                //string link = null;
                try
                {
                    yts = YouTubeService.Create(url);
                    title = yts.VideoTitle;
                    if ((_audio && yts.AvailableAudioFormat.Length == 0) ||
                         (!_audio && yts.AvailableVideoFormat.Length == 0)
                       )
                        throw new Exception("No videos found!");
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message, Application.ProductName + " error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    unlockGui();
                    return;
                }

                int format = 0;
                filePath = chooseFormat(out format);

                if (format == 0)
                {
                    unlockGui();
                    return;
                }

                if (_audio)		// audio only
                {
                    try
                    {
                        File.Create(filePath).Close();  //TODO: Close when end download and not here..
                    }
                    catch (Exception) { }
                    link = yts.AvailableAudioFormat[format - 1].VideoUrl;
                    dwnFile = Path.GetTempFileName();
                }
                else			// Video
                {
                    link = yts.AvailableVideoFormat[format - 1].VideoUrl;
                    dwnFile = filePath;
                }

                lblResult.Text = "Download file...";
                lblResult.Refresh();    

                try
                {
                    wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wc_DownloadProgressChanged);
                    wc.DownloadFileCompleted += new AsyncCompletedEventHandler(wc_DownloadFileCompleted);
                    lnkCancel.Enabled = true;

                    url = _downloadUrls.Dequeue();
                    wc.DownloadFileAsync(new Uri(this.link), dwnFile);
                    lblResult.Visible = false;
                }
                catch (Exception)
                {
                    MessageBox.Show("  Unexpected error occured.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    try { File.Delete(dwnFile); if (_audio) File.Delete(filePath); }
                    catch (Exception) { }
                    unlockGui();
                }
                lblResult.Text = "";
                break;
            }
        }

        
    }

    private void form1_Load(object sender, EventArgs e)
    {
        glacialList1.Columns.Add(new GLColumn("URL"));
        glacialList1.Columns.Add(new GLColumn("Progress"));
        glacialList1.Columns.Add(new GLColumn("Size"));

        txtUrl.Text = "";
    }

    private void button1_Click(object sender, EventArgs e)
    {
        // for Download Button

        //GLItem gi = new GLItem();
        //gi.SubItems[0].Text = "hi";
        //ProgressBar pb = new ProgressBar();
        //pb.Value = 0;
        //gi.SubItems[1].Control = pb;
        //glacialList1.Items.Add(gi);

        //glacialList1.Refresh();


    }

    private void colorFull_Button1_Click(object sender, EventArgs e)
    {
        for (int i = 0; i < glacialList1.Items.Count; i++)
        {
            //if (gi.SubItems[i].Selected == true)
            //{
            //    MessageBox.Show("Hello");
            //}

            if (glacialList1.Items[i].Selected == true)
            {
                MessageBox.Show("Hi");
                glacialList1.Refresh();
            }
        }
    }

    private void glacialList1_ColumnClickedEvent(object source, ClickEventArgs e)
    {
        for (int i = 0; i < glacialList1.Items.Count; i++)
        {
            if (gi.SubItems[i].Equals(colorFull_Button1))
            {
                MessageBox.Show("Hi");
            }
        }

    }
}
