From 4733d1e1bf9b14cd73001ec5da146d0609f88dbd Mon Sep 17 00:00:00 2001 From: croire <1432593898@qq.com> Date: Mon, 4 Apr 2022 16:48:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8B=E8=BD=BD=E5=AE=8C?= =?UTF-8?q?=E6=88=90=E5=90=8E=E7=9A=84=E5=8A=A8=E4=BD=9C=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E6=97=A0=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/Download/AriaDownloadService.cs | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/DownKyi/Services/Download/AriaDownloadService.cs b/DownKyi/Services/Download/AriaDownloadService.cs index 7f318ad..52d1307 100644 --- a/DownKyi/Services/Download/AriaDownloadService.cs +++ b/DownKyi/Services/Download/AriaDownloadService.cs @@ -510,6 +510,9 @@ namespace DownKyi.Services.Download /// private async Task DoWork() { + // 上次循环时正在下载的数量 + int lastDownloadingCount = 0; + while (true) { int maxDownloading = SettingsManager.GetInstance().GetAriaMaxConcurrentDownloads(); @@ -562,6 +565,13 @@ namespace DownKyi.Services.Download break; } + // 判断下载列表中的视频是否全部下载完成 + if (lastDownloadingCount > 0 && downloadingList.Count == 0 && downloadedList.Count > 0) + { + AfterDownload(); + } + lastDownloadingCount = downloadingList.Count; + // 降低CPU占用 await Task.Delay(500); } @@ -826,6 +836,36 @@ namespace DownKyi.Services.Download downloading.StartOrPause.Fill = DictionaryResource.GetColor("ColorPrimary"); } + /// + /// 下载完成后的操作 + /// + private void AfterDownload() + { + AfterDownloadOperation operation = SettingsManager.GetInstance().GetAfterDownloadOperation(); + switch (operation) + { + case AfterDownloadOperation.NONE: + // 没有操作 + break; + case AfterDownloadOperation.OPEN_FOLDER: + // 打开文件夹 + break; + case AfterDownloadOperation.CLOSE_APP: + // 关闭程序 + App.PropertyChangeAsync(() => + { + System.Windows.Application.Current.Shutdown(); + }); + break; + case AfterDownloadOperation.CLOSE_SYSTEM: + // 关机 + System.Diagnostics.Process.Start("shutdown.exe", "-s"); + break; + default: + break; + } + } + /// /// 获取图片的扩展名 ///