2003-02-23 Gaurav Vaish <gvaish_mono AT lycos.com>
authorGaurav Vaish <gvaish@mono-cvs.ximian.com>
Sun, 23 Feb 2003 16:11:52 +0000 (16:11 -0000)
committerGaurav Vaish <gvaish@mono-cvs.ximian.com>
Sun, 23 Feb 2003 16:11:52 +0000 (16:11 -0000)
* CustomValidator.cs     : Completed.
* DeviceSpecific.cs      : Initial implementation.
* DeviceSpecificChoiceTemplateContainer.cs
                         : Completed.
* DeviceSpecificChoiceCollection.cs
                         : Completed.
* DeviceSpecificChoice.cs: Initial implementation.

svn path=/trunk/mcs/; revision=11871

mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/ChangeLog
mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/CustomValidator.cs [new file with mode: 0644]
mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/DeviceSpecific.cs
mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/DeviceSpecificChoice.cs [new file with mode: 0644]
mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/DeviceSpecificChoiceCollection.cs [new file with mode: 0644]
mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/DeviceSpecificChoiceTemplateContainer.cs [new file with mode: 0644]

index e52c4ca80a66c6304e30595cb82472f718aa4273..9b45bd0535ab996f03f61c64c4eac4193070884c 100644 (file)
@@ -1,4 +1,14 @@
 
+2003-02-23     Gaurav Vaish <gvaish_mono AT lycos.com>
+
+       * CustomValidator.cs     : Completed.
+       * DeviceSpecific.cs      : Initial implementation.
+       * DeviceSpecificChoiceTemplateContainer.cs
+                                : Completed.
+       * DeviceSpecificChoiceCollection.cs
+                                : Completed.
+       * DeviceSpecificChoice.cs: Initial implementation.
+
 2003-02-23     Gaurav Vaish <gvaish_mono AT lycos.com>
 
        * Calendar.cs            : Completed.
diff --git a/mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/CustomValidator.cs b/mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/CustomValidator.cs
new file mode 100644 (file)
index 0000000..3146377
--- /dev/null
@@ -0,0 +1,77 @@
+/**
+ * Project   : Mono
+ * Namespace : System.Web.UI.MobileControls
+ * Class     : CustomValidator
+ * Author    : Gaurav Vaish
+ *
+ * Copyright : 2003 with Gaurav Vaish, and with
+ *             Ximian Inc
+ */
+
+using System.Web.UI;
+using System.Web.Mobile;
+using System.Web.UI.WebControls;
+
+namespace System.Web.UI.MobileControls
+{
+       public class CustomValidator : BaseValidator
+       {
+               private static readonly object ServerValidateEvent = new object();
+               private System.Web.UI.WebControls.CustomValidator webCV;
+
+               public CustomValidator()
+               {
+               }
+
+               protected override bool EvaluateIsValid()
+               {
+                       return base.EvaluateIsValidInternal();
+               }
+
+               protected override System.Web.UI.WebControls.BaseValidator CreateWebValidator()
+               {
+                       webCV = new System.Web.UI.WebControls.CustomValidator();
+                       webCV.ServerValidate += new ServerValidateEventHandler(WebServerValidate);
+                       return webCV;
+               }
+
+               private void WebServerValidate(object sender, ServerValidateEventArgs e)
+               {
+                       e.IsValid = OnServerValidate(e.Value);
+               }
+
+               protected bool OnServerValidate(string value)
+               {
+                       ServerValidateEventHandler sveh =
+                                (ServerValidateEventHandler)(Events[ServerValidateEvent]);
+                       if(sveh != null)
+                       {
+                               ServerValidateEventArgs e =
+                                     new ServerValidateEventArgs(value, true);
+                               sveh(this, e);
+                               return e.IsValid;
+                       }
+                       return false;
+               }
+
+               protected override bool ControlPropertiesValid()
+               {
+                       if(ControlToValidate.Length > 0)
+                               return true;
+
+                       return base.ControlPropertiesValid();
+               }
+
+               public event ServerValidateEventHandler ServerValidate
+               {
+                       add
+                       {
+                               Events.AddHandler(ServerValidateEvent, value);
+                       }
+                       remove
+                       {
+                               Events.RemoveHandler(ServerValidateEvent, value);
+                       }
+               }
+       }
+}
index f759a454d87ebe54a1055fe143795d79ea7c7086..2be2e03511397369d2e84b64f4007da35e3cfcbb 100644 (file)
@@ -9,13 +9,40 @@
  */
 
 using System.Web.UI;
