You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

354 lines
10 KiB

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Drawing.Design;
namespace OT.Controls.GridView
{
[TypeConverter(typeof(ExpandableObjectConverter))]
public class GridViewPager : ITemplate
{
private Button btnGo;
private string cssClass;
private int currentPageIndex = 1;
private DropDownList drpTurnPage;
private int itemCount = 0;
private Label lblItemCount;
private Label lblStr;
private Label lblStr2;
private Label lblStr3;
private Label lblTotalPage;
private ImageButton lbtnFirst;
private ImageButton lbtnLast;
private ImageButton lbtnNext;
private ImageButton lbtnProvious;
private int totalPageCount = 0;
private TextBox txtJumper;
public event ImageClickEventHandler FirstPageClick
{
add
{
this.lbtnFirst.Click += value;
}
remove
{
this.lbtnFirst.Click -= value;
}
}
public event ImageClickEventHandler LastPageClick
{
add
{
this.lbtnLast.Click += value;
}
remove
{
this.lbtnLast.Click -= value;
}
}
public event ImageClickEventHandler NextPageClick
{
add
{
this.lbtnNext.Click += value;
}
remove
{
this.lbtnNext.Click -= value;
}
}
public event EventHandler PageJump
{
add
{
this.btnGo.Click += value;
}
remove
{
this.btnGo.Click -= value;
}
}
public event EventHandler PageSelect
{
add
{
this.drpTurnPage.SelectedIndexChanged += value;
}
remove
{
this.drpTurnPage.SelectedIndexChanged -= value;
}
}
public event ImageClickEventHandler ProviousPageClick
{
add
{
this.lbtnProvious.Click += value;
}
remove
{
this.lbtnProvious.Click -= value;
}
}
public GridViewPager()
{
this.Initilize();
}
private static LiteralControl GetNewLineControl()
{
return new LiteralControl(Environment.NewLine);
}
private void Initilize()
{
this.lbtnProvious = new ImageButton();
this.lbtnProvious.ID = "lbtnProviousPage";
this.lbtnProvious.ToolTip = "Goto provious page";
this.lbtnProvious.ImageUrl = "../../App_Themes/Default/images/iPrePage.PNG";
this.lbtnNext = new ImageButton();
this.lbtnNext.ID = "lbtnNextPage";
this.lbtnNext.ToolTip = "Goto next page";
this.lbtnNext.ImageUrl = "../../App_Themes/Default/images/iNextPage.PNG";
this.lbtnFirst = new ImageButton();
this.lbtnFirst.ID = "lbtnFirst";
this.lbtnFirst.ToolTip = "Goto first page";
this.lbtnFirst.ImageUrl = "../../App_Themes/Default/images/iFirst.PNG";
this.lbtnLast = new ImageButton();
this.lbtnLast.ID = "lbtnLast";
this.lbtnLast.ToolTip = "Goto last page";
this.lbtnLast.ImageUrl = "../../App_Themes/Default/images/iLast.PNG";
this.lblItemCount = new Label();
this.lblItemCount.ID = "lblItemCount";
this.lblTotalPage = new Label();
this.lblTotalPage.ID = "lblTotalPage";
this.drpTurnPage = new DropDownList();
this.drpTurnPage.ID = "dprTurnPage";
this.drpTurnPage.AutoPostBack = true;
this.drpTurnPage.Visible = false; //Deleted by Ethan Chen(jxzsh), 2011/09/14.
this.txtJumper = new TextBox();
this.txtJumper.ID = "txtJumper";
this.txtJumper.Attributes.Add("onfocus", "this.select();");
this.txtJumper.MaxLength = 3;
this.txtJumper.Width = 30;
this.btnGo = new Button();
this.btnGo.ID = "btnGo";
this.btnGo.Attributes.Add("class", "button");
this.lblStr = new Label();
this.lblStr.ID = "lblStr";
this.lblStr2 = new Label();
this.lblStr2.ID = "lblStr2";
this.lblStr3 = new Label();
this.lblStr3.ID = "lblStr3";
this.lblStr.Text = "";
this.lblStr2.Text = "";
this.lblStr3.Text = "";
this.lblStr.Width = Unit.Pixel(10);
this.lblStr2.Width = Unit.Pixel(10);
this.lblStr3.Width = Unit.Pixel(10);
}
private void InitPageSelector()
{
this.drpTurnPage.Items.Clear();
for (int i = 0; i < this.totalPageCount; i++)
{
int num2 = i + 1;
this.drpTurnPage.Items.Add(new ListItem(num2.ToString()));
}
}
public void InstantiateIn(Control container)
{
Panel child = new Panel();
child.Width = Unit.Percentage(100.0);
child.CssClass = this.cssClass;
child.Controls.Add(this.lbtnFirst);
child.Controls.Add(GetNewLineControl());
child.Controls.Add(this.lbtnProvious);
child.Controls.Add(GetNewLineControl());
child.Controls.Add(this.lblItemCount);
child.Controls.Add(GetNewLineControl());
child.Controls.Add(this.lblStr);
child.Controls.Add(GetNewLineControl());
child.Controls.Add(this.lblTotalPage);
child.Controls.Add(GetNewLineControl());
child.Controls.Add(this.lbtnNext);
child.Controls.Add(GetNewLineControl());
child.Controls.Add(this.lbtnLast);
child.Controls.Add(GetNewLineControl());
this.InitPageSelector();
child.Controls.Add(this.drpTurnPage);
child.Controls.Add(GetNewLineControl());
child.Controls.Add(this.txtJumper);
child.Controls.Add(GetNewLineControl());
child.Controls.Add(this.btnGo);
container.Controls.Add(child);
}
public string CssClass
{
get
{
return this.cssClass;
}
set
{
this.cssClass = value;
}
}
[NotifyParentProperty(true), Editor("System.Web.UI.Design.UrlEditor", typeof(UITypeEditor)), DefaultValue("~/Images/iPrePage.PNG"), Category("扩展"), Description("上一页提示图片")]
public string PrePageImgUrl
{
get
{
return this.lbtnProvious.ImageUrl;
}
set
{
this.lbtnProvious.ImageUrl = value;
}
}
[NotifyParentProperty(true), Editor("System.Web.UI.Design.UrlEditor", typeof(UITypeEditor)), DefaultValue("~/Images/iNextPage.PNG"), Category("扩展"), Description("下一页提示图片")]
public string NextPageImgUrl
{
get
{
return this.lbtnNext.ImageUrl;
}
set
{
this.lbtnNext.ImageUrl = value;
}
}
[NotifyParentProperty(true), Editor("System.Web.UI.Design.UrlEditor", typeof(UITypeEditor)), DefaultValue("~/Images/iFirst.PNG"), Category("扩展"), Description("首页提示图片")]
public string FirstImgUrl
{
get
{
return this.lbtnFirst.ImageUrl;
}
set
{
this.lbtnFirst.ImageUrl = value;
}
}
[NotifyParentProperty(true), Editor("System.Web.UI.Design.UrlEditor", typeof(UITypeEditor)), DefaultValue("~/Images/iLast.PNG"), Category("扩展"), Description("末页提示图片")]
public string LastImgUrl
{
get
{
return this.lbtnLast.ImageUrl;
}
set
{
this.lbtnLast.ImageUrl = value;
}
}
public int CurrentPageIndex
{
get
{
return this.currentPageIndex;
}
set
{
this.currentPageIndex = value;
}
}
public string EmptyStr
{
get
{
return this.lblStr.Text;
}
set
{
this.lblStr.Text = value;
}
}
public string GoPageIndex
{
get
{
return this.txtJumper.Text;
}
}
public string GoPageText
{
get
{
return this.btnGo.Text;
}
set
{
this.btnGo.Text = value;
}
}
public Unit GoTextBoxWidth
{
get
{
return this.txtJumper.Width;
}
set
{
this.txtJumper.Width = value;
}
}
public int ItemCount
{
get
{
return this.itemCount;
}
set
{
this.itemCount = value;
}
}
public int TotalPageCount
{
get
{
return this.totalPageCount;
}
set
{
this.totalPageCount = value;
}
}
public string TotalPageString
{
get
{
return this.lblTotalPage.Text;
}
set
{
this.lblTotalPage.Text = value;
}
}
}
}