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

croire 3 years ago
parent c48ecc86c9
commit fee511cf33

@ -24,7 +24,7 @@ namespace DownKyi.Core.BiliApi.Favorites.Models
[JsonProperty("medias")]
public List<FavoritesMedia> Medias { get; set; }
[JsonProperty("has_more")]
public int HasMore { get; set; }
public bool HasMore { get; set; }
}
}

@ -1,13 +1,75 @@
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
namespace DownKyi.Models
{
public class FavoritesMedia : BindableBase
{
public long Avid { get; set; }
public string Bvid { get; set; }
public long UpperMid { get; set; }
private bool isSelected;
public bool IsSelected
{
get { return isSelected; }
set { SetProperty(ref isSelected, value); }
}
private int order;
public int Order
{
get { return order; }
set { SetProperty(ref order, value); }
}
private BitmapImage cover;
public BitmapImage Cover
{
get { return cover; }
set { SetProperty(ref cover, value); }
}
private string title;
public string Title
{
get { return title; }
set { SetProperty(ref title, value); }
}
private string playNumber;
public string PlayNumber
{
get { return playNumber; }
set { SetProperty(ref playNumber, value); }
}
private string danmakuNumber;
public string DanmakuNumber
{
get { return danmakuNumber; }
set { SetProperty(ref danmakuNumber, value); }
}
private string favoriteNumber;
public string FavoriteNumber
{
get { return favoriteNumber; }
set { SetProperty(ref favoriteNumber, value); }
}
private string duration;
public string Duration
{
get { return duration; }
set { SetProperty(ref duration, value); }
}
private string upName;
public string UpName
{
get { return upName; }
set { SetProperty(ref upName, value); }
}
}
}

@ -3,7 +3,9 @@ using DownKyi.Core.Storage;
using DownKyi.Core.Utils;
using DownKyi.Models;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading;
using System.Windows.Media.Imaging;
namespace DownKyi.Services
@ -82,9 +84,45 @@ namespace DownKyi.Services
/// </summary>
/// <param name="mediaId"></param>
/// <returns></returns>
public List<FavoritesMedia> GetFavoritesMediaList(long mediaId)
public void GetFavoritesMediaList(long mediaId, ObservableCollection<FavoritesMedia> result)
{
throw new NotImplementedException();
var medias = FavoritesResource.GetAllFavoritesMedia(mediaId);
if (medias.Count == 0) { return; }
int order = 0;
foreach (var media in medias)
{
order++;
// 查询、保存封面
StorageCover storageCover = new StorageCover();
string coverUrl = media.Cover;
string cover = storageCover.GetCover(media.Id, media.Bvid, -1, coverUrl);
App.PropertyChangeAsync(new Action(() =>
{
FavoritesMedia newMedia = new FavoritesMedia
{
Avid = media.Id,
Bvid = media.Bvid,
Order = order,
Cover = cover == null ? null : new BitmapImage(new Uri(cover)),
Title = media.Title,
PlayNumber = media.CntInfo != null ? Format.FormatNumber(media.CntInfo.Play) : "0",
DanmakuNumber = media.CntInfo != null ? Format.FormatNumber(media.CntInfo.Danmaku) : "0",
FavoriteNumber = media.CntInfo != null ? Format.FormatNumber(media.CntInfo.Collect) : "0",
Duration = Format.FormatDuration2(media.Duration),
UpName = media.Upper != null ? media.Upper.Name : string.Empty,
UpperMid = media.Upper != null ? media.Upper.Mid : -1
};
if (!result.ToList().Exists(t => t.Avid == newMedia.Avid))
{
result.Add(newMedia);
Thread.Sleep(50);
}
}));
}
}
}
}

@ -1,11 +1,11 @@
using DownKyi.Models;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace DownKyi.Services
{
public interface IFavoritesService
{
Favorites GetFavorites(long mediaId);
List<FavoritesMedia> GetFavoritesMediaList(long mediaId);
void GetFavoritesMediaList(long mediaId, ObservableCollection<FavoritesMedia> result);
}
}

@ -28,6 +28,8 @@
<SolidColorBrush x:Key="BrushBackgroundGreyTranslucent2" Color="{DynamicResource ColorBackgroundGreyTranslucent2}" />
<SolidColorBrush x:Key="BrushBackgroundGreyTranslucent3" Color="{DynamicResource ColorBackgroundGreyTranslucent3}" />
<SolidColorBrush x:Key="BrushMask" Color="{DynamicResource ColorMask}" />
<SolidColorBrush x:Key="BrushTabHeaderGrey" Color="{DynamicResource ColorTabHeaderGrey}" />
<SolidColorBrush x:Key="BrushHeaderGrey" Color="{DynamicResource ColorHeaderGrey}" />

@ -28,6 +28,8 @@
<Color x:Key="ColorBackgroundGreyTranslucent2">#7FBDBDBD</Color>
<Color x:Key="ColorBackgroundGreyTranslucent3">#33BDBDBD</Color>
<Color x:Key="ColorMask">#7F000000</Color>
<Color x:Key="ColorTabHeaderGrey">#FFF4F4F4</Color>
<Color x:Key="ColorHeaderGrey">#FFF4F4F4</Color>

