From 94237b5ee982221df7fb0cc0607994dd75ee4055 Mon Sep 17 00:00:00 2001 From: croire <1432593898@qq.com> Date: Sat, 26 Mar 2022 16:40:03 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=B8=8B=E8=BD=BD=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DownKyi/Languages/Default.xaml | 1 + .../Dialogs/ViewDownloadSetterViewModel.cs | 5 - .../ViewModels/Settings/ViewVideoViewModel.cs | 242 +++++++++++++++++- DownKyi/Views/Settings/ViewDanmaku.xaml | 10 +- DownKyi/Views/Settings/ViewVideo.xaml | 57 +++++ 5 files changed, 296 insertions(+), 19 deletions(-) diff --git a/DownKyi/Languages/Default.xaml b/DownKyi/Languages/Default.xaml index d506974..e468434 100644 --- a/DownKyi/Languages/Default.xaml +++ b/DownKyi/Languages/Default.xaml @@ -299,6 +299,7 @@ 浏览 盘剩余空间: 下载内容: + 下载内容 所有 音频 视频 diff --git a/DownKyi/ViewModels/Dialogs/ViewDownloadSetterViewModel.cs b/DownKyi/ViewModels/Dialogs/ViewDownloadSetterViewModel.cs index 900965b..d806a42 100644 --- a/DownKyi/ViewModels/Dialogs/ViewDownloadSetterViewModel.cs +++ b/DownKyi/ViewModels/Dialogs/ViewDownloadSetterViewModel.cs @@ -242,7 +242,6 @@ namespace DownKyi.ViewModels.Dialogs if (!DownloadAudio) { DownloadAll = false; - return; } if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover) @@ -265,7 +264,6 @@ namespace DownKyi.ViewModels.Dialogs if (!DownloadVideo) { DownloadAll = false; - return; } if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover) @@ -288,7 +286,6 @@ namespace DownKyi.ViewModels.Dialogs if (!DownloadDanmaku) { DownloadAll = false; - return; } if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover) @@ -311,7 +308,6 @@ namespace DownKyi.ViewModels.Dialogs if (!DownloadSubtitle) { DownloadAll = false; - return; } if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover) @@ -334,7 +330,6 @@ namespace DownKyi.ViewModels.Dialogs if (!DownloadCover) { DownloadAll = false; - return; } if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover) diff --git a/DownKyi/ViewModels/Settings/ViewVideoViewModel.cs b/DownKyi/ViewModels/Settings/ViewVideoViewModel.cs index 1a78dca..30c556a 100644 --- a/DownKyi/ViewModels/Settings/ViewVideoViewModel.cs +++ b/DownKyi/ViewModels/Settings/ViewVideoViewModel.cs @@ -1,6 +1,7 @@ using DownKyi.Core.BiliApi.BiliUtils; using DownKyi.Core.FileName; using DownKyi.Core.Settings; +using DownKyi.Core.Settings.Models; using DownKyi.Events; using DownKyi.Utils; using Prism.Commands; @@ -84,6 +85,48 @@ namespace DownKyi.ViewModels.Settings set => SetProperty(ref saveVideoDirectory, value); } + private bool downloadAll; + public bool DownloadAll + { + get { return downloadAll; } + set { SetProperty(ref downloadAll, value); } + } + + private bool downloadAudio; + public bool DownloadAudio + { + get { return downloadAudio; } + set { SetProperty(ref downloadAudio, value); } + } + + private bool downloadVideo; + public bool DownloadVideo + { + get { return downloadVideo; } + set { SetProperty(ref downloadVideo, value); } + } + + private bool downloadDanmaku; + public bool DownloadDanmaku + { + get { return downloadDanmaku; } + set { SetProperty(ref downloadDanmaku, value); } + } + + private bool downloadSubtitle; + public bool DownloadSubtitle + { + get { return downloadSubtitle; } + set { SetProperty(ref downloadSubtitle, value); } + } + + private bool downloadCover; + public bool DownloadCover + { + get { return downloadCover; } + set { SetProperty(ref downloadCover, value); } + } + private ObservableCollection selectedFileName; public ObservableCollection SelectedFileName { @@ -195,6 +238,24 @@ namespace DownKyi.ViewModels.Settings // 默认下载目录 SaveVideoDirectory = SettingsManager.GetInstance().GetSaveVideoRootPath(); + // 下载内容 + VideoContentSettings videoContent = SettingsManager.GetInstance().GetVideoContent(); + + DownloadAudio = videoContent.DownloadAudio; + DownloadVideo = videoContent.DownloadVideo; + DownloadDanmaku = videoContent.DownloadDanmaku; + DownloadSubtitle = videoContent.DownloadSubtitle; + DownloadCover = videoContent.DownloadCover; + + if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover) + { + DownloadAll = true; + } + else + { + DownloadAll = false; + } + // 文件命名格式 List fileNameParts = SettingsManager.GetInstance().GetFileNameParts(); SelectedFileName.Clear(); @@ -311,6 +372,145 @@ namespace DownKyi.ViewModels.Settings } } + // 所有内容选择事件 + private DelegateCommand downloadAllCommand; + public DelegateCommand DownloadAllCommand => downloadAllCommand ?? (downloadAllCommand = new DelegateCommand(ExecuteDownloadAllCommand)); + + /// + /// 所有内容选择事件 + /// + private void ExecuteDownloadAllCommand() + { + if (DownloadAll) + { + DownloadAudio = true; + DownloadVideo = true; + DownloadDanmaku = true; + DownloadSubtitle = true; + DownloadCover = true; + } + else + { + DownloadAudio = false; + DownloadVideo = false; + DownloadDanmaku = false; + DownloadSubtitle = false; + DownloadCover = false; + } + + SetVideoContent(); + } + + // 音频选择事件 + private DelegateCommand downloadAudioCommand; + public DelegateCommand DownloadAudioCommand => downloadAudioCommand ?? (downloadAudioCommand = new DelegateCommand(ExecuteDownloadAudioCommand)); + + /// + /// 音频选择事件 + /// + private void ExecuteDownloadAudioCommand() + { + if (!DownloadAudio) + { + DownloadAll = false; + } + + if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover) + { + DownloadAll = true; + } + + SetVideoContent(); + } + + // 视频选择事件 + private DelegateCommand downloadVideoCommand; + public DelegateCommand DownloadVideoCommand => downloadVideoCommand ?? (downloadVideoCommand = new DelegateCommand(ExecuteDownloadVideoCommand)); + + /// + /// 视频选择事件 + /// + private void ExecuteDownloadVideoCommand() + { + if (!DownloadVideo) + { + DownloadAll = false; + } + + if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover) + { + DownloadAll = true; + } + + SetVideoContent(); + } + + // 弹幕选择事件 + private DelegateCommand downloadDanmakuCommand; + public DelegateCommand DownloadDanmakuCommand => downloadDanmakuCommand ?? (downloadDanmakuCommand = new DelegateCommand(ExecuteDownloadDanmakuCommand)); + + /// + /// 弹幕选择事件 + /// + private void ExecuteDownloadDanmakuCommand() + { + if (!DownloadDanmaku) + { + DownloadAll = false; + } + + if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover) + { + DownloadAll = true; + } + + SetVideoContent(); + } + + // 字幕选择事件 + private DelegateCommand downloadSubtitleCommand; + public DelegateCommand DownloadSubtitleCommand => downloadSubtitleCommand ?? (downloadSubtitleCommand = new DelegateCommand(ExecuteDownloadSubtitleCommand)); + + /// + /// 字幕选择事件 + /// + private void ExecuteDownloadSubtitleCommand() + { + if (!DownloadSubtitle) + { + DownloadAll = false; + } + + if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover) + { + DownloadAll = true; + } + + SetVideoContent(); + } + + // 封面选择事件 + private DelegateCommand downloadCoverCommand; + public DelegateCommand DownloadCoverCommand => downloadCoverCommand ?? (downloadCoverCommand = new DelegateCommand(ExecuteDownloadCoverCommand)); + + /// + /// 封面选择事件 + /// + private void ExecuteDownloadCoverCommand() + { + if (!DownloadCover) + { + DownloadAll = false; + } + + if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover) + { + DownloadAll = true; + } + + SetVideoContent(); + } + // 选中文件名字段点击事件 private DelegateCommand selectedFileNameCommand; public DelegateCommand SelectedFileNameCommand => selectedFileNameCommand ?? (selectedFileNameCommand = new DelegateCommand(ExecuteSelectedFileNameCommand)); @@ -460,21 +660,21 @@ namespace DownKyi.ViewModels.Settings } /// - /// 发送需要显示的tip + /// 保存下载视频内容到设置 /// - /// - private void PublishTip(bool isSucceed) + private void SetVideoContent() { - if (isOnNavigatedTo) { return; } - - if (isSucceed) - { - eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipSettingUpdated")); - } - else + VideoContentSettings videoContent = new VideoContentSettings { - eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipSettingFailed")); - } + DownloadAudio = DownloadAudio, + DownloadVideo = DownloadVideo, + DownloadDanmaku = DownloadDanmaku, + DownloadSubtitle = DownloadSubtitle, + DownloadCover = DownloadCover + }; + + bool isSucceed = SettingsManager.GetInstance().SetVideoContent(videoContent); + PublishTip(isSucceed); } /// @@ -544,5 +744,23 @@ namespace DownKyi.ViewModels.Settings return display; } + /// + /// 发送需要显示的tip + /// + /// + private void PublishTip(bool isSucceed) + { + if (isOnNavigatedTo) { return; } + + if (isSucceed) + { + eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipSettingUpdated")); + } + else + { + eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipSettingFailed")); + } + } + } } diff --git a/DownKyi/Views/Settings/ViewDanmaku.xaml b/DownKyi/Views/Settings/ViewDanmaku.xaml index f490089..623cc54 100644 --- a/DownKyi/Views/Settings/ViewDanmaku.xaml +++ b/DownKyi/Views/Settings/ViewDanmaku.xaml @@ -19,8 +19,14 @@ + HorizontalAlignment="Left"> + + + + + + + + + + + + + + + + + + +