DownLoadFile.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using CefSharp;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Diagnostics;
  5. using System.Linq;
  6. using System.Text;
  7. namespace UAS_Web.tool
  8. {
  9. class DownLoadFile : IDownloadHandler
  10. {
  11. public static bool downloading = false;
  12. public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback)
  13. {
  14. if (!callback.IsDisposed)
  15. {
  16. using (callback)
  17. {
  18. if (downloadItem.SuggestedFileName.EndsWith("frx"))
  19. {
  20. callback.Continue(System.AppDomain.CurrentDomain.BaseDirectory + downloadItem.SuggestedFileName,
  21. showDialog: false);
  22. }else
  23. callback.Continue(System.AppDomain.CurrentDomain.BaseDirectory + downloadItem.SuggestedFileName,
  24. showDialog: true);
  25. }
  26. }
  27. }
  28. public void OnDownloadUpdated(IBrowser browser, DownloadItem downloadItem, IDownloadItemCallback callback)
  29. {
  30. if (downloadItem.IsComplete)
  31. {
  32. downloading = false;
  33. }
  34. else {
  35. downloading = true;
  36. }
  37. }
  38. }
  39. }