视频列表增加了一个搜索框

croire 2 years ago
parent 6a53d3c101
commit 951749bd0f

@ -135,6 +135,8 @@
<system:String x:Key="VideoCodec">视频编码</system:String> <system:String x:Key="VideoCodec">视频编码</system:String>
<system:String x:Key="SelectAll">全选</system:String> <system:String x:Key="SelectAll">全选</system:String>
<system:String x:Key="Search">搜索</system:String>
<system:String x:Key="SearchVideoByName">搜索视频名称</system:String>
<system:String x:Key="Parse">解析</system:String> <system:String x:Key="Parse">解析</system:String>
<system:String x:Key="ParseVideo">解析视频</system:String> <system:String x:Key="ParseVideo">解析视频</system:String>
<system:String x:Key="DownloadSelected">下载选中项</system:String> <system:String x:Key="DownloadSelected">下载选中项</system:String>

@ -56,7 +56,9 @@
<system:String x:Key="AudioQuality">音质</system:String> <system:String x:Key="AudioQuality">音质</system:String>
<system:String x:Key="VideoQuality">画质</system:String> <system:String x:Key="VideoQuality">画质</system:String>
<system:String x:Key="VideoCodec">视频编码</system:String> <system:String x:Key="VideoCodec">视频编码</system:String>
<system:String x:Key="Search">搜索</system:String>
<system:String x:Key="SearchVideoByName">搜索视频名称</system:String>
<system:String x:Key="SelectAll">全选</system:String> <system:String x:Key="SelectAll">全选</system:String>
<system:String x:Key="Parse">解析</system:String> <system:String x:Key="Parse">解析</system:String>
<system:String x:Key="ParseVideo">解析视频</system:String> <system:String x:Key="ParseVideo">解析视频</system:String>

@ -58,6 +58,8 @@
<system:String x:Key="VideoQuality">画质</system:String> <system:String x:Key="VideoQuality">画质</system:String>
<system:String x:Key="VideoCodec">视频编码</system:String> <system:String x:Key="VideoCodec">视频编码</system:String>
<system:String x:Key="Search">搜索</system:String>
<system:String x:Key="SearchVideoByName">搜索视频名称</system:String>
<system:String x:Key="SelectAll">全选</system:String> <system:String x:Key="SelectAll">全选</system:String>
<system:String x:Key="Parse">解析</system:String> <system:String x:Key="Parse">解析</system:String>
<system:String x:Key="ParseVideo">解析视频</system:String> <system:String x:Key="ParseVideo">解析视频</system:String>

@ -58,6 +58,8 @@
<system:String x:Key="VideoQuality">画质</system:String> <system:String x:Key="VideoQuality">画质</system:String>
<system:String x:Key="VideoCodec">视频编码</system:String> <system:String x:Key="VideoCodec">视频编码</system:String>
<system:String x:Key="Search">搜索</system:String>
<system:String x:Key="SearchVideoByName">搜索视频名称</system:String>
<system:String x:Key="SelectAll">全选</system:String> <system:String x:Key="SelectAll">全选</system:String>
<system:String x:Key="Parse">解析</system:String> <system:String x:Key="Parse">解析</system:String>
<system:String x:Key="ParseVideo">解析视频</system:String> <system:String x:Key="ParseVideo">解析视频</system:String>

