diff --git a/SlnMesnac.WPF/Page/WindowPage/MachineStopHistoryWindow.xaml b/SlnMesnac.WPF/Page/WindowPage/MachineStopHistoryWindow.xaml index a772787..4a5d4ef 100644 --- a/SlnMesnac.WPF/Page/WindowPage/MachineStopHistoryWindow.xaml +++ b/SlnMesnac.WPF/Page/WindowPage/MachineStopHistoryWindow.xaml @@ -5,7 +5,8 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:SlnMesnac.WPF.Page.WindowPage" xmlns:dxwui="http://schemas.devexpress.com/winfx/2008/xaml/windowsui" x:Class="SlnMesnac.WPF.Page.WindowPage.MachineStopHistoryWindow" - mc:Ignorable="d" + xmlns:ctls="clr-namespace:SlnMesnac.WPF.Templates" + mc:Ignorable="d" Title="MachineStopHistoryWindow" d:DesignHeight="1080" d:DesignWidth="1920" Height="500" Width="1000" Background="#1254AB" StateChanged="Window_StateChanged"> @@ -79,9 +80,15 @@ - - - + + + + diff --git a/SlnMesnac.WPF/SlnMesnac.WPF.csproj b/SlnMesnac.WPF/SlnMesnac.WPF.csproj index a0ec3d7..39f970e 100644 --- a/SlnMesnac.WPF/SlnMesnac.WPF.csproj +++ b/SlnMesnac.WPF/SlnMesnac.WPF.csproj @@ -42,6 +42,7 @@ + diff --git a/SlnMesnac.WPF/Templates/PagenationModel.cs b/SlnMesnac.WPF/Templates/PagenationModel.cs new file mode 100644 index 0000000..abd370c --- /dev/null +++ b/SlnMesnac.WPF/Templates/PagenationModel.cs @@ -0,0 +1,102 @@ +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 : 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 pageSizes = new List() { 10, 20, 30, 40, 50 }; + public List PageSizes + { + get => pageSizes; + set { pageSizes = value; RaisePropertyChanged(() => PageSizes); } + } + + private int pageSize; + public int PageSize + { + get => pageSize; + set { pageSize = value; RaisePropertyChanged(() => PageSize); } + } + + /// + /// 上一页 + /// + private RelayCommand findPreCommand; + public RelayCommand FindPreCommand + { + get => findPreCommand; + set { findPreCommand = value; RaisePropertyChanged(() => FindPreCommand); } + } + + /// + /// 下一页 + /// + private RelayCommand findNextCommand; + public RelayCommand FindNextCommand + { + get => findNextCommand; + set { findNextCommand = value; RaisePropertyChanged(() => FindNextCommand); } + } + + /// + /// 目标页 + /// + private RelayCommand findTargetCommand; + public RelayCommand FindTargetCommand + { + get => findTargetCommand; + set { findTargetCommand = value; RaisePropertyChanged(() => FindTargetCommand); } + } + + private ObservableCollection rows = new ObservableCollection(); + public ObservableCollection 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; + } + } + + } +} diff --git a/SlnMesnac.WPF/Templates/Pagination.xaml b/SlnMesnac.WPF/Templates/Pagination.xaml new file mode 100644 index 0000000..886e163 --- /dev/null +++ b/SlnMesnac.WPF/Templates/Pagination.xaml @@ -0,0 +1,33 @@ + + + + + + + + + +