添加CustomPager

croire 3 years ago
parent 30535c11cd
commit 4b1af53db7

@ -164,6 +164,7 @@ namespace DownKyi
containerRegistry.RegisterForNavigation<ViewUserSpace>(ViewUserSpaceViewModel.Tag);
containerRegistry.RegisterForNavigation<ViewMySpace>(ViewMySpaceViewModel.Tag);
containerRegistry.RegisterForNavigation<ViewPublicFavorites>(ViewPublicFavoritesViewModel.Tag);
containerRegistry.RegisterForNavigation<ViewPublication>(ViewPublicationViewModel.Tag);
// downloadManager pages
containerRegistry.RegisterForNavigation<ViewDownloading>(ViewDownloadingViewModel.Tag);

@ -0,0 +1,325 @@
<UserControl
x:Class="DownKyi.ui.CustomControl.CustomPager"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DownKyi.ui.CustomControl"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<UserControl.Resources>
<DrawingImage x:Key="ToLeftDrawingImage">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V1024 H1024 V0 H0 Z">
<DrawingGroup.Transform>
<TranslateTransform X="0" Y="1.7763568394002505E-15" />
</DrawingGroup.Transform>
<GeometryDrawing Brush="#FF666666" Geometry="F1 M1024,1024z M0,0z M345.49,512L778.27,80.69Q791.47,66.02 791.47,46.95 791.47,27.88 777.54,13.94 763.6,-1.77635683940025E-15 744.53,-1.77635683940025E-15 725.46,-1.77635683940025E-15 710.79,14.67L247.2,478.26Q232.53,492.93 232.53,512 232.53,531.07 247.2,545.74L710.79,1009.33Q725.46,1024 744.53,1024 763.6,1024 777.54,1010.07 791.47,996.13 791.47,977.06 791.47,957.98 778.27,943.31L345.49,512z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
<DrawingImage x:Key="ToLeftHoverDrawingImage">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V1024 H1024 V0 H0 Z">
<DrawingGroup.Transform>
<TranslateTransform X="0" Y="1.7763568394002505E-15" />
</DrawingGroup.Transform>
<GeometryDrawing Brush="#FF00A1D6" Geometry="F1 M1024,1024z M0,0z M345.49,512L778.27,80.69Q791.47,66.02 791.47,46.95 791.47,27.88 777.54,13.94 763.6,-1.77635683940025E-15 744.53,-1.77635683940025E-15 725.46,-1.77635683940025E-15 710.79,14.67L247.2,478.26Q232.53,492.93 232.53,512 232.53,531.07 247.2,545.74L710.79,1009.33Q725.46,1024 744.53,1024 763.6,1024 777.54,1010.07 791.47,996.13 791.47,977.06 791.47,957.98 778.27,943.31L345.49,512z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
<DrawingImage x:Key="ToRightDrawingImage">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V1024 H1024 V0 H0 Z">
<DrawingGroup.Transform>
<TranslateTransform X="0" Y="1.7763568394002505E-15" />
</DrawingGroup.Transform>
<GeometryDrawing Brush="#FF666666" Geometry="F1 M1024,1024z M0,0z M678.51,512L245.73,80.69Q232.53,66.02 232.53,46.95 232.53,27.88 246.46,13.94 260.4,-1.77635683940025E-15 279.47,-1.77635683940025E-15 298.54,-1.77635683940025E-15 313.21,14.67L776.8,478.26Q791.47,492.93 791.47,512 791.47,531.07 776.8,545.74L313.21,1009.33Q298.54,1024 279.47,1024 260.4,1024 246.46,1010.07 232.53,996.13 232.53,977.06 232.53,957.98 245.73,943.31L678.51,512z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
<DrawingImage x:Key="ToRightHoverDrawingImage">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V1024 H1024 V0 H0 Z">
<DrawingGroup.Transform>
<TranslateTransform X="0" Y="1.7763568394002505E-15" />
</DrawingGroup.Transform>
<GeometryDrawing Brush="#FF00A1D6" Geometry="F1 M1024,1024z M0,0z M678.51,512L245.73,80.69Q232.53,66.02 232.53,46.95 232.53,27.88 246.46,13.94 260.4,-1.77635683940025E-15 279.47,-1.77635683940025E-15 298.54,-1.77635683940025E-15 313.21,14.67L776.8,478.26Q791.47,492.93 791.47,512 791.47,531.07 776.8,545.74L313.21,1009.33Q298.54,1024 279.47,1024 260.4,1024 246.46,1010.07 232.53,996.13 232.53,977.06 232.53,957.98 245.73,943.31L678.51,512z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
<Style x:Key="pagerBorder" TargetType="Border">
<Setter Property="Background" Value="#FFFFFFFF" />
<Setter Property="BorderBrush" Value="#FFD7DDE4" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="CornerRadius" Value="4" />
<Setter Property="Width" Value="30" />
<Setter Property="Height" Value="30" />
<Setter Property="Cursor" Value="Hand" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="BorderBrush" Value="#FF00A1D6" />
</Trigger>
<Trigger Property="IsMouseOver" Value="false">
<Setter Property="BorderBrush" Value="#FFD7DDE4" />
</Trigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
<StackPanel Orientation="Horizontal">
<Border
Name="namePrevious"
Margin="0,0,8,0"
MouseLeftButtonUp="Previous_MouseLeftButtonUp"
Style="{StaticResource pagerBorder}">
<Image
Width="16"
Height="16"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<Image.Style>
<Style TargetType="Image">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsMouseOver, ElementName=namePrevious}" Value="True">
<Setter Property="Source" Value="{DynamicResource ToLeftHoverDrawingImage}" />
</DataTrigger>
<DataTrigger Binding="{Binding Path=IsMouseOver, ElementName=namePrevious}" Value="False">
<Setter Property="Source" Value="{DynamicResource ToLeftDrawingImage}" />
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
</Border>
<Border
Name="nameFirst"
Margin="0,0,4,0"
MouseLeftButtonUp="First_MouseLeftButtonUp"
Style="{StaticResource pagerBorder}">
<TextBlock
Name="nameFirstText"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="14">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsMouseOver, ElementName=nameFirst}" Value="True">
<Setter Property="Foreground" Value="#FF00A1D6" />
</DataTrigger>
<DataTrigger Binding="{Binding Path=IsMouseOver, ElementName=nameFirst}" Value="False">
<Setter Property="Foreground" Value="#FF657180" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Border>
<Border
Name="nameLeftJump"
Width="20"
Height="40"
Margin="0,0,4,0">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="#FF666666"
Text="&#x2022;&#x2022;&#x2022;" />
</Border>
<Border
Name="namePreviousSecond"
Margin="0,0,4,0"
MouseLeftButtonUp="PreviousSecond_MouseLeftButtonUp"
Style="{StaticResource pagerBorder}">
<TextBlock
Name="namePreviousSecondText"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="14">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsMouseOver, ElementName=namePreviousSecond}" Value="True">
<Setter Property="Foreground" Value="#FF00A1D6" />
</DataTrigger>
<DataTrigger Binding="{Binding Path=IsMouseOver, ElementName=namePreviousSecond}" Value="False">
<Setter Property="Foreground" Value="#FF657180" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Border>
<Border
Name="namePreviousFirst"
Margin="0,0,4,0"
MouseLeftButtonUp="PreviousFirst_MouseLeftButtonUp"
Style="{StaticResource pagerBorder}">
<TextBlock
Name="namePreviousFirstText"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="14">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsMouseOver, ElementName=namePreviousFirst}" Value="True">
<Setter Property="Foreground" Value="#FF00A1D6" />
</DataTrigger>
<DataTrigger Binding="{Binding Path=IsMouseOver, ElementName=namePreviousFirst}" Value="False">
<Setter Property="Foreground" Value="#FF657180" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Border>
<Border
Name="nameCurrent"
Margin="0,0,4,0"
Background="#FF00A1D6"
BorderThickness="0"
MouseLeftButtonUp="Current_MouseLeftButtonUp"
Style="{StaticResource pagerBorder}">
<TextBlock
Name="nameCurrentText"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="14"
Foreground="#FFFFFFFF">
<!--<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsMouseOver, ElementName=nameCurrent}" Value="True">
<Setter Property="Foreground" Value="#FF00A1D6"/>
</DataTrigger>
<DataTrigger Binding="{Binding Path=IsMouseOver, ElementName=nameCurrent}" Value="False">
<Setter Property="Foreground" Value="#FF657180"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>-->
</TextBlock>
</Border>
<Border
Name="nameNextFirst"
Margin="0,0,4,0"
MouseLeftButtonUp="NextFirst_MouseLeftButtonUp"
Style="{StaticResource pagerBorder}">
<TextBlock
Name="nameNextFirstText"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="14">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsMouseOver, ElementName=nameNextFirst}" Value="True">
<Setter Property="Foreground" Value="#FF00A1D6" />
</DataTrigger>
<DataTrigger Binding="{Binding Path=IsMouseOver, ElementName=nameNextFirst}" Value="False">
<Setter Property="Foreground" Value="#FF657180" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Border>
<Border
Name="nameNextSecond"
Margin="0,0,4,0"
MouseLeftButtonUp="NextSecond_MouseLeftButtonUp"
Style="{StaticResource pagerBorder}">
<TextBlock
Name="nameNextSecondText"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="14">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsMouseOver, ElementName=nameNextSecond}" Value="True">
<Setter Property="Foreground" Value="#FF00A1D6" />
</DataTrigger>
<DataTrigger Binding="{Binding Path=IsMouseOver, ElementName=nameNextSecond}" Value="False">
<Setter Property="Foreground" Value="#FF657180" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Border>
<Border
Name="nameRightJump"
Width="20"
Height="40"
Margin="0,0,4,0">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="#FF666666"
Text="&#x2022;&#x2022;&#x2022;" />
</Border>
<Border
Name="nameLast"
Margin="0,0,4,0"
MouseLeftButtonUp="Last_MouseLeftButtonUp"
Style="{StaticResource pagerBorder}">
<TextBlock
Name="nameLastText"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="14">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsMouseOver, ElementName=nameLast}" Value="True">
<Setter Property="Foreground" Value="#FF00A1D6" />
</DataTrigger>
<DataTrigger Binding="{Binding Path=IsMouseOver, ElementName=nameLast}" Value="False">
<Setter Property="Foreground" Value="#FF657180" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Border>
<Border
Name="nameNext"
Margin="4,0,4,0"
MouseLeftButtonUp="Next_MouseLeftButtonUp"
Style="{StaticResource pagerBorder}">
<Image
Width="16"
Height="16"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<Image.Style>
<Style TargetType="Image">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsMouseOver, ElementName=nameNext}" Value="True">
<Setter Property="Source" Value="{DynamicResource ToRightHoverDrawingImage}" />
</DataTrigger>
<DataTrigger Binding="{Binding Path=IsMouseOver, ElementName=nameNext}" Value="False">
<Setter Property="Source" Value="{DynamicResource ToRightDrawingImage}" />
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
</Border>
</StackPanel>
</UserControl>

