using NaiBa.Util.Extension; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace TemuKJD.UserControls { public partial class UcSplitPage : UserControl { int totalPage = 1; public int TotalPage { get { return totalPage; } set { if (TotalPage != value && value > 0) { totalPage = value; if (InvokeRequired) { Invoke(new Action(() => { this.lblTotal.Text = "共 " + totalPage + " 页"; })); } else this.lblTotal.Text = "共 " + totalPage + " 页"; } } } int currentPage = 1; public int CurrentPage { get { return currentPage; } set { if (currentPage != value) { currentPage = value; if (InvokeRequired) { Invoke(new Action(() => { this.lblPage.Text = "" + currentPage; })); } else this.lblPage.Text = "" + currentPage; OnPageChange(this); } } } public event Action PageChange; protected virtual void OnPageChange(object sender) { this.PageChange?.Invoke(sender); } public UcSplitPage() { InitializeComponent(); } private void pnlJump_Click(object sender, EventArgs e) { int page = this.txtJumpPage.Text.ParseToInt(); this.CurrentPage = Math.Max(1, page); } private void btnPrev_Click(object sender, EventArgs e) { int page = this.CurrentPage - 1; this.CurrentPage = Math.Max(1, page); } private void btnNext_Click(object sender, EventArgs e) { int page = this.CurrentPage + 1; this.CurrentPage = Math.Min(totalPage, page); } } }