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 Work.UserControls
{
public partial class UcSplitPage : UserControl
{
///
/// 是否显示每页条数(启用每页条数功能)
///
[Description("显示每页条数"), Category("UserProperty")]
public bool IsShowPageSize
{
get
{
return this.cmbPageSize.Visible;
}
set
{
if (cmbPageSize.Visible != value)
{
this.lblPageSize.Visible = this.cmbPageSize.Visible = value;
this.Invalidate();
}
}
}
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);
}
}
[Description("每页条数"), Category("UserProperty")]
public int PageSize
{
get
{
int pageSize = 50;
if (InvokeRequired)
{
Invoke(new Action(() =>
{
pageSize = Math.Max(this.cmbPageSize.Text.ParseToInt(), 1);
}));
}
else
pageSize = Math.Max(this.cmbPageSize.Text.ParseToInt(), 1);
return pageSize;
}
set
{
if (InvokeRequired)
{
Invoke(new Action(() =>
{
if (this.cmbPageSize.Text.ParseToInt() != value)
this.cmbPageSize.Text = value.ParseToString();
else
this.cmbPageSize.Text = value.ParseToString();
}));
}
else
{
if (this.cmbPageSize.Text.ParseToInt() != value)
this.cmbPageSize.Text = value.ParseToString();
else
this.cmbPageSize.Text = value.ParseToString();
}
//OnPageChange(this);
}
}
public event Action