예제 #1
0
        private void DisplayZIPOnTree(ZipRemoteFile zipFile)
        {
            checkableTreeView1.ImageList = FileTypeImageList.GetSharedInstance();
            checkableTreeView1.Nodes.Clear();

            foreach (ZipEntry entry in zipFile)
            {
                // skip folders...
                if (entry.Name.EndsWith("/"))
                {
                    continue;
                }

                string   displayName;
                TreeNode parentNd = GetNodeFromPath(entry.Name, out displayName);

                TreeNode newNd = new TreeNode(displayName);
                newNd.Tag                = entry;
                newNd.ImageIndex         = FileTypeImageList.GetImageIndexByExtention(Path.GetExtension(entry.Name));
                newNd.SelectedImageIndex = newNd.ImageIndex;

                if (parentNd == null)
                {
                    checkableTreeView1.Nodes.Add(newNd);
                }
                else
                {
                    parentNd.Nodes.Add(newNd);
                }
            }
        }
예제 #2
0
        public DownloadList()
        {
            InitializeComponent();

            DownloadManager.Instance.DownloadAdded   += new EventHandler <DownloaderEventArgs>(Instance_DownloadAdded);
            DownloadManager.Instance.DownloadRemoved += new EventHandler <DownloaderEventArgs>(Instance_DownloadRemoved);
            DownloadManager.Instance.DownloadEnded   += new EventHandler <DownloaderEventArgs>(Instance_DownloadEnded);

            for (int i = 0; i < DownloadManager.Instance.Downloads.Count; i++)
            {
                AddDownload(DownloadManager.Instance.Downloads[i]);
            }

            lvwDownloads.SmallImageList = FileTypeImageList.GetSharedInstance();
        }
예제 #3
0
        private TreeNode GetNodeFromPath(String path, out string displayName)
        {
            string[] subPaths = path.Split('/');

            if (subPaths.Length == 0)
            {
                displayName = null;
                return(null);
            }

            TreeNode result = null;

            TreeNodeCollection nodes = checkableTreeView1.Nodes;

            displayName = subPaths[subPaths.Length - 1];

            for (int j = 0; j < subPaths.Length - 1; j++)
            {
                TreeNode parentNode = null;

                for (int i = 0; i < nodes.Count; i++)
                {
                    if (String.Equals(nodes[i].Text, subPaths[j], StringComparison.OrdinalIgnoreCase))
                    {
                        parentNode = nodes[i];
                        break;
                    }
                }

                if (parentNode == null)
                {
                    // add the path
                    result                    = new TreeNode(subPaths[j]);
                    result.ImageIndex         = FileTypeImageList.GetImageIndexFromFolder(false);
                    result.SelectedImageIndex = FileTypeImageList.GetImageIndexFromFolder(true);
                    nodes.Add(result);
                }
                else
                {
                    result = parentNode;
                }

                nodes = result.Nodes;
            }

            return(result);
        }
예제 #4
0
        private void AddDownload(Downloader d)
        {
            d.RestartingSegment += new EventHandler <SegmentEventArgs>(download_RestartingSegment);
            d.SegmentStoped     += new EventHandler <SegmentEventArgs>(download_SegmentEnded);
            d.SegmentFailed     += new EventHandler <SegmentEventArgs>(download_SegmentFailed);
            d.SegmentStarted    += new EventHandler <SegmentEventArgs>(download_SegmentStarted);
            d.InfoReceived      += new EventHandler(download_InfoReceived);
            d.SegmentStarting   += new EventHandler <SegmentEventArgs>(Downloader_SegmentStarting);

            string ext = Path.GetExtension(d.LocalFile);

            ListViewItem item = new ListViewItem();

            item.ImageIndex = FileTypeImageList.GetImageIndexByExtention(ext);
            item.Text       = Path.GetFileName(d.LocalFile);

            // size
            item.SubItems.Add(ByteFormatter.ToString(d.FileSize));
            // completed
            item.SubItems.Add(ByteFormatter.ToString(d.Transfered));
            // progress
            item.SubItems.Add(String.Format("{0:0.##}%", d.Progress));
            // left
            item.SubItems.Add(TimeSpanFormatter.ToString(d.Left));
            // rate
            item.SubItems.Add("0");
            // added
            item.SubItems.Add(d.CreatedDateTime.ToShortDateString() + " " + d.CreatedDateTime.ToShortTimeString());
            // state
            item.SubItems.Add(d.State.ToString());
            // resume
            item.SubItems.Add(GetResumeStr(d));
            // url
            item.SubItems.Add(d.ResourceLocation.URL);

            mapDownloadToItem[d]    = item;
            mapItemToDownload[item] = d;

            lvwDownloads.Items.Add(item);
        }