示例#1
0
        private void btnTrash_Click(object sender, EventArgs e)
        {
            if (rowSelect < 0)
            {
                MessageBox.Show("Select file to remove");
                return;
            }
            string l = dataGridView1.Rows[rowSelect].Cells[9].Value.ToString();

            dataGridView1.Rows.RemoveAt(rowSelect);
            Classes.DB db = new Classes.DB();
            db.delete_by_link(l);
            db.Close();
        }
示例#2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            splitContainer2.SplitterDistance = splitContainer2.Height;
            Classes.DB db = new Classes.DB();
            DataTable  dt = db.get_all();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dataGridView1.Rows.Add(i + 1, dt.Rows[i]["name"], dt.Rows[i]["fsize"], dt.Rows[i]["dtime"], dt.Rows[i]["status"], "", "", "", "", dt.Rows[i]["link"], dt.Rows[i]["localpath"]);
            }
            db.Close();
            btnOpen.Enabled  = false;
            btnPause.Enabled = false;
            btnPlay.Enabled  = false;
            btnTrash.Enabled = false;
            dataGridView1.ClearSelection();
        }
示例#3
0
        private void Tracker(object sender, EventArgs e)
        {
            Classes.DB      db           = new Classes.DB();
            DataGridViewRow r            = dataGridView1.Rows[rowAt];
            string          strCompleted = downloader.FormatBytes(downloader.Completed);
            string          strSpeed     = "0.00 KBps";
            string          strProgress  = "Pending";
            string          valProgress  = "0%";

            switch (downloader.State)
            {
            case State.Create:
                strProgress = "Pending";

                break;

            case State.Idle:
                strProgress = "Paused";
                timer.Stop();
                db.insert(r.Cells[1].Value.ToString(), r.Cells[3].Value.ToString(), downloader.FormatBytes(downloader.FileSize), strProgress, r.Cells[9].Value.ToString(), r.Cells[10].Value.ToString());
                if (curDown < Queue)
                {
                    curDown++;
                    getNameFile(curDown);
                }
                else
                {
                    ResetUI();
                }
                break;

            case State.Start:
                strProgress = "Starting";

                break;

            case State.Download:
                strSpeed    = downloader.FormatBytes(downloader.Speed) + "ps";
                valProgress = string.Format("{0:f2}%", downloader.Progress);
                strProgress = "Downloading";

                break;

            case State.Append:
                strProgress = "Appending";

                break;

            case State.Complete:
                valProgress = "100%";
                strProgress = "Completed";
                db.insert(r.Cells[1].Value.ToString(), r.Cells[3].Value.ToString(), downloader.FormatBytes(downloader.FileSize), strProgress, r.Cells[9].Value.ToString(), r.Cells[10].Value.ToString());
                timer.Stop();
                if (curDown < Queue)
                {
                    curDown++;
                    getNameFile(curDown);
                }
                else
                {
                    if (isTurnOffComputer)
                    {
                        var psi = new System.Diagnostics.ProcessStartInfo("shutdown", "/s /t 1");
                        psi.CreateNoWindow  = true;
                        psi.UseShellExecute = false;
                        System.Diagnostics.Process.Start(psi);
                    }
                    ResetUI();
                }

                break;

            case State.Error:
                strProgress = "Error";
                timer.Stop();
                db.insert(r.Cells[1].Value.ToString(), r.Cells[3].Value.ToString(), downloader.FormatBytes(downloader.FileSize), strProgress, r.Cells[9].Value.ToString(), r.Cells[10].Value.ToString());

                if (curDown < Queue)
                {
                    curDown++;
                    getNameFile(curDown);
                }
                else
                {
                    ResetUI();
                }

                break;

            case State.Abort:
                strProgress = "Pausing";
                break;
            }
            dataGridView1.Rows[rowAt].Cells[4].Value = strProgress;
            dataGridView1.Rows[rowAt].Cells[5].Value = valProgress;
            dataGridView1.Rows[rowAt].Cells[8].Value = strSpeed;
            dataGridView1.Rows[rowAt].Cells[6].Value = strCompleted;
            dataGridView1.Rows[rowAt].Cells[7].Value = downloader.scheduler.ThreadLength;
            db.Close();
            ShowInfor(null, null, null, null, null, strProgress);
        }