/// <summary> /// Downloads the mod. /// </summary> /// <param name="modInfo">The infos of the mod. Must have at least ModURL and LocalPath</param> /// <param name="downloadProgressCallback">Callback function for download progress.</param> /// <returns>True if the mod was downloaded.</returns> public bool DownloadMod(ref ModInfo modInfo, DownloadProgressCallback downloadProgressCallback = null) { if (modInfo == null) { return(false); } string downloadUrl = GetDownloadPath(GetPathToDownloads(modInfo.ModURL)); modInfo.LocalPath = Path.Combine(OptionsController.DownloadPath, downloadUrl.Split("/").Last()); Www.DownloadFile(downloadUrl, modInfo.LocalPath, downloadProgressCallback); return(File.Exists(modInfo.LocalPath)); }
/// <summary> /// Downloads the mod. /// </summary> /// <param name="modInfo">The infos of the mod. Must have at least ModURL and LocalPath</param> /// <param name="downloadProgressCallback">Callback function for download progress.</param> /// <returns>True if the mod was downloaded.</returns> public bool DownloadMod(ref ModInfo modInfo, DownloadProgressCallback downloadProgressCallback = null) { if (modInfo == null) { return(false); } string downloadUrl = GetDownloadURL(modInfo); ////string siteContent = www.Load(GetFilesURL(modInfo.ModURL)); ////string filename = GetFileName(siteContent); modInfo.LocalPath = Path.Combine(OptionsController.DownloadPath, GetDownloadName(modInfo)); Www.DownloadFile(downloadUrl, modInfo.LocalPath, downloadProgressCallback); return(File.Exists(modInfo.LocalPath)); }
/// <summary> /// Downloads the mod. /// </summary> /// <param name="modInfo">The infos of the mod. Must have at least ModURL and LocalPath</param> /// <param name="downloadProgressCallback">Callback function for download progress.</param> /// <returns>True if the mod was downloaded.</returns> public bool DownloadMod(ref ModInfo modInfo, DownloadProgressCallback downloadProgressCallback = null) { if (modInfo == null) { return(false); } var downloadInfos = GetDownloadInfo(modInfo); DownloadInfo selected = null; if (downloadInfos.Count > 1) { // create new selection form if more than one download option found var dlg = new frmSelectDownload(downloadInfos); if (dlg.ShowDialog() == DialogResult.OK) { selected = dlg.SelectedLink; } } else if (downloadInfos.Count == 1) { selected = downloadInfos.First(); } else { string msg = string.Format(Messages.MSG_NO_BINARY_DOWNLOAD_FOUND_AT_0, modInfo.SiteHandlerName); MessageBox.Show(msg, Messages.MSG_TITLE_ERROR); Messenger.AddDebug(msg); return(false); } if (selected != null) { string downloadUrl = selected.DownloadURL; modInfo.LocalPath = Path.Combine(OptionsController.DownloadPath, selected.Filename); Www.DownloadFile(downloadUrl, modInfo.LocalPath, downloadProgressCallback); } return(File.Exists(modInfo.LocalPath)); }