1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
23 // Peter Bartok (pbartok@novell.com)
27 using System.ComponentModel;
29 namespace System.Web.UI.WebControls {
30 public sealed class DataGridPagerStyle : TableItemStyle {
32 internal DataGridPagerStyle () {
34 #endregion // Constructors
36 #region Public Instance Properties
38 [DefaultValue(PagerMode.NextPrev)]
39 [NotifyParentProperty(true)]
40 [WebSysDescription ("")]
41 [WebCategory ("Misc")]
42 public PagerMode Mode {
44 if ((styles & Styles.Mode) == 0) {
45 return PagerMode.NextPrev;
48 return (PagerMode)ViewState["Mode"];
52 styles |= Styles.Mode;
53 ViewState["Mode"] = value;
58 [DefaultValue(">")]
59 [NotifyParentProperty(true)]
60 [WebSysDescription ("")]
61 [WebCategory ("Misc")]
62 public string NextPageText {
64 if ((styles & Styles.NextPageText) == 0) {
68 return ViewState.GetString("NextPageText", ">");
72 styles |= Styles.NextPageText;
73 ViewState["NextPageText"] = value;
79 [NotifyParentProperty(true)]
80 [WebSysDescription ("")]
81 [WebCategory ("Misc")]
82 public int PageButtonCount {
84 if ((styles & Styles.PageButtonCount) == 0) {
88 return ViewState.GetInt("PageButtonCount", 10);
93 throw new ArgumentOutOfRangeException("value", "PageButtonCount must be greater than 0");
96 styles |= Styles.PageButtonCount;
97 ViewState["PageButtonCount"] = value;
102 [DefaultValue(PagerPosition.Bottom)]
103 [NotifyParentProperty(true)]
104 [WebSysDescription ("")]
105 [WebCategory ("Misc")]
106 public PagerPosition Position {
108 if ((styles & Styles.Position) == 0) {
109 return PagerPosition.Bottom;
112 return (PagerPosition)ViewState["Position"];
116 styles |= Styles.Position;
117 ViewState["Position"] = value;
122 [DefaultValue("<")]
123 [NotifyParentProperty(true)]
124 [WebSysDescription ("")]
125 [WebCategory ("Misc")]
126 public string PrevPageText {
128 if ((styles & Styles.NextPageText) == 0) {
132 return ViewState.GetString("PrevPageText", "<");
136 styles |= Styles.PrevPageText;
137 ViewState["PrevPageText"] = value;
143 [NotifyParentProperty(true)]
144 [WebSysDescription ("")]
145 [WebCategory ("Misc")]
146 public bool Visible {
148 if ((styles & Styles.Visible) == 0) {
152 return ViewState.GetBool("Visible", true);
156 styles |= Styles.Visible;
157 ViewState["Visible"] = value;
160 #endregion // Public Instance Properties
162 #region Public Instance Methods
163 public override void CopyFrom(Style s) {
166 if (s == null || s.IsEmpty) {
170 if (((s.styles & Styles.Mode) != 0) && (((DataGridPagerStyle)s).Mode != PagerMode.NextPrev)) {
171 this.Mode = ((DataGridPagerStyle)s).Mode;
174 if (((s.styles & Styles.NextPageText) != 0) && (((DataGridPagerStyle)s).NextPageText != ">")) {
175 this.NextPageText = ((DataGridPagerStyle)s).NextPageText;
178 if (((s.styles & Styles.PageButtonCount) != 0) && (((DataGridPagerStyle)s).PageButtonCount != 10)) {
179 this.PageButtonCount = ((DataGridPagerStyle)s).PageButtonCount;
182 if (((s.styles & Styles.Position) != 0) && (((DataGridPagerStyle)s).Position != PagerPosition.Bottom)) {
183 this.Position = ((DataGridPagerStyle)s).Position;
186 if (((s.styles & Styles.PrevPageText) != 0) && (((DataGridPagerStyle)s).PrevPageText != "<")) {
187 this.PrevPageText = ((DataGridPagerStyle)s).PrevPageText;
190 if (((s.styles & Styles.Visible) != 0) && (((DataGridPagerStyle)s).Visible != true)) {
191 this.Visible = ((DataGridPagerStyle)s).Visible;
196 public override void MergeWith(Style s) {
199 if (s == null || s.IsEmpty) {
203 if (((styles & Styles.Mode) == 0) && ((s.styles & Styles.Mode) != 0) && (((DataGridPagerStyle)s).Mode != PagerMode.NextPrev)) {
204 this.Mode = ((DataGridPagerStyle)s).Mode;
207 if (((styles & Styles.NextPageText) == 0) && ((s.styles & Styles.NextPageText) != 0) && (((DataGridPagerStyle)s).NextPageText != ">")) {
208 this.NextPageText = ((DataGridPagerStyle)s).NextPageText;
211 if (((styles & Styles.PageButtonCount) == 0) && ((s.styles & Styles.PageButtonCount) != 0) && (((DataGridPagerStyle)s).PageButtonCount != 10)) {
212 this.PageButtonCount = ((DataGridPagerStyle)s).PageButtonCount;
215 if (((styles & Styles.Position) == 0) && ((s.styles & Styles.Position) != 0) && (((DataGridPagerStyle)s).Position != PagerPosition.Bottom)) {
216 this.Position = ((DataGridPagerStyle)s).Position;
219 if (((styles & Styles.PrevPageText) == 0) && ((s.styles & Styles.PrevPageText) != 0) && (((DataGridPagerStyle)s).PrevPageText != "<")) {
220 this.PrevPageText = ((DataGridPagerStyle)s).PrevPageText;
223 if (((styles & Styles.Visible) == 0) && ((s.styles & Styles.Visible) != 0) && (((DataGridPagerStyle)s).Visible != true)) {
224 this.Visible = ((DataGridPagerStyle)s).Visible;
228 public override void Reset() {
229 // We call base.Reset(), we don't need this
230 //styles &= ~(Styles.Mode | Styles.NextPageText | Styles.PageButtonCount | Styles.Position | Styles.PrevPageText | Styles.Visible);
232 ViewState.Remove("Mode");
233 ViewState.Remove("NextPageText");
234 ViewState.Remove("PageButtonCount");
235 ViewState.Remove("Position");
236 ViewState.Remove("PrevPageText");
237 ViewState.Remove("Visible");
242 internal override void LoadViewStateInternal()
244 if (viewstate["Mode"] != null) {
245 styles |= Styles.Mode;
247 if (viewstate["NextPageText"] != null) {
248 styles |= Styles.NextPageText;
250 if (viewstate["PageButtonCount"] != null) {
251 styles |= Styles.PageButtonCount;
253 if (viewstate["Position"] != null) {
254 styles |= Styles.Position;
256 if (viewstate["PrevPageText"] != null) {
257 styles |= Styles.PrevPageText;
259 if (viewstate["Visible"] != null) {
260 styles |= Styles.Visible;
263 base.LoadViewStateInternal();
265 #endregion // Public Instance Methods