Ejemplo n.º 1
0
        /// <summary>
        /// Append a DownloadTask into the queue.
        /// </summary>
        /// <param name="downloadTask">DownloadTask</param>
        /// <returns>Successful</returns>
        public bool Append(DownloadTask downloadTask)
        {
            foreach (ListBoxItem i in QueueList.Items)
            {
                DownloadQueueItem dqi = (DownloadQueueItem)i.Content;
                if (dqi.downloadTask.Aid == downloadTask.Aid &&
                    dqi.downloadTask.Cid == downloadTask.Cid &&
                    dqi.downloadTask.Qn == downloadTask.Qn)
                {
                    return(false);
                }
            }
            DownloadQueueItem downloadQueueItem = new DownloadQueueItem(downloadTask);

            downloadQueueItem.Finished += DownloadQueueItem_Finished;
            downloadQueueItem.Remove   += DownloadQueueItem_Remove;
            ListBoxItem listBoxItem = new ListBoxItem();

            listBoxItem.Content = downloadQueueItem;
            QueueList.Items.Add(listBoxItem);
            ItemMap.Add(downloadQueueItem, listBoxItem);
            if (!((DownloadQueueItem)((ListBoxItem)QueueList.Items[0]).Content).IsRunning)
            {
                ((DownloadQueueItem)((ListBoxItem)QueueList.Items[0]).Content).Start();
            }

            ConfigManager.ConfigManager.AppendDownloadInfo(downloadTask.Info);
            return(true);
        }
Ejemplo n.º 2
0
 private void DownloadQueueItem_Finished(DownloadQueueItem downloadQueueItem)
 {
     Dispatcher.Invoke(new Action(() =>
     {
         QueueList.Items.Remove(ItemMap[downloadQueueItem]);
         ItemMap.Remove(downloadQueueItem);
     }));
 }
Ejemplo n.º 3
0
 private void DownloadQueueItem_Remove(DownloadQueueItem downloadQueueItem)
 {
     QueueList.Items.Remove(ItemMap[downloadQueueItem]);
     ItemMap.Remove(downloadQueueItem);
     if (QueueList.Items.Count > 0 && !((DownloadQueueItem)((ListBoxItem)QueueList.Items[0]).Content).IsRunning)
     {
         ((DownloadQueueItem)((ListBoxItem)QueueList.Items[0]).Content).Start();
     }
     ConfigManager.ConfigManager.RemoveDownloadInfo(downloadQueueItem.downloadTask.Info);
 }
Ejemplo n.º 4
0
 private void DownloadQueueItem_Finished(DownloadQueueItem downloadQueueItem)
 {
     Dispatcher.Invoke(new Action(() =>
     {
         QueueList.Items.Remove(ItemMap[downloadQueueItem]);
         ItemMap.Remove(downloadQueueItem);
         if (QueueList.Items.Count > 0)
         {
             ((DownloadQueueItem)((ListBoxItem)QueueList.Items[0]).Content).Start();
         }
     }));
     ConfigManager.ConfigManager.RemoveDownloadInfo(downloadQueueItem.downloadTask.Info);
 }
Ejemplo n.º 5
0
        private void Append(DownloadTask downloadTask)
        {
            foreach (ListBoxItem i in QueueList.Items)
            {
                DownloadQueueItem dqi = (DownloadQueueItem)i.Content;
                if (dqi.downloadTask.Aid == downloadTask.Aid &&
                    dqi.downloadTask.Cid == downloadTask.Cid &&
                    dqi.downloadTask.Qn == downloadTask.Qn)
                {
                    return;
                }
            }
            DownloadQueueItem downloadQueueItem = new DownloadQueueItem(downloadTask);

            downloadQueueItem.Finished += DownloadQueueItem_Finished;
            downloadQueueItem.Remove   += DownloadQueueItem_Remove;
            ListBoxItem listBoxItem = new ListBoxItem();

            listBoxItem.Content = downloadQueueItem;
            QueueList.Items.Add(listBoxItem);
            ItemMap.Add(downloadQueueItem, listBoxItem);
        }
Ejemplo n.º 6
0
 private void DownloadQueueItem_Remove(DownloadQueueItem downloadQueueItem)
 {
     DownloadManager.Remove(downloadQueueItem.downloadTask);
     QueueList.Items.Remove(ItemMap[downloadQueueItem]);
     ItemMap.Remove(downloadQueueItem);
 }