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

croire 3 years ago
parent fee511cf33
commit 4d2590605e

@ -440,6 +440,7 @@
<Content Include="FFmpeg_LICENSE.txt"> <Content Include="FFmpeg_LICENSE.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Resource Include="Resources\checked.png" />
<Content Include="打不开DownKyi请点我.txt"> <Content Include="打不开DownKyi请点我.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </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; using System.Windows.Media.Imaging;
namespace DownKyi.Models namespace DownKyi.Models
{ {
public class FavoritesMedia : BindableBase public class FavoritesMedia : BindableBase
{ {
protected readonly IEventAggregator eventAggregator;
public FavoritesMedia(IEventAggregator eventAggregator)
{
this.eventAggregator = eventAggregator;
}
public long Avid { get; set; } public long Avid { get; set; }
public string Bvid { get; set; } public string Bvid { get; set; }
public long UpperMid { get; set; } public long UpperMid { get; set; }
#region 页面属性申明
private bool isSelected; private bool isSelected;
public bool IsSelected public bool IsSelected
{ {
@ -71,5 +85,42 @@ namespace DownKyi.Models
get { return upName; } get { return upName; }
set { SetProperty(ref upName, value); } 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.Storage;
using DownKyi.Core.Utils; using DownKyi.Core.Utils;
using DownKyi.Models; using DownKyi.Models;
using Prism.Events;
using System; using System;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
@ -84,7 +85,7 @@ namespace DownKyi.Services
/// </summary> /// </summary>
/// <param name="mediaId"></param> /// <param name="mediaId"></param>
/// <returns></returns> /// <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); var medias = FavoritesResource.GetAllFavoritesMedia(mediaId);
if (medias.Count == 0) { return; } if (medias.Count == 0) { return; }
@ -101,7 +102,7 @@ namespace DownKyi.Services
App.PropertyChangeAsync(new Action(() => App.PropertyChangeAsync(new Action(() =>
{ {
FavoritesMedia newMedia = new FavoritesMedia FavoritesMedia newMedia = new FavoritesMedia(eventAggregator)
{ {
Avid = media.Id, Avid = media.Id,
Bvid = media.Bvid, Bvid = media.Bvid,

@ -1,4 +1,5 @@
using DownKyi.Models; using DownKyi.Models;
using Prism.Events;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
namespace DownKyi.Services namespace DownKyi.Services
@ -6,6 +7,6 @@ namespace DownKyi.Services
public interface IFavoritesService public interface IFavoritesService
{ {
Favorites GetFavorites(long mediaId); 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 页面属性申明 #region 页面属性申明
private string pageName = Tag;
public string PageName
{
get { return pageName; }
set { SetProperty(ref pageName, value); }
}
private VectorImage arrowBack; private VectorImage arrowBack;
public 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 #endregion
/// <summary> /// <summary>
@ -226,7 +245,7 @@ namespace DownKyi.ViewModels
NoDataVisibility = Visibility.Collapsed; NoDataVisibility = Visibility.Collapsed;
} }
favoritesService.GetFavoritesMediaList(favoritesId, FavoritesMedias); favoritesService.GetFavoritesMediaList(favoritesId, FavoritesMedias, eventAggregator);
} }
/// <summary> /// <summary>
@ -237,8 +256,6 @@ namespace DownKyi.ViewModels
{ {
base.OnNavigatedTo(navigationContext); base.OnNavigatedTo(navigationContext);
InitView();
// 根据传入参数不同执行不同任务 // 根据传入参数不同执行不同任务
long parameter = navigationContext.Parameters.GetValue<long>("Parameter"); long parameter = navigationContext.Parameters.GetValue<long>("Parameter");
if (parameter == 0) if (parameter == 0)
@ -246,6 +263,7 @@ namespace DownKyi.ViewModels
return; return;
} }
InitView();
await Task.Run(new Action(() => await Task.Run(new Action(() =>
{ {
UpdateView(new FavoritesService(), parameter); UpdateView(new FavoritesService(), parameter);

@ -314,6 +314,7 @@
<ColumnDefinition Width="auto" /> <ColumnDefinition Width="auto" />
<ColumnDefinition Width="150" /> <ColumnDefinition Width="150" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock <TextBlock
@ -326,7 +327,7 @@
Text="{Binding Order}" /> Text="{Binding Order}" />
<Image Grid.Column="1" Source="{Binding Cover}" /> <Image Grid.Column="1" Source="{Binding Cover}" />
<Border <Border
x:Name="nameInfoPanel" x:Name="nameInfoPanel"
Grid.Column="1" Grid.Column="1"
@ -343,6 +344,16 @@
Text="{Binding Duration}" /> Text="{Binding Duration}" />
</Border> </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 Grid.Column="2" Margin="20,0">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition /> <RowDefinition />
@ -359,6 +370,11 @@
Text="{Binding Title}" Text="{Binding Title}"
TextTrimming="CharacterEllipsis" TextTrimming="CharacterEllipsis"
ToolTip="{Binding Title}"> 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> <TextBlock.Style>
<Style TargetType="{x:Type TextBlock}"> <Style TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="{DynamicResource BrushTextDark}" /> <Setter Property="Foreground" Value="{DynamicResource BrushTextDark}" />
@ -415,6 +431,11 @@
Cursor="Hand" Cursor="Hand"
FontSize="12" FontSize="12"
Text="{Binding UpName, StringFormat={}UP: {0}}"> 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> <TextBlock.Style>
<Style TargetType="{x:Type TextBlock}"> <Style TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="{DynamicResource BrushTextGrey}" /> <Setter Property="Foreground" Value="{DynamicResource BrushTextGrey}" />
@ -427,12 +448,20 @@
</TextBlock.Style> </TextBlock.Style>
</TextBlock> </TextBlock>
</Grid> </Grid>
</Grid> </Grid>
<ControlTemplate.Triggers> <ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True"> <Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="nameInfoPanel" Property="Visibility" Value="Visible" /> <Setter TargetName="nameInfoPanel" Property="Visibility" Value="Visible" />
</Trigger> </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.Triggers>
</ControlTemplate> </ControlTemplate>
</Setter.Value> </Setter.Value>

Loading…
Cancel
Save