+using System.Web.Mobile;
 
 namespace System.Web.UI.MobileControls
 {
        public class DeviceSpecific : Control
        {
+               private DeviceSpecificChoiceCollection choices;
+               private TemplateControl closestTemplateControl = null;
+               private bool haveSelectedChoice;
+               private object owner;
+               private DeviceSpecificChoice selectedChoice;
+
                public DeviceSpecific()
                {
                }
+               
+               public DeviceSpecificChoiceCollection Choices
+               {
+                       get
+                       {
+                               if(this.choices == null)
+                               {
+                                       choices = new DeviceSpecificChoiceCollection(this);
+                               }
+                               return this.choices;
+                       }
+               }
+               
+               public object Owner
+               {
+                       get
+                       {
+                               throw new NotImplementedException();
+                       }
+               }
        }
 }
diff --git a/mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/DeviceSpecificChoice.cs b/mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/DeviceSpecificChoice.cs
new file mode 100644 (file)
index 0000000..1a7cdb1
--- /dev/null
@@ -0,0 +1,188 @@
+/**
+ * Project   : Mono
+ * Namespace : System.Web.UI.MobileControls
+ * Class     : DeviceSpecificChoice
+ * Author    : Gaurav Vaish
+ *
+ * Copyright : 2003 with Gaurav Vaish, and with
+ *             Ximian Inc
+ */
+
+using System.ComponentModel;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Reflection;
+using System.Web.UI;
+using System.Web.Mobile;
+
+namespace System.Web.UI.MobileControls
+{
+       public class DeviceSpecificChoice : IParserAccessor,
+                                           IAttributeAccessor
+       {
+               private string argument;
+               private IDictionary contents;
+               private string filter;
+               private DeviceSpecific owner;
+               private IDictionary templates;
+               private string xmlns;
+
+               private static IComparer caseInsensitiveComparer
+                                     = new CaseInsensitiveComparer();
+
+               public DeviceSpecificChoice()
+               {
+               }
+
+               string IAttributeAccessor.GetAttribute(string key)
+               {
+                       object val = Contents[key];
+                       if(val != null && val is string)
+                               return (string)val;
+                       //FIXME
+                       throw new ArgumentException("DeviceSpecificChoice" +
+                                                   "_PropetyNotAnAttribute");
+               }
+
+               void IAttributeAccessor.SetAttribute(string key, string value)
+               {
+                       Contents[key] = value;
+               }
+
+               void IParserAccessor.AddParsedSubObject(object obj)
+               {
+                       if(obj is DeviceSpecificChoiceTemplateContainer)
+                       {
+                               DeviceSpecificChoiceTemplateContainer ctr =
+                                   (DeviceSpecificChoiceTemplateContainer)obj;
+                               Templates[ctr.Name] = ctr.Template;
+                       }
+               }
+
+               public string Argument
+               {
+                       get
+                       {
+                               return this.argument;
+                       }
+                       set
+                       {
+                               this.argument = value;
+                       }
+               }
+
+               public IDictionary Contents
+               {
+                       get
+                       {
+                               if(this.contents == null)
+                               {
+                                       this.contents = new ListDictionary(caseInsensitiveComparer);
+                               }
+                               return this.contents;
+                       }
+               }
+
+               public string Filter
+               {
+                       get
+                       {
+                               return this.filter;
+                       }
+                       set
+                       {
+                               this.filter = value;
+                       }
+               }
+
+               public DeviceSpecific Owner
+               {
+                       get
+                       {
+                               return this.owner;
+                       }
+                       set
+                       {
+                               this.owner = value;
+                       }
+               }
+
+               public IDictionary Templates
+               {
+                       get
+                       {
+                               if(this.templates == null)
+                               {
+                                       this.templates = new ListDictionary(caseInsensitiveComparer);
+                               }
+                               return this.templates;
+                       }
+               }
+
+               internal void ApplyProperties()
+               {
+                       IDictionaryEnumerator ide = Contents.GetEnumerator();
+                       while(ide.MoveNext())
+                       {
+                               object owner = Owner.Owner;
+                               string key = (string)ide.Key;
+                               string value = (string)ide.Value;
+                               if(key.ToLower() == "id")
+                               {
+                                       //FIXME
+                                       throw new ArgumentException("DeviceSpecificChoice" +
+                                                                   "_InvalidPropertyOverride");
+                               }
+                               if(value != null)
+                               {
+                                       int dash = 0;
+                                       while((dash = key.IndexOf('-')) != -1)
+                                       {
+                                               string first = key.Substring(0, dash);
+                                               PropertyDescriptor pd =
+                                                            TypeDescriptor.GetProperties(owner).Find(key, true);
+                                               if(pd == null)
+                                               {
+                                                       //FIXME
+                                                       throw new ArgumentException("DeviceSpecificChoice" +
+                                                                                   "_OverridingPropertyNotFound");
+                                               }
+                                               owner = pd.GetValue(owner);
+                                               key = key.Substring(dash + 1);
+                                       }
+                                       if(!FindAndApplyProperty(owner, key, value) &&
+                                          !FindAndApplyEvent(owner, key, value))
+                                       {
+                                               if(owner is IAttributeAccessor)
+                                               {
+                                                       ((IAttributeAccessor)owner).SetAttribute(key, value);
+                                               } else
+                                               {
+                                                       //FIXME
+                                                       throw new ArgumentException("DeviceSpecificChoice" +
+                                                                                   "_OverridingPropertyNotFound");
+                                               }
+                                       }
+                               }
+                       }
+               }
+
+               private bool FindAndApplyProperty(object parentObj, string key,
+                                                 string value)
+               {
+                       throw new NotImplementedException();
+               }
+
+               private bool FindAndApplyEvent(object parentObj, string key,
+                                              string value)
+               {
+                       throw new NotImplementedException();
+               }
+
+               private bool CheckOnPageEvaluator(MobileCapabilities capabilities,
+                                                 out bool evaluatorResult)
+               {
+                       throw new NotImplementedException();
+               }
+       }
+}
diff --git a/mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/DeviceSpecificChoiceCollection.cs b/mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/DeviceSpecificChoiceCollection.cs
new file mode 100644 (file)
index 0000000..ba9fc9f
--- /dev/null
@@ -0,0 +1,63 @@
+/**
+ * Project   : Mono
+ * Namespace : System.Web.UI.MobileControls
+ * Class     : DeviceSpecificChoiceCollection
+ * Author    : Gaurav Vaish
+ *
+ * Copyright : 2003 with Gaurav Vaish, and with
+ *             Ximian Inc
+ */
+
+using System.Collections;
+using System.Reflection;
+using System.Web.UI;
+using System.Web.Mobile;
+
+namespace System.Web.UI.MobileControls
+{
+       public class DeviceSpecificChoiceCollection
+                    : ArrayListCollectionBase
+       {
+               private DeviceSpecific owner;
+
+               internal DeviceSpecificChoiceCollection(DeviceSpecific owner)
+               {
+                       this.owner = owner;
+               }
+
+               public DeviceSpecificChoice this[int index]
+               {
+                       get
+                       {
+                               return (DeviceSpecificChoice)base.Items[index];
+                       }
+               }
+
+               public ArrayList All
+               {
+                       get
+                       {
+                               return base.Items;
+                       }
+               }
+
+               public void Add(DeviceSpecificChoice choice)
+               {
+                       AddAt(-1, choice);
+               }
+
+               public void AddAt(int index, DeviceSpecificChoice choice)
+               {
+                       choice.Owner = owner;
+                       if(index == -1)
+                               Items.Add(choice);
+                       else
+                               Items.Insert(index, choice);
+               }
+
+               public void Clear()
+               {
+                       Items.Clear();
+               }
+       }
+}
diff --git a/mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/DeviceSpecificChoiceTemplateContainer.cs b/mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/DeviceSpecificChoiceTemplateContainer.cs
new file mode 100644 (file)
index 0000000..065e37a
--- /dev/null
@@ -0,0 +1,51 @@
+/**
+ * Project   : Mono
+ * Namespace : System.Web.UI.MobileControls
+ * Class     : DeviceSpecificChoiceTemplateContainer
+ * Author    : Gaurav Vaish
+ *
+ * Copyright : 2003 with Gaurav Vaish, and with
+ *             Ximian Inc
+ */
+
+using System.Collections;
+using System.Reflection;
+using System.Web.UI;
+using System.Web.Mobile;
+
+namespace System.Web.UI.MobileControls
+{
+       public class DeviceSpecificChoiceTemplateContainer
+       {
+               private string name;
+               private ITemplate template;
+
+               public DeviceSpecificChoiceTemplateContainer()
+               {
+               }
+
+               public string Name
+               {
+                       get
+                       {
+                               return name;
+                       }
+                       set
+                       {
+                               name = value;
+                       }
+               }
+
+               public ITemplate Template
+               {
+                       get
+                       {
+                               return template;
+                       }
+                       set
+                       {
+                               template = value;
+                       }
+               }
+       }
+}