add more detailed examples of pagination

This commit is contained in:
NaBian committed 2018-11-12 23:05:33 +08:00
1 parent 72bb3d1b48
commit faed201a2c
10 files changed
+161 -26

No files matched your search

+3 -4
View File
@@ -11,7 +11,7 @@ namespace HandyControl.Controls
private const string IndicatorTemplateName = "PART_Indicator";
public static readonly DependencyProperty ArcThicknessProperty = DependencyProperty.Register(
"ArcThickness", typeof(double), typeof(CircleProgressBar), new PropertyMetadata(ValueBoxes.Double0Box));
"ArcThickness", typeof(double), typeof(CircleProgressBar), new PropertyMetadata(.0));
public static readonly DependencyProperty ShowTextProperty = DependencyProperty.Register(
"ShowText", typeof(bool), typeof(CircleProgressBar), new PropertyMetadata(ValueBoxes.TrueBox));
@@ -20,9 +20,8 @@ namespace HandyControl.Controls
static CircleProgressBar()
{
FocusableProperty.OverrideMetadata(typeof(CircleProgressBar),
new FrameworkPropertyMetadata(ValueBoxes.FalseBox));
MaximumProperty.OverrideMetadata(typeof(CircleProgressBar), new PropertyMetadata(ValueBoxes.Double100Box));
FocusableProperty.OverrideMetadata(typeof(CircleProgressBar), new FrameworkPropertyMetadata(ValueBoxes.FalseBox));
MaximumProperty.OverrideMetadata(typeof(CircleProgressBar), new FrameworkPropertyMetadata(ValueBoxes.Double100Box));
}
public bool ShowText
+21 -5
View File
@@ -3,6 +3,7 @@ using System.Diagnostics;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
@@ -218,6 +219,9 @@ namespace HandyControl.Controls
public static readonly DependencyProperty ImageSourceProperty = DependencyProperty.Register(
"ImageSource", typeof(BitmapFrame), typeof(ImageViewer), new PropertyMetadata(default(BitmapFrame)));
public static readonly DependencyProperty IsFullScreenProperty = DependencyProperty.Register(
"IsFullScreen", typeof(bool), typeof(ImageViewer), new PropertyMetadata(ValueBoxes.FalseBox));
internal static readonly DependencyProperty ImgPathProperty = DependencyProperty.Register(
"ImgPath", typeof(string), typeof(ImageViewer), new PropertyMetadata(default(string)));
@@ -260,6 +264,12 @@ namespace HandyControl.Controls
internal static readonly DependencyProperty ShowSmallImgInternalProperty = DependencyProperty.Register(
"ShowSmallImgInternal", typeof(bool), typeof(ImageViewer), new PropertyMetadata(ValueBoxes.FalseBox));
public bool IsFullScreen
{
get => (bool)GetValue(IsFullScreenProperty);
set => SetValue(IsFullScreenProperty, value);
}
public bool ShowImgMap
{
get => (bool)GetValue(ShowImgMapProperty);
@@ -397,7 +407,13 @@ namespace HandyControl.Controls
_imageMain = GetTemplateChild(ElementImageMain) as Image;
_borderBottom = GetTemplateChild(ElementBorderBottom) as Border;
if (_imageMain != null) _imageMain.MouseLeftButtonDown += ImageMain_OnMouseLeftButtonDown;
if (_imageMain != null)
{
var t = new RotateTransform();
BindingOperations.SetBinding(t, RotateTransform.AngleProperty, new Binding(ImageRotateProperty.Name) {Source = this});
_imageMain.LayoutTransform = t;
_imageMain.MouseLeftButtonDown += ImageMain_OnMouseLeftButtonDown;
}
if (_canvasSmallImg != null)
{
@@ -410,11 +426,11 @@ namespace HandyControl.Controls
private static void OnImageScaleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is ImageViewer ImageViewer && e.NewValue is double newValue)
if (d is ImageViewer imageViewer && e.NewValue is double newValue)
{
ImageViewer.ImageWidth = ImageViewer.ImageOriWidth * newValue;
ImageViewer.ImageHeight = ImageViewer.ImageOriHeight * newValue;
ImageViewer.ScaleStr = $"{newValue * 100:#0}%";
imageViewer.ImageWidth = imageViewer.ImageOriWidth * newValue;
imageViewer.ImageHeight = imageViewer.ImageOriHeight * newValue;
imageViewer.ScaleStr = $"{newValue * 100:#0}%";
}
}
-1
View File
@@ -201,7 +201,6 @@ namespace HandyControl.Controls
if (d is ScrollViewer ctl && e.NewValue is double v)
{
ctl.ScrollToHorizontalOffset(v);
Console.WriteLine(v);
}
}
+4 -8
View File
@@ -24,22 +24,19 @@ namespace HandyControl.Expression.Shapes
public double ArcThickness
{
get =>
(double) GetValue(ArcThicknessProperty);
get => (double) GetValue(ArcThicknessProperty);
set => SetValue(ArcThicknessProperty, value);
}
public UnitType ArcThicknessUnit
{
get =>
(UnitType) GetValue(ArcThicknessUnitProperty);
get => (UnitType) GetValue(ArcThicknessUnitProperty);
set => SetValue(ArcThicknessUnitProperty, value);
}
public double EndAngle
{
get =>
(double) GetValue(EndAngleProperty);
get => (double) GetValue(EndAngleProperty);
set => SetValue(EndAngleProperty, value);
}
@@ -51,8 +48,7 @@ namespace HandyControl.Expression.Shapes
public double StartAngle
{
get =>
(double) GetValue(StartAngleProperty);
get => (double) GetValue(StartAngleProperty);
set => SetValue(StartAngleProperty, value);
}
+2 -6
View File
@@ -29,11 +29,7 @@
</Grid.RowDefinitions>
<Grid x:Name="PART_GridMain" ClipToBounds="True" Grid.RowSpan="2">
<Border HorizontalAlignment="Left" VerticalAlignment="Top" Height="{TemplateBinding ImageHeight}" Width="{TemplateBinding ImageWidth}" Margin="{TemplateBinding ImageMargin}">
<Image Name="PART_ImageMain" RenderTransformOrigin="0.5,0.5" Source="{TemplateBinding ImageSource}">
<Image.LayoutTransform>
<RotateTransform Angle="{Binding ImageRotate,RelativeSource={RelativeSource TemplatedParent}}"/>
</Image.LayoutTransform>
</Image>
<Image Name="PART_ImageMain" RenderTransformOrigin="0.5,0.5" Source="{TemplateBinding ImageSource}"/>
</Border>
</Grid>
<Border Grid.Row="0" Grid.RowSpan="2" Width="252" Height="162" HorizontalAlignment="Right" VerticalAlignment="Bottom" Background="{DynamicResource DarkOpacityBrush}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1">
@@ -73,7 +69,7 @@
</TransformGroup>
</Button.RenderTransform>
</Button>
<ToggleButton Visibility="{TemplateBinding ShowFullScreenButton,Converter={StaticResource Boolean2VisibilityConverter}}" Foreground="{DynamicResource TextIconBrush}" IsChecked="{Binding IsFullScreen,RelativeSource={RelativeSource FindAncestor,AncestorType=controls:ImageBrowser},Mode=TwoWay}" Margin="12,0,6,0" Style="{StaticResource ToggleButtonIconTransparent}" controls:IconSwitchElement.Geometry="{StaticResource FullScreenGeometry}" controls:IconSwitchElement.GeometrySelected="{StaticResource FullScreenReturnGeometry}" Padding="3"/>
<ToggleButton Visibility="{TemplateBinding ShowFullScreenButton,Converter={StaticResource Boolean2VisibilityConverter}}" Foreground="{DynamicResource TextIconBrush}" IsChecked="{Binding IsFullScreen,RelativeSource={RelativeSource TemplatedParent},Mode=TwoWay}" Margin="12,0,6,0" Style="{StaticResource ToggleButtonIconTransparent}" controls:IconSwitchElement.Geometry="{StaticResource FullScreenGeometry}" controls:IconSwitchElement.GeometrySelected="{StaticResource FullScreenReturnGeometry}" Padding="3"/>
</StackPanel>
</Border>
+1
View File
@@ -236,6 +236,7 @@
<Compile Include="ViewModel\GrowlDemoViewModel.cs" />
<Compile Include="ViewModel\ImageBrowserDemoViewModel.cs" />
<Compile Include="ViewModel\MainViewModel.cs" />
<Compile Include="ViewModel\PaginationDemoViewModel.cs" />
<Compile Include="ViewModel\StepBarDemoViewModel.cs" />
<Compile Include="ViewModel\ViewModelLocator.cs" />
<Compile Include="ViewModel\WindowDemoViewModel.cs" />
+21
View File
@@ -43,6 +43,27 @@ namespace HandyControlDemo.Service
return list;
}
public List<DemoDataModel> GetDemoDataList(int count)
{
var list = new List<DemoDataModel>();
for (var i = 1; i <= count; i++)
{
var index = i % 6 + 1;
var model = new DemoDataModel
{
Index = i,
IsSelected = i % 2 == 0,
Name = $"Name{i}",
Type = (DemoType)index,
ImgPath = $"/HandyControlDemo;component/Resources/Img/Avatar/avatar{index}.png",
Remark = new string(i.ToString()[0], 10)
};
list.Add(model);
}
return list;
}
internal List<string> GetComboBoxDemoDataList()
{
var converter = new StringRepeatConverter();
@@ -2,8 +2,44 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Background="{DynamicResource RegionBrush}"
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl">
DataContext="{Binding PaginationDemo,Source={StaticResource Locator}}"
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
xmlns:i="clr-namespace:HandyControl.Interactivity;assembly=HandyControl">
<controls:TransitioningContentControl>
<controls:Pagination Margin="32" Width="600" MaxPageCount="10" VerticalAlignment="Center"/>
<Grid Margin="32">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<controls:Pagination MaxPageCount="10" PageIndex="{Binding PageIndex}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="PageUpdated">
<i:EventToCommand Command="{Binding PageUpdatedCmd}" PassEventArgsToCommand="True" />
</i:EventTrigger>
</i:Interaction.Triggers>
</controls:Pagination>
<DataGrid IsReadOnly="True" Width="600" Margin="0,16,0,0" Grid.Row="1" HeadersVisibility="All" RowHeaderWidth="60" AutoGenerateColumns="False" ItemsSource="{Binding DataList}">
<DataGrid.RowHeaderTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding IsSelected,RelativeSource={RelativeSource FindAncestor,AncestorType=DataGridRow}}"/>
</DataTemplate>
</DataGrid.RowHeaderTemplate>
<DataGrid.Columns>
<DataGridTextColumn IsReadOnly="True" Width="80" CanUserResize="False" Binding="{Binding Index}" Header="{x:Static langs:Lang.Index}"/>
<DataGridTemplateColumn Width="50" CanUserResize="False">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding ImgPath}" Width="32" Height="32" Stretch="Uniform"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Width="1*" Binding="{Binding Name}" Header="{x:Static langs:Lang.Name}"/>
<DataGridCheckBoxColumn Width="100" CanUserResize="False" Binding="{Binding IsSelected}" Header="{x:Static langs:Lang.Selected}"/>
<DataGridComboBoxColumn ItemsSource="{Binding Source={StaticResource DemoTypes}}" Width="100" CanUserResize="False" SelectedValueBinding="{Binding Type}" Header="{x:Static langs:Lang.Type}"/>
<DataGridTextColumn Width="1*" Binding="{Binding Remark}" Header="{x:Static langs:Lang.Remark}"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
</controls:TransitioningContentControl>
</UserControl>
@@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Linq;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.CommandWpf;
using HandyControl.Data;
using HandyControlDemo.Data;
using HandyControlDemo.Service;
namespace HandyControlDemo.ViewModel
{
public class PaginationDemoViewModel : ViewModelBase
{
/// <summary>
/// 所有数据
/// </summary>
private readonly List<DemoDataModel> _totalDataList;
/// <summary>
/// 显示的数据
/// </summary>
private List<DemoDataModel> _dataList;
/// <summary>
/// 显示的数据
/// </summary>
public List<DemoDataModel> DataList
{
get => _dataList;
set => Set(ref _dataList, value);
}
/// <summary>
/// 页码
/// </summary>
private int _pageIndex = 1;
/// <summary>
/// 页码
/// </summary>
public int PageIndex
{
get => _pageIndex;
set => Set(ref _pageIndex, value);
}
public PaginationDemoViewModel(DataService dataService)
{
_totalDataList = dataService.GetDemoDataList(100);
DataList = _totalDataList.Take(10).ToList();
}
/// <summary>
/// 页码改变命令
/// </summary>
public RelayCommand<FunctionEventArgs<int>> PageUpdatedCmd =>
new Lazy<RelayCommand<FunctionEventArgs<int>>>(() =>
new RelayCommand<FunctionEventArgs<int>>(PageUpdated)).Value;
/// <summary>
/// 页码改变
/// </summary>
private void PageUpdated(FunctionEventArgs<int> info)
{
DataList = _totalDataList.Skip((info.Info - 1) * 10).Take(10).ToList();
}
}
}
@@ -21,6 +21,7 @@ namespace HandyControlDemo.ViewModel
SimpleIoc.Default.Register<WindowDemoViewModel>();
SimpleIoc.Default.Register<ContributorsViewModel>();
SimpleIoc.Default.Register<StepBarDemoViewModel>();
SimpleIoc.Default.Register<PaginationDemoViewModel>();
}
public static ViewModelLocator Instance => new Lazy<ViewModelLocator>(() =>
@@ -42,6 +43,8 @@ namespace HandyControlDemo.ViewModel
public StepBarDemoViewModel StepBarDemo => ServiceLocator.Current.GetInstance<StepBarDemoViewModel>();
public PaginationDemoViewModel PaginationDemo => ServiceLocator.Current.GetInstance<PaginationDemoViewModel>();
#endregion
}
}