@ -0,0 +1,275 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace DownKyi.ui.CustomControl
{
/// <summary>
/// CustomPager.xaml 的交互逻辑
/// </summary>
public partial class CustomPager : UserControl
{
public CustomPager()
{
InitializeComponent();
DataContext = this;
}
// Current修改的回调
public delegate void CurrentChangedHandler(int current);
public event CurrentChangedHandler CurrentChanged;
protected virtual void OnCurrentChanged(int current)
{
CurrentChanged?.Invoke(current);
}
// Count修改的回调
public delegate void CountChangedHandler(int current);
public event CountChangedHandler CountChanged;
protected virtual void OnCountChanged(int count)
{
CountChanged?.Invoke(count);
}
private int current;
public int Current
{
get
{
var value = GetValue(CurrentProperty);
if (value == null) { return 1; }
if ((int)value < 1)
{
return 1;
}
return (int)value;
}
set
{
SetValue(CurrentProperty, value);
if (Count > 0 && (value > Count || value < 1))
{
//throw new Exception("数值不在允许的范围内。");
}
else
{
current = value;
SetView();
OnCurrentChanged(current);
}
}
}
public static readonly DependencyProperty CurrentProperty =
DependencyProperty.Register(
"Current",
typeof(object),
typeof(CustomPager),
new PropertyMetadata(default, OnCurrentPropertyChanged));
private static void OnCurrentPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
//CustomPager source = d as CustomPager;
}
//private int count;
public int Count
{
get
{
return (int)GetValue(CountProperty);
}
set
{
SetValue(CountProperty, value);
//if (value < Current || value < 1)
//{
// //throw new Exception("数值不在允许的范围内。");
//}
//else
//{
// count = value;
// if (count == 1) { Visibility = Visibility.Hidden; }
// else { Visibility = Visibility.Visible; }
// SetView();
// OnCountChanged(count);
//}
}
}
public static readonly DependencyProperty CountProperty =
DependencyProperty.Register(
"Count",
typeof(object),
typeof(CustomPager),
new PropertyMetadata(default, OnCountPropertyChanged));
private static void OnCountPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
CustomPager source = d as CustomPager;
if ((int)e.NewValue < source.Current || (int)e.NewValue < 1)
{
//throw new Exception("数值不在允许的范围内。");
}
else
{
//source.Count = (int)e.NewValue;
if (source.Count == 1) { source.Visibility = Visibility.Hidden; }
else { source.Visibility = Visibility.Visible; }
source.SetView();
source.OnCountChanged(source.Count);
}
}
private void Previous_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
Current -= 1;
}
private void First_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
Current = 1;
}
private void PreviousSecond_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
Current -= 2;
}
private void PreviousFirst_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
Current -= 1;
}
private void Current_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{ }
private void NextFirst_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
Current += 1;
}
private void NextSecond_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
Current += 2;
}
private void Last_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
Current = Count;
}
private void Next_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
Current += 1;
}
/// <summary>
/// 控制显示,暴力实现,以后重构
/// </summary>
protected void SetView()
{
nameFirstText.Text = "1";
namePreviousSecondText.Text = (Current - 2).ToString();
namePreviousFirstText.Text = (Current - 1).ToString();
nameCurrentText.Text = Current.ToString();
nameNextFirstText.Text = (Current + 1).ToString();
nameNextSecondText.Text = (Current + 2).ToString();
nameLastText.Text = Count.ToString();
// 控制Current左边的控件
if (Current == 1)
{
namePrevious.Visibility = Visibility.Collapsed;
nameFirst.Visibility = Visibility.Collapsed;
nameLeftJump.Visibility = Visibility.Collapsed;
namePreviousSecond.Visibility = Visibility.Collapsed;
namePreviousFirst.Visibility = Visibility.Collapsed;
}
else if (Current == 2)
{
namePrevious.Visibility = Visibility.Visible;
nameFirst.Visibility = Visibility.Collapsed;
nameLeftJump.Visibility = Visibility.Collapsed;
namePreviousSecond.Visibility = Visibility.Collapsed;
namePreviousFirst.Visibility = Visibility.Visible;
}
else if (Current == 3)
{
namePrevious.Visibility = Visibility.Visible;
nameFirst.Visibility = Visibility.Collapsed;
nameLeftJump.Visibility = Visibility.Collapsed;
namePreviousSecond.Visibility = Visibility.Visible;
namePreviousFirst.Visibility = Visibility.Visible;
}
else if (Current == 4)
{
namePrevious.Visibility = Visibility.Visible;
nameFirst.Visibility = Visibility.Visible;
nameLeftJump.Visibility = Visibility.Collapsed;
namePreviousSecond.Visibility = Visibility.Visible;
namePreviousFirst.Visibility = Visibility.Visible;
}
else
{
namePrevious.Visibility = Visibility.Visible;
nameFirst.Visibility = Visibility.Visible;
nameLeftJump.Visibility = Visibility.Visible;
namePreviousSecond.Visibility = Visibility.Visible;
namePreviousFirst.Visibility = Visibility.Visible;
}
// 控制Current右边的控件
if (Current == Count)
{
nameNextFirst.Visibility = Visibility.Collapsed;
nameNextSecond.Visibility = Visibility.Collapsed;
nameRightJump.Visibility = Visibility.Collapsed;
nameLast.Visibility = Visibility.Collapsed;
nameNext.Visibility = Visibility.Collapsed;
}
else if (Current == Count - 1)
{
nameNextFirst.Visibility = Visibility.Visible;
nameNextSecond.Visibility = Visibility.Collapsed;
nameRightJump.Visibility = Visibility.Collapsed;
nameLast.Visibility = Visibility.Collapsed;
nameNext.Visibility = Visibility.Visible;
}
else if (Current == Count - 2)
{
nameNextFirst.Visibility = Visibility.Visible;
nameNextSecond.Visibility = Visibility.Visible;
nameRightJump.Visibility = Visibility.Collapsed;
nameLast.Visibility = Visibility.Collapsed;
nameNext.Visibility = Visibility.Visible;
}
else if (Current == Count - 3)
{
nameNextFirst.Visibility = Visibility.Visible;
nameNextSecond.Visibility = Visibility.Visible;
nameRightJump.Visibility = Visibility.Collapsed;
nameLast.Visibility = Visibility.Visible;
nameNext.Visibility = Visibility.Visible;
}
else
{
nameNextFirst.Visibility = Visibility.Visible;
nameNextSecond.Visibility = Visibility.Visible;
nameRightJump.Visibility = Visibility.Visible;
nameLast.Visibility = Visibility.Visible;
nameNext.Visibility = Visibility.Visible;
}
}
}
}

