From 4d2590605ebf5b226021a59050bf45114bf0038f Mon Sep 17 00:00:00 2001 From: croire <1432593898@qq.com> Date: Tue, 26 Oct 2021 23:51:49 +0800 Subject: [PATCH] =?UTF-8?q?PagePublicFavorites=E5=BC=80=E5=8F=91=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E4=B8=AD=EF=BC=8C=E5=AE=8C=E6=88=90=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=EF=BC=8C20211026=E6=9A=82=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DownKyi/DownKyi.csproj | 1 + DownKyi/Models/FavoritesMedia.cs | 53 +++++++++++++++++- DownKyi/Resources/checked.png | Bin 0 -> 393 bytes DownKyi/Services/FavoritesService.cs | 5 +- DownKyi/Services/IFavoritesService.cs | 3 +- .../ViewPublicFavoritesViewModel.cs | 24 +++++++- DownKyi/Views/ViewPublicFavorites.xaml | 31 +++++++++- 7 files changed, 109 insertions(+), 8 deletions(-) create mode 100644 DownKyi/Resources/checked.png diff --git a/DownKyi/DownKyi.csproj b/DownKyi/DownKyi.csproj index 54d9a1d..d2b905c 100644 --- a/DownKyi/DownKyi.csproj +++ b/DownKyi/DownKyi.csproj @@ -440,6 +440,7 @@ PreserveNewest + PreserveNewest diff --git a/DownKyi/Models/FavoritesMedia.cs b/DownKyi/Models/FavoritesMedia.cs index 562544b..99f30b8 100644 --- a/DownKyi/Models/FavoritesMedia.cs +++ b/DownKyi/Models/FavoritesMedia.cs @@ -1,14 +1,28 @@ -using Prism.Mvvm; +using DownKyi.Core.BiliApi.BiliUtils; +using DownKyi.Utils; +using DownKyi.ViewModels; +using Prism.Commands; +using Prism.Events; +using Prism.Mvvm; using System.Windows.Media.Imaging; namespace DownKyi.Models { public class FavoritesMedia : BindableBase { + protected readonly IEventAggregator eventAggregator; + + public FavoritesMedia(IEventAggregator eventAggregator) + { + this.eventAggregator = eventAggregator; + } + public long Avid { get; set; } public string Bvid { get; set; } public long UpperMid { get; set; } + #region 页面属性申明 + private bool isSelected; public bool IsSelected { @@ -71,5 +85,42 @@ namespace DownKyi.Models get { return upName; } set { SetProperty(ref upName, value); } } + + #endregion + + #region 命令申明 + + // 视频标题点击事件 + private DelegateCommand titleCommand; + public DelegateCommand TitleCommand => titleCommand ?? (titleCommand = new DelegateCommand(ExecuteTitleCommand)); + + /// + /// 视频标题点击事件 + /// + /// + private void ExecuteTitleCommand(object parameter) + { + if (!(parameter is string tag)) { return; } + + NavigateToView.NavigationView(eventAggregator, ViewVideoDetailViewModel.Tag, tag, $"{ParseEntrance.VideoUrl}{Bvid}"); + } + + // 视频的UP主点击事件 + private DelegateCommand videoUpperCommand; + public DelegateCommand VideoUpperCommand => videoUpperCommand ?? (videoUpperCommand = new DelegateCommand(ExecuteVideoUpperCommand)); + + /// + /// 视频的UP主点击事件 + /// + /// + private void ExecuteVideoUpperCommand(object parameter) + { + if (!(parameter is string tag)) { return; } + + NavigateToView.NavigateToViewUserSpace(eventAggregator, tag, UpperMid); + } + + #endregion + } } diff --git a/DownKyi/Resources/checked.png b/DownKyi/Resources/checked.png new file mode 100644 index 0000000000000000000000000000000000000000..d011e83bc0edf02e66d9da47f6c73fd48a0ba165 GIT binary patch literal 393 zcmV;40e1e0P)S6orpbu?zn|sf%Wzi&7t;h=Mz--RP!t<6HPBzJ(j>R?vuo_yhJG6vRTsLQ`GX zioJ5i6oz1?BpE?G5V#@X`!X|-d%=iEUPNjl;!FDY0V_}Th=>#b+ya<|-LwI$Qcwd> zIe2)*Ui}5n@1LnG*~}>Ri}ToBoZ{^f1wMf3g~R*Qa9z@@F0p)b2xnyr9%4;8)~FHr z`+}Kq2bWteuFI}{0pVULhxKd*{fKuG3kLAw+yv^aF1F7b_5@-0=Ghb4y`R?*TM!3s z6kL^Eb$A3Og&PHZfjT?_2@b>p4);HX!;LH8*KrF7BsdA& zD9|N$t**M_!eQDXU9xig7z?WBfBft^2%3bgXe`xmJXUOTHY9_V8RUd5a~Z(RFE#x& nRdKQiMvabzv4sq>3IOm0>@+=xJa8)a00000NkvXXu0mjfZ&|C> literal 0 HcmV?d00001 diff --git a/DownKyi/Services/FavoritesService.cs b/DownKyi/Services/FavoritesService.cs index a619554..b4bfe9a 100644 --- a/DownKyi/Services/FavoritesService.cs +++ b/DownKyi/Services/FavoritesService.cs @@ -2,6 +2,7 @@ using DownKyi.Core.Storage; using DownKyi.Core.Utils; using DownKyi.Models; +using Prism.Events; using System; using System.Collections.ObjectModel; using System.Linq; @@ -84,7 +85,7 @@ namespace DownKyi.Services /// /// /// - public void GetFavoritesMediaList(long mediaId, ObservableCollection result) + public void GetFavoritesMediaList(long mediaId, ObservableCollection result, IEventAggregator eventAggregator) { var medias = FavoritesResource.GetAllFavoritesMedia(mediaId); if (medias.Count == 0) { return; } @@ -101,7 +102,7 @@ namespace DownKyi.Services App.PropertyChangeAsync(new Action(() => { - FavoritesMedia newMedia = new FavoritesMedia + FavoritesMedia newMedia = new FavoritesMedia(eventAggregator) { Avid = media.Id, Bvid = media.Bvid, diff --git a/DownKyi/Services/IFavoritesService.cs b/DownKyi/Services/IFavoritesService.cs index 96ec9d8..0fb7d82 100644 --- a/DownKyi/Services/IFavoritesService.cs +++ b/DownKyi/Services/IFavoritesService.cs @@ -1,4 +1,5 @@ using DownKyi.Models; +using Prism.Events; using System.Collections.ObjectModel; namespace DownKyi.Services @@ -6,6 +7,6 @@ namespace DownKyi.Services public interface IFavoritesService { Favorites GetFavorites(long mediaId); - void GetFavoritesMediaList(long mediaId, ObservableCollection result); + void GetFavoritesMediaList(long mediaId, ObservableCollection result, IEventAggregator eventAggregator); } } diff --git a/DownKyi/ViewModels/ViewPublicFavoritesViewModel.cs b/DownKyi/ViewModels/ViewPublicFavoritesViewModel.cs index 1f268fe..7db9b83 100644 --- a/DownKyi/ViewModels/ViewPublicFavoritesViewModel.cs +++ b/DownKyi/ViewModels/ViewPublicFavoritesViewModel.cs @@ -20,6 +20,13 @@ namespace DownKyi.ViewModels #region 页面属性申明 + private string pageName = Tag; + public string PageName + { + get { return pageName; } + set { SetProperty(ref pageName, value); } + } + private VectorImage arrowBack; public VectorImage ArrowBack { @@ -191,6 +198,18 @@ namespace DownKyi.ViewModels { } + // 列表选择事件 + private DelegateCommand favoritesMediasCommand; + public DelegateCommand FavoritesMediasCommand => favoritesMediasCommand ?? (favoritesMediasCommand = new DelegateCommand(ExecuteFavoritesMediasCommand)); + + /// + /// 列表选择事件 + /// + /// + private void ExecuteFavoritesMediasCommand(object parameter) + { + } + #endregion /// @@ -226,7 +245,7 @@ namespace DownKyi.ViewModels NoDataVisibility = Visibility.Collapsed; } - favoritesService.GetFavoritesMediaList(favoritesId, FavoritesMedias); + favoritesService.GetFavoritesMediaList(favoritesId, FavoritesMedias, eventAggregator); } /// @@ -237,8 +256,6 @@ namespace DownKyi.ViewModels { base.OnNavigatedTo(navigationContext); - InitView(); - // 根据传入参数不同执行不同任务 long parameter = navigationContext.Parameters.GetValue("Parameter"); if (parameter == 0) @@ -246,6 +263,7 @@ namespace DownKyi.ViewModels return; } + InitView(); await Task.Run(new Action(() => { UpdateView(new FavoritesService(), parameter); diff --git a/DownKyi/Views/ViewPublicFavorites.xaml b/DownKyi/Views/ViewPublicFavorites.xaml index d768a26..83caaf9 100644 --- a/DownKyi/Views/ViewPublicFavorites.xaml +++ b/DownKyi/Views/ViewPublicFavorites.xaml @@ -314,6 +314,7 @@ + - + + + @@ -359,6 +370,11 @@ Text="{Binding Title}" TextTrimming="CharacterEllipsis" ToolTip="{Binding Title}"> + + + + +