PagePublicFavorites开发工作中,完成页面设计,20211026暂存

croire 3 years ago
parent fee511cf33
commit 4d2590605e

@ -440,6 +440,7 @@
<Content Include="FFmpeg_LICENSE.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Resource Include="Resources\checked.png" />
<Content Include="打不开DownKyi请点我.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

@ -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<object> titleCommand;
public DelegateCommand<object> TitleCommand => titleCommand ?? (titleCommand = new DelegateCommand<object>(ExecuteTitleCommand));
/// <summary>
/// 视频标题点击事件
/// </summary>
/// <param name="parameter"></param>
private void ExecuteTitleCommand(object parameter)
{
if (!(parameter is string tag)) { return; }
NavigateToView.NavigationView(eventAggregator, ViewVideoDetailViewModel.Tag, tag, $"{ParseEntrance.VideoUrl}{Bvid}");
}
// 视频的UP主点击事件
private DelegateCommand<object> videoUpperCommand;
public DelegateCommand<object> VideoUpperCommand => videoUpperCommand ?? (videoUpperCommand = new DelegateCommand<object>(ExecuteVideoUpperCommand));
/// <summary>
/// 视频的UP主点击事件
/// </summary>
/// <param name="parameter"></param>
private void ExecuteVideoUpperCommand(object parameter)
{
if (!(parameter is string tag)) { return; }
NavigateToView.NavigateToViewUserSpace(eventAggregator, tag, UpperMid);
}
#endregion
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 393 B

@ -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
/// </summary>
/// <param name="mediaId"></param>
/// <returns></returns>
public void GetFavoritesMediaList(long mediaId, ObservableCollection<FavoritesMedia> result)
public void GetFavoritesMediaList(long mediaId, ObservableCollection<FavoritesMedia> 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,

@ -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<FavoritesMedia> result);
void GetFavoritesMediaList(long mediaId, ObservableCollection<FavoritesMedia> result, IEventAggregator eventAggregator);
}
}

@ -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<object> favoritesMediasCommand;
public DelegateCommand<object> FavoritesMediasCommand => favoritesMediasCommand ?? (favoritesMediasCommand = new DelegateCommand<object>(ExecuteFavoritesMediasCommand));
/// <summary>
/// 列表选择事件
/// </summary>
/// <param name="parameter"></param>
private void ExecuteFavoritesMediasCommand(object parameter)
{
}
#endregion
/// <summary>
@ -226,7 +245,7 @@ namespace DownKyi.ViewModels
NoDataVisibility = Visibility.Collapsed;
}
favoritesService.GetFavoritesMediaList(favoritesId, FavoritesMedias);
favoritesService.GetFavoritesMediaList(favoritesId, FavoritesMedias, eventAggregator);
}
/// <summary>
@ -237,8 +256,6 @@ namespace DownKyi.ViewModels
{
base.OnNavigatedTo(navigationContext);
InitView();
// 根据传入参数不同执行不同任务
long parameter = navigationContext.Parameters.GetValue<long>("Parameter");
if (parameter == 0)
@ -246,6 +263,7 @@ namespace DownKyi.ViewModels
return;
}
InitView();
await Task.Run(new Action(() =>
{
UpdateView(new FavoritesService(), parameter);

@ -314,6 +314,7 @@
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="150" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<TextBlock
@ -326,7 +327,7 @@
Text="{Binding Order}" />
<Image Grid.Column="1" Source="{Binding Cover}" />
<Border
x:Name="nameInfoPanel"
Grid.Column="1"
@ -343,6 +344,16 @@
Text="{Binding Duration}" />
</Border>
<Image
x:Name="nameIsSelected"
Grid.Column="1"
Width="24"
Height="24"
Margin="10"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Source="/DownKyi;component/Resources/checked.png" />
<Grid Grid.Column="2" Margin="20,0">
<Grid.RowDefinitions>
<RowDefinition />
@ -359,6 +370,11 @@
Text="{Binding Title}"
TextTrimming="CharacterEllipsis"
ToolTip="{Binding Title}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeftButtonUp">
<i:InvokeCommandAction Command="{Binding TitleCommand}" CommandParameter="{Binding DataContext.PageName, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<TextBlock.Style>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="{DynamicResource BrushTextDark}" />
@ -415,6 +431,11 @@
Cursor="Hand"
FontSize="12"
Text="{Binding UpName, StringFormat={}UP: {0}}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeftButtonUp">
<i:InvokeCommandAction Command="{Binding VideoUpperCommand}" CommandParameter="{Binding DataContext.PageName, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<TextBlock.Style>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="{DynamicResource BrushTextGrey}" />
@ -427,12 +448,20 @@
</TextBlock.Style>
</TextBlock>
</Grid>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="nameInfoPanel" Property="Visibility" Value="Visible" />
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="nameIsSelected" Property="Visibility" Value="Visible" />
</Trigger>
<Trigger Property="IsSelected" Value="False">
<Setter TargetName="nameIsSelected" Property="Visibility" Value="Collapsed" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>

Loading…
Cancel
Save