Browse Source

2003-01-25 Gaurav Vaish <gvaish_mono AT lycos.com>

	* ControlPager.cs        : Completed.
	* ItemPager.cs           : Initial implementation.

svn path=/trunk/mcs/; revision=10884
Gaurav Vaish 23 years ago
parent
commit
fcccc24e23

+ 5 - 0
mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/ChangeLog

@@ -1,4 +1,9 @@
 
+2003-01-25	Gaurav Vaish <gvaish_mono AT lycos.com>
+
+	* ControlPager.cs        : Completed.
+	* ItemPager.cs           : Initial implementation.
+
 2003-01-24	Gaurav Vaish <gvaish_mono AT lycos.com>
 
 	* ControlPager.cs        : PageCount { get; set; }   - Stubbed.

+ 72 - 2
mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/ControlPager.cs

@@ -14,11 +14,21 @@ namespace System.Web.UI.MobileControls
 {
 	public class ControlPager
 	{
-		private int pageCount;
+		private int pageCount = 0;
+		private int maxPage   = -1;
+		private int pageWt;
+		private int remainingWt = 0;
+
+		private Form form;
+
+		// To ponder: will const be better?
+		public static readonly int DefaultWeight = 100;
+		public static readonly int UseDefaultWeight = -1;
 
 		public ControlPager(Form form, int pageWeight)
 		{
-			throw new NotImplementedException();
+			this.form   = form;
+			this.pageWt = pageWeight;
 		}
 
 		public int PageCount
@@ -32,5 +42,65 @@ namespace System.Web.UI.MobileControls
 				pageCount = value;
 			}
 		}
+
+		public int MaximumPage
+		{
+			get
+			{
+				return maxPage;
+			}
+			set
+			{
+				maxPage = value;
+			}
+		}
+
+		public int PageWeight
+		{
+			get
+			{
+				return pageWt;
+			}
+			set
+			{
+				pageWt = value;
+			}
+		}
+
+		public int RemainingWeight
+		{
+			get
+			{
+				return remainingWt;
+			}
+			set
+			{
+				remainingWt = value;
+			}
+		}
+
+		public ItemPager GetItemPager(MobileControl control, int itemCount,
+		                              int itemsPerPage, int itemWeight)
+		{
+			return new ItemPager(this, control, itemCount,
+			                     itemsPerPage, itemWeight);
+		}
+
+		public int GetPage(int weight)
+		{
+			if(weight > remainingWt)
+			{
+				PageCount += 1;
+				RemainingWeight = PageWeight;
+			}
+			if(remainingWt > weight)
+			{
+				remainingWt -= weight;
+			} else
+			{
+				remainingWt = 0;
+			}
+			return PageCount;
+		}
 	}
 }

+ 43 - 0
mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/ItemPager.cs

@@ -0,0 +1,43 @@
+/**
+ * Project   : Mono
+ * Namespace : System.Web.UI.MobileControls
+ * Class     : ItemPager
+ * Author    : Gaurav Vaish
+ *
+ * Copyright : 2003 with Gaurav Vaish, and with
+ *             Ximian Inc
+ */
+
+using System.Web.Mobile;
+
+namespace System.Web.UI.MobileControls
+{
+	public class ItemPager
+	{
+		private MobileControl control;
+
+		private int firstPage;
+		private int lastPage;
+
+		private int firstPageItemCount;
+		private int fullPageItemCount;
+		private int lastPageItemCount;
+
+		public ItemPager()
+		{
+		}
+
+		public ItemPager(ControlPager pager, MobileControl control,
+		                 int itemCount, int itemsPerPage, int itemWeight)
+		{
+			this.control = control;
+			if(itemsPerPage > 0)
+			{
+				throw new NotImplementedException();
+			} else
+			{
+				throw new NotImplementedException();
+			}
+		}
+	}
+}