/// <summary>
        /// Refreshes the ListView containing the all currently active downloads
        /// </summary>
        /// <param name="session"></param>
        private void RefreshDownloadsView()
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new MethodInvoker(() => RefreshDownloadsView()));
                return;
            }

            List <YoutubeDownload> activeDownloads = YoutubeDownloadManager.GetCurrentlyActiveDownloads();

            lvDownloads.Items.Clear();

            if (activeDownloads.Count != 0)
            {
                for (int c = 0; c < 5; c++)
                {
                    try
                    {
                        ListViewItem newLvi = new ListViewItem(activeDownloads[c].Url);
                        newLvi.SubItems.Add(activeDownloads[c].SessionID);
                        lvDownloads.Items.Add(newLvi);
                        AssignValueToProgressBar(c, (int)activeDownloads[c].DownloadProgress);
                    }
                    catch
                    {
                        AssignValueToProgressBar(c, 0);
                    }
                }
            }

            lvDownloads.Refresh();
        }
Пример #2
0
        /// <summary>
        /// Default constructor for the SessionManager
        /// </summary>
        public SessionManager()
        {
            SettingsForm.SettingsChanged += new SettingsForm.SettingsChangedHandler(SettingsForm_SettingsChanged);

            Sessions  = new List <Session>();
            FreePorts = new List <int>();
            YoutubeDownloadManager.Initialize();

            this.LastCleanUp           = DateTime.Now;
            this.LastInactiveUserCheck = DateTime.Now;

            int[] ports = Actions.TranslatePortRange(Settings.STREAM_PORTRANGE);
            FreePorts.AddRange(ports);
            InititializeThread();
        }
        /// <summary>
        /// Refreshes the ListView containing the all currently active downloads
        /// </summary>
        /// <param name="session"></param>
        private void RefreshDownloadQueueView()
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new MethodInvoker(() => RefreshDownloadQueueView()));
                return;
            }

            Queue <YoutubeDownload> downloadQueue = YoutubeDownloadManager.GetCurrentlyQueuedDownloads();

            lvQueue.Items.Clear();

            foreach (YoutubeDownload download in downloadQueue)
            {
                ListViewItem newLvi = new ListViewItem(download.Url);
                newLvi.SubItems.Add(download.SessionID);
                newLvi.SubItems.Add(download.VideoInfo.Title);
                lvQueue.Items.Add(newLvi);
            }

            lvQueue.Refresh();
        }