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); } } }
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(); //ListViewItem.ListViewSubItem subItem; item.ImageIndex = FileTypeImageList.GetImageIndexByExtention(ext); //lvwDownloads.Columns["columnFile"].ImageIndex = FileTypeImageList.GetImageIndexByExtention(ext); //lvwDownloads.Columns[1].ImageIndex = FileTypeImageList.GetImageIndexByExtention(ext); //item.Text = Path.GetFileName(d.LocalFile); //item.Text = d.Id.ToString(); item.Text = (d.OrderedIndex + 1).ToString(); // Id item.SubItems.Add(d.Id.ToString()); //File item.SubItems.Add(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); }