@ -5,6 +5,7 @@ using DownKyi.Utils;
using Prism.Commands; using Prism.Commands;
using Prism.Services.Dialogs; using Prism.Services.Dialogs;
using System.IO; using System.IO;
using System.Linq;
namespace DownKyi.ViewModels.DownloadManager namespace DownKyi.ViewModels.DownloadManager
{ {
@ -91,8 +92,24 @@ namespace DownKyi.ViewModels.DownloadManager
private void ExecuteOpenFolderCommand() private void ExecuteOpenFolderCommand()
{ {
if (DownloadBase == null) { return; } if (DownloadBase == null) { return; }
//TODO:这里不光有mp4视频文件也可能存在音频文件、字幕或者其他文件类型
string videoPath = $"{DownloadBase.FilePath}.mp4"; //fix bug:Issues #709
//这里根据需要下载的类型判断,具体对应的文件后缀名
var downLoadContents = DownloadBase.NeedDownloadContent.Where(e => e.Value == true).Select(e => e.Key);
string fileSuffix = string.Empty;
if (downLoadContents.Contains("downloadVideo"))
{
fileSuffix = ".mp4";
}
else if (downLoadContents.Contains("downloadAudio"))
{
fileSuffix = ".aac";
}
else if (downLoadContents.Contains("downloadCover"))
{
fileSuffix = ".jpg";
}
string videoPath = $"{DownloadBase.FilePath}{fileSuffix}";
FileInfo fileInfo = new FileInfo(videoPath); FileInfo fileInfo = new FileInfo(videoPath);
if (File.Exists(fileInfo.FullName)) if (File.Exists(fileInfo.FullName))
{ {

@ -41,6 +41,7 @@ namespace DownKyi.ViewModels
#endregion #endregion
public ViewSettingsViewModel(IRegionManager regionManager, IEventAggregator eventAggregator) : base(eventAggregator) public ViewSettingsViewModel(IRegionManager regionManager, IEventAggregator eventAggregator) : base(eventAggregator)
{ {
this.regionManager = regionManager; this.regionManager = regionManager;

@ -10,6 +10,7 @@ using DownKyi.Services.Download;
using DownKyi.Utils; using DownKyi.Utils;
using DownKyi.ViewModels.Dialogs; using DownKyi.ViewModels.Dialogs;
using DownKyi.ViewModels.PageViewModels; using DownKyi.ViewModels.PageViewModels;
using Newtonsoft.Json;
using Prism.Commands; using Prism.Commands;
using Prism.Events; using Prism.Events;
using Prism.Regions; using Prism.Regions;
@ -17,7 +18,9 @@ using Prism.Services.Dialogs;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
@ -46,7 +49,13 @@ namespace DownKyi.ViewModels
get => inputText; get => inputText;
set => SetProperty(ref inputText, value); set => SetProperty(ref inputText, value);
} }
private string inputSearchText;
public string InputSearchText
{
get => inputSearchText;
set => SetProperty(ref inputSearchText, value);
}
private GifImage loading; private GifImage loading;
public GifImage Loading public GifImage Loading
{ {
@ -81,7 +90,7 @@ namespace DownKyi.ViewModels
get => videoSections; get => videoSections;
set => SetProperty(ref videoSections, value); set => SetProperty(ref videoSections, value);
} }
public ObservableCollection<VideoSection> CaCheVideoSections { get; set; }
private bool isSelectAll; private bool isSelectAll;
public bool IsSelectAll public bool IsSelectAll
{ {
@ -125,7 +134,7 @@ namespace DownKyi.ViewModels
DownloadManage.Fill = DictionaryResource.GetColor("ColorPrimary"); DownloadManage.Fill = DictionaryResource.GetColor("ColorPrimary");
VideoSections = new ObservableCollection<VideoSection>(); VideoSections = new ObservableCollection<VideoSection>();
CaCheVideoSections = new ObservableCollection<VideoSection>();
#endregion #endregion
} }
@ -172,6 +181,41 @@ namespace DownKyi.ViewModels
private DelegateCommand inputCommand; private DelegateCommand inputCommand;
public DelegateCommand InputCommand => inputCommand ?? (inputCommand = new DelegateCommand(ExecuteInputCommand, CanExecuteInputCommand)); public DelegateCommand InputCommand => inputCommand ?? (inputCommand = new DelegateCommand(ExecuteInputCommand, CanExecuteInputCommand));
private DelegateCommand inputSearchCommand;
public DelegateCommand InputSearchCommand => inputSearchCommand ?? (inputSearchCommand = new DelegateCommand(ExcuteInputSearchCommand));
/// <summary>
/// 搜索视频输入时间
/// </summary>
private async void ExcuteInputSearchCommand() {
await Task.Run(() =>
{
if (InputSearchText == null || InputSearchText == string.Empty)
{
foreach (VideoSection section in VideoSections) {
var cache= CaCheVideoSections.FirstOrDefault(e=>e.Id==section.Id);
if (cache!=null)
{
section.VideoPages=cache.VideoPages;
}
}
}
else
{
foreach (VideoSection section in VideoSections)
{
var cache = CaCheVideoSections.FirstOrDefault(e => e.Id == section.Id);
if (cache != null)
{
var pages = cache.VideoPages.Where(e => e.Name.Contains(InputSearchText)).ToList();
section.VideoPages = pages;
}
}
}
});
}
/// <summary> /// <summary>
/// 处理输入事件 /// 处理输入事件
/// </summary> /// </summary>
@ -582,6 +626,7 @@ namespace DownKyi.ViewModels
NoDataVisibility = Visibility.Collapsed; NoDataVisibility = Visibility.Collapsed;
VideoSections.Clear(); VideoSections.Clear();
CaCheVideoSections.Clear();
} }
/// <summary> /// <summary>
@ -642,6 +687,7 @@ namespace DownKyi.ViewModels
PropertyChangeAsync(new Action(() => PropertyChangeAsync(new Action(() =>
{ {
VideoSections.Clear(); VideoSections.Clear();
CaCheVideoSections.Clear();
})); }));
// 添加新数据 // 添加新数据
@ -660,17 +706,27 @@ namespace DownKyi.ViewModels
IsSelected = true, IsSelected = true,
VideoPages = pages VideoPages = pages
}); });
CaCheVideoSections.Add(new VideoSection
{
Id = 0,
Title = "default",
IsSelected = true,
VideoPages = pages
});
})); }));
} }
else else
{ {
//这里如果浅拷贝会导致用于查询的CaCheVideoSections数据变化所以这样处理
var videoSectionsStr = JsonConvert.SerializeObject(videoSections);
var videoSectionsData = JsonConvert.DeserializeObject<List<VideoSection>>(videoSectionsStr);
PropertyChangeAsync(new Action(() => PropertyChangeAsync(new Action(() =>
{ {
VideoSections.AddRange(videoSections); VideoSections.AddRange(videoSections);
CaCheVideoSections.AddRange(videoSectionsData);
})); }));
} }
} }
/// <summary> /// <summary>
/// 解析视频流 /// 解析视频流
/// </summary> /// </summary>

