From 49740c4f5180f3c238328d8ae44240eb443ab9d4 Mon Sep 17 00:00:00 2001 From: liuwf Date: Wed, 13 Nov 2024 19:02:23 +0800 Subject: [PATCH] =?UTF-8?q?add-=E8=AE=BE=E5=A4=87=E5=81=9C=E6=9C=BA?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=B7=BB=E5=8A=A0=E5=88=86=E9=A1=B5=E6=8E=A7?= =?UTF-8?q?=E4=BB=B6=EF=BC=8C=E5=BE=85=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WindowPage/MachineStopHistoryWindow.xaml | 15 +- SlnMesnac.WPF/SlnMesnac.WPF.csproj | 1 + SlnMesnac.WPF/Templates/PagenationModel.cs | 102 ++++++++++++ SlnMesnac.WPF/Templates/Pagination.xaml | 33 ++++ SlnMesnac.WPF/Templates/Pagination.xaml.cs | 147 ++++++++++++++++++ .../ViewModel/MachineStopHistoryViewModel.cs | 44 +++++- 6 files changed, 333 insertions(+), 9 deletions(-) create mode 100644 SlnMesnac.WPF/Templates/PagenationModel.cs create mode 100644 SlnMesnac.WPF/Templates/Pagination.xaml create mode 100644 SlnMesnac.WPF/Templates/Pagination.xaml.cs 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 @@ + + + + + + + + + +