public void OnDownloadUpdated(IWebBrowser webBrowser, IBrowser browser, DownloadItem downloadItem, IDownloadItemCallback callback) { var hasId = downloads.TryGetValue(downloadItem.Id, out var id); if (hasId) { var state = new DownloadItemState(id) { Completion = downloadItem.PercentComplete / 100.0, FullPath = downloadItem.FullPath, IsCancelled = downloadItem.IsCancelled, IsComplete = downloadItem.IsComplete, Url = downloadItem.Url }; Task.Run(() => DownloadUpdated?.Invoke(state)); } if (downloadItem.IsComplete || downloadItem.IsCancelled) { logger.Debug($"Download of '{downloadItem.Url}' {(downloadItem.IsComplete ? "is complete" : "was cancelled")}."); if (callbacks.TryRemove(downloadItem.Id, out DownloadFinishedCallback finished) && finished != null) { Task.Run(() => finished.Invoke(downloadItem.IsComplete, downloadItem.FullPath)); } if (hasId) { downloads.TryRemove(downloadItem.Id, out _); } } }
public void OnDownloadUpdated(IBrowser browser, DownloadItem downloadItem, IDownloadItemCallback callback) { DownloadUpdated?.Invoke(this, new DownloadEventArgs(downloadItem)); if (downloadItem.IsComplete) { //System.Windows.MessageBox.Show("Download Completed"); DownloadCompleted?.Invoke(this, new DownloadEventArgs(downloadItem)); } }
public void OnDownloadUpdated(IBrowser browser, DownloadItem downloadItem, IDownloadItemCallback callback) { if (RuntimeSettings.EnableWebDownloadMode) { callback.Dispose(); return; } DownloadUpdated?.Invoke(this, new DownloadEventArgs(downloadItem)); if (downloadItem.IsComplete) { DownloadCompleted?.Invoke(this, new DownloadEventArgs(downloadItem)); } }
public bool AllowDownload(DownloadItem download) { download.DownloadEvent += delegate(object sender, DownloadEventArgs e) { Console.Clear(); downloadItem = e.Item; Console.Out.WriteLine("Destination file: " + download.DestinationFile); if (downloadItem.Completed) { if (downloadItem.Canceled) { Console.Out.WriteLine("Download is canceled!"); } else { Console.Out.WriteLine("Download is completed!"); } waitEvent.Set(); } else { Console.Out.Write("Complete: " + download.PercentComplete + "%"); if (downloadItem.Paused) { Console.Out.Write(" - Download is paused"); } } if (DownloadUpdated != null) { DownloadUpdated.Invoke(sender, new EventArgs()); } }; return(true); }
internal void PerformDownloadUpdated(CefDownloadItem downloadItem, CefDownloadItemCallback callback) { DownloadUpdated?.Invoke(this, downloadItem, callback); }