diff --git a/DownKyi/Services/Download/AddToDownloadService.cs b/DownKyi/Services/Download/AddToDownloadService.cs index 62ecf3d..9028eeb 100644 --- a/DownKyi/Services/Download/AddToDownloadService.cs +++ b/DownKyi/Services/Download/AddToDownloadService.cs @@ -100,10 +100,7 @@ public class AddToDownloadService { foreach (var item in section.VideoPages) { - if (selectedVideo.Contains(item.Order)) - { - item.IsSelected = true; - } + item.IsSelected = selectedVideo.Contains(item.Order); } } } diff --git a/DownKyi/ViewModels/ViewVideoDetailViewModel.cs b/DownKyi/ViewModels/ViewVideoDetailViewModel.cs index 170941e..401dd84 100644 --- a/DownKyi/ViewModels/ViewVideoDetailViewModel.cs +++ b/DownKyi/ViewModels/ViewVideoDetailViewModel.cs @@ -87,9 +87,9 @@ public class ViewVideoDetailViewModel : ViewModelBase set => SetProperty(ref _downloadManage, value); } - private VideoInfoView _videoInfoView; + private VideoInfoView? _videoInfoView; - public VideoInfoView VideoInfoView + public VideoInfoView? VideoInfoView { get => _videoInfoView; set => SetProperty(ref _videoInfoView, value); @@ -291,8 +291,7 @@ public class ViewVideoDetailViewModel : ViewModelBase // 复制封面事件 private DelegateCommand? _copyCoverCommand; - public DelegateCommand CopyCoverCommand => - _copyCoverCommand ??= new DelegateCommand(ExecuteCopyCoverCommand); + public DelegateCommand CopyCoverCommand => _copyCoverCommand ??= new DelegateCommand(ExecuteCopyCoverCommand); /// /// 复制封面事件 @@ -307,8 +306,7 @@ public class ViewVideoDetailViewModel : ViewModelBase // 复制封面URL事件 private DelegateCommand? _copyCoverUrlCommand; - public DelegateCommand CopyCoverUrlCommand => - _copyCoverUrlCommand ??= new DelegateCommand(ExecuteCopyCoverUrlCommand); + public DelegateCommand CopyCoverUrlCommand => _copyCoverUrlCommand ??= new DelegateCommand(ExecuteCopyCoverUrlCommand); /// /// 复制封面URL事件 @@ -349,15 +347,7 @@ public class ViewVideoDetailViewModel : ViewModelBase return; } - var isSelectAll = true; - foreach (var page in section.VideoPages) - { - if (!page.IsSelected) - { - isSelectAll = false; - break; - } - } + var isSelectAll = section.VideoPages.All(page => page.IsSelected); IsSelectAll = section.VideoPages.Count != 0 && isSelectAll; } @@ -365,8 +355,7 @@ public class ViewVideoDetailViewModel : ViewModelBase // 视频page选择事件 private DelegateCommand? _videoPagesCommand; - public DelegateCommand VideoPagesCommand => - _videoPagesCommand ??= new DelegateCommand(ExecuteVideoPagesCommand); + public DelegateCommand VideoPagesCommand => _videoPagesCommand ??= new DelegateCommand(ExecuteVideoPagesCommand); /// /// 视频page选择事件 @@ -398,8 +387,7 @@ public class ViewVideoDetailViewModel : ViewModelBase // Ctrl+A 全选事件 private DelegateCommand? _keySelectAllCommand; - public DelegateCommand KeySelectAllCommand => - _keySelectAllCommand ??= new DelegateCommand(ExecuteKeySelectAllCommand); + public DelegateCommand KeySelectAllCommand => _keySelectAllCommand ??= new DelegateCommand(ExecuteKeySelectAllCommand); /// /// Ctrl+A 全选事件 @@ -447,8 +435,7 @@ public class ViewVideoDetailViewModel : ViewModelBase // 解析视频流事件 private DelegateCommand? _parseCommand; - public DelegateCommand ParseCommand => _parseCommand ??= new DelegateCommand(ExecuteParseCommand, - CanExecuteParseCommand); + public DelegateCommand ParseCommand => _parseCommand ??= new DelegateCommand(ExecuteParseCommand, CanExecuteParseCommand); /// /// 解析视频流事件 @@ -497,8 +484,7 @@ public class ViewVideoDetailViewModel : ViewModelBase // 解析所有视频流事件 private DelegateCommand? _parseAllVideoCommand; - public DelegateCommand ParseAllVideoCommand => _parseAllVideoCommand ??= - new DelegateCommand(ExecuteParseAllVideoCommand, CanExecuteParseAllVideoCommand); + public DelegateCommand ParseAllVideoCommand => _parseAllVideoCommand ??= new DelegateCommand(ExecuteParseAllVideoCommand, CanExecuteParseAllVideoCommand); /// /// 解析所有视频流事件 @@ -506,7 +492,7 @@ public class ViewVideoDetailViewModel : ViewModelBase private async void ExecuteParseAllVideoCommand() { // 解析范围 - ParseScope parseScope = SettingsManager.GetInstance().GetParseScope(); + var parseScope = SettingsManager.GetInstance().GetParseScope(); // 是否选择了解析范围 if (parseScope == ParseScope.NONE) @@ -514,12 +500,10 @@ public class ViewVideoDetailViewModel : ViewModelBase //打开解析选择器 await DialogService?.ShowDialogAsync(ViewParsingSelectorViewModel.Tag, null, async result => { - if (result.Result == ButtonResult.OK) - { - // 选择的解析范围 - parseScope = result.Parameters.GetValue("parseScope"); - await ExecuteParse(parseScope); - } + if (result.Result != ButtonResult.OK) return; + // 选择的解析范围 + parseScope = result.Parameters.GetValue("parseScope"); + await ExecuteParse(parseScope); }); } else @@ -621,8 +605,7 @@ public class ViewVideoDetailViewModel : ViewModelBase // 添加到下载列表事件 private DelegateCommand? _addToDownloadCommand; - public DelegateCommand AddToDownloadCommand => _addToDownloadCommand ??= - new DelegateCommand(ExecuteAddToDownloadCommand, CanExecuteAddToDownloadCommand); + public DelegateCommand AddToDownloadCommand => _addToDownloadCommand ??= new DelegateCommand(ExecuteAddToDownloadCommand, CanExecuteAddToDownloadCommand); /// /// 添加到下载列表事件 @@ -663,8 +646,7 @@ public class ViewVideoDetailViewModel : ViewModelBase /// /// /// - private void UnityUpdateView(Action action, string input, VideoPage page, - bool refresh = false) + private void UnityUpdateView(Action action, string input, VideoPage page, bool refresh = false) { if (_infoService == null || refresh) { @@ -815,8 +797,7 @@ public class ViewVideoDetailViewModel : ViewModelBase await Task.Run(async () => { // 传递video对象 - addToDownloadService.GetVideo(VideoInfoView, VideoSections.ToList(), - selectedVideoPages.Select(video => video.Order).ToList()); + addToDownloadService.GetVideo(VideoInfoView, VideoSections.ToList(), selectedVideoPages.Select(video => video.Order).ToList()); // 下载 i = await addToDownloadService.AddToDownload(EventAggregator, DialogService, directory, isAll); });