private void dL_StateChanged(object sender, DownloadEventArgs e)
 {
     if (this.StateChanged != null)
     {
         this.StateChanged(this, e);
     }
 }
        private void dL_ProgressChanged(object sender, DownloadEventArgs e)
        {
            // resend the progress info
            if (this.CurrentProgressChanged != null)
            {
                this.CurrentProgressChanged(this, e);
            }

            int percent = 0;

            if ((UrlsInfo == null) || (UrlsInfo.Length == 0))
            {
                // calculate total progress
                double percentForEach = (double)100 / this.totalDownloads;
                percent  = (int)((((double)this.downloadCount) / this.totalDownloads) * 100);
                percent += (int)(percentForEach * ((double)e.PercentDone / 100));
                if (percent > 100)
                {
                    percent = 100;
                }
            }
            else
            {
                double totalvalue      = 0;
                double downloadedvalue = 0;
                foreach (BatchUrlInfo bui in UrlsInfo)
                {
                    if (bui.downloaded)
                    {
                        downloadedvalue += (double)bui.length / 1000;
                    }
                    if (bui.url == currentUrl)
                    {
                        downloadedvalue += (double)(bui.length * e.PercentDone / 100) / 1000.0;
                    }
                    totalvalue += (double)bui.length / 1000.0;
                }
                if (totalvalue > 0)
                {
                    percent = (int)(((double)downloadedvalue / totalvalue) * 100);

                    if (percent > 100)
                    {
                        percent = 100;
                    }
                }
            }

            // send total progress info
            if (this.TotalProgressChanged != null)
            {
                this.TotalProgressChanged(this, new DownloadEventArgs(percent, ""));
            }
        }