2 // System.Web.UI.WebControls.DataGridPagerStyle.cs
5 // Gaurav Vaish (gvaish@iitk.ac.in)
6 // Andreas Nahr (ClassDevelopment@A-SoftTech.com)
8 // (C) Gaurav Vaish (2002)
9 // (C) 2003 Andreas Nahr
13 using System.ComponentModel;
17 namespace System.Web.UI.WebControls
19 public sealed class DataGridPagerStyle : TableItemStyle
23 private static int MODE = (0x01 << 19);
24 private static int NEXT_PG_TEXT = (0x01 << 20);
25 private static int PG_BTN_COUNT = (0x01 << 21);
26 private static int POSITION = (0x01 << 22);
27 private static int VISIBLE = (0x01 << 23);
28 private static int PREV_PG_TEXT = (0x01 << 24);
30 internal DataGridPagerStyle(DataGrid owner): base()
35 internal bool IsPagerOnTop
38 PagerPosition p = Position;
39 return (p == PagerPosition.Top || p == PagerPosition.TopAndBottom);
43 internal bool IsPagerOnBottom
46 PagerPosition p = Position;
47 return (p == PagerPosition.Bottom || p == PagerPosition.TopAndBottom);
51 [DefaultValue (typeof (PagerMode), "NextPrev"), Bindable (true), WebCategory ("Misc")]
52 [NotifyParentProperty (true)]
53 [WebSysDescription ("The mode used for displaying multiple pages.")]
60 return (PagerMode)ViewState["Mode"];
62 return PagerMode.NextPrev;
66 if(!Enum.IsDefined(typeof(PagerMode), value))
68 throw new ArgumentOutOfRangeException("value");
70 ViewState["Mode"] = value;
75 [DefaultValue (">"), Bindable (true), WebCategory ("Misc")]
76 [NotifyParentProperty (true)]
77 [WebSysDescription ("The text for the 'next page' button.")]
78 public string NextPageText
82 if(IsSet(NEXT_PG_TEXT))
84 return (string)ViewState["NextPageText"];
90 ViewState["NextPageText"] = value;
95 [DefaultValue ("<"), Bindable (true), WebCategory ("Misc")]
96 [NotifyParentProperty (true)]
97 [WebSysDescription ("The text for the 'previous page' button.")]
98 public string PrevPageText
102 if(IsSet(PREV_PG_TEXT))
104 return (string)ViewState["PrevPageText"];
110 ViewState["PrevPageText"] = value;
115 [DefaultValue (10), Bindable (true), WebCategory ("Misc")]
116 [NotifyParentProperty (true)]
117 [WebSysDescription ("The maximum number of pages to show as direct links.")]
118 public int PageButtonCount
122 if(IsSet(PG_BTN_COUNT))
124 return (int)ViewState["PageButtonCount"];
131 throw new ArgumentOutOfRangeException("value");
133 ViewState["PageButtonCount"] = value;
138 [DefaultValue (typeof (PagerPosition), "Bottom"), Bindable (true), WebCategory ("Misc")]
139 [NotifyParentProperty (true)]
140 [WebSysDescription ("The position for the page display.")]
141 public PagerPosition Position
147 return (PagerPosition)ViewState["Position"];
149 return PagerPosition.Bottom;
153 if(!Enum.IsDefined(typeof(PagerPosition), value))
155 throw new ArgumentException();
157 ViewState["Position"] = value;
162 [DefaultValue (true), Bindable (true), WebCategory ("Misc")]
163 [NotifyParentProperty (true)]
164 [WebSysDescription ("Determines if paging functionallity is visible to the user.")]
171 return (bool)ViewState["PagerVisible"];
177 ViewState["PagerVisible"] = value;
179 owner.OnPagerChanged();
183 public override void CopyFrom(Style s)
185 if(s != null && !s.IsEmpty)
188 if(!(s is DataGridPagerStyle)) return;
190 DataGridPagerStyle from = (DataGridPagerStyle)s;
195 if(from.IsSet(NEXT_PG_TEXT))
197 NextPageText = from.NextPageText;
199 if(from.IsSet(PG_BTN_COUNT))
201 PageButtonCount = from.PageButtonCount;
203 if(from.IsSet(POSITION))
205 Position = from.Position;
207 if(from.IsSet(VISIBLE))
209 Visible = from.Visible;
211 if(from.IsSet(PREV_PG_TEXT))
213 PrevPageText = from.PrevPageText;
218 public override void MergeWith(Style s)
220 if(s != null && !s.IsEmpty)
230 if(!(s is DataGridPagerStyle)) return;
232 DataGridPagerStyle with = (DataGridPagerStyle)s;
233 if(with.IsSet(MODE) && !IsSet(MODE))
237 if(with.IsSet(NEXT_PG_TEXT) && !IsSet(NEXT_PG_TEXT))
239 NextPageText = with.NextPageText;
241 if(with.IsSet(PG_BTN_COUNT) && !IsSet(PG_BTN_COUNT))
243 PageButtonCount = with.PageButtonCount;
245 if(with.IsSet(POSITION) && !IsSet(POSITION))
247 Position = with.Position;
249 if(with.IsSet(VISIBLE) && !IsSet(VISIBLE))
251 Visible = with.Visible;
253 if(with.IsSet(PREV_PG_TEXT) && !IsSet(PREV_PG_TEXT))
255 PrevPageText = with.PrevPageText;
260 public override void Reset()
264 ViewState.Remove("Mode");
266 if(IsSet(NEXT_PG_TEXT))
268 ViewState.Remove("NextPageText");
270 if(IsSet(PG_BTN_COUNT))
272 ViewState.Remove("PageButtonCount");
276 ViewState.Remove("Position");
280 ViewState.Remove("PagerVisible");
282 if(IsSet(PREV_PG_TEXT))
284 ViewState.Remove("PrevPageText");