* Form.cs : HasActiveHandler() - Stubbed.
* List.cs : Initial implementation.
* ItemPager.cs,
* Image.cs,
* Link.cs,
* ListDataBindEventArgs.cs,
* ListDataBindEventHandler.cs,
* ListCommandEventArgs.cs,
* ListCommandEventHandler.cs,
* LoadItemsEventArgs.cs,
* LoadItemsEventHandler.cs
: Completed.
* MobilePage.cs : ActivePage { get; set; } - Stubbed.
: GetForm(string) - Stubbed.
* PagedControl.cs : Initial implementation.
svn path=/trunk/mcs/; revision=10950
+2003-01-26 Gaurav Vaish <gvaish_mono AT lycos.com>
+
+ * Form.cs : HasActiveHandler() - Stubbed.
+ * List.cs : Initial implementation.
+ * ItemPager.cs,
+ * Image.cs,
+ * Link.cs,
+ * ListDataBindEventArgs.cs,
+ * ListDataBindEventHandler.cs,
+ * ListCommandEventArgs.cs,
+ * ListCommandEventHandler.cs,
+ * LoadItemsEventArgs.cs,
+ * LoadItemsEventHandler.cs
+ : Completed.
+ * MobilePage.cs : ActivePage { get; set; } - Stubbed.
+ : GetForm(string) - Stubbed.
+ * PagedControl.cs : Initial implementation.
+
2003-01-25 Gaurav Vaish <gvaish_mono AT lycos.com>
* ControlPager.cs : Completed.
throw new NotImplementedException();
}
}
+
+ public bool HasActiveHandler()
+ {
+ throw new NotImplementedException();
+ }
}
}
--- /dev/null
+/**
+ * Project : Mono
+ * Namespace : System.Web.UI.MobileControls
+ * Class : Image
+ * Author : Gaurav Vaish
+ *
+ * Copyright : 2003 with Gaurav Vaish, and with
+ * Ximian Inc
+ */
+
+using System;
+using System.Web.UI;
+using System.Web.Mobile;
+
+namespace System.Web.UI.MobileControls
+{
+ public class Image : MobileControl, IPostBackEventHandler
+ {
+ public Image()
+ {
+ }
+
+ void IPostBackEventHandler.RaisePostBackEvent(string argument)
+ {
+ MobilePage.ActiveForm = MobilePage.GetForm(argument);
+ }
+
+ public string AlternateText
+ {
+ get
+ {
+ object o = ViewState["AlternateText"];
+ if(o != null)
+ return (string)o;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["AlternateText"] = value;
+ }
+ }
+
+ public string ImageUrl
+ {
+ get
+ {
+ object o = ViewState["ImageUrl"];
+ if(o != null)
+ return (string)o;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["ImageUrl"] = value;
+ }
+ }
+
+ public string NavigateUrl
+ {
+ get
+ {
+ object o = ViewState["NavigateUrl"];
+ if(o != null)
+ return (string)o;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["NavigateUrl"] = value;
+ }
+ }
+
+ public string SoftkeyLabel
+ {
+ get
+ {
+ object o = ViewState["SoftkeyLabel"];
+ if(o != null)
+ return (string)o;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["SoftkeyLabel"] = value;
+ }
+ }
+ }
+}
this.control = control;
if(itemsPerPage > 0)
{
- throw new NotImplementedException();
+ if(itemCount < itemsPerPage)
+ {
+ firstPageItemCount = itemCount;
+ firstPage = pager.GetPage(itemWeight * itemCount);
+ lastPage = firstPage;
+ } else
+ {
+ int ppic = (itemCount - 1)/itemsPerPage + 1;
+ firstPageItemCount = itemsPerPage;
+ fullPageItemCount = itemsPerPage;
+ lastPageItemCount = ppic - (ppic - 1)*itemsPerPage;
+ firstPage = pager.GetPage(itemsPerPage * itemWeight);
+ pager.PageCount += (ppic - 1);
+ if(ppic > 1)
+ {
+ pager.RemainingWeight = pager.PageWeight
+ - (itemsPerPage * itemWeight);
+ lastPage = firstPage + ppic - 1;
+ }
+ }
} else
{
- throw new NotImplementedException();
+ int totalWt = itemWeight * itemCount;
+ if(totalWt <= pager.RemainingWeight)
+ {
+ firstPageItemCount = itemCount;
+ firstPage = pager.GetPage(totalWt);
+ lastPage = firstPage;
+ } else
+ {
+ firstPageItemCount = pager.RemainingWeight / itemWeight;
+ int rem = itemCount - firstPageItemCount;
+ fullPageItemCount = Math.Max(itemWeight, pager.PageWeight);
+ int pages = rem / fullPageItemCount;
+ lastPageItemCount = rem % fullPageItemCount;
+ firstPage = pager.PageCount;
+ pager.PageCount += 1;
+ pager.RemainingWeight = pager.PageWeight;
+ pager.PageCount += pages;
+ pager.RemainingWeight -= lastPageItemCount * itemWeight;
+ if(firstPageItemCount == 0)
+ {
+ firstPage += 1;
+ firstPageItemCount = Math.Min(fullPageItemCount,
+ itemCount);
+ }
+ if(lastPageItemCount == 0)
+ {
+ pager.PageCount -= 1;
+ lastPageItemCount = Math.Min(fullPageItemCount,
+ itemCount);
+ pager.RemainingWeight = 0;
+ }
+ lastPage = pager.PageCount;
+ }
+ control.FirstPage = firstPage;
+ control.LastPage = lastPage;
}
}
+
+ public int ItemCount
+ {
+ get
+ {
+ return GetItemCount();
+ }
+ }
+
+ public int ItemIndex
+ {
+ get
+ {
+ return GetItemIndex();
+ }
+ }
+
+ private int GetItemCount()
+ {
+ int cp = control.Form.CurrentPage;
+ int retVal;
+ if(cp >= firstPage && cp <= lastPage)
+ {
+ if(cp == firstPage)
+ retVal = firstPageItemCount;
+ else if(cp == lastPage)
+ retVal = lastPageItemCount;
+ else
+ retVal = fullPageItemCount;
+ } else
+ {
+ retVal = -1;
+ }
+ return retVal;
+ }
+
+ private int GetItemIndex()
+ {
+ int cp = control.Form.CurrentPage;
+ int retVal;
+ if(cp >= firstPage && cp <= lastPage)
+ {
+ if(cp == firstPage)
+ retVal = 0;
+ else
+ {
+ retVal = (cp - firstPage - 1)* fullPageItemCount
+ + firstPageItemCount;
+ }
+ } else
+ {
+ retVal = -1;
+ }
+ return retVal;
+ }
}
}
--- /dev/null
+/**
+ * Project : Mono
+ * Namespace : System.Web.UI.MobileControls
+ * Class : Link
+ * Author : Gaurav Vaish
+ *
+ * Copyright : 2003 with Gaurav Vaish, and with
+ * Ximian Inc
+ */
+
+using System;
+using System.Collections;
+using System.Web.UI;
+using System.Web.Mobile;
+
+namespace System.Web.UI.MobileControls
+{
+ public class Link : MobileControl, IPostBackEventHandler
+ {
+ public Link()
+ {
+ }
+
+ void IPostBackEventHandler.RaisePostBackEvent(string argument)
+ {
+ MobilePage.ActiveForm = MobilePage.GetForm(argument);
+ }
+
+ public override void AddLinkedForms(IList linkedForms)
+ {
+ string url = NavigateUrl;
+ string pref = Constants.FormIDPrefix;
+ if(url.StartsWith(pref))
+ {
+ url = url.Substring(pref.Length);
+ Form toAdd = ResolveFormReference(url);
+ if(toAdd != null && !toAdd.HasActiveHandler())
+ linkedForms.Add(toAdd);
+ }
+ }
+
+ public string NavigateUrl
+ {
+ get
+ {
+ object o = ViewState["NavigateUrl"];
+ if(o != null)
+ return (string)o;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["NavigateUrl"] = value;
+ }
+ }
+
+ public string SoftkeyLabel
+ {
+ get
+ {
+ object o = ViewState["SoftkeyLabel"];
+ if(o != null)
+ return (string)o;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["SoftkeyLabel"] = value;
+ }
+ }
+ }
+}
--- /dev/null
+/**
+ * Project : Mono
+ * Namespace : System.Web.UI.MobileControls
+ * Class : List
+ * Author : Gaurav Vaish
+ *
+ * Copyright : 2003 with Gaurav Vaish, and with
+ * Ximian Inc
+ */
+
+using System.Web.UI;
+using System.Web.Mobile;
+
+namespace System.Web.UI.MobileControls
+{
+ public class List : PagedControl//, INamingContainer, IListControl,
+// ITemplateable, IPostBackEventHandler
+ {
+ public List()
+ {
+ }
+
+ protected override int InternalItemCount
+ {
+ get
+ {
+ throw new NotImplementedException();
+ }
+ }
+ }
+}
--- /dev/null
+/**
+ * Project : Mono
+ * Namespace : System.Web.UI.MobileControls
+ * Class : ListCommandEventArgs
+ * Author : Gaurav Vaish
+ *
+ * Copyright : 2003 with Gaurav Vaish, and with
+ * Ximian Inc
+ */
+
+using System.Web.UI.WebControls;
+using System.Web.Mobile;
+
+namespace System.Web.UI.MobileControls
+{
+ public class ListCommandEventArgs : CommandEventArgs
+ {
+ protected static readonly string DefaultCommand = "Default";
+
+ private object cmdSource;
+ private MobileListItem listItem;
+
+ public ListCommandEventArgs(MobileListItem item,
+ object commandSource)
+ :base(DefaultCommand, commandSource)
+ {
+ this.listItem = item;
+ this.cmdSource = commandSource;
+ }
+
+ public ListCommandEventArgs(MobileListItem item,
+ object commandSource, CommandEventArgs originalArgs)
+ : base(originalArgs)
+ {
+ this.cmdSource = commandSource;
+ this.listItem = item;
+ }
+
+ public object CommandSource
+ {
+ get
+ {
+ return this.cmdSource;
+ }
+ }
+
+ public MobileListItem ListItem
+ {
+ get
+ {
+ return this.listItem;
+ }
+ }
+ }
+}
--- /dev/null
+/**
+ * Project : Mono
+ * Namespace : System.Web.UI.MobileControls
+ * Class : ListCommandEventHandler
+ * Author : Gaurav Vaish
+ *
+ * Copyright : 2003 with Gaurav Vaish, and with
+ * Ximian Inc
+ */
+
+namespace System.Web.UI.MobileControls
+{
+ public delegate void ListCommandEventHandler(object sender,
+ ListCommandEventArgs e);
+}
--- /dev/null
+/**
+ * Project : Mono
+ * Namespace : System.Web.UI.MobileControls
+ * Class : ListDataBindEventArgs
+ * Author : Gaurav Vaish
+ *
+ * Copyright : 2003 with Gaurav Vaish, and with
+ * Ximian Inc
+ */
+
+using System;
+using System.Web.Mobile;
+
+namespace System.Web.UI.MobileControls
+{
+ public class ListDataBindEventArgs : EventArgs
+ {
+ private MobileListItem item;
+ private object dataItem;
+
+ public ListDataBindEventArgs(MobileListItem item, object dataItem)
+ {
+ this.item = item;
+ this.dataItem = dataItem;
+ }
+
+ public object DataItem
+ {
+ get
+ {
+ return dataItem;
+ }
+ }
+
+ public MobileListItem ListItem
+ {
+ get
+ {
+ return item;
+ }
+ }
+ }
+}
--- /dev/null
+/**
+ * Project : Mono
+ * Namespace : System.Web.UI.MobileControls
+ * Class : ListDataBindEventHandler
+ * Author : Gaurav Vaish
+ *
+ * Copyright : 2003 with Gaurav Vaish, and with
+ * Ximian Inc
+ */
+
+using System;
+using System.Web.Mobile;
+
+namespace System.Web.UI.MobileControls
+{
+ public delegate void ListDataBindEventHandler(object sender,
+ ListDataBindEventArgs e);
+}
--- /dev/null
+/**
+ * Project : Mono
+ * Namespace : System.Web.UI.MobileControls
+ * Class : LoadItemsEventArgs
+ * Author : Gaurav Vaish
+ *
+ * Copyright : 2003 with Gaurav Vaish, and with
+ * Ximian Inc
+ */
+
+namespace System.Web.UI.MobileControls
+{
+ public class LoadItemsEventArgs : EventArgs
+ {
+ private int index;
+ private int count;
+
+ public LoadItemsEventArgs(int index, int count)
+ {
+ this.index = index;
+ this.count = count;
+ }
+
+ public int ItemCount
+ {
+ get
+ {
+ return count;
+ }
+ }
+
+ public int ItemIndex
+ {
+ get
+ {
+ return index;
+ }
+ }
+ }
+}
--- /dev/null
+/**
+ * Project : Mono
+ * Namespace : System.Web.UI.MobileControls
+ * Class : LoadItemsEventHandler
+ * Author : Gaurav Vaish
+ *
+ * Copyright : 2003 with Gaurav Vaish, and with
+ * Ximian Inc
+ */
+
+namespace System.Web.UI.MobileControls
+{
+ public delegate void LoadItemsEventHandler(object sender,
+ LoadItemsEventArgs e);
+}
{
throw new NotImplementedException();
}
+
+ public Form ActiveForm
+ {
+ get
+ {
+ throw new NotImplementedException();
+ }
+ set
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ public Form GetForm(string id)
+ {
+ throw new NotImplementedException();
+ }
}
}
--- /dev/null
+/**
+ * Project : Mono
+ * Namespace : System.Web.UI.MobileControls
+ * Class : PagedControl
+ * Author : Gaurav Vaish
+ *
+ * Copyright : 2003 with Gaurav Vaish, and with
+ * Ximian Inc
+ */
+
+using System.Web.UI;
+using System.Web.Mobile;
+
+namespace System.Web.UI.MobileControls
+{
+ public abstract class PagedControl : MobileControl
+ {
+ private static readonly object LoadItemsEvent = new object();
+ private static readonly object ItemDataBindEvent = new object();
+ private static readonly object ItemCommandEvent = new object();
+
+ private int itemCount = 0;
+ private ItemPager itemPager;
+ private bool pagingCharsChanged = false;
+
+ protected PagedControl()
+ {
+ }
+
+ public event LoadItemsEventHandler LoadItems
+ {
+ add
+ {
+ Events.AddHandler(LoadItemsEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(LoadItemsEvent, value);
+ }
+ }
+
+ private void OnLoadItems()
+ {
+ OnLoadItems(new LoadItemsEventArgs(PagerItemIndex, PagerItemCount));
+ }
+
+ private int PagerItemIndex
+ {
+ get
+ {
+ return (itemPager == null ? 0 : itemPager.ItemIndex);
+ }
+ }
+
+ private int PagerItemCount
+ {
+ get
+ {
+ return (itemPager == null ? InternalItemCount :
+ itemPager.ItemCount);
+ }
+ }
+
+ protected abstract int InternalItemCount { get; }
+
+ protected virtual void OnLoadItems(LoadItemsEventArgs e)
+ {
+ LoadItemsEventHandler lieh = (LoadItemsEventHandler)(Events[LoadItemsEvent]);
+ if(lieh != null)
+ lieh(this, e);
+ }
+
+ protected override bool OnBubbleEvent(object sender, EventArgs e)
+ {
+ if(e is ListCommandEventArgs)
+ {
+ OnItemCommand((ListCommandEventArgs)e);
+ return true;
+ }
+ return false;
+ }
+
+ protected override void OnDataBinding(EventArgs e)
+ {
+ base.OnDataBinding(e);
+ throw new NotImplementedException();
+ }
+
+ protected void OnItemDataBind(ListDataBindEventArgs e)
+ {
+ ListDataBindEventHandler ldbeh = (ListDataBindEventHandler)(Events[ItemDataBindEvent]);
+ if(ldbeh != null)
+ ldbeh(this, e);
+ }
+
+ protected virtual void OnItemCommand(ListCommandEventArgs e)
+ {
+ ListCommandEventHandler lceh = (ListCommandEventHandler)(Events[ItemCommandEvent]);
+ if(lceh != null)
+ lceh(this, e);
+ }
+ }
+}