private void DownloadsAction(ActionDownloader action) { if (NodeSelection.SelectedNodes.Length > 0) { try { NodeSelection.Changed -= lvwDownloads_ItemSelectionChanged; for (int i = NodeSelection.SelectedNodes.Length - 1; i >= 0; i--) { DownloadListNode item = (DownloadListNode)NodeSelection.SelectedNodes[i]; action((Downloader)mapItemToDownload[item], item); } NodeSelection.Changed += lvwDownloads_ItemSelectionChanged; lvwDownloads_ItemSelectionChanged(null, null); } finally { Application.Invoke((s, e) => { QueueDraw(); }); //UpdateSegments(); } } }
private void AddDownload(Downloader d) { d.RestartingSegment += download_RestartingSegment; d.SegmentStoped += download_SegmentEnded; d.SegmentFailed += download_SegmentFailed; d.SegmentStarted += download_SegmentStarted; d.InfoReceived += download_InfoReceived; d.SegmentStarting += Downloader_SegmentStarting; string ext = System.IO.Path.GetExtension(d.LocalFile); DownloadListNode item = new DownloadListNode(d); mapDownloadToItem[d] = item; mapItemToDownload[item] = d; NodeStore.AddNode(item); }
void Instance_DownloadRemoved(object sender, DownloaderEventArgs e) { Application.Invoke((s, ea) => { if (mapDownloadToItem[e.Downloader] is DownloadListNode item) { if (lastSelection == item) { lastSelection = null; } mapDownloadToItem[e.Downloader] = null; mapItemToDownload[item] = null; NodeStore.RemoveNode(item); } } ); }