From 17036f3681c4413386ceed3ef7cbf6547a0eeea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9A=E5=BD=AA?= <1315508912@qq.com> Date: Sun, 17 Dec 2023 18:38:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=AD=A3=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DownKyi.Core/BiliApi/Login/LoginHelper.cs | 5 +- DownKyi.Core/DownKyi.Core.csproj | 7 +- .../Utils/Encryptor/Encryptor.File.cs | 13 +- DownKyi.Core/ffmpeg.config.json | 3 + DownKyi/App.axaml.cs | 8 +- DownKyi/Converter/CountConverter.cs | 4 +- DownKyi/DownKyi.csproj | 1 + .../Download/CustomAriaDownloadService.cs | 466 ++++++++++++++++++ DownKyi/Services/VideoInfoService.cs | 2 +- DownKyi/Utils/PlatformHelper.cs | 2 +- .../DownloadManager/DownloadedItem.cs | 4 +- .../ViewDownloadFinishedViewModel.cs | 4 +- .../ViewDownloadingViewModel.cs | 4 +- .../Friends/ViewFollowerViewModel.cs | 2 +- .../Friends/ViewFollowingViewModel.cs | 2 +- .../ViewModels/Settings/ViewAboutViewModel.cs | 4 +- .../ViewModels/Settings/ViewBasicViewModel.cs | 4 +- .../Settings/ViewDanmakuViewModel.cs | 4 +- .../Settings/ViewNetworkViewModel.cs | 6 +- .../ViewModels/Settings/ViewVideoViewModel.cs | 4 +- .../ViewModels/Toolbox/ViewDelogoViewModel.cs | 14 +- .../Toolbox/ViewExtractMediaViewModel.cs | 10 +- .../UserSpace/ViewArchiveViewModel.cs | 2 +- .../UserSpace/ViewSeasonsSeriesViewModel.cs | 2 +- .../ViewDownloadManagerViewModel.cs | 2 +- DownKyi/ViewModels/ViewFriendsViewModel.cs | 2 +- DownKyi/ViewModels/ViewIndexViewModel.cs | 14 +- DownKyi/ViewModels/ViewLoginViewModel.cs | 18 +- DownKyi/ViewModels/ViewModelBase.cs | 20 +- .../ViewMyBangumiFollowViewModel.cs | 16 +- .../ViewModels/ViewMyFavoritesViewModel.cs | 16 +- DownKyi/ViewModels/ViewMyHistoryViewModel.cs | 16 +- DownKyi/ViewModels/ViewMySpaceViewModel.cs | 18 +- .../ViewModels/ViewMyToViewVideoViewModel.cs | 16 +- .../ViewPublicFavoritesViewModel.cs | 18 +- .../ViewModels/ViewPublicationViewModel.cs | 16 +- .../ViewModels/ViewSeasonsSeriesViewModel.cs | 18 +- DownKyi/ViewModels/ViewSettingsViewModel.cs | 2 +- DownKyi/ViewModels/ViewToolboxViewModel.cs | 2 +- DownKyi/ViewModels/ViewUserSpaceViewModel.cs | 6 +- .../ViewModels/ViewVideoDetailViewModel.cs | 74 ++- .../ViewDownloadFinished.axaml | 15 + .../DownloadManager/ViewDownloading.axaml | 12 + DownKyi/Views/ViewVideoDetail.axaml | 3 - 44 files changed, 715 insertions(+), 166 deletions(-) create mode 100644 DownKyi.Core/ffmpeg.config.json create mode 100644 DownKyi/Services/Download/CustomAriaDownloadService.cs diff --git a/DownKyi.Core/BiliApi/Login/LoginHelper.cs b/DownKyi.Core/BiliApi/Login/LoginHelper.cs index 1136f3c..de4ce2f 100644 --- a/DownKyi.Core/BiliApi/Login/LoginHelper.cs +++ b/DownKyi.Core/BiliApi/Login/LoginHelper.cs @@ -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) diff --git a/DownKyi.Core/DownKyi.Core.csproj b/DownKyi.Core/DownKyi.Core.csproj index 3238b73..6b38c0d 100644 --- a/DownKyi.Core/DownKyi.Core.csproj +++ b/DownKyi.Core/DownKyi.Core.csproj @@ -23,10 +23,13 @@ - + PreserveNewest - + + PreserveNewest + + PreserveNewest diff --git a/DownKyi.Core/Utils/Encryptor/Encryptor.File.cs b/DownKyi.Core/Utils/Encryptor/Encryptor.File.cs index e329d89..ef978f7 100644 --- a/DownKyi.Core/Utils/Encryptor/Encryptor.File.cs +++ b/DownKyi.Core/Utils/Encryptor/Encryptor.File.cs @@ -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; } diff --git a/DownKyi.Core/ffmpeg.config.json b/DownKyi.Core/ffmpeg.config.json new file mode 100644 index 0000000..9631df7 --- /dev/null +++ b/DownKyi.Core/ffmpeg.config.json @@ -0,0 +1,3 @@ +{ + "BinaryFolder": "./ffmpeg" +} \ No newline at end of file diff --git a/DownKyi/App.axaml.cs b/DownKyi/App.axaml.cs index f681d0e..ab25c94 100644 --- a/DownKyi/App.axaml.cs +++ b/DownKyi/App.axaml.cs @@ -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(); } diff --git a/DownKyi/Converter/CountConverter.cs b/DownKyi/Converter/CountConverter.cs index 115a3f5..e0bcc1d 100644 --- a/DownKyi/Converter/CountConverter.cs +++ b/DownKyi/Converter/CountConverter.cs @@ -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(); } diff --git a/DownKyi/DownKyi.csproj b/DownKyi/DownKyi.csproj index d2978b5..c0c3cef 100644 --- a/DownKyi/DownKyi.csproj +++ b/DownKyi/DownKyi.csproj @@ -24,6 +24,7 @@ + diff --git a/DownKyi/Services/Download/CustomAriaDownloadService.cs b/DownKyi/Services/Download/CustomAriaDownloadService.cs new file mode 100644 index 0000000..0ced738 --- /dev/null +++ b/DownKyi/Services/Download/CustomAriaDownloadService.cs @@ -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; + +/// +/// 音视频采用Aria下载,其余采用WebClient下载 +/// +public class CustomAriaDownloadService : DownloadService, IDownloadService +{ + public CustomAriaDownloadService(ObservableCollection downloadingList, + ObservableCollection downloadedList, + IDialogService dialogService + ) : base(downloadingList, downloadedList, dialogService) + { + Tag = "AriaDownloadService"; + } + + #region 音视频 + + /// + /// 下载音频,返回下载文件路径 + /// + /// + /// + public override string DownloadAudio(DownloadingItem downloading) + { + PlayUrlDashVideo downloadAudio = BaseDownloadAudio(downloading); + + return DownloadVideo(downloading, downloadAudio); + } + + /// + /// 下载视频,返回下载文件路径 + /// + /// + /// + public override string DownloadVideo(DownloadingItem downloading) + { + PlayUrlDashVideo downloadVideo = BaseDownloadVideo(downloading); + + return DownloadVideo(downloading, downloadVideo); + } + + /// + /// 将下载音频和视频的函数中相同代码抽象出来 + /// + /// + /// + /// + private string DownloadVideo(DownloadingItem downloading, PlayUrlDashVideo downloadVideo) + { + // 如果为空,说明没有匹配到可下载的音频视频 + if (downloadVideo == null) + { + return null; + } + + // 下载链接 + List urls = new List(); + 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(); + } + + 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 + + /// + /// 下载封面 + /// + /// + public override string DownloadCover(DownloadingItem downloading, string coverUrl, string fileName) + { + return BaseDownloadCover(downloading, coverUrl, fileName); + } + + /// + /// 下载弹幕 + /// + /// + public override string DownloadDanmaku(DownloadingItem downloading) + { + return BaseDownloadDanmaku(downloading); + } + + /// + /// 下载字幕 + /// + /// + public override List DownloadSubtitle(DownloadingItem downloading) + { + return BaseDownloadSubtitle(downloading); + } + + /// + /// 混流音频和视频 + /// + /// + /// + /// + /// + public override string MixedFlow(DownloadingItem downloading, string audioUid, string videoUid) + { + if (videoUid == nullMark) + { + return null; + } + + return BaseMixedFlow(downloading, audioUid, videoUid); + } + + /// + /// 解析视频流的下载链接 + /// + /// + public override void Parse(DownloadingItem downloading) + { + BaseParse(downloading); + } + + /// + /// 停止下载服务(转换await和Task.Wait两种调用形式) + /// + private async Task EndTask() + { + // 停止基本任务 + await BaseEndTask(); + + // 关闭Aria服务器 + await CloseAriaServer(); + } + + /// + /// 停止下载服务 + /// + public void End() + { + Task.Run(EndTask).Wait(); + } + + /// + /// 启动下载服务 + /// + 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(); + } + + /// + /// 强制暂停 + /// + /// + /// + 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"); + } + } + + /// + /// 是否存在于下载列表中 + /// + /// + /// + private async Task 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; + } + } + + /// + /// 关闭Aria服务器 + /// + 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 + } + + /// + /// 采用Aria下载文件 + /// + /// + /// + private DownloadResult DownloadByAria(DownloadingItem downloading, List urls, string path, + string localFileName) + { + // path已斜杠结尾,去掉斜杠 + path = path.TrimEnd('/').TrimEnd('\\'); + + //检查gid对应任务,如果已创建那么直接使用 + //但是代理设置会出现不能随时更新的问题 + + if (downloading.Downloading.Gid != null) + { + Task 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 = 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 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 = 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(); + } +} \ No newline at end of file diff --git a/DownKyi/Services/VideoInfoService.cs b/DownKyi/Services/VideoInfoService.cs index 934fd0e..833e505 100644 --- a/DownKyi/Services/VideoInfoService.cs +++ b/DownKyi/Services/VideoInfoService.cs @@ -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" diff --git a/DownKyi/Utils/PlatformHelper.cs b/DownKyi/Utils/PlatformHelper.cs index cfb3c78..05921db 100644 --- a/DownKyi/Utils/PlatformHelper.cs +++ b/DownKyi/Utils/PlatformHelper.cs @@ -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()) diff --git a/DownKyi/ViewModels/DownloadManager/DownloadedItem.cs b/DownKyi/ViewModels/DownloadManager/DownloadedItem.cs index 8f5e82b..3421810 100644 --- a/DownKyi/ViewModels/DownloadManager/DownloadedItem.cs +++ b/DownKyi/ViewModels/DownloadManager/DownloadedItem.cs @@ -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 { diff --git a/DownKyi/ViewModels/DownloadManager/ViewDownloadFinishedViewModel.cs b/DownKyi/ViewModels/DownloadManager/ViewDownloadFinishedViewModel.cs index 379ed01..d9f104d 100644 --- a/DownKyi/ViewModels/DownloadManager/ViewDownloadFinishedViewModel.cs +++ b/DownKyi/ViewModels/DownloadManager/ViewDownloadFinishedViewModel.cs @@ -110,7 +110,7 @@ namespace DownKyi.ViewModels.DownloadManager /// 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; } } }); diff --git a/DownKyi/ViewModels/DownloadManager/ViewDownloadingViewModel.cs b/DownKyi/ViewModels/DownloadManager/ViewDownloadingViewModel.cs index 9a96a98..07946d6 100644 --- a/DownKyi/ViewModels/DownloadManager/ViewDownloadingViewModel.cs +++ b/DownKyi/ViewModels/DownloadManager/ViewDownloadingViewModel.cs @@ -158,7 +158,7 @@ namespace DownKyi.ViewModels.DownloadManager /// 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; } } }); diff --git a/DownKyi/ViewModels/Friends/ViewFollowerViewModel.cs b/DownKyi/ViewModels/Friends/ViewFollowerViewModel.cs index b8b5d50..0b3801a 100644 --- a/DownKyi/ViewModels/Friends/ViewFollowerViewModel.cs +++ b/DownKyi/ViewModels/Friends/ViewFollowerViewModel.cs @@ -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 }); })); } diff --git a/DownKyi/ViewModels/Friends/ViewFollowingViewModel.cs b/DownKyi/ViewModels/Friends/ViewFollowingViewModel.cs index dfafdc1..5a4b711 100644 --- a/DownKyi/ViewModels/Friends/ViewFollowingViewModel.cs +++ b/DownKyi/ViewModels/Friends/ViewFollowingViewModel.cs @@ -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 }); })); } diff --git a/DownKyi/ViewModels/Settings/ViewAboutViewModel.cs b/DownKyi/ViewModels/Settings/ViewAboutViewModel.cs index a52924a..382e34e 100644 --- a/DownKyi/ViewModels/Settings/ViewAboutViewModel.cs +++ b/DownKyi/ViewModels/Settings/ViewAboutViewModel.cs @@ -110,7 +110,7 @@ public class ViewAboutViewModel : ViewModelBase private void ExecuteCheckUpdateCommand() { //eventAggregator.GetEvent().Publish("开始查找更新,请稍后~"); - eventAggregator.GetEvent().Publish("请前往主页下载最新版~"); + EventAggregator.GetEvent().Publish("请前往主页下载最新版~"); } // 意见反馈事件 @@ -292,7 +292,7 @@ public class ViewAboutViewModel : ViewModelBase return; } - eventAggregator.GetEvent().Publish(isSucceed + EventAggregator.GetEvent().Publish(isSucceed ? DictionaryResource.GetString("TipSettingUpdated") : DictionaryResource.GetString("TipSettingFailed")); } diff --git a/DownKyi/ViewModels/Settings/ViewBasicViewModel.cs b/DownKyi/ViewModels/Settings/ViewBasicViewModel.cs index f390e62..1e6256e 100644 --- a/DownKyi/ViewModels/Settings/ViewBasicViewModel.cs +++ b/DownKyi/ViewModels/Settings/ViewBasicViewModel.cs @@ -283,11 +283,11 @@ public class ViewBasicViewModel : ViewModelBase if (isSucceed) { - eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipSettingUpdated")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipSettingUpdated")); } else { - eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipSettingFailed")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipSettingFailed")); } } } \ No newline at end of file diff --git a/DownKyi/ViewModels/Settings/ViewDanmakuViewModel.cs b/DownKyi/ViewModels/Settings/ViewDanmakuViewModel.cs index 232dbe1..26b3e63 100644 --- a/DownKyi/ViewModels/Settings/ViewDanmakuViewModel.cs +++ b/DownKyi/ViewModels/Settings/ViewDanmakuViewModel.cs @@ -400,11 +400,11 @@ public class ViewDanmakuViewModel : ViewModelBase if (isSucceed) { - eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipSettingUpdated")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipSettingUpdated")); } else { - eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipSettingFailed")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipSettingFailed")); } } } \ No newline at end of file diff --git a/DownKyi/ViewModels/Settings/ViewNetworkViewModel.cs b/DownKyi/ViewModels/Settings/ViewNetworkViewModel.cs index b61f309..c7161af 100644 --- a/DownKyi/ViewModels/Settings/ViewNetworkViewModel.cs +++ b/DownKyi/ViewModels/Settings/ViewNetworkViewModel.cs @@ -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().Publish(DictionaryResource.GetString("TipSettingUpdated")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipSettingUpdated")); } else { - eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipSettingFailed")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipSettingFailed")); } } } \ No newline at end of file diff --git a/DownKyi/ViewModels/Settings/ViewVideoViewModel.cs b/DownKyi/ViewModels/Settings/ViewVideoViewModel.cs index 12731d2..659b952 100644 --- a/DownKyi/ViewModels/Settings/ViewVideoViewModel.cs +++ b/DownKyi/ViewModels/Settings/ViewVideoViewModel.cs @@ -917,11 +917,11 @@ public class ViewVideoViewModel : ViewModelBase if (isSucceed) { - eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipSettingUpdated")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipSettingUpdated")); } else { - eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipSettingFailed")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipSettingFailed")); } } } \ No newline at end of file diff --git a/DownKyi/ViewModels/Toolbox/ViewDelogoViewModel.cs b/DownKyi/ViewModels/Toolbox/ViewDelogoViewModel.cs index 83a5dce..3dc6e28 100644 --- a/DownKyi/ViewModels/Toolbox/ViewDelogoViewModel.cs +++ b/DownKyi/ViewModels/Toolbox/ViewDelogoViewModel.cs @@ -97,7 +97,7 @@ public class ViewDelogoViewModel : ViewModelBase { if (isDelogo) { - eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipWaitTaskFinished")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipWaitTaskFinished")); return; } @@ -117,37 +117,37 @@ public class ViewDelogoViewModel : ViewModelBase { if (isDelogo) { - eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipWaitTaskFinished")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipWaitTaskFinished")); return; } if (VideoPath == "") { - eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipNoSeletedVideo")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipNoSeletedVideo")); return; } if (LogoWidth == -1) { - eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipInputRightLogoWidth")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipInputRightLogoWidth")); return; } if (LogoHeight == -1) { - eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipInputRightLogoHeight")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipInputRightLogoHeight")); return; } if (LogoX == -1) { - eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipInputRightLogoX")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipInputRightLogoX")); return; } if (LogoY == -1) { - eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipInputRightLogoY")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipInputRightLogoY")); return; } diff --git a/DownKyi/ViewModels/Toolbox/ViewExtractMediaViewModel.cs b/DownKyi/ViewModels/Toolbox/ViewExtractMediaViewModel.cs index 3d009ce..9f61628 100644 --- a/DownKyi/ViewModels/Toolbox/ViewExtractMediaViewModel.cs +++ b/DownKyi/ViewModels/Toolbox/ViewExtractMediaViewModel.cs @@ -72,7 +72,7 @@ public class ViewExtractMediaViewModel : ViewModelBase { if (isExtracting) { - eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipWaitTaskFinished")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipWaitTaskFinished")); return; } @@ -93,13 +93,13 @@ public class ViewExtractMediaViewModel : ViewModelBase { if (isExtracting) { - eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipWaitTaskFinished")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipWaitTaskFinished")); return; } if (VideoPaths.Length <= 0) { - eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipNoSeletedVideo")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipNoSeletedVideo")); return; } @@ -137,13 +137,13 @@ public class ViewExtractMediaViewModel : ViewModelBase { if (isExtracting) { - eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipWaitTaskFinished")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipWaitTaskFinished")); return; } if (VideoPaths.Length <= 0) { - eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipNoSeletedVideo")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipNoSeletedVideo")); return; } diff --git a/DownKyi/ViewModels/UserSpace/ViewArchiveViewModel.cs b/DownKyi/ViewModels/UserSpace/ViewArchiveViewModel.cs index 8efa6fb..2fa7dad 100644 --- a/DownKyi/ViewModels/UserSpace/ViewArchiveViewModel.cs +++ b/DownKyi/ViewModels/UserSpace/ViewArchiveViewModel.cs @@ -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; diff --git a/DownKyi/ViewModels/UserSpace/ViewSeasonsSeriesViewModel.cs b/DownKyi/ViewModels/UserSpace/ViewSeasonsSeriesViewModel.cs index 431aece..ae0cce5 100644 --- a/DownKyi/ViewModels/UserSpace/ViewSeasonsSeriesViewModel.cs +++ b/DownKyi/ViewModels/UserSpace/ViewSeasonsSeriesViewModel.cs @@ -97,7 +97,7 @@ public class ViewSeasonsSeriesViewModel : ViewModelBase ParentViewName = ViewUserSpaceViewModel.Tag, Parameter = data }; - eventAggregator.GetEvent().Publish(param); + EventAggregator.GetEvent().Publish(param); SelectedItem = -1; } diff --git a/DownKyi/ViewModels/ViewDownloadManagerViewModel.cs b/DownKyi/ViewModels/ViewDownloadManagerViewModel.cs index 63892f1..78f9b9d 100644 --- a/DownKyi/ViewModels/ViewDownloadManagerViewModel.cs +++ b/DownKyi/ViewModels/ViewDownloadManagerViewModel.cs @@ -89,7 +89,7 @@ public class ViewDownloadManagerViewModel : ViewModelBase ParentViewName = null, Parameter = null }; - eventAggregator.GetEvent().Publish(parameter); + EventAggregator.GetEvent().Publish(parameter); } // 左侧tab点击事件 diff --git a/DownKyi/ViewModels/ViewFriendsViewModel.cs b/DownKyi/ViewModels/ViewFriendsViewModel.cs index 9a3f8c6..b07c7b7 100644 --- a/DownKyi/ViewModels/ViewFriendsViewModel.cs +++ b/DownKyi/ViewModels/ViewFriendsViewModel.cs @@ -89,7 +89,7 @@ namespace DownKyi.ViewModels ParentViewName = null, Parameter = null }; - eventAggregator.GetEvent().Publish(parameter); + EventAggregator.GetEvent().Publish(parameter); } // 顶部tab点击事件 diff --git a/DownKyi/ViewModels/ViewIndexViewModel.cs b/DownKyi/ViewModels/ViewIndexViewModel.cs index c0de6d5..7b95a58 100644 --- a/DownKyi/ViewModels/ViewIndexViewModel.cs +++ b/DownKyi/ViewModels/ViewIndexViewModel.cs @@ -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 /// 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 /// 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 /// 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; diff --git a/DownKyi/ViewModels/ViewLoginViewModel.cs b/DownKyi/ViewModels/ViewLoginViewModel.cs index 2e5c711..b5ac52c 100644 --- a/DownKyi/ViewModels/ViewLoginViewModel.cs +++ b/DownKyi/ViewModels/ViewLoginViewModel.cs @@ -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().Publish(parameter); + EventAggregator.GetEvent().Publish(parameter); } /// @@ -105,7 +108,7 @@ public class ViewLoginViewModel : ViewModelBase if (loginUrl.Data == null || loginUrl.Data.Url == null) { - eventAggregator.GetEvent().Publish(DictionaryResource.GetString("GetLoginUrlFailed")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("GetLoginUrlFailed")); return; } @@ -160,7 +163,7 @@ public class ViewLoginViewModel : ViewModelBase // 不匹配的oauthKey,超时或已确认的oauthKey // 发送通知 - eventAggregator.GetEvent().Publish(DictionaryResource.GetString("LoginTimeOut")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("LoginTimeOut")); LogManager.Info(Tag, DictionaryResource.GetString("LoginTimeOut")); // 取消任务 @@ -187,17 +190,16 @@ public class ViewLoginViewModel : ViewModelBase // 确认登录 // 发送通知 - eventAggregator.GetEvent().Publish("登陆成功"); + EventAggregator.GetEvent().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() + EventAggregator.GetEvent() .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().Publish(DictionaryResource.GetString("LoginFailed")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("LoginFailed")); } // TODO 其他操作 @@ -214,7 +216,7 @@ public class ViewLoginViewModel : ViewModelBase // 取消任务 Thread.Sleep(3000); - PropertyChangeAsync(ExecuteBackSpace); + PropertyChange(ExecuteBackSpace); break; } diff --git a/DownKyi/ViewModels/ViewModelBase.cs b/DownKyi/ViewModels/ViewModelBase.cs index 36cd44f..e7d9158 100644 --- a/DownKyi/ViewModels/ViewModelBase.cs +++ b/DownKyi/ViewModels/ViewModelBase.cs @@ -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); } + + /// + /// 同步修改绑定到UI的属性 + /// + /// + protected void PropertyChange(Action callback) + { + Dispatcher.UIThread.Invoke(callback); + } } \ No newline at end of file diff --git a/DownKyi/ViewModels/ViewMyBangumiFollowViewModel.cs b/DownKyi/ViewModels/ViewMyBangumiFollowViewModel.cs index 22ec1d4..a79bae6 100644 --- a/DownKyi/ViewModels/ViewMyBangumiFollowViewModel.cs +++ b/DownKyi/ViewModels/ViewMyBangumiFollowViewModel.cs @@ -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().Publish(parameter); + EventAggregator.GetEvent().Publish(parameter); } // 前往下载管理页面 @@ -220,7 +220,7 @@ public class ViewMyBangumiFollowViewModel : ViewModelBase ParentViewName = Tag, Parameter = null }; - eventAggregator.GetEvent().Publish(parameter); + EventAggregator.GetEvent().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().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); } else { - eventAggregator.GetEvent() + EventAggregator.GetEvent() .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, diff --git a/DownKyi/ViewModels/ViewMyFavoritesViewModel.cs b/DownKyi/ViewModels/ViewMyFavoritesViewModel.cs index dedceee..adc2ecc 100644 --- a/DownKyi/ViewModels/ViewMyFavoritesViewModel.cs +++ b/DownKyi/ViewModels/ViewMyFavoritesViewModel.cs @@ -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().Publish(parameter); + EventAggregator.GetEvent().Publish(parameter); } // 前往下载管理页面 @@ -252,7 +252,7 @@ public class ViewMyFavoritesViewModel : ViewModelBase ParentViewName = Tag, Parameter = null }; - eventAggregator.GetEvent().Publish(parameter); + EventAggregator.GetEvent().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().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); } else { - eventAggregator.GetEvent() + EventAggregator.GetEvent() .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; diff --git a/DownKyi/ViewModels/ViewMyHistoryViewModel.cs b/DownKyi/ViewModels/ViewMyHistoryViewModel.cs index be88cba..e84274d 100644 --- a/DownKyi/ViewModels/ViewMyHistoryViewModel.cs +++ b/DownKyi/ViewModels/ViewMyHistoryViewModel.cs @@ -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().Publish(parameter); + EventAggregator.GetEvent().Publish(parameter); } // 前往下载管理页面 @@ -179,7 +179,7 @@ public class ViewMyHistoryViewModel : ViewModelBase ParentViewName = Tag, Parameter = null }; - eventAggregator.GetEvent().Publish(parameter); + EventAggregator.GetEvent().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().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); } else { - eventAggregator.GetEvent() + EventAggregator.GetEvent() .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, diff --git a/DownKyi/ViewModels/ViewMySpaceViewModel.cs b/DownKyi/ViewModels/ViewMySpaceViewModel.cs index d0616db..7ffd333 100644 --- a/DownKyi/ViewModels/ViewMySpaceViewModel.cs +++ b/DownKyi/ViewModels/ViewMySpaceViewModel.cs @@ -341,7 +341,7 @@ public class ViewMySpaceViewModel : ViewModelBase ParentViewName = null, Parameter = null }; - eventAggregator.GetEvent().Publish(parameter); + EventAggregator.GetEvent().Publish(parameter); } // 退出登录事件 @@ -365,7 +365,7 @@ public class ViewMySpaceViewModel : ViewModelBase ParentViewName = null, Parameter = "logout" }; - eventAggregator.GetEvent().Publish(parameter); + EventAggregator.GetEvent().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; diff --git a/DownKyi/ViewModels/ViewMyToViewVideoViewModel.cs b/DownKyi/ViewModels/ViewMyToViewVideoViewModel.cs index 650f257..70da174 100644 --- a/DownKyi/ViewModels/ViewMyToViewVideoViewModel.cs +++ b/DownKyi/ViewModels/ViewMyToViewVideoViewModel.cs @@ -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().Publish(parameter); + EventAggregator.GetEvent().Publish(parameter); } // 前往下载管理页面 @@ -175,7 +175,7 @@ public class ViewMyToViewVideoViewModel : ViewModelBase ParentViewName = Tag, Parameter = null }; - eventAggregator.GetEvent().Publish(parameter); + EventAggregator.GetEvent().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().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); } else { - eventAggregator.GetEvent() + EventAggregator.GetEvent() .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, diff --git a/DownKyi/ViewModels/ViewPublicFavoritesViewModel.cs b/DownKyi/ViewModels/ViewPublicFavoritesViewModel.cs index 7d235bd..f7c4ea2 100644 --- a/DownKyi/ViewModels/ViewPublicFavoritesViewModel.cs +++ b/DownKyi/ViewModels/ViewPublicFavoritesViewModel.cs @@ -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().Publish(parameter); + EventAggregator.GetEvent().Publish(parameter); } // 前往下载管理页面 @@ -198,7 +198,7 @@ public class ViewPublicFavoritesViewModel : ViewModelBase ParentViewName = Tag, Parameter = null }; - eventAggregator.GetEvent().Publish(parameter); + EventAggregator.GetEvent().Publish(parameter); } // 复制封面事件 @@ -243,7 +243,7 @@ public class ViewPublicFavoritesViewModel : ViewModelBase /// 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().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); } else { - eventAggregator.GetEvent() + EventAggregator.GetEvent() .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); } /// diff --git a/DownKyi/ViewModels/ViewPublicationViewModel.cs b/DownKyi/ViewModels/ViewPublicationViewModel.cs index c89a691..54d6e9f 100644 --- a/DownKyi/ViewModels/ViewPublicationViewModel.cs +++ b/DownKyi/ViewModels/ViewPublicationViewModel.cs @@ -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().Publish(parameter); + EventAggregator.GetEvent().Publish(parameter); } // 前往下载管理页面 @@ -207,7 +207,7 @@ namespace DownKyi.ViewModels ParentViewName = Tag, Parameter = null }; - eventAggregator.GetEvent().Publish(parameter); + EventAggregator.GetEvent().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().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); } else { - eventAggregator.GetEvent() + EventAggregator.GetEvent() .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, diff --git a/DownKyi/ViewModels/ViewSeasonsSeriesViewModel.cs b/DownKyi/ViewModels/ViewSeasonsSeriesViewModel.cs index 7adf883..f6b8317 100644 --- a/DownKyi/ViewModels/ViewSeasonsSeriesViewModel.cs +++ b/DownKyi/ViewModels/ViewSeasonsSeriesViewModel.cs @@ -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().Publish(parameter); + EventAggregator.GetEvent().Publish(parameter); } // 前往下载管理页面 @@ -198,7 +198,7 @@ public class ViewSeasonsSeriesViewModel : ViewModelBase ParentViewName = Tag, Parameter = null }; - eventAggregator.GetEvent().Publish(parameter); + EventAggregator.GetEvent().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().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); } else { - eventAggregator.GetEvent() + EventAggregator.GetEvent() .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, diff --git a/DownKyi/ViewModels/ViewSettingsViewModel.cs b/DownKyi/ViewModels/ViewSettingsViewModel.cs index f0599f8..8acf0fe 100644 --- a/DownKyi/ViewModels/ViewSettingsViewModel.cs +++ b/DownKyi/ViewModels/ViewSettingsViewModel.cs @@ -87,7 +87,7 @@ public class ViewSettingsViewModel : ViewModelBase ParentViewName = null, Parameter = null }; - eventAggregator.GetEvent().Publish(parameter); + EventAggregator.GetEvent().Publish(parameter); } // 左侧tab点击事件 diff --git a/DownKyi/ViewModels/ViewToolboxViewModel.cs b/DownKyi/ViewModels/ViewToolboxViewModel.cs index c0251c9..e7fbb53 100644 --- a/DownKyi/ViewModels/ViewToolboxViewModel.cs +++ b/DownKyi/ViewModels/ViewToolboxViewModel.cs @@ -83,7 +83,7 @@ namespace DownKyi.ViewModels ParentViewName = null, Parameter = null }; - eventAggregator.GetEvent().Publish(parameter); + EventAggregator.GetEvent().Publish(parameter); } // 左侧tab点击事件 diff --git a/DownKyi/ViewModels/ViewUserSpaceViewModel.cs b/DownKyi/ViewModels/ViewUserSpaceViewModel.cs index 9c80ef5..6fcfb59 100644 --- a/DownKyi/ViewModels/ViewUserSpaceViewModel.cs +++ b/DownKyi/ViewModels/ViewUserSpaceViewModel.cs @@ -222,7 +222,7 @@ public class ViewUserSpaceViewModel : ViewModelBase ParentViewName = null, Parameter = null }; - eventAggregator.GetEvent().Publish(parameter); + EventAggregator.GetEvent().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; } diff --git a/DownKyi/ViewModels/ViewVideoDetailViewModel.cs b/DownKyi/ViewModels/ViewVideoDetailViewModel.cs index 1dfae8c..6584920 100644 --- a/DownKyi/ViewModels/ViewVideoDetailViewModel.cs +++ b/DownKyi/ViewModels/ViewVideoDetailViewModel.cs @@ -171,7 +171,7 @@ public class ViewVideoDetailViewModel : ViewModelBase ParentViewName = null, Parameter = null }; - eventAggregator.GetEvent().Publish(parameter); + EventAggregator.GetEvent().Publish(parameter); } // 前往下载管理页面 @@ -192,7 +192,7 @@ public class ViewVideoDetailViewModel : ViewModelBase ParentViewName = Tag, Parameter = null }; - eventAggregator.GetEvent().Publish(parameter); + EventAggregator.GetEvent().Publish(parameter); } // 输入确认事件 @@ -330,7 +330,7 @@ public class ViewVideoDetailViewModel : ViewModelBase /// 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 parseCommand; + + public DelegateCommand ParseCommand => parseCommand ?? + (parseCommand = new DelegateCommand(ExecuteParseCommand, + CanExecuteParseCommand)); + + /// + /// 解析视频流事件 + /// + /// + 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; + } + + /// + /// 解析视频流事件是否允许执行 + /// + /// + /// + private bool CanExecuteParseCommand(object parameter) + { + return LoadingVisibility != true; + } + + // 解析所有视频流事件 private DelegateCommand parseAllVideoCommand; @@ -431,8 +482,6 @@ public class ViewVideoDetailViewModel : ViewModelBase /// 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"); 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().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); + EventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); } else { - eventAggregator.GetEvent() + EventAggregator.GetEvent() .Publish( $"{DictionaryResource.GetString("TipAddDownloadingFinished1")}{i}{DictionaryResource.GetString("TipAddDownloadingFinished2")}"); } diff --git a/DownKyi/Views/DownloadManager/ViewDownloadFinished.axaml b/DownKyi/Views/DownloadManager/ViewDownloadFinished.axaml index 22f397e..c3c2b73 100644 --- a/DownKyi/Views/DownloadManager/ViewDownloadFinished.axaml +++ b/DownKyi/Views/DownloadManager/ViewDownloadFinished.axaml @@ -1,11 +1,14 @@  + + @@ -240,6 +243,18 @@ Width="256" Height="256" Source="/Resources/nodata02.png"> + + + + + + + + + + + \ No newline at end of file diff --git a/DownKyi/Views/DownloadManager/ViewDownloading.axaml b/DownKyi/Views/DownloadManager/ViewDownloading.axaml index d6ff3c5..07d3f0e 100644 --- a/DownKyi/Views/DownloadManager/ViewDownloading.axaml +++ b/DownKyi/Views/DownloadManager/ViewDownloading.axaml @@ -307,6 +307,18 @@ Width="256" Height="256" Source="/Resources/nodata02.png"> + + + + + + + + + + + \ No newline at end of file diff --git a/DownKyi/Views/ViewVideoDetail.axaml b/DownKyi/Views/ViewVideoDetail.axaml index f63f5f4..7e580ec 100644 --- a/DownKyi/Views/ViewVideoDetail.axaml +++ b/DownKyi/Views/ViewVideoDetail.axaml @@ -359,9 +359,6 @@ CommandParameter="{Binding ElementName=NameVideoPages1,Path=SelectedItems}" /> - - -