-/**\r
- * Namespace: System.Web.UI.WebControls\r
- * Class: DataGridPagerStyle\r
- * \r
- * Author: Gaurav Vaish\r
- * Maintainer: gvaish@iitk.ac.in\r
- * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>\r
- * Implementation: yes\r
- * Status: 100%\r
- * \r
- * (C) Gaurav Vaish (2002)\r
- */\r
-\r
-using System;\r
-using System.Web;\r
-using System.Web.UI;\r
-\r
-namespace System.Web.UI.WebControls\r
-{\r
- public class DataGridPagerStyle : TableItemStyle\r
- {\r
- DataGrid owner;\r
- \r
- public static int MODE = (0x01 << 19);\r
- public static int NEXT_PG_TEXT = (0x01 << 20);\r
- public static int PG_BTN_COUNT = (0x01 << 21);\r
- public static int POSITION = (0x01 << 22);\r
- public static int VISIBLE = (0x01 << 23);\r
- public static int PREV_PG_TEXT = (0x01 << 24);\r
-\r
- internal DataGridPagerStyle(DataGrid owner): base()\r
- {\r
- this.owner = owner;\r
- }\r
- \r
- public PagerMode Mode\r
- {\r
- get\r
- {\r
- if(IsSet(MODE))\r
- {\r
- return (PagerMode)ViewState["Mode"];\r
- }\r
- return PagerMode.NextPrev;\r
- }\r
- set\r
- {\r
- if(!Enum.IsDefined(typeof(PagerMode), value))\r
- {\r
- throw new NotImplementedException();\r
- }\r
- ViewState["Mode"] = value;\r
- Set(MODE);\r
- }\r
- }\r
- \r
- public string NextPageText\r
- {\r
- get\r
- {\r
- if(IsSet(NEXT_PG_TEXT))\r
- {\r
- return (string)ViewState["NextPageText"];\r
- }\r
- return ">";\r
- }\r
- set\r
- {\r
- ViewState["NextPageText"] = value;\r
- Set(NEXT_PG_TEXT);\r
- }\r
- }\r
- \r
- public string PrevPageText\r
- {\r
- get\r
- {\r
- if(IsSet(PREV_PG_TEXT))\r
- {\r
- return (string)ViewState["PrevPageText"];\r
- }\r
- return "<";\r
- }\r
- set\r
- {\r
- ViewState["PrevPageText"] = value;\r
- Set(PREV_PG_TEXT);\r
- }\r
- }\r
- \r
- public int PageButtonCount\r
- {\r
- get\r
- {\r
- if(IsSet(PG_BTN_COUNT))\r
- {\r
- return (int)ViewState["PageButtonCount"];\r
- }\r
- return 10;\r
- }\r
- set\r
- {\r
- ViewState["PageButtonCount"] = value;\r
- Set(PG_BTN_COUNT);\r
- }\r
- }\r
- \r
- public PagerPosition Position\r
- {\r
- get\r
- {\r
- if(IsSet(POSITION))\r
- {\r
- return (PagerPosition)ViewState["Position"];\r
- }\r
- return PagerPosition.Bottom;\r
- }\r
- set\r
- {\r
- if(!Enum.IsDefined(typeof(PagerPosition), value))\r
- {\r
- throw new ArgumentException();\r
- }\r
- ViewState["Position"] = value;\r
- Set(POSITION);\r
- }\r
- }\r
- \r
- public bool Visible\r
- {\r
- get\r
- {\r
- if(IsSet(VISIBLE))\r
- {\r
- return (bool)ViewState["Visible"];\r
- }\r
- return true;\r
- }\r
- set\r
- {\r
- ViewState["Visible"] = value;\r
- Set(PG_BTN_COUNT);\r
- }\r
- }\r
- \r
- public override void CopyFrom(Style s)\r
- {\r
- if(s != null && !s.IsEmpty && s is TableItemStyle)\r
- {\r
- base.CopyFrom(s);\r
- TableItemStyle from = (TableItemStyle)s;\r
- if(from.IsSet(MODE))\r
- {\r
- Mode = from.Mode;\r
- }\r
- if(from.IsSet(NEXT_PG_TEXT))\r
- {\r
- NextPageText = from.NextPageText;\r
- }\r
- if(from.IsSet(PG_BTN_COUNT))\r
- {\r
- PageButtonCount = from.PageButtonCount;\r
- }\r
- if(from.IsSet(POSITION))\r
- {\r
- Position = from.Position;\r
- }\r
- if(from.IsSet(VISIBLE))\r
- {\r
- Visible = from.Visible;\r
- }\r
- if(from.IsSet(PREV_PG_TEXT))\r
- {\r
- PrevPageText = from.PrevPageText;\r
- }\r
- }\r
- }\r
- \r
- public override void MergeWith(Style s)\r
- {\r
- if(s != null && !s.IsEmpty && s is TableItemStyle)\r
- {\r
- base.MergeWith(s);\r
- TableItemStyle with = (TableItemStyle)s;\r
- if(with.IsSet(MODE) && !IsSet(MODE))\r
- {\r
- Mode = from.Mode;\r
- }\r
- if(with.IsSet(NEXT_PG_TEXT) && !IsSet(NEXT_PG_TEXT))\r
- {\r
- NextPageText = with.NextPageText;\r
- }\r
- if(with.IsSet(PG_BTN_COUNT) && !IsSet(PG_BTN_COUNT))\r
- {\r
- PageButtonCount = with.PageButtonCount;\r
- }\r
- if(with.IsSet(POSITION) && !IsSet(POSITION))\r
- {\r
- Position = with.Position;\r
- }\r
- if(with.IsSet(VISIBLE) && !IsSet(VISIBLE))\r
- {\r
- Visible = with.Visible;\r
- }\r
- if(with.IsSet(PREV_PG_TEXT) && !IsSet(PREV_PG_TEXT))\r
- {\r
- PrevPageText = with.PrevPageText;\r
- }\r
- }\r
- }\r
-\r
- public override void Reset()\r
- {\r
- if(IsSet(MODE))\r
- {\r
- ViewState.Remove("Mode");\r
- }\r
- if(IsSet(NEXT_PG_TEXT))\r
- {\r
- ViewState.Remove("NextPageText");\r
- }\r
- if(IsSet(PG_BTN_COUNT))\r
- {\r
- ViewState.Remove("PageButtonCount");\r
- }\r
- if(IsSet(POSITION))\r
- {\r
- ViewState.Remove("Position");\r
- }\r
- if(IsSet(VISIBLE))\r
- {\r
- ViewState.Remove("Visible");\r
- }\r
- if(IsSet(PREV_PG_TEXT))\r
- {\r
- ViewState.Remove("PrevPageText");\r
- }\r
- base.Reset();\r
- }\r
- }\r
-}\r
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok (pbartok@novell.com)
+//
+//
+
+using System.ComponentModel;
+using System.Security.Permissions;
+
+namespace System.Web.UI.WebControls {
+
+ // CAS - no inheritance demand required because the class is sealed
+ [AspNetHostingPermissionAttribute (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+ public sealed class DataGridPagerStyle : TableItemStyle {
+ #region Constructors
+ internal DataGridPagerStyle () {
+ }
+ #endregion // Constructors
+
+ #region Public Instance Properties
+#if ONLY_1_1
+ [Bindable(true)]
+#endif
+ [DefaultValue(PagerMode.NextPrev)]
+ [NotifyParentProperty(true)]
+ [WebSysDescription ("")]
+ [WebCategory ("Misc")]
+ public PagerMode Mode {
+ get {
+ if ((styles & Styles.Mode) == 0) {
+ return PagerMode.NextPrev;
+ }
+
+ return (PagerMode)ViewState["Mode"];
+ }
+
+ set {
+ styles |= Styles.Mode;
+ ViewState["Mode"] = value;
+ }
+ }
+
+#if NET_2_0
+ [Localizable (true)]
+#else
+ [Bindable(true)]
+#endif
+ [DefaultValue(">")]
+ [NotifyParentProperty(true)]
+ [WebSysDescription ("")]
+ [WebCategory ("Misc")]
+ public string NextPageText {
+ get {
+ if ((styles & Styles.NextPageText) == 0) {
+ return ">";
+ }
+
+ return ViewState.GetString("NextPageText", ">");
+ }
+
+ set {
+ styles |= Styles.NextPageText;
+ ViewState["NextPageText"] = value;
+ }
+ }
+
+#if ONLY_1_1
+ [Bindable(true)]
+#endif
+ [DefaultValue(10)]
+ [NotifyParentProperty(true)]
+ [WebSysDescription ("")]
+ [WebCategory ("Misc")]
+ public int PageButtonCount {
+ get {
+ if ((styles & Styles.PageButtonCount) == 0) {
+ return 10;
+ }
+
+ return ViewState.GetInt("PageButtonCount", 10);
+ }
+
+ set {
+ if (value < 1) {
+ throw new ArgumentOutOfRangeException("value", "PageButtonCount must be greater than 0");
+ }
+
+ styles |= Styles.PageButtonCount;
+ ViewState["PageButtonCount"] = value;
+ }
+ }
+
+#if ONLY_1_1
+ [Bindable(true)]
+#endif
+ [DefaultValue(PagerPosition.Bottom)]
+ [NotifyParentProperty(true)]
+ [WebSysDescription ("")]
+ [WebCategory ("Misc")]
+ public PagerPosition Position {
+ get {
+ if ((styles & Styles.Position) == 0) {
+ return PagerPosition.Bottom;
+ }
+
+ return (PagerPosition)ViewState["Position"];
+ }
+
+ set {
+ styles |= Styles.Position;
+ ViewState["Position"] = value;
+ }
+ }
+
+#if NET_2_0
+ [Localizable (true)]
+#else
+ [Bindable(true)]
+#endif
+ [DefaultValue("<")]
+ [NotifyParentProperty(true)]
+ [WebSysDescription ("")]
+ [WebCategory ("Misc")]
+ public string PrevPageText {
+ get {
+ if ((styles & Styles.NextPageText) == 0) {
+ return "<";
+ }
+
+ return ViewState.GetString("PrevPageText", "<");
+ }
+
+ set {
+ styles |= Styles.PrevPageText;
+ ViewState["PrevPageText"] = value;
+ }
+ }
+
+#if ONLY_1_1
+ [Bindable(true)]
+#endif
+ [DefaultValue(true)]
+ [NotifyParentProperty(true)]
+ [WebSysDescription ("")]
+ [WebCategory ("Misc")]
+ public bool Visible {
+ get {
+ if ((styles & Styles.Visible) == 0) {
+ return true;
+ }
+
+ return ViewState.GetBool("Visible", true);
+ }
+
+ set {
+ styles |= Styles.Visible;
+ ViewState["Visible"] = value;
+ }
+ }
+ #endregion // Public Instance Properties
+
+ #region Public Instance Methods
+ public override void CopyFrom(Style s) {
+ base.CopyFrom (s);
+
+ if (s == null || s.IsEmpty) {
+ return;
+ }
+
+ if (((s.styles & Styles.Mode) != 0) && (((DataGridPagerStyle)s).Mode != PagerMode.NextPrev)) {
+ this.Mode = ((DataGridPagerStyle)s).Mode;
+ }
+
+ if (((s.styles & Styles.NextPageText) != 0) && (((DataGridPagerStyle)s).NextPageText != ">")) {
+ this.NextPageText = ((DataGridPagerStyle)s).NextPageText;
+ }
+
+ if (((s.styles & Styles.PageButtonCount) != 0) && (((DataGridPagerStyle)s).PageButtonCount != 10)) {
+ this.PageButtonCount = ((DataGridPagerStyle)s).PageButtonCount;
+ }
+
+ if (((s.styles & Styles.Position) != 0) && (((DataGridPagerStyle)s).Position != PagerPosition.Bottom)) {
+ this.Position = ((DataGridPagerStyle)s).Position;
+ }
+
+ if (((s.styles & Styles.PrevPageText) != 0) && (((DataGridPagerStyle)s).PrevPageText != "<")) {
+ this.PrevPageText = ((DataGridPagerStyle)s).PrevPageText;
+ }
+
+ if (((s.styles & Styles.Visible) != 0) && (((DataGridPagerStyle)s).Visible != true)) {
+ this.Visible = ((DataGridPagerStyle)s).Visible;
+ }
+
+ }
+
+ public override void MergeWith(Style s) {
+ base.MergeWith (s);
+
+ if (s == null || s.IsEmpty) {
+ return;
+ }
+
+ if (((styles & Styles.Mode) == 0) && ((s.styles & Styles.Mode) != 0) && (((DataGridPagerStyle)s).Mode != PagerMode.NextPrev)) {
+ this.Mode = ((DataGridPagerStyle)s).Mode;
+ }
+
+ if (((styles & Styles.NextPageText) == 0) && ((s.styles & Styles.NextPageText) != 0) && (((DataGridPagerStyle)s).NextPageText != ">")) {
+ this.NextPageText = ((DataGridPagerStyle)s).NextPageText;
+ }
+
+ if (((styles & Styles.PageButtonCount) == 0) && ((s.styles & Styles.PageButtonCount) != 0) && (((DataGridPagerStyle)s).PageButtonCount != 10)) {
+ this.PageButtonCount = ((DataGridPagerStyle)s).PageButtonCount;
+ }
+
+ if (((styles & Styles.Position) == 0) && ((s.styles & Styles.Position) != 0) && (((DataGridPagerStyle)s).Position != PagerPosition.Bottom)) {
+ this.Position = ((DataGridPagerStyle)s).Position;
+ }
+
+ if (((styles & Styles.PrevPageText) == 0) && ((s.styles & Styles.PrevPageText) != 0) && (((DataGridPagerStyle)s).PrevPageText != "<")) {
+ this.PrevPageText = ((DataGridPagerStyle)s).PrevPageText;
+ }
+
+ if (((styles & Styles.Visible) == 0) && ((s.styles & Styles.Visible) != 0) && (((DataGridPagerStyle)s).Visible != true)) {
+ this.Visible = ((DataGridPagerStyle)s).Visible;
+ }
+ }
+
+ public override void Reset() {
+ // We call base.Reset(), we don't need this
+ //styles &= ~(Styles.Mode | Styles.NextPageText | Styles.PageButtonCount | Styles.Position | Styles.PrevPageText | Styles.Visible);
+
+ ViewState.Remove("Mode");
+ ViewState.Remove("NextPageText");
+ ViewState.Remove("PageButtonCount");
+ ViewState.Remove("Position");
+ ViewState.Remove("PrevPageText");
+ ViewState.Remove("Visible");
+
+ base.Reset ();
+ }
+
+ internal override void LoadViewStateInternal()
+ {
+ if (viewstate["Mode"] != null) {
+ styles |= Styles.Mode;
+ }
+ if (viewstate["NextPageText"] != null) {
+ styles |= Styles.NextPageText;
+ }
+ if (viewstate["PageButtonCount"] != null) {
+ styles |= Styles.PageButtonCount;
+ }
+ if (viewstate["Position"] != null) {
+ styles |= Styles.Position;
+ }
+ if (viewstate["PrevPageText"] != null) {
+ styles |= Styles.PrevPageText;
+ }
+ if (viewstate["Visible"] != null) {
+ styles |= Styles.Visible;
+ }
+
+ base.LoadViewStateInternal();
+ }
+ #endregion // Public Instance Methods
+ }
+}