Exemple #1
0
        public void AddDownloadItem(string browsername, string filename, string url, int uDlId, string FromUrl, string ToPath, int filesize)
        {
            try
            {
                FileDownloadStatusCtl m_stat = new FileDownloadStatusCtl();
                m_namecounter++;
                m_stat.Name                  = "DownloadStatus" + m_namecounter.ToString();
                m_stat.lblFrom.Text          = FromUrl;
                m_stat.lblTo.Text            = ToPath;
                m_stat.lblStatus.Text        = "Downloading";
                m_stat.lblBytesReceived.Text = "0";
                m_stat.lblBytesTotal.Text    = filesize.ToString();
                DLIDS id = new DLIDS(browsername, filename, url, uDlId, filesize);
                m_stat.Tag              = id;
                m_stat.btnCancel.Tag    = id;
                m_stat.btnCancel.Click += new EventHandler(btnCancel_Click);
                flowLayoutPanel1.Controls.Add(m_stat);

                UpdateThisText(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #2
0
        public void UpdateDownloadItem(string browsername, int uDlId, string url, int progress, int progressmax)
        {
            try
            {
                DLIDS id = new DLIDS();
                foreach (Control item in flowLayoutPanel1.Controls)
                {
                    if (item.Tag == null) //first one
                    {
                        continue;
                    }
                    id = (DLIDS)item.Tag;
                    if ((id.DlUid == uDlId) &&
                        (id.URL == url) &&
                        (id.BrowserName == browsername))
                    {
                        FileDownloadStatusCtl ctl = (FileDownloadStatusCtl)item;

                        if ((ctl != null) && (progress > 0))
                        {
                            if ((id.FileSize == 0) && (progressmax > 0))
                            {
                                id.FileSize = progressmax;
                            }
                            if ((id.FileSize > 0) && (id.FileSize > progress))
                            {
                                ctl.pbProgress.Maximum = id.FileSize;
                                ctl.pbProgress.Value   = progress;
                                //item.SubItems[4].Text = ((progress * 100) / id.FileSize).ToString() + "%";
                                ctl.lblBytesReceived.Text = progress.ToString();
                            }
                            else
                            {
                                //last progress will contain actual file size
                                ctl.lblBytesReceived.Text = progress.ToString();
                            }
                        }
                        return;
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #3
0
        public void DeleteDownloadItem(string browsername, int uDlId, string url, string Msg)
        {
            try
            {
                DLIDS id = new DLIDS();
                FileDownloadStatusCtl ctl = null;
                foreach (Control item in flowLayoutPanel1.Controls)
                {
                    if (item.Tag == null) //first one
                    {
                        continue;
                    }
                    id = (DLIDS)item.Tag;
                    if ((id.DlUid == uDlId) &&
                        (id.URL == url) &&
                        (id.BrowserName == browsername))
                    {
                        id.DlDone = true;
                        ctl       = (FileDownloadStatusCtl)item;
                        if (ctl == null)
                        {
                            return;
                        }

                        if (id.FileSize > 0)
                        {
                            ctl.lblBytesReceived.Text = id.FileSize.ToString();
                        }
                        ctl.btnCancel.Enabled = false;
                        ctl.lblStatus.Text    = Msg;
                        UpdateThisText(false);
                        if (NotifyEndDownload)
                        {
                            MessageBox.Show(this, "Finished downloading\r\n" +
                                            ctl.lblFrom.ToString() + "\r\nTO:\r\n" + ctl.lblTo.ToString());
                        }
                        break;
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #4
0
 private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
 {
     //Clear completed - Save download list
     if (e.ClickedItem.Name == tsCloseDownload.Name)
     {
         this.Hide();
     }
     else if (e.ClickedItem.Name == this.tsSave.Name)
     {
         if (AllForms.ShowStaticSaveDialogForText(this) == DialogResult.OK)
         {
             string tmp = "====================\r\nDownload Date: ";
             tmp += DateTime.Today.ToLongDateString();
             tmp += "\r\nDownload From: {0}\r\nDownload To: {0}\r\nFile Size: {0} Bytes\r\n====================\r\n";
             using (StreamWriter sw = new StreamWriter(AllForms.m_dlgSave.FileName, true))
             {
                 try
                 {
                     DLIDS id = new DLIDS();
                     FileDownloadStatusCtl ctl = null;
                     foreach (Control item in flowLayoutPanel1.Controls)
                     {
                         if (item.Tag == null) //first one
                         {
                             continue;
                         }
                         id = (DLIDS)item.Tag;
                         if (id.DlDone)
                         {
                             ctl = (FileDownloadStatusCtl)item;
                             if (ctl == null)
                             {
                                 return;
                             }
                             //Date - From - To - filesize
                             sw.Write(
                                 string.Format(tmp,
                                               ctl.lblFrom.Text,
                                               ctl.lblTo.Text,
                                               id.FileSize.ToString())
                                 );
                         }
                     }
                 }
                 catch (Exception)
                 {
                     throw;
                 }
             }
         }
     }
     else if (e.ClickedItem.Name == this.tsClearFinished.Name)
     {
         try
         {
             DLIDS id = new DLIDS();
             Control.ControlCollection col = flowLayoutPanel1.Controls;
             foreach (Control item in col)
             {
                 if (item.Tag == null) //first one
                 {
                     continue;
                 }
                 id = (DLIDS)item.Tag;
                 if (id.DlDone)
                 {
                     flowLayoutPanel1.Controls.Remove(item);
                     break;
                 }
             }
         }
         catch (Exception)
         {
             throw;
         }
     }
 }