private void downloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
        {
            double totalReceivedValue = Convert.ToDouble(e.TotalBytesToReceive);
            double receivedValue      = Convert.ToDouble(e.BytesReceived);

            progressBar1.Value = e.ProgressPercentage;
            lblStatus.Text     = "Downloading - " + progressBar1.Value + "%";

            lblSpeed.Text      = "Speed: " + string.Format("{0}/s", UtilityTools.ToFileSize((e.BytesReceived / 1024d / sw.Elapsed.TotalSeconds)));
            lblDownloaded.Text = "Downloaded: " + UtilityTools.ToFileSize(receivedValue);
            lblSize.Text       = "Size: " + UtilityTools.ToFileSize(totalReceivedValue);
        }
 private void timerUpdateInfo_Tick(object sender, EventArgs e)
 {
     // Checks for local file, and get/compare file size
     if (infoFileURL != null)
     {
         if (File.Exists(Properties.Settings.Default.downloadsDirectory + Path.GetFileName(new Uri(infoFileURL).LocalPath)))
         {
             if (infoFileSize.Text == UtilityTools.ToFileSize(Convert.ToDouble(new FileInfo(Properties.Settings.Default.downloadsDirectory + Path.GetFileName(new Uri(infoFileURL).LocalPath)).Length)))
             {
                 imgDownload.Image = Properties.Resources.cloud_done;
             }
         }
     }
 }
        private void ctrlStreamInfo_Load(object sender, EventArgs e)
        {
            BackColor = Color.Transparent;
            VLCToolStripMenuItem.Visible = File.Exists(frmOpenTheatre.pathVLC);
            MPCToolStripMenuItem.Visible = File.Exists(frmOpenTheatre.pathMPCCodec64) || File.Exists(frmOpenTheatre.pathMPC64) || File.Exists(frmOpenTheatre.pathMPC86);
            if (Properties.Settings.Default.Bookmarks.Contains(infoFileURL))
            {
                imgAddToBookmarks.Image = Properties.Resources.bookmark_remove;
            }
            else
            {
                imgAddToBookmarks.Image = Properties.Resources.bookmark_plus;
            }

            try
            {
                WebRequest req = WebRequest.Create(infoFileURL);
                req.Method  = "HEAD";
                req.Timeout = 1500;
                using (HttpWebResponse fileResponse = (HttpWebResponse)req.GetResponse())
                {
                    DateTime fileModifiedTime = fileResponse.LastModified;
                    if (fileModifiedTime != null)
                    {
                        infoFileDateAdded.Text = UtilityTools.getTimeAgo(fileModifiedTime);
                    }
                    else
                    {
                        infoFileDateAdded.Text = "n/a";
                    }

                    int ContentLength;
                    if (int.TryParse(fileResponse.Headers.Get("Content-Length"), out ContentLength))
                    {
                        infoFileSize.Text = UtilityTools.ToFileSize(Convert.ToDouble(ContentLength));
                    }
                    else
                    {
                        infoFileSize.Text = "n/a";
                    }
                }
            }
            catch { infoFileSize.Text = "n/a"; infoFileDateAdded.Text = "n/a"; }
        }
        private void downloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
        {
            double totalReceivedValue = Convert.ToDouble(e.TotalBytesToReceive);
            double receivedValue      = Convert.ToDouble(e.BytesReceived);

            progressBar1.Value  = e.ProgressPercentage;
            infoStatus.Text     = "Downloading";
            infoPercentage.Text = e.ProgressPercentage + "%";

            // Get remaining time
            var      elapsedTime           = (DateTime.Now - startTime).TotalSeconds;
            var      allTimeFordownloading = (elapsedTime * e.TotalBytesToReceive / e.BytesReceived);
            var      remainingTime         = allTimeFordownloading - elapsedTime;
            TimeSpan time = TimeSpan.FromSeconds(remainingTime);

            infoEstimatedTime.Text = string.Format("{0} Minutes {1} Seconds", time.Minutes, time.Seconds);

            infoDownloadedOutOfSize.Text = string.Format("{0}/{1}", UtilityTools.ToFileSize(receivedValue), UtilityTools.ToFileSize(totalReceivedValue));
            infoSpeed.Text = string.Format("{0}/s ↓", UtilityTools.ToFileSize((e.BytesReceived / 1024d / sw.Elapsed.TotalSeconds)));

            Refresh();
        }