@ -694,7 +694,36 @@
<!-- 考虑将下列两个选项移入设置页面 --> <!-- 考虑将下列两个选项移入设置页面 -->
<!--<CheckBox Grid.Column="1" Content="自动解析" IsChecked="False" Foreground="{DynamicResource BrushTextDark}" Style="{StaticResource CheckBoxStyle}" Margin="0 10 0 0" VerticalAlignment="Top" HorizontalAlignment="Left"/> <!--<CheckBox Grid.Column="1" Content="自动解析" IsChecked="False" Foreground="{DynamicResource BrushTextDark}" Style="{StaticResource CheckBoxStyle}" Margin="0 10 0 0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
<CheckBox Grid.Column="2" Content="解析后自动下载所有" IsChecked="False" Foreground="{DynamicResource BrushTextDark}" Style="{StaticResource CheckBoxStyle}" Margin="0 10 0 0" VerticalAlignment="Top" HorizontalAlignment="Left"/>--> <CheckBox Grid.Column="2" Content="解析后自动下载所有" IsChecked="False" Foreground="{DynamicResource BrushTextDark}" Style="{StaticResource CheckBoxStyle}" Margin="0 10 0 0" VerticalAlignment="Top" HorizontalAlignment="Left"/>-->
<TextBox Grid.Column="3" HorizontalAlignment="Left" Height="20" TextWrapping="Wrap" VerticalAlignment="Top" Width="140" Margin="48,0,0,0"
Text="{Binding Path=InputSearchText, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}">
<TextBox.InputBindings>
<KeyBinding Key="Enter" Command="{Binding InputSearchCommand}" />
</TextBox.InputBindings>
<TextBox.Resources>
<VisualBrush
x:Key="HintText"
AlignmentX="Left"
Opacity="0.5"
Stretch="None"
TileMode="None">
<VisualBrush.Visual>
<TextBlock Text="{DynamicResource SearchVideoByName}" />
</VisualBrush.Visual>
</VisualBrush>
</TextBox.Resources>
<TextBox.Style>
<Style TargetType="TextBox">
<Style.Triggers>
<Trigger Property="Text" Value="{x:Null}">
<Setter Property="Background" Value="{StaticResource HintText}" />
</Trigger>
<Trigger Property="Text" Value="">
<Setter Property="Background" Value="{StaticResource HintText}" />
</Trigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
<Button <Button
Grid.Column="4" Grid.Column="4"
HorizontalAlignment="Right" HorizontalAlignment="Right"
@ -713,6 +742,7 @@
FontSize="12" FontSize="12"
Foreground="{DynamicResource BrushText}" Foreground="{DynamicResource BrushText}"
Style="{StaticResource BtnStyle}" /> Style="{StaticResource BtnStyle}" />
<Label Content="{DynamicResource Search}" Grid.Column="3" HorizontalAlignment="Left" Margin="9,-2,0,0" VerticalAlignment="Top"/>
</Grid> </Grid>
</Grid> </Grid>

Loading…
Cancel
Save