示例#1
0
        void wc_DownloadCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            int index = _webClients.IndexOf((WebClient)sender);

            if (index >= 0)
            {
                //progressBars[index].Enabled = false;
                _finished[index] = true;
                if (e.Error == null && !e.Cancelled)
                {
                    _labels[index].Text = "✔ " + _files[index];
                    ModifyProgressBarColor.SetState(_progressBars[index], 3);
                }
                else
                {
                    _labels[index].Text        = "✖ " + _files[index];
                    _progressBars[index].Value = _progressBars[index].Maximum;
                    File.Delete(_paths[index] + _files[index]);
                    ModifyProgressBarColor.SetState(_progressBars[index], 2);
                }
                bool allFinished = true;
                foreach (bool finish in _finished)
                {
                    if (!finish)
                    {
                        allFinished = false;
                    }
                }
                if (allFinished)
                {
                    if ((Form)this != Form.ActiveForm)
                    {
                        downloadFinishedNotification.Visible = true;
                        downloadFinishedNotification.ShowBalloonTip(2000);
                    }
                    _parentform.ReloadMedia();
                    _parentform.AllowClosing();
                }
            }
        }