/// <summary> /// Handles the Install button click; fetches and installs the updates selected. /// </summary> /// <param name="sender">The object triggering this event/</param> /// <param name="e">Event argument.</param> private void updatesBtn_Click(object sender, EventArgs e) { updatesPanel.Visible = false; downloadingPnl.Visible = true; List <DownloadInfo> updatesToInstall = new List <DownloadInfo>(); //Collect the items that need to be installed foreach (ListViewItem item in updatesLv.CheckedItems) { item.Remove(); item.SubItems.RemoveAt(1); item.SubItems.RemoveAt(1); downloadingLv.Items.Add(item); DownloadInfo download = (DownloadInfo)item.Tag; updatesToInstall.Add(download); DownloadItems.Add(download, new DownloadUIInfo(download, item)); } //Then run the thread if there are updates. if (updatesToInstall.Count > 0) { downloader.RunWorkerAsync(updatesToInstall); } else { Close(); } }
public async Task FillDownloadItemsAsync() { var allItems = await GetAllMediaItemsAsync(); DownloadItems.Clear(); foreach (var item in allItems.Where(m => !DownloadItem.AllreadyDownloaded(m, Settings.LocalPhotosPath))) { DownloadItems.Add(DownloadItem.CreateDownloadItem(item, Settings.LocalPhotosPath)); } }
public DownloadItems CastSelectToDwDownloadItems() { var selectItems = DownloadItemsListBox.SelectedItems; var lb = DownloadItemsListBox; var di = new DownloadItems(); foreach (var selectItem in selectItems) { var i = lb.Items.IndexOf(selectItem); di.Add(Downloader.DownloadItems[i]); } return(di); }
public void AddDownload(DownloadItem downitem) { downitem.DownloadStatusChanged += di => DownloadStatusChanged(); DownloadItems.Add(downitem); //DownloadItemsListBox.Items.Refresh(); if (DownloadingItemsPool.Count < Settings.MaxOnDownloadingImageCount) { DownloadingItemsPool.Add(downitem); } else { WaitForDownloadItemsPool.Add(downitem); } DownloadStatusChanged(); }
private void OnRefreshCommandExecute() { switch (SelectedTab) { case ClaimsTabIndex: AppService.ReloadClaims(); break; case DownloadsTabIndex: var worker = new BackgroundWorker(); worker.DoWork += (i, j) => { var list = AppService.GetDownloads(); DispatcherHelper.CheckBeginInvokeOnUI(() => { DownloadItems.Clear(); foreach (var item in list) { DownloadItems.Add(item); } }); }; worker.RunWorkerAsync(); break; case PaymentsTabIndex: worker = new BackgroundWorker(); worker.DoWork += (i, j) => { var list = AppService.GetPayments(); DispatcherHelper.CheckBeginInvokeOnUI(() => { PaymentItems.Clear(); foreach (var item in list) { PaymentItems.Add(item); } }); }; worker.RunWorkerAsync(); break; default: throw new ArgumentOutOfRangeException(); } }
public void AddDownload(MoeItem item, dynamic bitimg) { var downItem = new DownloadItem(Set, bitimg, item); if (item.ChildrenItems.Count > 0) { for (var i = 0; i < item.ChildrenItems.Count; i++) { var subItem = item.ChildrenItems[i]; var downSubItem = new DownloadItem(Set, bitimg, subItem, i + 1, item); downItem.SubItems.Add(downSubItem); } } DownloadItems.Add(downItem); }
// while download button is clicked private void Download_Click(object sender, RoutedEventArgs args) { int index = Files.SelectedIndex; DownloadLinksViewModel item = Links[index]; // open a SaveFileDialog to choose where to save the file SaveFileDialog sfd = new SaveFileDialog(); sfd.FileName = "video." + item.Type; sfd.Filter = "All Files (*.*) | *.*"; if ((bool)sfd.ShowDialog()) { //ToggleControls(false); // determine the filename set by user. string fileName = sfd.FileName; int taskIndex = DownloadTasks.Count; DownloadItems.Add(new DownloadListViewModel() { Title = fileName, Progress = 0, Tag = taskIndex }); WebClient client = new WebClient(); client.DownloadProgressChanged += (s, e) => { // update the progress bar DownloadItems[taskIndex].Progress = e.ProgressPercentage; }; client.DownloadFileCompleted += (s, e) => { }; // start to download file. Task task = client.DownloadFileTaskAsync(new Uri(Links[index].Link), fileName); DownloadTasks.Add(task); // clear the url and combobox Url.Text = ""; Url.Focus(); Links.Clear(); } }
private void DownloadBeatmap(Beatmap beatmap, bool fireUpdateEvent) { if (beatmap != null) { BeatmapsToDownload.Add((BeatmapExtension)beatmap); var downloadItem = GetDownloadItem((BeatmapExtension)beatmap); if (downloadItem == null) { return; } DownloadItems.Add(downloadItem); ListedMapSetIds.Add(beatmap.MapSetId); } if (fireUpdateEvent) { DownloadItemsChanged?.Invoke(this, EventArgs.Empty); } }