private void marketplace_directdownload_btn_Click(object sender, EventArgs e) { //Todo:Rewrite marketplace_directdownload_btn_Click to not Lock Thread //Will Lock thread a few moments If Dl has not been checked var selecteditem = (MarketPlaceContent)contentview.SelectedValue; if (selecteditem == null) { return; } if (!selecteditem.DownloadChecked) { selecteditem.CheckDownloadUrl(false, true); } if (selecteditem.CanDownload.IsTrue()) { DownloadInstance contentdl = new DownloadInstance(selecteditem.DownloadUrl, BindingStrings.Instance.DownloadPath + @"\" + selecteditem.Title.MakeFileSystemSafe() + ".xcp", selecteditem); _downloads.Add(contentdl); if (_downloads.All(d => d.DLStatus != DownloadStatus.Downloading)) { contentdl.StartDownload(); } contentdl.ProgressChanged += download_Contentdl_ProgressChanged; contentdl.DownloadFileCompleted += download_Contentdl_DownloadFileCompleted; downloadmanager_blv.AutoResizeColumn(0, BetterListViewColumnHeaderAutoResizeStyle.ColumnContent); } }
private void downloadmanager_controls_Remove_btn_Click(object sender, EventArgs e) { try { var itemToRemove = downloadmanager_blv.Items.Where( obj => { DownloadInstance di = (DownloadInstance)obj.Value; if (di.DLStatus == DownloadStatus.Finished) { return(true); } return(false); }).ToList(); foreach (var item in itemToRemove) { downloadmanager_blv.Items.Remove(item); } } catch (Exception ex) { Console.Write(ex.ToString()); throw; } }
private void download_Contentdl_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { if (ConverterOptions.autostart) { var firstOrDefault = _downloads.FirstOrDefault(d => d.DLStatus == DownloadStatus.Waiting); if (firstOrDefault != null) { firstOrDefault.StartDownload(); } } DownloadInstance dli = (DownloadInstance)e.UserState; dli.ProgressChanged -= download_Contentdl_ProgressChanged; dli.DownloadFileCompleted -= download_Contentdl_DownloadFileCompleted; dli.CancelDownload(); _xcpList.Add(dli.GetXcpInstance); dli.Dispose(); }
private void download_Contentdl_ProgressChanged(object sender, DownloadProgressChangedEventArgs e) { DownloadInstance dli = (DownloadInstance)e.UserState; _downloads.ResetItem(_downloads.IndexOf(dli)); }