@ -6,11 +6,9 @@ using DownKyi.Services;
using DownKyi.Utils;
using Prism.Commands;
using Prism.Events;
using Prism.Mvvm;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using System.Windows;
@ -64,11 +62,11 @@ namespace DownKyi.ViewModels
set { SetProperty(ref favorites, value); }
}
private List<FavoritesMedia> favoritesMedia;
public List<FavoritesMedia> FavoritesMedia
private ObservableCollection<FavoritesMedia> favoritesMedias;
public ObservableCollection<FavoritesMedia> FavoritesMedias
{
get { return favoritesMedia; }
set { SetProperty(ref favoritesMedia, value); }
get { return favoritesMedias; }
set { SetProperty(ref favoritesMedias, value); }
}
private Visibility contentVisibility;
@ -106,6 +104,8 @@ namespace DownKyi.ViewModels
Share = NormalIcon.Instance().Share;
Share.Fill = DictionaryResource.GetColor("ColorTextGrey2");
FavoritesMedias = new ObservableCollection<FavoritesMedia>();
#endregion
}
@ -202,6 +202,8 @@ namespace DownKyi.ViewModels
ContentVisibility = Visibility.Collapsed;
NoDataVisibility = Visibility.Collapsed;
FavoritesMedias.Clear();
}
/// <summary>
@ -224,6 +226,7 @@ namespace DownKyi.ViewModels
NoDataVisibility = Visibility.Collapsed;
}
favoritesService.GetFavoritesMediaList(favoritesId, FavoritesMedias);
}
/// <summary>

@ -281,9 +281,165 @@
Style="{StaticResource BtnStyle}" />
</StackPanel>
<!-- 右侧内容区 -->
<ContentControl Grid.Column="1" prism:RegionManager.RegionName="SettingsContentRegion" />
<ListBox
x:Name="nameFavoritesMedias"
Grid.Column="1"
Margin="30,0,0,0"
ItemsSource="{Binding FavoritesMedias, Mode=TwoWay}"
SelectionMode="Extended">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding FavoritesMediasCommand}" CommandParameter="{Binding ElementName=nameFavoritesMedias, Path=SelectedItem}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<ListBox.Template>
<ControlTemplate TargetType="{x:Type ListBox}">
<ScrollViewer
CanContentScroll="False"
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Auto">
<StackPanel IsItemsHost="True" Orientation="Vertical" />
</ScrollViewer>
</ControlTemplate>
</ListBox.Template>
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Grid Margin="0,10" Background="{DynamicResource BrushBackground}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="150" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="0"
Width="35"
Margin="0,0,5,0"
VerticalAlignment="Center"
FontSize="14"
Foreground="{DynamicResource BrushTextDark}"
Text="{Binding Order}" />
<Image Grid.Column="1" Source="{Binding Cover}" />
<Border
x:Name="nameInfoPanel"
Grid.Column="1"
Width="150"
Height="95"
Background="{DynamicResource BrushMask}"
Visibility="Hidden">
<TextBlock
Margin="5,0,0,5"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
FontSize="12"
Foreground="{DynamicResource BrushText}"
Text="{Binding Duration}" />
</Border>
<Grid Grid.Column="2" Margin="20,0">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<TextBlock
Grid.Row="0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Cursor="Hand"
FontSize="14"
Text="{Binding Title}"
TextTrimming="CharacterEllipsis"
ToolTip="{Binding Title}">
<TextBlock.Style>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="{DynamicResource BrushTextDark}" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="{DynamicResource BrushPrimary}" />
</Trigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
<StackPanel Grid.Row="1" Orientation="Horizontal">
<TextBlock
FontSize="12"
Foreground="{DynamicResource BrushTextGrey}"
Text="{Binding PlayNumber}" />
<TextBlock
FontSize="12"
Foreground="{DynamicResource BrushTextGrey}"
Text="{DynamicResource Play}" />
<TextBlock
FontSize="12"
Foreground="{DynamicResource BrushTextGrey}"
Text=" · " />
<TextBlock
FontSize="12"
Foreground="{DynamicResource BrushTextGrey}"
Text="{Binding DanmakuNumber}" />
<TextBlock
FontSize="12"
Foreground="{DynamicResource BrushTextGrey}"
Text="{DynamicResource Danmaku}" />
<TextBlock
FontSize="12"
Foreground="{DynamicResource BrushTextGrey}"
Text=" · " />
<TextBlock
FontSize="12"
Foreground="{DynamicResource BrushTextGrey}"
Text="{Binding FavoriteNumber}" />
<TextBlock
FontSize="12"
Foreground="{DynamicResource BrushTextGrey}"
Text="{DynamicResource Favorite}" />
</StackPanel>
<TextBlock
Grid.Row="2"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Cursor="Hand"
FontSize="12"
Text="{Binding UpName, StringFormat={}UP: {0}}">
<TextBlock.Style>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="{DynamicResource BrushTextGrey}" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="{DynamicResource BrushPrimary}" />
</Trigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Grid>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="nameInfoPanel" Property="Visibility" Value="Visible" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
</Grid>
<!-- 没有数据提示 -->

Loading…
Cancel
Save