Ejemplo n.º 1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (dgvDownload.SelectedRows.Count == 0)
            {
                return;
            }

            bool deleteDownloading = false;

            for (int i = dgvDownload.SelectedRows.Count - 1; i >= 0; i--)
            {
                DownloaderState state = (DownloaderState) dgvDownload.SelectedRows[i].Cells[5].Tag;

                if (state == DownloaderState.Downloading)
                {
                    dlBeat.Stop();
                    dlBeat = null;
                    deleteDownloading = true;
                    //SetStatus(row.Index, DownloaderState.Stopped);
                }

                dgvDownload.Rows.RemoveAt(dgvDownload.SelectedRows[i].Index);
            }

            if (deleteDownloading)
            {
                DoDownload();
            }
        }
Ejemplo n.º 2
0
        private void dlBeat_Stopped(object sender, EventArgs e)
        {
            if (InvokeRequired)
            {
                Invoke(new Downloader.StoppedHandler(dlBeat_Stopped), new object[] { sender, e });
                return;
            }

            int index = FindIndexByStatus(DownloaderState.Downloading);
            SetStatus(index, DownloaderState.Stopped);

            lbDownloadStatus.Text = "Stopped";

            dlBeat = null;
            isDownloading = false;
            DoDownload();
            //dgvDownload_SelectionChanged(sender, e);
        }
Ejemplo n.º 3
0
        private void DownloadBeat(Object info)
        {
            if (InvokeRequired)
            {
                Invoke(new DownloadBeatCallBack(DownloadBeat), info);
                return;
            }

            prgDownload.Value = 0;
            lbDownloadPercent.Text = "";
            //lbDownloadStatus.Text = "";
            lbDownloadSize.Text = "";

            if (dlBeat != null)
            {
                dlBeat.Stop();
                dlBeat = null;
            }

            dlBeat = new Downloader((BeatInfo)info);
            dlBeat.SavePath = GlobalVar.SaveFolder;
            dlBeat.Completed += new Downloader.CompletedHandler(dlBeat_Completed);
            dlBeat.Stopped += new Downloader.StoppedHandler(dlBeat_Stopped);
            dlBeat.Error += new Downloader.ErrorHandler(dlBeat_Error);
            dlBeat.UpdateProgress += new Downloader.UpdateProgressHandler(dlBeat_UpdateProgress);

            dlBeat.Start();
        }
Ejemplo n.º 4
0
        private void dlBeat_Error(object sender, EventArgs e)
        {
            if (InvokeRequired)
            {
                Invoke(new Downloader.ErrorHandler(dlBeat_Error), new object[] { sender, e });
                return;
            }

            int index = FindIndexByStatus(DownloaderState.Downloading);
            if (index != -1)
            {
                SetStatus(index, DownloaderState.EndedWithError);
            }

            lbDownloadStatus.Text = "Error";
            btnDownload.Enabled = true;
            btnStop.Enabled = false;

            isDownloading = false;
            dlBeat = null;
            DoDownload();
            //dgvDownload_SelectionChanged(sender, e);
        }