@ -80,6 +80,9 @@
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Converter\CountConverter.cs" />
<Compile Include="CustomControl\CustomPager.xaml.cs">
<DependentUpon>CustomPager.xaml</DependentUpon>
</Compile>
<Compile Include="CustomControl\GifImage.cs" />
<Compile Include="Events\MessageEvent.cs" />
<Compile Include="Events\NavigationEvent.cs" />
@ -145,6 +148,7 @@
<Compile Include="ViewModels\Settings\ViewNetworkViewModel.cs" />
<Compile Include="ViewModels\Dialogs\ViewParsingSelectorViewModel.cs" />
<Compile Include="ViewModels\ViewMySpaceViewModel.cs" />
<Compile Include="ViewModels\ViewPublicationViewModel.cs" />
<Compile Include="ViewModels\ViewPublicFavoritesViewModel.cs" />
<Compile Include="ViewModels\ViewSettingsViewModel.cs" />
<Compile Include="ViewModels\ViewToolboxViewModel.cs" />
@ -208,6 +212,9 @@
<Compile Include="Views\ViewMySpace.xaml.cs">
<DependentUpon>ViewMySpace.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ViewPublication.xaml.cs">
<DependentUpon>ViewPublication.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ViewPublicFavorites.xaml.cs">
<DependentUpon>ViewPublicFavorites.xaml</DependentUpon>
</Compile>
@ -223,6 +230,10 @@
<Compile Include="Views\ViewVideoDetail.xaml.cs">
<DependentUpon>ViewVideoDetail.xaml</DependentUpon>
</Compile>
<Page Include="CustomControl\CustomPager.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Languages\en_US.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@ -379,6 +390,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\ViewPublication.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\ViewPublicFavorites.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

