mirror of
https://github.com/yaobiao131/downkyicore.git
synced 2025-08-10 00:52:31 +00:00
feat: 修正命名
This commit is contained in:
@@ -4,6 +4,7 @@ using DownKyi.Core.Settings;
|
||||
using DownKyi.Core.Settings.Models;
|
||||
using DownKyi.Core.Storage;
|
||||
using DownKyi.Core.Utils;
|
||||
using DownKyi.Core.Utils.Encryptor;
|
||||
using Console = DownKyi.Core.Utils.Debugging.Console;
|
||||
|
||||
namespace DownKyi.Core.BiliApi.Login
|
||||
@@ -30,7 +31,7 @@ namespace DownKyi.Core.BiliApi.Login
|
||||
if (isSucceed)
|
||||
{
|
||||
// 加密密钥,增加机器码
|
||||
string password = SecretKey;
|
||||
var password = SecretKey;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -68,7 +69,7 @@ namespace DownKyi.Core.BiliApi.Login
|
||||
{
|
||||
File.Copy(LOCAL_LOGIN_INFO, tempFile, true);
|
||||
// 加密密钥,增加机器码
|
||||
// string password = SecretKey;
|
||||
var password = SecretKey;
|
||||
// Encryptor.DecryptFile(LOCAL_LOGIN_INFO, tempFile, password);
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
@@ -23,10 +23,13 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Binary/$(RuntimeIdentifier)/aria2/*" Link="aria2/%(Filename)%(Extension)">
|
||||
<None Update="ffmpeg.config.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Binary/$(RuntimeIdentifier)/ffmpeg/*" Link="ffmpeg/%(Filename)%(Extension)">
|
||||
<None Update="Binary/$(RuntimeIdentifier)/aria2/*" Link="aria2/%(Filename)%(Extension)" Visible="false">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Binary/$(RuntimeIdentifier)/ffmpeg/*" Link="ffmpeg/%(Filename)%(Extension)" Visible="false">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
@@ -131,17 +131,6 @@ public static partial class Encryptor
|
||||
|
||||
if (slack > 0)
|
||||
{
|
||||
// .net6引入变更,使用旧方法无法读取完毕
|
||||
// int totalRead = 0;
|
||||
// while (totalRead < slack)
|
||||
// {
|
||||
// read = cin.Read(bytes, 0, (int)slack-totalRead);
|
||||
// fout.Write(bytes, 0, read);
|
||||
// chash.Write(bytes, 0, read);
|
||||
// value += read;
|
||||
// outValue += read;
|
||||
// totalRead += read;
|
||||
// }
|
||||
read = cin.Read(bytes, 0, (int)slack);
|
||||
fout.Write(bytes, 0, read);
|
||||
chash.Write(bytes, 0, read);
|
||||
@@ -209,7 +198,7 @@ public static partial class Encryptor
|
||||
SymmetricAlgorithm sma = Rijndael.Create();
|
||||
sma.KeySize = 256;
|
||||
sma.Key = pdb.GetBytes(32);
|
||||
sma.Padding = PaddingMode.PKCS7;
|
||||
sma.Padding = PaddingMode.Zeros;
|
||||
return sma;
|
||||
}
|
||||
|
||||
|
||||
3
DownKyi.Core/ffmpeg.config.json
Normal file
3
DownKyi.Core/ffmpeg.config.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"BinaryFolder": "./ffmpeg"
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Threading;
|
||||
@@ -209,7 +210,12 @@ public partial class App : PrismApplication
|
||||
break;
|
||||
}
|
||||
|
||||
_downloadService?.Start();
|
||||
// 防止设计器启动aria2导致端口占用
|
||||
if (!Design.IsDesignMode)
|
||||
{
|
||||
_downloadService?.Start();
|
||||
}
|
||||
|
||||
|
||||
return Container.Resolve<MainWindow>();
|
||||
}
|
||||
|
||||
@@ -8,12 +8,12 @@ namespace DownKyi.Converter
|
||||
{
|
||||
public int Count { get; set; }
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
return ((int)value) > Count;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.1.999-cibuild0042781-beta" />
|
||||
<PackageReference Include="Avalonia.ReactiveUI" Version="11.1.999-cibuild0042781-beta" />
|
||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.1.999-cibuild0042781-beta" />
|
||||
<PackageReference Include="Avalonia.Themes.Simple" Version="11.1.999-cibuild0042781-beta" />
|
||||
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.0.5" />
|
||||
<PackageReference Include="Prism.Avalonia" Version="8.1.97.11000" />
|
||||
|
||||
466
DownKyi/Services/Download/CustomAriaDownloadService.cs
Normal file
466
DownKyi/Services/Download/CustomAriaDownloadService.cs
Normal file
@@ -0,0 +1,466 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using DownKyi.Core.Aria2cNet;
|
||||
using DownKyi.Core.Aria2cNet.Client;
|
||||
using DownKyi.Core.Aria2cNet.Client.Entity;
|
||||
using DownKyi.Core.Aria2cNet.Server;
|
||||
using DownKyi.Core.BiliApi.VideoStream.Models;
|
||||
using DownKyi.Core.Logging;
|
||||
using DownKyi.Core.Settings;
|
||||
using DownKyi.Core.Utils;
|
||||
using DownKyi.Models;
|
||||
using DownKyi.Utils;
|
||||
using DownKyi.ViewModels.DownloadManager;
|
||||
using Prism.Services.Dialogs;
|
||||
|
||||
namespace DownKyi.Services.Download;
|
||||
|
||||
/// <summary>
|
||||
/// 音视频采用Aria下载,其余采用WebClient下载
|
||||
/// </summary>
|
||||
public class CustomAriaDownloadService : DownloadService, IDownloadService
|
||||
{
|
||||
public CustomAriaDownloadService(ObservableCollection<DownloadingItem> downloadingList,
|
||||
ObservableCollection<DownloadedItem> downloadedList,
|
||||
IDialogService dialogService
|
||||
) : base(downloadingList, downloadedList, dialogService)
|
||||
{
|
||||
Tag = "AriaDownloadService";
|
||||
}
|
||||
|
||||
#region 音视频
|
||||
|
||||
/// <summary>
|
||||
/// 下载音频,返回下载文件路径
|
||||
/// </summary>
|
||||
/// <param name="downloading"></param>
|
||||
/// <returns></returns>
|
||||
public override string DownloadAudio(DownloadingItem downloading)
|
||||
{
|
||||
PlayUrlDashVideo downloadAudio = BaseDownloadAudio(downloading);
|
||||
|
||||
return DownloadVideo(downloading, downloadAudio);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下载视频,返回下载文件路径
|
||||
/// </summary>
|
||||
/// <param name="downloading"></param>
|
||||
/// <returns></returns>
|
||||
public override string DownloadVideo(DownloadingItem downloading)
|
||||
{
|
||||
PlayUrlDashVideo downloadVideo = BaseDownloadVideo(downloading);
|
||||
|
||||
return DownloadVideo(downloading, downloadVideo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将下载音频和视频的函数中相同代码抽象出来
|
||||
/// </summary>
|
||||
/// <param name="downloading"></param>
|
||||
/// <param name="downloadVideo"></param>
|
||||
/// <returns></returns>
|
||||
private string DownloadVideo(DownloadingItem downloading, PlayUrlDashVideo downloadVideo)
|
||||
{
|
||||
// 如果为空,说明没有匹配到可下载的音频视频
|
||||
if (downloadVideo == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// 下载链接
|
||||
List<string> urls = new List<string>();
|
||||
if (downloadVideo.BaseUrl != null)
|
||||
{
|
||||
urls.Add(downloadVideo.BaseUrl);
|
||||
}
|
||||
|
||||
if (downloadVideo.BackupUrl != null)
|
||||
{
|
||||
urls.AddRange(downloadVideo.BackupUrl);
|
||||
}
|
||||
|
||||
// 路径
|
||||
downloading.DownloadBase.FilePath = downloading.DownloadBase.FilePath.Replace("\\", "/");
|
||||
string[] temp = downloading.DownloadBase.FilePath.Split('/');
|
||||
//string path = downloading.DownloadBase.FilePath.Replace(temp[temp.Length - 1], "");
|
||||
string path = downloading.DownloadBase.FilePath.TrimEnd(temp[temp.Length - 1].ToCharArray());
|
||||
|
||||
// 下载文件名
|
||||
string fileName = Guid.NewGuid().ToString("N");
|
||||
string key = $"{downloadVideo.Id}_{downloadVideo.Codecs}";
|
||||
|
||||
// 老版本数据库没有这一项,会变成null
|
||||
if (downloading.Downloading.DownloadedFiles == null)
|
||||
{
|
||||
downloading.Downloading.DownloadedFiles = new List<string>();
|
||||
}
|
||||
|
||||
if (downloading.Downloading.DownloadFiles.ContainsKey(key))
|
||||
{
|
||||
// 如果存在,表示下载过,
|
||||
// 则继续使用上次下载的文件名
|
||||
fileName = downloading.Downloading.DownloadFiles[key];
|
||||
|
||||
// 还要检查一下文件有没有被人删掉,删掉的话重新下载
|
||||
// 如果下载视频之后音频文件被人删了。此时gid还是视频的,会下错文件
|
||||
if (downloading.Downloading.DownloadedFiles.Contains(key) && File.Exists(Path.Combine(path, fileName)))
|
||||
{
|
||||
return Path.Combine(path, fileName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 记录本次下载的文件
|
||||
try
|
||||
{
|
||||
downloading.Downloading.DownloadFiles.Add(key, fileName);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
}
|
||||
|
||||
// Gid最好能是每个文件单独存储,现在复用有可能会混
|
||||
// 不过好消息是下载是按固定顺序的,而且下载了两个音频会混流不过
|
||||
downloading.Downloading.Gid = null;
|
||||
}
|
||||
|
||||
// 启用https
|
||||
AllowStatus useSSL = SettingsManager.GetInstance().UseSSL();
|
||||
if (useSSL == AllowStatus.YES)
|
||||
{
|
||||
for (int i = 0; i < urls.Count; i++)
|
||||
{
|
||||
string url = urls[i];
|
||||
if (url.StartsWith("http://"))
|
||||
{
|
||||
urls[i] = url.Replace("http://", "https://");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < urls.Count; i++)
|
||||
{
|
||||
string url = urls[i];
|
||||
if (url.StartsWith("https://"))
|
||||
{
|
||||
urls[i] = url.Replace("https://", "http://");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 开始下载
|
||||
DownloadResult downloadStatus = DownloadByAria(downloading, urls, path, fileName);
|
||||
switch (downloadStatus)
|
||||
{
|
||||
case DownloadResult.SUCCESS:
|
||||
downloading.Downloading.DownloadedFiles.Add(key);
|
||||
downloading.Downloading.Gid = null;
|
||||
return Path.Combine(path, fileName);
|
||||
case DownloadResult.FAILED:
|
||||
case DownloadResult.ABORT:
|
||||
default:
|
||||
return nullMark;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 下载封面
|
||||
/// </summary>
|
||||
/// <param name="downloading"></param>
|
||||
public override string DownloadCover(DownloadingItem downloading, string coverUrl, string fileName)
|
||||
{
|
||||
return BaseDownloadCover(downloading, coverUrl, fileName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下载弹幕
|
||||
/// </summary>
|
||||
/// <param name="downloading"></param>
|
||||
public override string DownloadDanmaku(DownloadingItem downloading)
|
||||
{
|
||||
return BaseDownloadDanmaku(downloading);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下载字幕
|
||||
/// </summary>
|
||||
/// <param name="downloading"></param>
|
||||
public override List<string> DownloadSubtitle(DownloadingItem downloading)
|
||||
{
|
||||
return BaseDownloadSubtitle(downloading);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 混流音频和视频
|
||||
/// </summary>
|
||||
/// <param name="downloading"></param>
|
||||
/// <param name="audioUid"></param>
|
||||
/// <param name="videoUid"></param>
|
||||
/// <returns></returns>
|
||||
public override string MixedFlow(DownloadingItem downloading, string audioUid, string videoUid)
|
||||
{
|
||||
if (videoUid == nullMark)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return BaseMixedFlow(downloading, audioUid, videoUid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析视频流的下载链接
|
||||
/// </summary>
|
||||
/// <param name="downloading"></param>
|
||||
public override void Parse(DownloadingItem downloading)
|
||||
{
|
||||
BaseParse(downloading);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 停止下载服务(转换await和Task.Wait两种调用形式)
|
||||
/// </summary>
|
||||
private async Task EndTask()
|
||||
{
|
||||
// 停止基本任务
|
||||
await BaseEndTask();
|
||||
|
||||
// 关闭Aria服务器
|
||||
await CloseAriaServer();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 停止下载服务
|
||||
/// </summary>
|
||||
public void End()
|
||||
{
|
||||
Task.Run(EndTask).Wait();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 启动下载服务
|
||||
/// </summary>
|
||||
public void Start()
|
||||
{
|
||||
// 设置aria token
|
||||
AriaClient.SetToken(SettingsManager.GetInstance().GetAriaToken());
|
||||
// 设置aria host
|
||||
AriaClient.SetHost(SettingsManager.GetInstance().GetAriaHost());
|
||||
// 设置aria listenPort
|
||||
AriaClient.SetListenPort(SettingsManager.GetInstance().GetAriaListenPort());
|
||||
|
||||
// 启动基本服务
|
||||
BaseStart();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 强制暂停
|
||||
/// </summary>
|
||||
/// <param name="downloading"></param>
|
||||
/// <exception cref="OperationCanceledException"></exception>
|
||||
protected override void Pause(DownloadingItem downloading)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
downloading.DownloadStatusTitle = DictionaryResource.GetString("Pausing");
|
||||
if (downloading.Downloading.DownloadStatus == DownloadStatus.PAUSE)
|
||||
{
|
||||
throw new OperationCanceledException("Stop thread by pause");
|
||||
}
|
||||
|
||||
// 是否存在
|
||||
var isExist = IsExist(downloading);
|
||||
if (!isExist.Result)
|
||||
{
|
||||
throw new OperationCanceledException("Task is deleted");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否存在于下载列表中
|
||||
/// </summary>
|
||||
/// <param name="downloading"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<bool> IsExist(DownloadingItem downloading)
|
||||
{
|
||||
bool isExist = downloadingList.Contains(downloading);
|
||||
if (isExist)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 先恢复为waiting状态,暂停状态下Remove会导致文件重新下载,原因暂不清楚
|
||||
await AriaClient.UnpauseAsync(downloading.Downloading.Gid);
|
||||
// 移除下载项
|
||||
var ariaRemove = await AriaClient.RemoveAsync(downloading.Downloading.Gid);
|
||||
if (ariaRemove == null || ariaRemove.Result == downloading.Downloading.Gid)
|
||||
{
|
||||
// 从内存中删除下载项
|
||||
await AriaClient.RemoveDownloadResultAsync(downloading.Downloading.Gid);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭Aria服务器
|
||||
/// </summary>
|
||||
private async Task CloseAriaServer()
|
||||
{
|
||||
// 暂停所有下载
|
||||
var ariaPause = await AriaClient.PauseAllAsync();
|
||||
#if DEBUG
|
||||
Core.Utils.Debugging.Console.PrintLine(ariaPause.ToString());
|
||||
#endif
|
||||
|
||||
// 关闭服务器
|
||||
bool close = AriaServer.CloseServer();
|
||||
#if DEBUG
|
||||
Core.Utils.Debugging.Console.PrintLine(close);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 采用Aria下载文件
|
||||
/// </summary>
|
||||
/// <param name="downloading"></param>
|
||||
/// <returns></returns>
|
||||
private DownloadResult DownloadByAria(DownloadingItem downloading, List<string> urls, string path,
|
||||
string localFileName)
|
||||
{
|
||||
// path已斜杠结尾,去掉斜杠
|
||||
path = path.TrimEnd('/').TrimEnd('\\');
|
||||
|
||||
//检查gid对应任务,如果已创建那么直接使用
|
||||
//但是代理设置会出现不能随时更新的问题
|
||||
|
||||
if (downloading.Downloading.Gid != null)
|
||||
{
|
||||
Task<AriaTellStatus> status = AriaClient.TellStatus(downloading.Downloading.Gid);
|
||||
if (status == null || status.Result == null)
|
||||
downloading.Downloading.Gid = null;
|
||||
else if (status.Result.Result == null && status.Result.Error != null)
|
||||
{
|
||||
if (status.Result.Error.Message.Contains("is not found"))
|
||||
{
|
||||
downloading.Downloading.Gid = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (downloading.Downloading.Gid == null)
|
||||
{
|
||||
AriaSendOption option = new AriaSendOption
|
||||
{
|
||||
//HttpProxy = $"http://{Settings.GetAriaHttpProxy()}:{Settings.GetAriaHttpProxyListenPort()}",
|
||||
Dir = path,
|
||||
Out = localFileName,
|
||||
//Header = $"cookie: {LoginHelper.GetLoginInfoCookiesString()}\nreferer: https://www.bilibili.com",
|
||||
//UseHead = "true",
|
||||
UserAgent = SettingsManager.GetInstance().GetUserAgent(),
|
||||
};
|
||||
|
||||
//// 如果设置了代理,则增加HttpProxy
|
||||
//if (SettingsManager.GetInstance().IsAriaHttpProxy() == AllowStatus.YES)
|
||||
//{
|
||||
// option.HttpProxy = $"http://{SettingsManager.GetInstance().GetAriaHttpProxy()}:{SettingsManager.GetInstance().GetAriaHttpProxyListenPort()}";
|
||||
//}
|
||||
|
||||
// 添加一个下载
|
||||
Task<AriaAddUri> ariaAddUri = AriaClient.AddUriAsync(urls, option);
|
||||
if (ariaAddUri == null || ariaAddUri.Result == null || ariaAddUri.Result.Result == null)
|
||||
{
|
||||
return DownloadResult.FAILED;
|
||||
}
|
||||
|
||||
// 保存gid
|
||||
string gid = ariaAddUri.Result.Result;
|
||||
downloading.Downloading.Gid = gid;
|
||||
}
|
||||
else
|
||||
{
|
||||
Task<AriaPause> ariaUnpause = AriaClient.UnpauseAsync(downloading.Downloading.Gid);
|
||||
}
|
||||
|
||||
// 管理下载
|
||||
AriaManager ariaManager = new AriaManager();
|
||||
ariaManager.TellStatus += AriaTellStatus;
|
||||
ariaManager.DownloadFinish += AriaDownloadFinish;
|
||||
return ariaManager.GetDownloadStatus(downloading.Downloading.Gid, new Action(() =>
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
switch (downloading.Downloading.DownloadStatus)
|
||||
{
|
||||
case DownloadStatus.PAUSE:
|
||||
Task<AriaPause> ariaPause = AriaClient.PauseAsync(downloading.Downloading.Gid);
|
||||
// 通知UI,并阻塞当前线程
|
||||
Pause(downloading);
|
||||
break;
|
||||
case DownloadStatus.DOWNLOADING:
|
||||
break;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private void AriaTellStatus(long totalLength, long completedLength, long speed, string gid)
|
||||
{
|
||||
// 当前的下载视频
|
||||
DownloadingItem video = null;
|
||||
try
|
||||
{
|
||||
video = downloadingList.FirstOrDefault(it => it.Downloading.Gid == gid);
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
{
|
||||
Core.Utils.Debugging.Console.PrintLine("AriaTellStatus()发生异常: {0}", e);
|
||||
LogManager.Error("AriaTellStatus()", e);
|
||||
}
|
||||
|
||||
if (video == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 下载进度百分比
|
||||
float percent = 0;
|
||||
if (totalLength != 0)
|
||||
{
|
||||
percent = (float)completedLength / totalLength * 100;
|
||||
}
|
||||
|
||||
// 根据进度判断本次是否需要更新UI
|
||||
if (Math.Abs(percent - video.Progress) < 0.01)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 下载进度
|
||||
video.Progress = percent;
|
||||
|
||||
// 下载大小
|
||||
video.DownloadingFileSize = Format.FormatFileSize(completedLength) + "/" + Format.FormatFileSize(totalLength);
|
||||
|
||||
// 下载速度
|
||||
video.SpeedDisplay = Format.FormatSpeed(speed);
|
||||
|
||||
// 最大下载速度
|
||||
if (video.Downloading.MaxSpeed < speed)
|
||||
{
|
||||
video.Downloading.MaxSpeed = speed;
|
||||
}
|
||||
}
|
||||
|
||||
private void AriaDownloadFinish(bool isSuccess, string downloadPath, string gid, string msg)
|
||||
{
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -180,7 +180,7 @@ public class VideoInfoService : IInfoService
|
||||
Bvid = episode.Bvid,
|
||||
Cid = episode.Cid,
|
||||
EpisodeId = -1,
|
||||
FirstFrame = episode.Page.FirstFrame,
|
||||
FirstFrame = episode.Arc.Pic,
|
||||
Order = order,
|
||||
Name = episode.Title,
|
||||
Duration = "N/A"
|
||||
|
||||
@@ -13,7 +13,7 @@ public static class PlatformHelper
|
||||
{
|
||||
if (OperatingSystem.IsWindows())
|
||||
{
|
||||
Process.Start("explorer.exe", $"/select,{folder}");
|
||||
Process.Start("explorer.exe", $"{folder}");
|
||||
}
|
||||
|
||||
if (OperatingSystem.IsMacOS())
|
||||
|
||||
@@ -121,9 +121,9 @@ namespace DownKyi.ViewModels.DownloadManager
|
||||
|
||||
var videoPath = $"{DownloadBase.FilePath}{fileSuffix}";
|
||||
var fileInfo = new FileInfo(videoPath);
|
||||
if (File.Exists(fileInfo.FullName))
|
||||
if (File.Exists(fileInfo.FullName) && fileInfo.DirectoryName != null)
|
||||
{
|
||||
PlatformHelper.OpenFolder(fileInfo.FullName);
|
||||
PlatformHelper.OpenFolder(fileInfo.DirectoryName);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace DownKyi.ViewModels.DownloadManager
|
||||
/// </summary>
|
||||
private async void ExecuteClearAllDownloadedCommand()
|
||||
{
|
||||
AlertService alertService = new AlertService(dialogService);
|
||||
AlertService alertService = new AlertService(DialogService);
|
||||
ButtonResult result = await alertService.ShowWarning(DictionaryResource.GetString("ConfirmDelete"));
|
||||
if (result != ButtonResult.OK)
|
||||
{
|
||||
@@ -146,7 +146,7 @@ namespace DownKyi.ViewModels.DownloadManager
|
||||
{
|
||||
if (item != null && item.DialogService == null)
|
||||
{
|
||||
item.DialogService = dialogService;
|
||||
item.DialogService = DialogService;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -158,7 +158,7 @@ namespace DownKyi.ViewModels.DownloadManager
|
||||
/// </summary>
|
||||
private async void ExecuteDeleteAllDownloadingCommand()
|
||||
{
|
||||
var alertService = new AlertService(dialogService);
|
||||
var alertService = new AlertService(DialogService);
|
||||
var result = await alertService.ShowWarning(DictionaryResource.GetString("ConfirmDelete"));
|
||||
if (result != ButtonResult.OK)
|
||||
{
|
||||
@@ -191,7 +191,7 @@ namespace DownKyi.ViewModels.DownloadManager
|
||||
{
|
||||
if (item != null && item.DialogService == null)
|
||||
{
|
||||
item.DialogService = dialogService;
|
||||
item.DialogService = DialogService;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -115,7 +115,7 @@ public class ViewFollowerViewModel : ViewModelBase
|
||||
Bitmap header = storageHeader.GetHeaderThumbnail(item.Mid, item.Name, item.Face, 64, 64);
|
||||
App.PropertyChangeAsync(new Action(() =>
|
||||
{
|
||||
Contents.Add(new FriendInfo(eventAggregator)
|
||||
Contents.Add(new FriendInfo(EventAggregator)
|
||||
{ Mid = item.Mid, Header = header, Name = item.Name, Sign = item.Sign });
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ public class ViewFollowingViewModel : ViewModelBase
|
||||
Bitmap header = storageHeader.GetHeaderThumbnail(item.Mid, item.Name, item.Face, 64, 64);
|
||||
App.PropertyChangeAsync(new Action(() =>
|
||||
{
|
||||
Contents.Add(new FriendInfo(eventAggregator)
|
||||
Contents.Add(new FriendInfo(EventAggregator)
|
||||
{ Mid = item.Mid, Header = header, Name = item.Name, Sign = item.Sign });
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public class ViewAboutViewModel : ViewModelBase
|
||||
private void ExecuteCheckUpdateCommand()
|
||||
{
|
||||
//eventAggregator.GetEvent<MessageEvent>().Publish("开始查找更新,请稍后~");
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish("请前往主页下载最新版~");
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish("请前往主页下载最新版~");
|
||||
}
|
||||
|
||||
// 意见反馈事件
|
||||
@@ -292,7 +292,7 @@ public class ViewAboutViewModel : ViewModelBase
|
||||
return;
|
||||
}
|
||||
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(isSucceed
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(isSucceed
|
||||
? DictionaryResource.GetString("TipSettingUpdated")
|
||||
: DictionaryResource.GetString("TipSettingFailed"));
|
||||
}
|
||||
|
||||
@@ -283,11 +283,11 @@ public class ViewBasicViewModel : ViewModelBase
|
||||
|
||||
if (isSucceed)
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipSettingUpdated"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipSettingUpdated"));
|
||||
}
|
||||
else
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipSettingFailed"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipSettingFailed"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -400,11 +400,11 @@ public class ViewDanmakuViewModel : ViewModelBase
|
||||
|
||||
if (isSucceed)
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipSettingUpdated"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipSettingUpdated"));
|
||||
}
|
||||
else
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipSettingFailed"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipSettingFailed"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -462,7 +462,7 @@ public class ViewNetworkViewModel : ViewModelBase
|
||||
var isSucceed = SettingsManager.GetInstance().SetDownloader(downloader);
|
||||
PublishTip(isSucceed);
|
||||
|
||||
var alertService = new AlertService(dialogService);
|
||||
var alertService = new AlertService(DialogService);
|
||||
var result = await alertService.ShowInfo(DictionaryResource.GetString("ConfirmReboot"));
|
||||
if (result == ButtonResult.OK)
|
||||
{
|
||||
@@ -830,11 +830,11 @@ public class ViewNetworkViewModel : ViewModelBase
|
||||
|
||||
if (isSucceed)
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipSettingUpdated"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipSettingUpdated"));
|
||||
}
|
||||
else
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipSettingFailed"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipSettingFailed"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -917,11 +917,11 @@ public class ViewVideoViewModel : ViewModelBase
|
||||
|
||||
if (isSucceed)
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipSettingUpdated"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipSettingUpdated"));
|
||||
}
|
||||
else
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipSettingFailed"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipSettingFailed"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public class ViewDelogoViewModel : ViewModelBase
|
||||
{
|
||||
if (isDelogo)
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipWaitTaskFinished"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipWaitTaskFinished"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -117,37 +117,37 @@ public class ViewDelogoViewModel : ViewModelBase
|
||||
{
|
||||
if (isDelogo)
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipWaitTaskFinished"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipWaitTaskFinished"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (VideoPath == "")
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipNoSeletedVideo"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipNoSeletedVideo"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (LogoWidth == -1)
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipInputRightLogoWidth"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipInputRightLogoWidth"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (LogoHeight == -1)
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipInputRightLogoHeight"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipInputRightLogoHeight"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (LogoX == -1)
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipInputRightLogoX"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipInputRightLogoX"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (LogoY == -1)
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipInputRightLogoY"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipInputRightLogoY"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ public class ViewExtractMediaViewModel : ViewModelBase
|
||||
{
|
||||
if (isExtracting)
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipWaitTaskFinished"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipWaitTaskFinished"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -93,13 +93,13 @@ public class ViewExtractMediaViewModel : ViewModelBase
|
||||
{
|
||||
if (isExtracting)
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipWaitTaskFinished"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipWaitTaskFinished"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (VideoPaths.Length <= 0)
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipNoSeletedVideo"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipNoSeletedVideo"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -137,13 +137,13 @@ public class ViewExtractMediaViewModel : ViewModelBase
|
||||
{
|
||||
if (isExtracting)
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipWaitTaskFinished"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipWaitTaskFinished"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (VideoPaths.Length <= 0)
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipNoSeletedVideo"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipNoSeletedVideo"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ public class ViewArchiveViewModel : ViewModelBase
|
||||
};
|
||||
|
||||
// 进入视频页面
|
||||
NavigateToView.NavigationView(eventAggregator, ViewPublicationViewModel.Tag, ViewUserSpaceViewModel.Tag,
|
||||
NavigateToView.NavigationView(EventAggregator, ViewPublicationViewModel.Tag, ViewUserSpaceViewModel.Tag,
|
||||
data);
|
||||
|
||||
SelectedItem = -1;
|
||||
|
||||
@@ -97,7 +97,7 @@ public class ViewSeasonsSeriesViewModel : ViewModelBase
|
||||
ParentViewName = ViewUserSpaceViewModel.Tag,
|
||||
Parameter = data
|
||||
};
|
||||
eventAggregator.GetEvent<NavigationEvent>().Publish(param);
|
||||
EventAggregator.GetEvent<NavigationEvent>().Publish(param);
|
||||
|
||||
SelectedItem = -1;
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public class ViewDownloadManagerViewModel : ViewModelBase
|
||||
ParentViewName = null,
|
||||
Parameter = null
|
||||
};
|
||||
eventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
EventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
}
|
||||
|
||||
// 左侧tab点击事件
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace DownKyi.ViewModels
|
||||
ParentViewName = null,
|
||||
Parameter = null
|
||||
};
|
||||
eventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
EventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
}
|
||||
|
||||
// 顶部tab点击事件
|
||||
|
||||
@@ -145,7 +145,7 @@ public class ViewIndexViewModel : ViewModelBase
|
||||
{
|
||||
if (UserName == null)
|
||||
{
|
||||
NavigateToView.NavigationView(eventAggregator, ViewLoginViewModel.Tag, Tag, null);
|
||||
NavigateToView.NavigationView(EventAggregator, ViewLoginViewModel.Tag, Tag, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -153,7 +153,7 @@ public class ViewIndexViewModel : ViewModelBase
|
||||
var userInfo = SettingsManager.GetInstance().GetUserInfo();
|
||||
if (userInfo != null && userInfo.Mid != -1)
|
||||
{
|
||||
NavigateToView.NavigationView(eventAggregator, ViewMySpaceViewModel.Tag, Tag, userInfo.Mid);
|
||||
NavigateToView.NavigationView(EventAggregator, ViewMySpaceViewModel.Tag, Tag, userInfo.Mid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -169,7 +169,7 @@ public class ViewIndexViewModel : ViewModelBase
|
||||
/// </summary>
|
||||
private void ExecuteSettingsCommand()
|
||||
{
|
||||
NavigateToView.NavigationView(eventAggregator, ViewSettingsViewModel.Tag, Tag, null);
|
||||
NavigateToView.NavigationView(EventAggregator, ViewSettingsViewModel.Tag, Tag, null);
|
||||
}
|
||||
|
||||
// 进入下载管理页面
|
||||
@@ -184,7 +184,7 @@ public class ViewIndexViewModel : ViewModelBase
|
||||
/// </summary>
|
||||
private void ExecuteDownloadManagerCommand()
|
||||
{
|
||||
NavigateToView.NavigationView(eventAggregator, ViewDownloadManagerViewModel.Tag, Tag, null);
|
||||
NavigateToView.NavigationView(EventAggregator, ViewDownloadManagerViewModel.Tag, Tag, null);
|
||||
}
|
||||
|
||||
// 进入工具箱页面
|
||||
@@ -198,7 +198,7 @@ public class ViewIndexViewModel : ViewModelBase
|
||||
/// </summary>
|
||||
private async void ExecuteToolboxCommand()
|
||||
{
|
||||
NavigateToView.NavigationView(eventAggregator, ViewToolboxViewModel.Tag, Tag, null);
|
||||
NavigateToView.NavigationView(EventAggregator, ViewToolboxViewModel.Tag, Tag, null);
|
||||
}
|
||||
|
||||
|
||||
@@ -217,11 +217,11 @@ public class ViewIndexViewModel : ViewModelBase
|
||||
LogManager.Debug(Tag, $"InputText: {InputText}");
|
||||
InputText = Regex.Replace(InputText, @"[【]*[^【]*[^】]*[】 ]", "");
|
||||
SearchService searchService = new SearchService();
|
||||
bool isSupport = searchService.BiliInput(InputText, Tag, eventAggregator);
|
||||
bool isSupport = searchService.BiliInput(InputText, Tag, EventAggregator);
|
||||
if (!isSupport)
|
||||
{
|
||||
// 关键词搜索
|
||||
searchService.SearchKey(InputText, Tag, eventAggregator);
|
||||
searchService.SearchKey(InputText, Tag, EventAggregator);
|
||||
}
|
||||
|
||||
InputText = string.Empty;
|
||||
|
||||
@@ -20,6 +20,8 @@ public class ViewLoginViewModel : ViewModelBase
|
||||
|
||||
private CancellationTokenSource _tokenSource;
|
||||
|
||||
#region 页面属性申明
|
||||
|
||||
private VectorImage _arrowBack;
|
||||
|
||||
public VectorImage ArrowBack
|
||||
@@ -52,6 +54,7 @@ public class ViewLoginViewModel : ViewModelBase
|
||||
set => SetProperty(ref _loginQrCodeStatus, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public ViewLoginViewModel(IEventAggregator eventAggregator) : base(eventAggregator)
|
||||
{
|
||||
@@ -81,7 +84,7 @@ public class ViewLoginViewModel : ViewModelBase
|
||||
ParentViewName = null,
|
||||
Parameter = "login"
|
||||
};
|
||||
eventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
EventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -105,7 +108,7 @@ public class ViewLoginViewModel : ViewModelBase
|
||||
|
||||
if (loginUrl.Data == null || loginUrl.Data.Url == null)
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("GetLoginUrlFailed"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("GetLoginUrlFailed"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -160,7 +163,7 @@ public class ViewLoginViewModel : ViewModelBase
|
||||
// 不匹配的oauthKey,超时或已确认的oauthKey
|
||||
|
||||
// 发送通知
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("LoginTimeOut"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("LoginTimeOut"));
|
||||
LogManager.Info(Tag, DictionaryResource.GetString("LoginTimeOut"));
|
||||
|
||||
// 取消任务
|
||||
@@ -187,17 +190,16 @@ public class ViewLoginViewModel : ViewModelBase
|
||||
// 确认登录
|
||||
|
||||
// 发送通知
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish("登陆成功");
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish("登陆成功");
|
||||
// LogManager.Info(Tag, DictionaryResource.GetString("LoginSuccessful"));
|
||||
|
||||
// 保存登录信息
|
||||
try
|
||||
{
|
||||
System.Console.Out.WriteLine(loginStatus.Data.Url);
|
||||
bool isSucceed = LoginHelper.SaveLoginInfoCookies(loginStatus.Data.Url);
|
||||
if (!isSucceed)
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>()
|
||||
EventAggregator.GetEvent<MessageEvent>()
|
||||
.Publish(DictionaryResource.GetString("LoginFailed"));
|
||||
LogManager.Error(Tag, DictionaryResource.GetString("LoginFailed"));
|
||||
}
|
||||
@@ -206,7 +208,7 @@ public class ViewLoginViewModel : ViewModelBase
|
||||
{
|
||||
Console.PrintLine("PageLogin 保存登录信息发生异常: {0}", e);
|
||||
LogManager.Error(e);
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("LoginFailed"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("LoginFailed"));
|
||||
}
|
||||
|
||||
// TODO 其他操作
|
||||
@@ -214,7 +216,7 @@ public class ViewLoginViewModel : ViewModelBase
|
||||
|
||||
// 取消任务
|
||||
Thread.Sleep(3000);
|
||||
PropertyChangeAsync(ExecuteBackSpace);
|
||||
PropertyChange(ExecuteBackSpace);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,20 +11,19 @@ namespace DownKyi.ViewModels;
|
||||
|
||||
public class ViewModelBase : BindableBase, INavigationAware
|
||||
{
|
||||
protected readonly IEventAggregator eventAggregator;
|
||||
protected IDialogService dialogService;
|
||||
protected readonly IEventAggregator? EventAggregator;
|
||||
protected IDialogService? DialogService;
|
||||
protected string ParentView = string.Empty;
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public ViewModelBase(IEventAggregator eventAggregator)
|
||||
{
|
||||
this.eventAggregator = eventAggregator;
|
||||
EventAggregator = eventAggregator;
|
||||
}
|
||||
|
||||
public ViewModelBase(IEventAggregator eventAggregator, IDialogService dialogService)
|
||||
{
|
||||
this.eventAggregator = eventAggregator;
|
||||
this.dialogService = dialogService;
|
||||
EventAggregator = eventAggregator;
|
||||
DialogService = dialogService;
|
||||
}
|
||||
|
||||
public virtual void OnNavigatedTo(NavigationContext navigationContext)
|
||||
@@ -53,4 +52,13 @@ public class ViewModelBase : BindableBase, INavigationAware
|
||||
{
|
||||
Dispatcher.UIThread.InvokeAsync(callback);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步修改绑定到UI的属性
|
||||
/// </summary>
|
||||
/// <param name="callback"></param>
|
||||
protected void PropertyChange(Action callback)
|
||||
{
|
||||
Dispatcher.UIThread.Invoke(callback);
|
||||
}
|
||||
}
|
||||
@@ -144,7 +144,7 @@ public class ViewMyBangumiFollowViewModel : ViewModelBase
|
||||
public ViewMyBangumiFollowViewModel(IEventAggregator eventAggregator, IDialogService dialogService) : base(
|
||||
eventAggregator)
|
||||
{
|
||||
this.dialogService = dialogService;
|
||||
this.DialogService = dialogService;
|
||||
|
||||
#region 属性初始化
|
||||
|
||||
@@ -199,7 +199,7 @@ public class ViewMyBangumiFollowViewModel : ViewModelBase
|
||||
ParentViewName = null,
|
||||
Parameter = null
|
||||
};
|
||||
eventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
EventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
}
|
||||
|
||||
// 前往下载管理页面
|
||||
@@ -220,7 +220,7 @@ public class ViewMyBangumiFollowViewModel : ViewModelBase
|
||||
ParentViewName = Tag,
|
||||
Parameter = null
|
||||
};
|
||||
eventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
EventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
}
|
||||
|
||||
// 顶部tab点击事件
|
||||
@@ -358,7 +358,7 @@ public class ViewMyBangumiFollowViewModel : ViewModelBase
|
||||
AddToDownloadService addToDownloadService = new AddToDownloadService(PlayStreamType.BANGUMI);
|
||||
|
||||
// 选择文件夹
|
||||
string directory = await addToDownloadService.SetDirectory(dialogService);
|
||||
string directory = await addToDownloadService.SetDirectory(DialogService);
|
||||
|
||||
// 视频计数
|
||||
int i = 0;
|
||||
@@ -387,7 +387,7 @@ public class ViewMyBangumiFollowViewModel : ViewModelBase
|
||||
addToDownloadService.GetVideo();
|
||||
addToDownloadService.ParseVideo(service);
|
||||
// 下载
|
||||
i += addToDownloadService.AddToDownload(eventAggregator, directory);
|
||||
i += addToDownloadService.AddToDownload(EventAggregator, directory);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -399,11 +399,11 @@ public class ViewMyBangumiFollowViewModel : ViewModelBase
|
||||
// 通知用户添加到下载列表的结果
|
||||
if (i <= 0)
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
|
||||
}
|
||||
else
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>()
|
||||
EventAggregator.GetEvent<MessageEvent>()
|
||||
.Publish(
|
||||
$"{DictionaryResource.GetString("TipAddDownloadingFinished1")}{i}{DictionaryResource.GetString("TipAddDownloadingFinished2")}");
|
||||
}
|
||||
@@ -507,7 +507,7 @@ public class ViewMyBangumiFollowViewModel : ViewModelBase
|
||||
|
||||
App.PropertyChangeAsync(() =>
|
||||
{
|
||||
BangumiFollowMedia media = new BangumiFollowMedia(eventAggregator)
|
||||
BangumiFollowMedia media = new BangumiFollowMedia(EventAggregator)
|
||||
{
|
||||
MediaId = bangumiFollow.MediaId,
|
||||
SeasonId = bangumiFollow.SeasonId,
|
||||
|
||||
@@ -176,7 +176,7 @@ public class ViewMyFavoritesViewModel : ViewModelBase
|
||||
public ViewMyFavoritesViewModel(IEventAggregator eventAggregator, IDialogService dialogService) : base(
|
||||
eventAggregator)
|
||||
{
|
||||
this.dialogService = dialogService;
|
||||
this.DialogService = dialogService;
|
||||
|
||||
#region 属性初始化
|
||||
|
||||
@@ -231,7 +231,7 @@ public class ViewMyFavoritesViewModel : ViewModelBase
|
||||
ParentViewName = null,
|
||||
Parameter = null
|
||||
};
|
||||
eventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
EventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
}
|
||||
|
||||
// 前往下载管理页面
|
||||
@@ -252,7 +252,7 @@ public class ViewMyFavoritesViewModel : ViewModelBase
|
||||
ParentViewName = Tag,
|
||||
Parameter = null
|
||||
};
|
||||
eventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
EventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
}
|
||||
|
||||
// 左侧tab点击事件
|
||||
@@ -389,7 +389,7 @@ public class ViewMyFavoritesViewModel : ViewModelBase
|
||||
AddToDownloadService addToDownloadService = new AddToDownloadService(PlayStreamType.VIDEO);
|
||||
|
||||
// 选择文件夹
|
||||
string directory = await addToDownloadService.SetDirectory(dialogService);
|
||||
string directory = await addToDownloadService.SetDirectory(DialogService);
|
||||
|
||||
// 视频计数
|
||||
int i = 0;
|
||||
@@ -417,7 +417,7 @@ public class ViewMyFavoritesViewModel : ViewModelBase
|
||||
addToDownloadService.GetVideo();
|
||||
addToDownloadService.ParseVideo(videoInfoService);
|
||||
// 下载
|
||||
i += addToDownloadService.AddToDownload(eventAggregator, directory);
|
||||
i += addToDownloadService.AddToDownload(EventAggregator, directory);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -429,11 +429,11 @@ public class ViewMyFavoritesViewModel : ViewModelBase
|
||||
// 通知用户添加到下载列表的结果
|
||||
if (i <= 0)
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
|
||||
}
|
||||
else
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>()
|
||||
EventAggregator.GetEvent<MessageEvent>()
|
||||
.Publish(
|
||||
$"{DictionaryResource.GetString("TipAddDownloadingFinished1")}{i}{DictionaryResource.GetString("TipAddDownloadingFinished2")}");
|
||||
}
|
||||
@@ -489,7 +489,7 @@ public class ViewMyFavoritesViewModel : ViewModelBase
|
||||
MediaNoDataVisibility = false;
|
||||
|
||||
var service = new FavoritesService();
|
||||
service.GetFavoritesMediaList(medias, Medias, eventAggregator, cancellationToken);
|
||||
service.GetFavoritesMediaList(medias, Medias, EventAggregator, cancellationToken);
|
||||
}), (tokenSource2 = new CancellationTokenSource()).Token);
|
||||
|
||||
IsEnabled = true;
|
||||
|
||||
@@ -109,7 +109,7 @@ public class ViewMyHistoryViewModel : ViewModelBase
|
||||
public ViewMyHistoryViewModel(IEventAggregator eventAggregator, IDialogService dialogService) : base(
|
||||
eventAggregator)
|
||||
{
|
||||
this.dialogService = dialogService;
|
||||
this.DialogService = dialogService;
|
||||
|
||||
#region 属性初始化
|
||||
|
||||
@@ -158,7 +158,7 @@ public class ViewMyHistoryViewModel : ViewModelBase
|
||||
ParentViewName = null,
|
||||
Parameter = null
|
||||
};
|
||||
eventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
EventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
}
|
||||
|
||||
// 前往下载管理页面
|
||||
@@ -179,7 +179,7 @@ public class ViewMyHistoryViewModel : ViewModelBase
|
||||
ParentViewName = Tag,
|
||||
Parameter = null
|
||||
};
|
||||
eventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
EventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
}
|
||||
|
||||
// 全选按钮点击事件
|
||||
@@ -279,7 +279,7 @@ public class ViewMyHistoryViewModel : ViewModelBase
|
||||
AddToDownloadService addToDownloadService = new AddToDownloadService(PlayStreamType.VIDEO);
|
||||
|
||||
// 选择文件夹
|
||||
string directory = await addToDownloadService.SetDirectory(dialogService);
|
||||
string directory = await addToDownloadService.SetDirectory(DialogService);
|
||||
|
||||
// 视频计数
|
||||
int i = 0;
|
||||
@@ -321,7 +321,7 @@ public class ViewMyHistoryViewModel : ViewModelBase
|
||||
addToDownloadService.GetVideo();
|
||||
addToDownloadService.ParseVideo(service);
|
||||
// 下载
|
||||
i += addToDownloadService.AddToDownload(eventAggregator, directory);
|
||||
i += addToDownloadService.AddToDownload(EventAggregator, directory);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -333,11 +333,11 @@ public class ViewMyHistoryViewModel : ViewModelBase
|
||||
// 通知用户添加到下载列表的结果
|
||||
if (i <= 0)
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
|
||||
}
|
||||
else
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>()
|
||||
EventAggregator.GetEvent<MessageEvent>()
|
||||
.Publish(
|
||||
$"{DictionaryResource.GetString("TipAddDownloadingFinished1")}{i}{DictionaryResource.GetString("TipAddDownloadingFinished2")}");
|
||||
}
|
||||
@@ -493,7 +493,7 @@ public class ViewMyHistoryViewModel : ViewModelBase
|
||||
Format.FormatDuration3(history.Progress);
|
||||
}
|
||||
|
||||
HistoryMedia media = new HistoryMedia(eventAggregator)
|
||||
HistoryMedia media = new HistoryMedia(EventAggregator)
|
||||
{
|
||||
Business = history.History.Business,
|
||||
Bvid = history.History.Bvid,
|
||||
|
||||
@@ -341,7 +341,7 @@ public class ViewMySpaceViewModel : ViewModelBase
|
||||
ParentViewName = null,
|
||||
Parameter = null
|
||||
};
|
||||
eventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
EventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
}
|
||||
|
||||
// 退出登录事件
|
||||
@@ -365,7 +365,7 @@ public class ViewMySpaceViewModel : ViewModelBase
|
||||
ParentViewName = null,
|
||||
Parameter = "logout"
|
||||
};
|
||||
eventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
EventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
}
|
||||
|
||||
// 页面选择事件
|
||||
@@ -394,15 +394,15 @@ public class ViewMySpaceViewModel : ViewModelBase
|
||||
{
|
||||
case 0:
|
||||
data["friendId"] = 0;
|
||||
NavigateToView.NavigationView(eventAggregator, ViewFriendsViewModel.Tag, Tag, data);
|
||||
NavigateToView.NavigationView(EventAggregator, ViewFriendsViewModel.Tag, Tag, data);
|
||||
break;
|
||||
case 1:
|
||||
data["friendId"] = 0;
|
||||
NavigateToView.NavigationView(eventAggregator, ViewFriendsViewModel.Tag, Tag, data);
|
||||
NavigateToView.NavigationView(EventAggregator, ViewFriendsViewModel.Tag, Tag, data);
|
||||
break;
|
||||
case 2:
|
||||
data["friendId"] = 1;
|
||||
NavigateToView.NavigationView(eventAggregator, ViewFriendsViewModel.Tag, Tag, data);
|
||||
NavigateToView.NavigationView(EventAggregator, ViewFriendsViewModel.Tag, Tag, data);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -432,16 +432,16 @@ public class ViewMySpaceViewModel : ViewModelBase
|
||||
switch (SelectedPackage)
|
||||
{
|
||||
case 0:
|
||||
NavigateToView.NavigationView(eventAggregator, ViewMyFavoritesViewModel.Tag, Tag, mid);
|
||||
NavigateToView.NavigationView(EventAggregator, ViewMyFavoritesViewModel.Tag, Tag, mid);
|
||||
break;
|
||||
case 1:
|
||||
NavigateToView.NavigationView(eventAggregator, ViewMyBangumiFollowViewModel.Tag, Tag, mid);
|
||||
NavigateToView.NavigationView(EventAggregator, ViewMyBangumiFollowViewModel.Tag, Tag, mid);
|
||||
break;
|
||||
case 2:
|
||||
NavigateToView.NavigationView(eventAggregator, ViewMyToViewVideoViewModel.Tag, Tag, mid);
|
||||
NavigateToView.NavigationView(EventAggregator, ViewMyToViewVideoViewModel.Tag, Tag, mid);
|
||||
break;
|
||||
case 3:
|
||||
NavigateToView.NavigationView(eventAggregator, ViewMyHistoryViewModel.Tag, Tag, mid);
|
||||
NavigateToView.NavigationView(EventAggregator, ViewMyHistoryViewModel.Tag, Tag, mid);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -105,7 +105,7 @@ public class ViewMyToViewVideoViewModel : ViewModelBase
|
||||
public ViewMyToViewVideoViewModel(IEventAggregator eventAggregator, IDialogService dialogService) : base(
|
||||
eventAggregator)
|
||||
{
|
||||
this.dialogService = dialogService;
|
||||
this.DialogService = dialogService;
|
||||
|
||||
#region 属性初始化
|
||||
|
||||
@@ -154,7 +154,7 @@ public class ViewMyToViewVideoViewModel : ViewModelBase
|
||||
ParentViewName = null,
|
||||
Parameter = null
|
||||
};
|
||||
eventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
EventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
}
|
||||
|
||||
// 前往下载管理页面
|
||||
@@ -175,7 +175,7 @@ public class ViewMyToViewVideoViewModel : ViewModelBase
|
||||
ParentViewName = Tag,
|
||||
Parameter = null
|
||||
};
|
||||
eventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
EventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
}
|
||||
|
||||
// 全选按钮点击事件
|
||||
@@ -275,7 +275,7 @@ public class ViewMyToViewVideoViewModel : ViewModelBase
|
||||
AddToDownloadService addToDownloadService = new AddToDownloadService(PlayStreamType.VIDEO);
|
||||
|
||||
// 选择文件夹
|
||||
string directory = await addToDownloadService.SetDirectory(dialogService);
|
||||
string directory = await addToDownloadService.SetDirectory(DialogService);
|
||||
|
||||
// 视频计数
|
||||
int i = 0;
|
||||
@@ -303,7 +303,7 @@ public class ViewMyToViewVideoViewModel : ViewModelBase
|
||||
addToDownloadService.GetVideo();
|
||||
addToDownloadService.ParseVideo(videoInfoService);
|
||||
// 下载
|
||||
i += addToDownloadService.AddToDownload(eventAggregator, directory);
|
||||
i += addToDownloadService.AddToDownload(EventAggregator, directory);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -315,11 +315,11 @@ public class ViewMyToViewVideoViewModel : ViewModelBase
|
||||
// 通知用户添加到下载列表的结果
|
||||
if (i <= 0)
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
|
||||
}
|
||||
else
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>()
|
||||
EventAggregator.GetEvent<MessageEvent>()
|
||||
.Publish(
|
||||
$"{DictionaryResource.GetString("TipAddDownloadingFinished1")}{i}{DictionaryResource.GetString("TipAddDownloadingFinished2")}");
|
||||
}
|
||||
@@ -382,7 +382,7 @@ public class ViewMyToViewVideoViewModel : ViewModelBase
|
||||
|
||||
App.PropertyChangeAsync(() =>
|
||||
{
|
||||
ToViewMedia media = new ToViewMedia(eventAggregator)
|
||||
ToViewMedia media = new ToViewMedia(EventAggregator)
|
||||
{
|
||||
Aid = toView.Aid,
|
||||
Bvid = toView.Bvid,
|
||||
|
||||
@@ -128,7 +128,7 @@ public class ViewPublicFavoritesViewModel : ViewModelBase
|
||||
public ViewPublicFavoritesViewModel(IEventAggregator eventAggregator, IDialogService dialogService) : base(
|
||||
eventAggregator)
|
||||
{
|
||||
this.dialogService = dialogService;
|
||||
this.DialogService = dialogService;
|
||||
|
||||
#region 属性初始化
|
||||
|
||||
@@ -177,7 +177,7 @@ public class ViewPublicFavoritesViewModel : ViewModelBase
|
||||
ParentViewName = null,
|
||||
Parameter = null
|
||||
};
|
||||
eventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
EventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
}
|
||||
|
||||
// 前往下载管理页面
|
||||
@@ -198,7 +198,7 @@ public class ViewPublicFavoritesViewModel : ViewModelBase
|
||||
ParentViewName = Tag,
|
||||
Parameter = null
|
||||
};
|
||||
eventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
EventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
}
|
||||
|
||||
// 复制封面事件
|
||||
@@ -243,7 +243,7 @@ public class ViewPublicFavoritesViewModel : ViewModelBase
|
||||
/// </summary>
|
||||
private void ExecuteUpperCommand()
|
||||
{
|
||||
NavigateToView.NavigateToViewUserSpace(eventAggregator, Tag, Favorites.UpperMid);
|
||||
NavigateToView.NavigateToViewUserSpace(EventAggregator, Tag, Favorites.UpperMid);
|
||||
}
|
||||
|
||||
// 添加选中项到下载列表事件
|
||||
@@ -300,7 +300,7 @@ public class ViewPublicFavoritesViewModel : ViewModelBase
|
||||
AddToDownloadService addToDownloadService = new AddToDownloadService(PlayStreamType.VIDEO);
|
||||
|
||||
// 选择文件夹
|
||||
string directory = await addToDownloadService.SetDirectory(dialogService);
|
||||
string directory = await addToDownloadService.SetDirectory(DialogService);
|
||||
|
||||
// 视频计数
|
||||
int i = 0;
|
||||
@@ -328,7 +328,7 @@ public class ViewPublicFavoritesViewModel : ViewModelBase
|
||||
addToDownloadService.GetVideo();
|
||||
addToDownloadService.ParseVideo(videoInfoService);
|
||||
// 下载
|
||||
i += addToDownloadService.AddToDownload(eventAggregator, directory);
|
||||
i += addToDownloadService.AddToDownload(EventAggregator, directory);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -340,11 +340,11 @@ public class ViewPublicFavoritesViewModel : ViewModelBase
|
||||
// 通知用户添加到下载列表的结果
|
||||
if (i <= 0)
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
|
||||
}
|
||||
else
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>()
|
||||
EventAggregator.GetEvent<MessageEvent>()
|
||||
.Publish(
|
||||
$"{DictionaryResource.GetString("TipAddDownloadingFinished1")}{i}{DictionaryResource.GetString("TipAddDownloadingFinished2")}");
|
||||
}
|
||||
@@ -412,7 +412,7 @@ public class ViewPublicFavoritesViewModel : ViewModelBase
|
||||
MediaNoDataVisibility = false;
|
||||
}
|
||||
|
||||
favoritesService.GetFavoritesMediaList(medias, FavoritesMedias, eventAggregator, cancellationToken);
|
||||
favoritesService.GetFavoritesMediaList(medias, FavoritesMedias, EventAggregator, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace DownKyi.ViewModels
|
||||
public ViewPublicationViewModel(IEventAggregator eventAggregator, IDialogService dialogService) : base(
|
||||
eventAggregator)
|
||||
{
|
||||
this.dialogService = dialogService;
|
||||
this.DialogService = dialogService;
|
||||
|
||||
#region 属性初始化
|
||||
|
||||
@@ -186,7 +186,7 @@ namespace DownKyi.ViewModels
|
||||
ParentViewName = null,
|
||||
Parameter = null
|
||||
};
|
||||
eventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
EventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
}
|
||||
|
||||
// 前往下载管理页面
|
||||
@@ -207,7 +207,7 @@ namespace DownKyi.ViewModels
|
||||
ParentViewName = Tag,
|
||||
Parameter = null
|
||||
};
|
||||
eventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
EventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
}
|
||||
|
||||
// 左侧tab点击事件
|
||||
@@ -343,7 +343,7 @@ namespace DownKyi.ViewModels
|
||||
AddToDownloadService addToDownloadService = new AddToDownloadService(PlayStreamType.VIDEO);
|
||||
|
||||
// 选择文件夹
|
||||
string directory = await addToDownloadService.SetDirectory(dialogService);
|
||||
string directory = await addToDownloadService.SetDirectory(DialogService);
|
||||
|
||||
// 视频计数
|
||||
int i = 0;
|
||||
@@ -371,7 +371,7 @@ namespace DownKyi.ViewModels
|
||||
addToDownloadService.GetVideo();
|
||||
addToDownloadService.ParseVideo(videoInfoService);
|
||||
// 下载
|
||||
i += addToDownloadService.AddToDownload(eventAggregator, directory);
|
||||
i += addToDownloadService.AddToDownload(EventAggregator, directory);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -383,11 +383,11 @@ namespace DownKyi.ViewModels
|
||||
// 通知用户添加到下载列表的结果
|
||||
if (i <= 0)
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
|
||||
}
|
||||
else
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>()
|
||||
EventAggregator.GetEvent<MessageEvent>()
|
||||
.Publish(
|
||||
$"{DictionaryResource.GetString("TipAddDownloadingFinished1")}{i}{DictionaryResource.GetString("TipAddDownloadingFinished2")}");
|
||||
}
|
||||
@@ -482,7 +482,7 @@ namespace DownKyi.ViewModels
|
||||
|
||||
App.PropertyChangeAsync(() =>
|
||||
{
|
||||
PublicationMedia media = new PublicationMedia(eventAggregator)
|
||||
PublicationMedia media = new PublicationMedia(EventAggregator)
|
||||
{
|
||||
Avid = video.Aid,
|
||||
Bvid = video.Bvid,
|
||||
|
||||
@@ -130,7 +130,7 @@ public class ViewSeasonsSeriesViewModel : ViewModelBase
|
||||
public ViewSeasonsSeriesViewModel(IEventAggregator eventAggregator, IDialogService dialogService) : base(
|
||||
eventAggregator)
|
||||
{
|
||||
this.dialogService = dialogService;
|
||||
this.DialogService = dialogService;
|
||||
|
||||
#region 属性初始化
|
||||
|
||||
@@ -177,7 +177,7 @@ public class ViewSeasonsSeriesViewModel : ViewModelBase
|
||||
ParentViewName = null,
|
||||
Parameter = null
|
||||
};
|
||||
eventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
EventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
}
|
||||
|
||||
// 前往下载管理页面
|
||||
@@ -198,7 +198,7 @@ public class ViewSeasonsSeriesViewModel : ViewModelBase
|
||||
ParentViewName = Tag,
|
||||
Parameter = null
|
||||
};
|
||||
eventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
EventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
}
|
||||
|
||||
// 全选按钮点击事件
|
||||
@@ -299,7 +299,7 @@ public class ViewSeasonsSeriesViewModel : ViewModelBase
|
||||
AddToDownloadService addToDownloadService = new AddToDownloadService(PlayStreamType.VIDEO);
|
||||
|
||||
// 选择文件夹
|
||||
string directory = await addToDownloadService.SetDirectory(dialogService);
|
||||
string directory = await addToDownloadService.SetDirectory(DialogService);
|
||||
|
||||
// 视频计数
|
||||
int i = 0;
|
||||
@@ -327,7 +327,7 @@ public class ViewSeasonsSeriesViewModel : ViewModelBase
|
||||
addToDownloadService.GetVideo();
|
||||
addToDownloadService.ParseVideo(videoInfoService);
|
||||
// 下载
|
||||
i += addToDownloadService.AddToDownload(eventAggregator, directory);
|
||||
i += addToDownloadService.AddToDownload(EventAggregator, directory);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -339,11 +339,11 @@ public class ViewSeasonsSeriesViewModel : ViewModelBase
|
||||
// 通知用户添加到下载列表的结果
|
||||
if (i <= 0)
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
|
||||
}
|
||||
else
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>()
|
||||
EventAggregator.GetEvent<MessageEvent>()
|
||||
.Publish(
|
||||
$"{DictionaryResource.GetString("TipAddDownloadingFinished1")}{i}{DictionaryResource.GetString("TipAddDownloadingFinished2")}");
|
||||
}
|
||||
@@ -545,7 +545,7 @@ public class ViewSeasonsSeriesViewModel : ViewModelBase
|
||||
|
||||
App.PropertyChangeAsync(new Action(() =>
|
||||
{
|
||||
ChannelMedia media = new ChannelMedia(eventAggregator)
|
||||
ChannelMedia media = new ChannelMedia(EventAggregator)
|
||||
{
|
||||
Avid = video.Aid,
|
||||
Bvid = video.Bvid,
|
||||
@@ -643,7 +643,7 @@ public class ViewSeasonsSeriesViewModel : ViewModelBase
|
||||
|
||||
App.PropertyChangeAsync(new Action(() =>
|
||||
{
|
||||
ChannelMedia media = new ChannelMedia(eventAggregator)
|
||||
ChannelMedia media = new ChannelMedia(EventAggregator)
|
||||
{
|
||||
Avid = video.Aid,
|
||||
Bvid = video.Bvid,
|
||||
|
||||
@@ -87,7 +87,7 @@ public class ViewSettingsViewModel : ViewModelBase
|
||||
ParentViewName = null,
|
||||
Parameter = null
|
||||
};
|
||||
eventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
EventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
}
|
||||
|
||||
// 左侧tab点击事件
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace DownKyi.ViewModels
|
||||
ParentViewName = null,
|
||||
Parameter = null
|
||||
};
|
||||
eventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
EventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
}
|
||||
|
||||
// 左侧tab点击事件
|
||||
|
||||
@@ -222,7 +222,7 @@ public class ViewUserSpaceViewModel : ViewModelBase
|
||||
ParentViewName = null,
|
||||
Parameter = null
|
||||
};
|
||||
eventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
EventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
}
|
||||
|
||||
// 左侧tab点击事件
|
||||
@@ -303,11 +303,11 @@ public class ViewUserSpaceViewModel : ViewModelBase
|
||||
{
|
||||
case 0:
|
||||
data["friendId"] = 0;
|
||||
NavigateToView.NavigationView(eventAggregator, ViewFriendsViewModel.Tag, parentViewName, data);
|
||||
NavigateToView.NavigationView(EventAggregator, ViewFriendsViewModel.Tag, parentViewName, data);
|
||||
break;
|
||||
case 1:
|
||||
data["friendId"] = 1;
|
||||
NavigateToView.NavigationView(eventAggregator, ViewFriendsViewModel.Tag, parentViewName, data);
|
||||
NavigateToView.NavigationView(EventAggregator, ViewFriendsViewModel.Tag, parentViewName, data);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ public class ViewVideoDetailViewModel : ViewModelBase
|
||||
ParentViewName = null,
|
||||
Parameter = null
|
||||
};
|
||||
eventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
EventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
}
|
||||
|
||||
// 前往下载管理页面
|
||||
@@ -192,7 +192,7 @@ public class ViewVideoDetailViewModel : ViewModelBase
|
||||
ParentViewName = Tag,
|
||||
Parameter = null
|
||||
};
|
||||
eventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
EventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
|
||||
}
|
||||
|
||||
// 输入确认事件
|
||||
@@ -330,7 +330,7 @@ public class ViewVideoDetailViewModel : ViewModelBase
|
||||
/// </summary>
|
||||
private void ExecuteUpperCommand()
|
||||
{
|
||||
NavigateToView.NavigateToViewUserSpace(eventAggregator, Tag, VideoInfoView.UpperMid);
|
||||
NavigateToView.NavigateToViewUserSpace(EventAggregator, Tag, VideoInfoView.UpperMid);
|
||||
}
|
||||
|
||||
// 视频章节选择事件
|
||||
@@ -420,6 +420,57 @@ public class ViewVideoDetailViewModel : ViewModelBase
|
||||
}
|
||||
}
|
||||
|
||||
// 解析视频流事件
|
||||
private DelegateCommand<object> parseCommand;
|
||||
|
||||
public DelegateCommand<object> ParseCommand => parseCommand ??
|
||||
(parseCommand = new DelegateCommand<object>(ExecuteParseCommand,
|
||||
CanExecuteParseCommand));
|
||||
|
||||
/// <summary>
|
||||
/// 解析视频流事件
|
||||
/// </summary>
|
||||
/// <param name="parameter"></param>
|
||||
private async void ExecuteParseCommand(object parameter)
|
||||
{
|
||||
if (!(parameter is VideoPage videoPage))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LoadingVisibility = true;
|
||||
|
||||
try
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
LogManager.Debug(Tag, $"Video Page: {videoPage.Cid}");
|
||||
|
||||
UnityUpdateView(ParseVideo, input, videoPage, true);
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.PrintLine("ParseCommand()发生异常: {0}", e);
|
||||
LogManager.Error(Tag, e);
|
||||
|
||||
LoadingVisibility = false;
|
||||
}
|
||||
|
||||
LoadingVisibility = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析视频流事件是否允许执行
|
||||
/// </summary>
|
||||
/// <param name="parameter"></param>
|
||||
/// <returns></returns>
|
||||
private bool CanExecuteParseCommand(object parameter)
|
||||
{
|
||||
return LoadingVisibility != true;
|
||||
}
|
||||
|
||||
|
||||
// 解析所有视频流事件
|
||||
private DelegateCommand parseAllVideoCommand;
|
||||
|
||||
@@ -431,8 +482,6 @@ public class ViewVideoDetailViewModel : ViewModelBase
|
||||
/// </summary>
|
||||
private async void ExecuteParseAllVideoCommand()
|
||||
{
|
||||
LoadingVisibility = true;
|
||||
|
||||
// 解析范围
|
||||
ParseScope parseScope = SettingsManager.GetInstance().GetParseScope();
|
||||
|
||||
@@ -440,7 +489,7 @@ public class ViewVideoDetailViewModel : ViewModelBase
|
||||
if (parseScope == ParseScope.NONE)
|
||||
{
|
||||
//打开解析选择器
|
||||
dialogService.ShowDialog(ViewParsingSelectorViewModel.Tag, null, async result =>
|
||||
DialogService.ShowDialog(ViewParsingSelectorViewModel.Tag, null, async result =>
|
||||
{
|
||||
if (result.Result == ButtonResult.OK)
|
||||
{
|
||||
@@ -448,10 +497,6 @@ public class ViewVideoDetailViewModel : ViewModelBase
|
||||
parseScope = result.Parameters.GetValue<ParseScope>("parseScope");
|
||||
await ExecuteParse(parseScope);
|
||||
}
|
||||
else
|
||||
{
|
||||
loadingVisibility = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
@@ -473,6 +518,7 @@ public class ViewVideoDetailViewModel : ViewModelBase
|
||||
{
|
||||
try
|
||||
{
|
||||
LoadingVisibility = true;
|
||||
await Task.Run(() =>
|
||||
{
|
||||
LogManager.Debug(Tag, "Parse video");
|
||||
@@ -737,7 +783,7 @@ public class ViewVideoDetailViewModel : ViewModelBase
|
||||
}
|
||||
|
||||
// 选择文件夹
|
||||
string directory = await addToDownloadService.SetDirectory(dialogService);
|
||||
string directory = await addToDownloadService.SetDirectory(DialogService);
|
||||
|
||||
// 视频计数
|
||||
int i = 0;
|
||||
@@ -747,7 +793,7 @@ public class ViewVideoDetailViewModel : ViewModelBase
|
||||
addToDownloadService.GetVideo(VideoInfoView, VideoSections.ToList(),
|
||||
selectedVideoPages.Select(video => video.Order).ToList());
|
||||
// 下载
|
||||
i = addToDownloadService.AddToDownload(eventAggregator, directory, isAll);
|
||||
i = addToDownloadService.AddToDownload(EventAggregator, directory, isAll);
|
||||
});
|
||||
|
||||
if (directory == null)
|
||||
@@ -758,11 +804,11 @@ public class ViewVideoDetailViewModel : ViewModelBase
|
||||
// 通知用户添加到下载列表的结果
|
||||
if (i <= 0)
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
|
||||
EventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
|
||||
}
|
||||
else
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>()
|
||||
EventAggregator.GetEvent<MessageEvent>()
|
||||
.Publish(
|
||||
$"{DictionaryResource.GetString("TipAddDownloadingFinished1")}{i}{DictionaryResource.GetString("TipAddDownloadingFinished2")}");
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:converter="clr-namespace:DownKyi.Converter"
|
||||
x:Class="DownKyi.Views.DownloadManager.ViewDownloadFinished"
|
||||
xmlns:vmdm="clr-namespace:DownKyi.ViewModels.DownloadManager"
|
||||
x:DataType="vmdm:ViewDownloadFinishedViewModel"
|
||||
xmlns:i="using:Avalonia.Xaml.Interactivity"
|
||||
xmlns:ia="clr-namespace:Avalonia.Xaml.Interactions.Core;assembly=Avalonia.Xaml.Interactions">
|
||||
<UserControl.Resources>
|
||||
<converter:CountConverter x:Key="CountConverter" Count="0" />
|
||||
|
||||
<ControlTheme x:Key="DownloadedStyle" TargetType="{x:Type ListBoxItem}" x:DataType="vmdm:DownloadedItem">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
@@ -240,6 +243,18 @@
|
||||
Width="256"
|
||||
Height="256"
|
||||
Source="/Resources/nodata02.png">
|
||||
<i:Interaction.Behaviors>
|
||||
<ia:DataTriggerBehavior Binding="{Binding DownloadedList}" Value="{x:Null}">
|
||||
<ia:ChangePropertyAction PropertyName="IsVisible" Value="True" />
|
||||
</ia:DataTriggerBehavior>
|
||||
<ia:DataTriggerBehavior Binding="{Binding DownloadedList.Count}" Value="0">
|
||||
<ia:ChangePropertyAction PropertyName="IsVisible" Value="True" />
|
||||
</ia:DataTriggerBehavior>
|
||||
<ia:DataTriggerBehavior
|
||||
Binding="{Binding DownloadedList.Count, Converter={StaticResource CountConverter}}" Value="true">
|
||||
<ia:ChangePropertyAction PropertyName="IsVisible" Value="False" />
|
||||
</ia:DataTriggerBehavior>
|
||||
</i:Interaction.Behaviors>
|
||||
</Image>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -307,6 +307,18 @@
|
||||
Width="256"
|
||||
Height="256"
|
||||
Source="/Resources/nodata02.png">
|
||||
<i:Interaction.Behaviors>
|
||||
<ia:DataTriggerBehavior Binding="{Binding DownloadingList}" Value="{x:Null}">
|
||||
<ia:ChangePropertyAction PropertyName="IsVisible" Value="True" />
|
||||
</ia:DataTriggerBehavior>
|
||||
<ia:DataTriggerBehavior Binding="{Binding DownloadingList.Count}" Value="0">
|
||||
<ia:ChangePropertyAction PropertyName="IsVisible" Value="True" />
|
||||
</ia:DataTriggerBehavior>
|
||||
<ia:DataTriggerBehavior
|
||||
Binding="{Binding DownloadingList.Count, Converter={StaticResource CountConverter}}" Value="true">
|
||||
<ia:ChangePropertyAction PropertyName="IsVisible" Value="False" />
|
||||
</ia:DataTriggerBehavior>
|
||||
</i:Interaction.Behaviors>
|
||||
</Image>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -359,9 +359,6 @@
|
||||
CommandParameter="{Binding ElementName=NameVideoPages1,Path=SelectedItems}" />
|
||||
</ia:EventTriggerBehavior>
|
||||
</i:Interaction.Behaviors>
|
||||
<DataGrid.RowTheme>
|
||||
|
||||
</DataGrid.RowTheme>
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn
|
||||
Width="50"
|
||||
|
||||
Reference in New Issue
Block a user