Exemple #5
0
        private void btnRequestFileSize_ClickButtonArea(object Sender, MouseEventArgs e)
        {
            try
            {
                btnRequestFileSize.Visible = false;

                WebRequest req = WebRequest.Create(infoFileURL.Text);
                req.Method  = "HEAD";
                req.Timeout = 10000;
                using (HttpWebResponse fileResponse = (HttpWebResponse)req.GetResponse())
                {
                    int ContentLength;
                    if (int.TryParse(fileResponse.Headers.Get("Content-Length"), out ContentLength))
                    {
                        infoSize.Text = UtilityTools.ToFileSize(Convert.ToDouble(ContentLength));
                    }
                    else
                    {
                        infoSize.Text = "Error";
                    }
                }
            }
            catch { infoSize.Text = "Error"; }
        }
        private void ctrlStreamInfo_Load(object sender, EventArgs e)
        {
            BackColor = Color.Transparent;

            VLCToolStripMenuItem.Visible = File.Exists(frmOpenTheatre.pathVLC);
            MPCToolStripMenuItem.Visible = File.Exists(frmOpenTheatre.pathMPCCodec64) || File.Exists(frmOpenTheatre.pathMPC64) || File.Exists(frmOpenTheatre.pathMPC86);

            if (Properties.Settings.Default.dataBookmarks.Contains(infoFileURL))
            {
                imgAddToBookmarks.Image = Properties.Resources.bookmark_remove;
            }
            else
            {
                imgAddToBookmarks.Image = Properties.Resources.bookmark_plus;
            }
            if (frmOpenTheatre.currentDownloads.Contains(infoFileURL))
            {
                imgDownload.Image = Properties.Resources.cloud_sync;
            }
            else if (File.Exists(Properties.Settings.Default.downloadsDirectory + Path.GetFileName(new Uri(infoFileURL).LocalPath)) && infoFileSize.Text == UtilityTools.ToFileSize(Convert.ToDouble(new FileInfo(Properties.Settings.Default.downloadsDirectory + Path.GetFileName(new Uri(infoFileURL).LocalPath)).Length)))
            {
                imgDownload.Image = Properties.Resources.cloud_done;
            }

            if (isTorrent == true)
            {
                imgReportBroken.Visible = false;
                imgWatch.Visible        = false;
                imgMagnet.Visible       = true;
            }

            if (isLocal == false)
            {
                try
                {
                    WebRequest req = WebRequest.Create(infoFileURL);
                    req.Method  = "HEAD";
                    req.Timeout = 1500;
                    using (HttpWebResponse fileResponse = (HttpWebResponse)req.GetResponse())
                    {
                        DateTime fileModifiedTime = fileResponse.LastModified;
                        if (fileModifiedTime != null)
                        {
                            infoFileAge.Text = UtilityTools.getTimeAgo(fileModifiedTime);
                        }
                        else
                        {
                            infoFileAge.Text = "n/a";
                        }

                        int ContentLength;
                        if (int.TryParse(fileResponse.Headers.Get("Content-Length"), out ContentLength))
                        {
                            infoFileSize.Text = UtilityTools.ToFileSize(Convert.ToDouble(ContentLength));
                        }
                        else
                        {
                            infoFileSize.Text = "n/a";
                        }
                    }
                }
                catch { infoFileSize.Text = "n/a"; infoFileAge.Text = "n/a"; }
            }
            else
            {
                infoFileHost.Text = frmOpenTheatre.rm.GetString("local"); infoFileSize.Text = UtilityTools.ToFileSize(new FileInfo(infoFileURL).Length); infoFileAge.Text = UtilityTools.getTimeAgo(File.GetLastWriteTime(infoFileURL)); imgDownload.Visible = false; imgReportBroken.Visible = false; imgShare.Visible = false; imgCopyURL.Visible = false;
            }

            // Checks for exact file name of a subtitle file that matches the one being loaded (e.g. Media File Name: 'Jigsaw.2017.mp4' > Subtitle File Name: 'Jigsaw.2017.srt' will be loaded)
            if (infoFileSubtitles == null)
            {
                if (UtilityTools.isExistingSubtitlesFile(infoFileURL) == true)
                {
                    infoFileSubtitles = Properties.Settings.Default.downloadsDirectory + Path.GetFileNameWithoutExtension(infoFileURL) + ".srt";
                }
            }
        }