@ -64,6 +64,14 @@
<system:String x:Key="Publication">投稿视频</system:String>
<system:String x:Key="Channel">频道</system:String>
<!-- PublicFavorites -->
<system:String x:Key="PublicFavorites">收藏夹</system:String>
<system:String x:Key="FavoritesMediaCount">个内容</system:String>
<!-- Publication -->
<system:String x:Key="DownloadSelectedPublication">下载选中项</system:String>
<system:String x:Key="DownloadAllPublication">下载全部</system:String>
<!-- VideoDetail -->
<system:String x:Key="CopyCover">复制封面图片</system:String>
<system:String x:Key="CopyCoverUrl">复制封面URL</system:String>
@ -252,10 +260,6 @@
<system:String x:Key="ExtractAudio">提取音频</system:String>
<system:String x:Key="ExtractVideo">提取视频</system:String>
<!-- PublicFavorites -->
<system:String x:Key="PublicFavorites">收藏夹</system:String>
<system:String x:Key="FavoritesMediaCount">个内容</system:String>
<!-- Dialog -->
<system:String x:Key="Cancel">取消</system:String>
<system:String x:Key="SelectDirectory">请选择文件夹</system:String>

@ -6,7 +6,13 @@
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Grid x:Name="panel" Height="60">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackPanel
Grid.Column="0"
Margin="20,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
@ -34,12 +40,26 @@
Fill="{Binding Image.Fill}"
Stretch="UniformToFill" />
</ContentControl>
<TextBlock
x:Name="text"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="12"
Text="{Binding Title}" />
Foreground="{DynamicResource BrushTextDark}"
Text="{Binding Title}"
TextTrimming="CharacterEllipsis" />
</StackPanel>
<TextBlock
x:Name="sub"
Grid.Column="1"
Margin="10,0,20,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
FontSize="12"
Foreground="{DynamicResource BrushTextGrey2}"
Text="{Binding SubTitle}" />
</Grid>
<ControlTemplate.Triggers>

