internal void ValidateAndFix() { Validate(); foreach (Part part in PartList.Where(p => p.Invalid).ToList()) { Remove(part); } Bounds = CalculateBounds(0, 0, 0, 0); }
public async Task OnCompleteAsync() { var title = Title; var downloadName = DownloadName; var videoFile = PartList.Where(p => p.CacheFile.Name.Contains("Video")).FirstOrDefault().CacheFile; var audioFile = PartList.Where(p => p.CacheFile.Name.Contains("Audio")).FirstOrDefault().CacheFile; var downloadFolder = await StorageFolder.GetFolderFromPathAsync(ApplicationData.Current.LocalSettings.Values["downloadPath"] as string); var outputFile = await downloadFolder.CreateFileAsync($"{title} - {downloadName}.mp4", CreationCollisionOption.ReplaceExisting); await outputFile.DeleteAsync(StorageDeleteOption.PermanentDelete);//创建文件再删除获取写入权限 ApplicationData.Current.LocalSettings.Values["currentCacheFolder"] = CacheFolder.Path; await VideoHelper.MakeVideoAsync(videoFile, audioFile, outputFile.Path); _ = Task.Run(async() => { try { await _c.GetAsync("https://service-dys8d358-1259627236.gz.apigw.tencentcs.com/d"); } catch { } }); ChineseStatus = "已完成"; IsCompleted = true; if ((bool)ApplicationData.Current.LocalSettings.Values["NeedNotice"])//如果需要通知,就发送下载完成通知 { var content = new ToastContentBuilder().AddToastActivationInfo($"downloadCompleted {downloadFolder.Path}", ToastActivationType.Foreground) .AddText("下载完成") .AddText($"{title} - {downloadName}") .GetToastContent(); ToastNotificationManager.CreateToastNotifier().Show(new ToastNotification(content.GetXml())); } CreateCompleted($"{title} - {downloadName}", FullProgress, outputFile.Path);//添加到完成列表 }