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

  1.  using System;
  2. using System.Web.UI;
  3. using System.Web.UI.WebControls;
  4. using System.ComponentModel;
  5. using System.Drawing.Design;
  6. namespace OT.Controls.GridView
  7. {
  8. [TypeConverter(typeof(ExpandableObjectConverter))]
  9. public class GridViewPager : ITemplate
  10. {
  11. private Button btnGo;
  12. private string cssClass;
  13. private int currentPageIndex = 1;
  14. private DropDownList drpTurnPage;
  15. private int itemCount = 0;
  16. private Label lblItemCount;
  17. private Label lblStr;
  18. private Label lblStr2;
  19. private Label lblStr3;
  20. private Label lblTotalPage;
  21. private ImageButton lbtnFirst;
  22. private ImageButton lbtnLast;
  23. private ImageButton lbtnNext;
  24. private ImageButton lbtnProvious;
  25. private int totalPageCount = 0;
  26. private TextBox txtJumper;
  27. public event ImageClickEventHandler FirstPageClick
  28. {
  29. add
  30. {
  31. this.lbtnFirst.Click += value;
  32. }
  33. remove
  34. {
  35. this.lbtnFirst.Click -= value;
  36. }
  37. }
  38. public event ImageClickEventHandler LastPageClick
  39. {
  40. add
  41. {
  42. this.lbtnLast.Click += value;
  43. }
  44. remove
  45. {
  46. this.lbtnLast.Click -= value;
  47. }
  48. }
  49. public event ImageClickEventHandler NextPageClick
  50. {
  51. add
  52. {
  53. this.lbtnNext.Click += value;
  54. }
  55. remove
  56. {
  57. this.lbtnNext.Click -= value;
  58. }
  59. }
  60. public event EventHandler PageJump
  61. {
  62. add
  63. {
  64. this.btnGo.Click += value;
  65. }
  66. remove
  67. {
  68. this.btnGo.Click -= value;
  69. }
  70. }
  71. public event EventHandler PageSelect
  72. {
  73. add
  74. {
  75. this.drpTurnPage.SelectedIndexChanged += value;
  76. }
  77. remove
  78. {
  79. this.drpTurnPage.SelectedIndexChanged -= value;
  80. }
  81. }
  82. public event ImageClickEventHandler ProviousPageClick
  83. {
  84. add
  85. {
  86. this.lbtnProvious.Click += value;
  87. }
  88. remove
  89. {
  90. this.lbtnProvious.Click -= value;
  91. }
  92. }
  93. public GridViewPager()
  94. {
  95. this.Initilize();
  96. }
  97. private static LiteralControl GetNewLineControl()
  98. {
  99. return new LiteralControl(Environment.NewLine);
  100. }
  101. private void Initilize()
  102. {
  103. this.lbtnProvious = new ImageButton();
  104. this.lbtnProvious.ID = "lbtnProviousPage";
  105. this.lbtnProvious.ToolTip = "Goto provious page";
  106. this.lbtnProvious.ImageUrl = "../../App_Themes/Default/images/iPrePage.PNG";
  107. this.lbtnNext = new ImageButton();
  108. this.lbtnNext.ID = "lbtnNextPage";
  109. this.lbtnNext.ToolTip = "Goto next page";
  110. this.lbtnNext.ImageUrl = "../../App_Themes/Default/images/iNextPage.PNG";
  111. this.lbtnFirst = new ImageButton();
  112. this.lbtnFirst.ID = "lbtnFirst";
  113. this.lbtnFirst.ToolTip = "Goto first page";
  114. this.lbtnFirst.ImageUrl = "../../App_Themes/Default/images/iFirst.PNG";
  115. this.lbtnLast = new ImageButton();
  116. this.lbtnLast.ID = "lbtnLast";
  117. this.lbtnLast.ToolTip = "Goto last page";
  118. this.lbtnLast.ImageUrl = "../../App_Themes/Default/images/iLast.PNG";
  119. this.lblItemCount = new Label();
  120. this.lblItemCount.ID = "lblItemCount";
  121. this.lblTotalPage = new Label();
  122. this.lblTotalPage.ID = "lblTotalPage";
  123. this.drpTurnPage = new DropDownList();
  124. this.drpTurnPage.ID = "dprTurnPage";
  125. this.drpTurnPage.AutoPostBack = true;
  126. this.drpTurnPage.Visible = false; //Deleted by Ethan Chen(jxzsh), 2011/09/14.
  127. this.txtJumper = new TextBox();
  128. this.txtJumper.ID = "txtJumper";
  129. this.txtJumper.Attributes.Add("onfocus", "this.select();");
  130. this.txtJumper.MaxLength = 3;
  131. this.txtJumper.Width = 30;
  132. this.btnGo = new Button();
  133. this.btnGo.ID = "btnGo";
  134. this.btnGo.Attributes.Add("class", "button");
  135. this.lblStr = new Label();
  136. this.lblStr.ID = "lblStr";
  137. this.lblStr2 = new Label();
  138. this.lblStr2.ID = "lblStr2";
  139. this.lblStr3 = new Label();
  140. this.lblStr3.ID = "lblStr3";
  141. this.lblStr.Text = "";
  142. this.lblStr2.Text = "";
  143. this.lblStr3.Text = "";
  144. this.lblStr.Width = Unit.Pixel(10);
  145. this.lblStr2.Width = Unit.Pixel(10);
  146. this.lblStr3.Width = Unit.Pixel(10);
  147. }
  148. private void InitPageSelector()
  149. {
  150. this.drpTurnPage.Items.Clear();
  151. for (int i = 0; i < this.totalPageCount; i++)
  152. {
  153. int num2 = i + 1;
  154. this.drpTurnPage.Items.Add(new ListItem(num2.ToString()));
  155. }
  156. }
  157. public void InstantiateIn(Control container)
  158. {
  159. Panel child = new Panel();
  160. child.Width = Unit.Percentage(100.0);
  161. child.CssClass = this.cssClass;
  162. child.Controls.Add(this.lbtnFirst);
  163. child.Controls.Add(GetNewLineControl());
  164. child.Controls.Add(this.lbtnProvious);
  165. child.Controls.Add(GetNewLineControl());
  166. child.Controls.Add(this.lblItemCount);
  167. child.Controls.Add(GetNewLineControl());
  168. child.Controls.Add(this.lblStr);
  169. child.Controls.Add(GetNewLineControl());
  170. child.Controls.Add(this.lblTotalPage);
  171. child.Controls.Add(GetNewLineControl());
  172. child.Controls.Add(this.lbtnNext);
  173. child.Controls.Add(GetNewLineControl());
  174. child.Controls.Add(this.lbtnLast);
  175. child.Controls.Add(GetNewLineControl());
  176. this.InitPageSelector();
  177. child.Controls.Add(this.drpTurnPage);
  178. child.Controls.Add(GetNewLineControl());
  179. child.Controls.Add(this.txtJumper);
  180. child.Controls.Add(GetNewLineControl());
  181. child.Controls.Add(this.btnGo);
  182. container.Controls.Add(child);
  183. }
  184. public string CssClass
  185. {
  186. get
  187. {
  188. return this.cssClass;
  189. }
  190. set
  191. {
  192. this.cssClass = value;
  193. }
  194. }
  195. [NotifyParentProperty(true), Editor("System.Web.UI.Design.UrlEditor", typeof(UITypeEditor)), DefaultValue("~/Images/iPrePage.PNG"), Category("扩展"), Description("上一页提示图片")]
  196. public string PrePageImgUrl
  197. {
  198. get
  199. {
  200. return this.lbtnProvious.ImageUrl;
  201. }
  202. set
  203. {
  204. this.lbtnProvious.ImageUrl = value;
  205. }
  206. }
  207. [NotifyParentProperty(true), Editor("System.Web.UI.Design.UrlEditor", typeof(UITypeEditor)), DefaultValue("~/Images/iNextPage.PNG"), Category("扩展"), Description("下一页提示图片")]
  208. public string NextPageImgUrl
  209. {
  210. get
  211. {
  212. return this.lbtnNext.ImageUrl;
  213. }
  214. set
  215. {
  216. this.lbtnNext.ImageUrl = value;
  217. }
  218. }
  219. [NotifyParentProperty(true), Editor("System.Web.UI.Design.UrlEditor", typeof(UITypeEditor)), DefaultValue("~/Images/iFirst.PNG"), Category("扩展"), Description("首页提示图片")]
  220. public string FirstImgUrl
  221. {
  222. get
  223. {
  224. return this.lbtnFirst.ImageUrl;
  225. }
  226. set
  227. {
  228. this.lbtnFirst.ImageUrl = value;
  229. }
  230. }
  231. [NotifyParentProperty(true), Editor("System.Web.UI.Design.UrlEditor", typeof(UITypeEditor)), DefaultValue("~/Images/iLast.PNG"), Category("扩展"), Description("末页提示图片")]
  232. public string LastImgUrl
  233. {
  234. get
  235. {
  236. return this.lbtnLast.ImageUrl;
  237. }
  238. set
  239. {
  240. this.lbtnLast.ImageUrl = value;
  241. }
  242. }
  243. public int CurrentPageIndex
  244. {
  245. get
  246. {
  247. return this.currentPageIndex;
  248. }
  249. set
  250. {
  251. this.currentPageIndex = value;
  252. }
  253. }
  254. public string EmptyStr
  255. {
  256. get
  257. {
  258. return this.lblStr.Text;
  259. }
  260. set
  261. {
  262. this.lblStr.Text = value;
  263. }
  264. }
  265. public string GoPageIndex
  266. {
  267. get
  268. {
  269. return this.txtJumper.Text;
  270. }
  271. }
  272. public string GoPageText
  273. {
  274. get
  275. {
  276. return this.btnGo.Text;
  277. }
  278. set
  279. {
  280. this.btnGo.Text = value;
  281. }
  282. }
  283. public Unit GoTextBoxWidth
  284. {
  285. get
  286. {
  287. return this.txtJumper.Width;
  288. }
  289. set
  290. {
  291. this.txtJumper.Width = value;
  292. }
  293. }
  294. public int ItemCount
  295. {
  296. get
  297. {
  298. return this.itemCount;
  299. }
  300. set
  301. {
  302. this.itemCount = value;
  303. }
  304. }
  305. public int TotalPageCount
  306. {
  307. get
  308. {
  309. return this.totalPageCount;
  310. }
  311. set
  312. {
  313. this.totalPageCount = value;
  314. }
  315. }
  316. public string TotalPageString
  317. {
  318. get
  319. {
  320. return this.lblTotalPage.Text;
  321. }
  322. set
  323. {
  324. this.lblTotalPage.Text = value;
  325. }
  326. }
  327. }
  328. }