设置下载视频内容

croire 3 years ago
parent 74a9450680
commit 94237b5ee9

@ -299,6 +299,7 @@
<system:String x:Key="Browse">浏览</system:String>
<system:String x:Key="HardDiskFreeSpace">盘剩余空间:</system:String>
<system:String x:Key="DownloadContent">下载内容:</system:String>
<system:String x:Key="DownloadContent2">下载内容</system:String>
<system:String x:Key="DownloadAll">所有</system:String>
<system:String x:Key="DownloadAudio">音频</system:String>
<system:String x:Key="DownloadVideo">视频</system:String>

@ -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)

@ -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<DisplayFileNamePart> selectedFileName;
public ObservableCollection<DisplayFileNamePart> 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<FileNamePart> 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));
/// <summary>
/// 所有内容选择事件
/// </summary>
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));
/// <summary>
/// 音频选择事件
/// </summary>
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));
/// <summary>
/// 视频选择事件
/// </summary>
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));
/// <summary>
/// 弹幕选择事件
/// </summary>
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));
/// <summary>
/// 字幕选择事件
/// </summary>
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));
/// <summary>
/// 封面选择事件
/// </summary>
private void ExecuteDownloadCoverCommand()
{
if (!DownloadCover)
{
DownloadAll = false;
}
if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover)
{
DownloadAll = true;
}
SetVideoContent();
}
// 选中文件名字段点击事件
private DelegateCommand<object> selectedFileNameCommand;
public DelegateCommand<object> SelectedFileNameCommand => selectedFileNameCommand ?? (selectedFileNameCommand = new DelegateCommand<object>(ExecuteSelectedFileNameCommand));
@ -460,21 +660,21 @@ namespace DownKyi.ViewModels.Settings
}
/// <summary>
/// 发送需要显示的tip
/// 保存下载视频内容到设置
/// </summary>
/// <param name="isSucceed"></param>
private void PublishTip(bool isSucceed)
{
if (isOnNavigatedTo) { return; }
if (isSucceed)
private void SetVideoContent()
{
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipSettingUpdated"));
}
else
VideoContentSettings videoContent = new VideoContentSettings
{
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipSettingFailed"));
}
DownloadAudio = DownloadAudio,
DownloadVideo = DownloadVideo,
DownloadDanmaku = DownloadDanmaku,
DownloadSubtitle = DownloadSubtitle,
DownloadCover = DownloadCover
};
bool isSucceed = SettingsManager.GetInstance().SetVideoContent(videoContent);
PublishTip(isSucceed);
}
/// <summary>
@ -544,5 +744,23 @@ namespace DownKyi.ViewModels.Settings
return display;
}
/// <summary>
/// 发送需要显示的tip
/// </summary>
/// <param name="isSucceed"></param>
private void PublishTip(bool isSucceed)
{
if (isOnNavigatedTo) { return; }
if (isSucceed)
{
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipSettingUpdated"));
}
else
{
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipSettingFailed"));
}
}
}
}

@ -19,8 +19,14 @@
<GroupBox
Margin="0,20,0,0"
Padding="20,5"
HorizontalAlignment="Left"
Header="{DynamicResource FilterType}">
HorizontalAlignment="Left">
<GroupBox.Header>
<TextBlock
FontSize="12"
Foreground="{DynamicResource BrushTextDark}"
Text="{DynamicResource FilterType}" />
</GroupBox.Header>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<CheckBox
Margin="0,0,0,0"

@ -151,6 +151,63 @@
</StackPanel>
</StackPanel>
<GroupBox
Margin="0,20,0,0"
Padding="10,10"
HorizontalAlignment="Stretch">
<GroupBox.Header>
<TextBlock
FontSize="12"
Foreground="{DynamicResource BrushTextDark}"
Text="{DynamicResource DownloadContent2}" />
</GroupBox.Header>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<CheckBox
Margin="0,0,0,0"
Command="{Binding DownloadAllCommand}"
Content="{DynamicResource DownloadAll}"
Foreground="{DynamicResource BrushTextDark}"
IsChecked="{Binding DownloadAll, Mode=TwoWay}"
Style="{StaticResource CheckBoxStyle}" />
<CheckBox
Margin="40,0,0,0"
Command="{Binding DownloadAudioCommand}"
Content="{DynamicResource DownloadAudio}"
Foreground="{DynamicResource BrushTextDark}"
IsChecked="{Binding DownloadAudio, Mode=TwoWay}"
Style="{StaticResource CheckBoxStyle}" />
<CheckBox
Margin="40,0,0,0"
Command="{Binding DownloadVideoCommand}"
Content="{DynamicResource DownloadVideo}"
Foreground="{DynamicResource BrushTextDark}"
IsChecked="{Binding DownloadVideo, Mode=TwoWay}"
Style="{StaticResource CheckBoxStyle}" />
<CheckBox
Margin="40,0,0,0"
Command="{Binding DownloadDanmakuCommand}"
Content="{DynamicResource DownloadDanmaku}"
Foreground="{DynamicResource BrushTextDark}"
IsChecked="{Binding DownloadDanmaku, Mode=TwoWay}"
Style="{StaticResource CheckBoxStyle}" />
<CheckBox
Margin="40,0,0,0"
Command="{Binding DownloadSubtitleCommand}"
Content="{DynamicResource DownloadSubtitle}"
Foreground="{DynamicResource BrushTextDark}"
IsChecked="{Binding DownloadSubtitle, Mode=TwoWay}"
Style="{StaticResource CheckBoxStyle}" />
<CheckBox
Margin="40,0,0,0"
Command="{Binding DownloadCoverCommand}"
Content="{DynamicResource DownloadCover}"
Foreground="{DynamicResource BrushTextDark}"
IsChecked="{Binding DownloadCover, Mode=TwoWay}"
Style="{StaticResource CheckBoxStyle}" />
</StackPanel>
</GroupBox>
<GroupBox
Margin="0,20,0,0"
Padding="10,10"

Loading…
Cancel
Save