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 0000000..d011e83 Binary files /dev/null and b/DownKyi/Resources/checked.png differ 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}"> + + + + +