|
|
|
|
using GalaSoft.MvvmLight;
|
|
|
|
|
using GalaSoft.MvvmLight.Command;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace SlnMesnac.WPF.Templates
|
|
|
|
|
{
|
|
|
|
|
public class PagenationModel<T> : ObservableObject
|
|
|
|
|
{
|
|
|
|
|
private long total = 0;
|
|
|
|
|
public long Total
|
|
|
|
|
{
|
|
|
|
|
get => total;
|
|
|
|
|
set { total = value; RaisePropertyChanged(() => Total); }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int page;
|
|
|
|
|
public int Page
|
|
|
|
|
{
|
|
|
|
|
get => page;
|
|
|
|
|
set { page = value; RaisePropertyChanged(() => Page); }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int current = 1;
|
|
|
|
|
public int Current
|
|
|
|
|
{
|
|
|
|
|
get => current;
|
|
|
|
|
set { current = value; RaisePropertyChanged(() => Current); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<int> pageSizes = new List<int>() { 10, 20, 30, 40, 50 };
|
|
|
|
|
public List<int> PageSizes
|
|
|
|
|
{
|
|
|
|
|
get => pageSizes;
|
|
|
|
|
set { pageSizes = value; RaisePropertyChanged(() => PageSizes); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int pageSize;
|
|
|
|
|
public int PageSize
|
|
|
|
|
{
|
|
|
|
|
get => pageSize;
|
|
|
|
|
set { pageSize = value; RaisePropertyChanged(() => PageSize); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 上一页
|
|
|
|
|
/// </summary>
|
|
|
|
|
private RelayCommand findPreCommand;
|
|
|
|
|
public RelayCommand FindPreCommand
|
|
|
|
|
{
|
|
|
|
|
get => findPreCommand;
|
|
|
|
|
set { findPreCommand = value; RaisePropertyChanged(() => FindPreCommand); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 下一页
|
|
|
|
|
/// </summary>
|
|
|
|
|
private RelayCommand findNextCommand;
|
|
|
|
|
public RelayCommand FindNextCommand
|
|
|
|
|
{
|
|
|
|
|
get => findNextCommand;
|
|
|
|
|
set { findNextCommand = value; RaisePropertyChanged(() => FindNextCommand); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 目标页
|
|
|
|
|
/// </summary>
|
|
|
|
|
private RelayCommand findTargetCommand;
|
|
|
|
|
public RelayCommand FindTargetCommand
|
|
|
|
|
{
|
|
|
|
|
get => findTargetCommand;
|
|
|
|
|
set { findTargetCommand = value; RaisePropertyChanged(() => FindTargetCommand); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ObservableCollection<T> rows = new ObservableCollection<T>();
|
|
|
|
|
public ObservableCollection<T> Rows
|
|
|
|
|
{
|
|
|
|
|
get => rows;
|
|
|
|
|
set { rows = value; RaisePropertyChanged(() => Rows); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int GetPageNumber()
|
|
|
|
|
{
|
|
|
|
|
return (current - 1) * PageSize;
|
|
|
|
|
}
|
|
|
|
|
public void computePage()
|
|
|
|
|
{
|
|
|
|
|
Page = Convert.ToInt32(Total / PageSize);
|
|
|
|
|
if (Total % PageSize != 0)
|
|
|
|
|
{
|
|
|
|
|
Page += 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|