@ -1,10 +1,13 @@
using DownKyi.Core.BiliApi.Users.Models;
using DownKyi.Core.BiliApi.Zone;
using DownKyi.Events;
using DownKyi.Utils;
using Prism.Commands;
using Prism.Events;
using Prism.Regions;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using System.Windows.Media;
@ -12,7 +15,9 @@ namespace DownKyi.ViewModels.UserSpace
{
public class ViewArchiveViewModel : BaseViewModel
{
public const string Tag = "ArchiveView";
public const string Tag = "PageUserSpaceArchiveView";
private long mid = -1;
#region 页面属性申明
@ -23,6 +28,13 @@ namespace DownKyi.ViewModels.UserSpace
set => SetProperty(ref publicationZones, value);
}
private int selectedItem;
public int SelectedItem
{
get => selectedItem;
set => SetProperty(ref selectedItem, value);
}
#endregion
public ViewArchiveViewModel(IEventAggregator eventAggregator) : base(eventAggregator)
@ -35,6 +47,38 @@ namespace DownKyi.ViewModels.UserSpace
}
#region 命令申明
// 视频选择事件
private DelegateCommand<object> publicationZonesCommand;
public DelegateCommand<object> PublicationZonesCommand => publicationZonesCommand ?? (publicationZonesCommand = new DelegateCommand<object>(ExecutePublicationZonesCommand));
/// <summary>
/// 视频选择事件
/// </summary>
/// <param name="parameter"></param>
private void ExecutePublicationZonesCommand(object parameter)
{
if (!(parameter is PublicationZone zone)) { return; }
Dictionary<string, object> data = new Dictionary<string, object>
{
{ "mid", mid },
{ "tid", zone.Tid },
{ "list", PublicationZones.ToList() }
};
// 进入视频页面
NavigationParam param = new NavigationParam
{
ViewName = ViewPublicationViewModel.Tag,
ParentViewName = ViewUserSpaceViewModel.Tag,
Parameter = data
};
eventAggregator.GetEvent<NavigationEvent>().Publish(param);
SelectedItem = -1;
}
#endregion
public override void OnNavigatedFrom(NavigationContext navigationContext)
@ -42,6 +86,7 @@ namespace DownKyi.ViewModels.UserSpace
base.OnNavigatedFrom(navigationContext);
PublicationZones.Clear();
SelectedItem = -1;
}
/// <summary>
@ -53,6 +98,7 @@ namespace DownKyi.ViewModels.UserSpace
base.OnNavigatedTo(navigationContext);
PublicationZones.Clear();
SelectedItem = -1;
// 根据传入参数不同执行不同任务
var parameter = navigationContext.Parameters.GetValue<List<SpacePublicationListTypeVideoZone>>("object");
@ -61,6 +107,9 @@ namespace DownKyi.ViewModels.UserSpace
return;
}
// 传入mid
mid = navigationContext.Parameters.GetValue<long>("mid");
int VideoCount = 0;
foreach (var zone in parameter)
{

@ -12,7 +12,7 @@ namespace DownKyi.ViewModels.UserSpace
{
public class ViewChannelViewModel : BaseViewModel
{
public const string Tag = "Channel";
public const string Tag = "PageUserSpaceChannel";
#region 页面属性申明

@ -0,0 +1,171 @@
using DownKyi.Events;
using DownKyi.Images;
using DownKyi.Utils;
using DownKyi.ViewModels.PageViewModels;
using DownKyi.ViewModels.UserSpace;
using Prism.Commands;
using Prism.Events;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DownKyi.ViewModels
{
public class ViewPublicationViewModel : BaseViewModel
{
public const string Tag = "PagePublication";
private long mid = -1;
// 每页视频数量,暂时在此写死,以后在设置中增加选项
private readonly int VideoNumberInPage = 30;
#region 页面属性申明
private VectorImage arrowBack;
public VectorImage ArrowBack
{
get => arrowBack;
set => SetProperty(ref arrowBack, value);
}
private ObservableCollection<TabHeader> tabHeaders;
public ObservableCollection<TabHeader> TabHeaders
{
get => tabHeaders;
set => SetProperty(ref tabHeaders, value);
}
private int selectTabId;
public int SelectTabId
{
get => selectTabId;
set => SetProperty(ref selectTabId, value);
}
private int countPage;
public int CountPage
{
get => countPage;
set => SetProperty(ref countPage, value);
}
private int currentPage;
public int CurrentPage
{
get => currentPage;
set => SetProperty(ref currentPage, value);
}
#endregion
public ViewPublicationViewModel(IEventAggregator eventAggregator) : base(eventAggregator)
{
#region 属性初始化
ArrowBack = NavigationIcon.Instance().ArrowBack;
ArrowBack.Fill = DictionaryResource.GetColor("ColorTextDark");
TabHeaders = new ObservableCollection<TabHeader>();
#endregion
}
#region 命令申明
// 返回事件
private DelegateCommand backSpaceCommand;
public DelegateCommand BackSpaceCommand => backSpaceCommand ?? (backSpaceCommand = new DelegateCommand(ExecuteBackSpace));
/// <summary>
/// 返回事件
/// </summary>
private void ExecuteBackSpace()
{
ArrowBack.Fill = DictionaryResource.GetColor("ColorText");
NavigationParam parameter = new NavigationParam
{
ViewName = ParentView,
ParentViewName = null,
Parameter = null
};
eventAggregator.GetEvent<NavigationEvent>().Publish(parameter);
}
// 左侧tab点击事件
private DelegateCommand<object> leftTabHeadersCommand;
public DelegateCommand<object> LeftTabHeadersCommand => leftTabHeadersCommand ?? (leftTabHeadersCommand = new DelegateCommand<object>(ExecuteLeftTabHeadersCommand));
/// <summary>
/// 左侧tab点击事件
/// </summary>
/// <param name="parameter"></param>
private void ExecuteLeftTabHeadersCommand(object parameter)
{
if (!(parameter is TabHeader tabHeader)) { return; }
// 页面选择
CountPage = (int)Math.Ceiling(double.Parse(tabHeader.SubTitle) / VideoNumberInPage);
CurrentPage = 1;
}
#endregion
/// <summary>
/// 初始化页面数据
/// </summary>
private void InitView()
{
ArrowBack.Fill = DictionaryResource.GetColor("ColorTextDark");
TabHeaders.Clear();
SelectTabId = -1;
}
/// <summary>
/// 导航到VideoDetail页面时执行
/// </summary>
/// <param name="navigationContext"></param>
public override void OnNavigatedTo(NavigationContext navigationContext)
{
base.OnNavigatedTo(navigationContext);
InitView();
// 根据传入参数不同执行不同任务
var parameter = navigationContext.Parameters.GetValue<Dictionary<string, object>>("Parameter");
if (parameter == null)
{
return;
}
mid = (long)parameter["mid"];
int tid = (int)parameter["tid"];
List<PublicationZone> zones = (List<PublicationZone>)parameter["list"];
foreach (var item in zones)
{
TabHeaders.Add(new TabHeader
{
Id = item.Tid,
Title = item.Name,
SubTitle = item.Count.ToString()
});
}
// 初始选中项
var selectTab = TabHeaders.FirstOrDefault(item => item.Id == tid);
SelectTabId = TabHeaders.IndexOf(selectTab);
// 页面选择
CountPage = (int)Math.Ceiling(double.Parse(selectTab.SubTitle) / VideoNumberInPage);
CurrentPage = 1;
}
}
}

@ -216,6 +216,7 @@ namespace DownKyi.ViewModels
NavigationParameters param = new NavigationParameters()
{
{ "object", banner.Object },
{ "mid", mid },
};
switch (banner.Id)

@ -2,6 +2,7 @@
x:Class="DownKyi.Views.UserSpace.ViewArchive"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True">
<Grid>
@ -10,9 +11,16 @@
</Grid.RowDefinitions>
<ListBox
Name="namePublicationZones"
Margin="30,0,0,0"
ItemsSource="{Binding PublicationZones}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
SelectedIndex="{Binding SelectedItem}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding PublicationZonesCommand}" CommandParameter="{Binding ElementName=namePublicationZones, Path=SelectedItem}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel IsItemsHost="True" />

@ -0,0 +1,156 @@
<UserControl
x:Class="DownKyi.Views.ViewPublication"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:custom="clr-namespace:DownKyi.ui.CustomControl"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True">
<UserControl.Resources />
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="1" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="100" />
</Grid.ColumnDefinitions>
<Button
Grid.Column="0"
Margin="10,5,0,5"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Command="{Binding BackSpaceCommand}"
Style="{StaticResource ImageBtnStyle}">
<StackPanel Orientation="Horizontal">
<ContentControl Width="24" Height="24">
<Path
Width="{Binding ArrowBack.Width}"
Height="{Binding ArrowBack.Height}"
Data="{Binding ArrowBack.Data}"
Fill="{Binding ArrowBack.Fill}"
Stretch="None" />
</ContentControl>
<TextBlock
VerticalAlignment="Center"
FontSize="16"
Foreground="{DynamicResource BrushTextDark}"
Text="{DynamicResource Publication}" />
</StackPanel>
</Button>
</Grid>
<TextBlock Grid.Row="1" Background="{DynamicResource BrushBorder}" />
<Grid Grid.Row="2" Visibility="{Binding ContentVisibility}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<!-- 左侧tab header -->
<ListBox
Name="nameLeftTabHeaders"
Grid.Column="0"
BorderThickness="0"
ItemContainerStyle="{StaticResource LeftTabHeaderItemStyle}"
ItemsSource="{Binding TabHeaders}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Hidden"
SelectedIndex="{Binding SelectTabId, Mode=TwoWay}"
Style="{StaticResource LeftTabHeaderStyle}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding LeftTabHeadersCommand}" CommandParameter="{Binding ElementName=nameLeftTabHeaders, Path=SelectedItem}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</ListBox>
<Grid Name="nameMediaPanel" Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="1" />
<RowDefinition Height="49" />
</Grid.RowDefinitions>
<ListBox Grid.Row="0" SelectionMode="Extended">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel IsItemsHost="True" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
<TextBlock Grid.Row="1" Background="{DynamicResource BrushBorder}" />
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="80" />
<ColumnDefinition />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="80" />
</Grid.ColumnDefinitions>
<CheckBox
Grid.Column="0"
Margin="10,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Command="{Binding SelectAllCommand}"
CommandParameter="{Binding ElementName=nameVideoSections, Path=SelectedItem}"
Content="{DynamicResource SelectAll}"
Foreground="{DynamicResource BrushTextDark}"
IsChecked="{Binding IsSelectAll, Mode=TwoWay}"
Style="{StaticResource CheckBoxStyle}" />
<custom:CustomPager
x:Name="namePager"
Grid.Column="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Count="{Binding CountPage, Mode=TwoWay}"
Current="{Binding CurrentPage, Mode=TwoWay}"
DataContext="{Binding}" />
<Button
Grid.Column="2"
Margin="0,0,10,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Command="{Binding AddToDownloadCommand}"
Content="{DynamicResource DownloadSelectedPublication}"
FontSize="12"
Foreground="{DynamicResource BrushText}"
Style="{StaticResource BtnStyle}" />
<Button
Grid.Column="3"
Margin="0,0,10,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Command="{Binding AddAllCommand}"
Content="{DynamicResource DownloadAllPublication}"
FontSize="12"
Foreground="{DynamicResource BrushText}"
Style="{StaticResource BtnStyle}" />
</Grid>
</Grid>
</Grid>
<!-- 没有数据提示 -->
<Image
Grid.Row="2"
Width="256"
Height="256"
Source="/DownKyi;component/Resources/no-data.png"
Visibility="{Binding NoDataVisibility}" />
</Grid>
</UserControl>

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace DownKyi.Views
{
/// <summary>
/// ViewPublication.xaml 的交互逻辑
/// </summary>
public partial class ViewPublication : UserControl
{
public ViewPublication()
{
InitializeComponent();
}
}
}
Loading…
Cancel
Save