Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs
diff options
context:
space:
mode:
authorGaurav Vaish <gvaish@mono-cvs.ximian.com>2003-02-23 10:42:11 +0300
committerGaurav Vaish <gvaish@mono-cvs.ximian.com>2003-02-23 10:42:11 +0300
commit4aad18b2f3dc213d5cb2474e15c8fddc25d3c137 (patch)
treef481c6a21864cd7855ba6cd8aa4db5fad6a43535 /mcs
parent1d65971a97c926d14bdbd6332a93c62ebc1749af (diff)
2003-02-23 Gaurav Vaish <gvaish_mono AT lycos.com>
* Calendar.cs : Completed. * BaseValidator.cs : Completed. * CompareValidator.cs : Completed. svn path=/trunk/mcs/; revision=11859
Diffstat (limited to 'mcs')
-rw-r--r--mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/BaseValidator.cs205
-rw-r--r--mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/Calendar.cs164
-rw-r--r--mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/ChangeLog8
-rw-r--r--mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/CompareValidator.cs109
4 files changed, 482 insertions, 4 deletions
diff --git a/mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/BaseValidator.cs b/mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/BaseValidator.cs
new file mode 100644
index 00000000000..bac56a5e957
--- /dev/null
+++ b/mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/BaseValidator.cs
@@ -0,0 +1,205 @@
+/**
+ * Project : Mono
+ * Namespace : System.Web.UI.MobileControls
+ * Class : BaseValidator
+ * Author : Gaurav Vaish
+ *
+ * Copyright : 2003 with Gaurav Vaish, and with
+ * Ximian Inc
+ */
+
+using System.ComponentModel;
+using System.Web.UI;
+using System.Web.Mobile;
+using System.Web.UI.WebControls;
+
+namespace System.Web.UI.MobileControls
+{
+ public abstract class BaseValidator : TextControl, IValidator
+ {
+ private System.Web.UI.WebControls.BaseValidator webBaseValidator;
+ private bool isValid = true;
+
+ protected BaseValidator()
+ {
+ StyleReference = "error";
+ webBaseValidator = CreateWebValidator();
+ if(webBaseValidator == null)
+ this.webBaseValidator = new DefaultWebValidator();
+ Controls.Add(webBaseValidator);
+ webBaseValidator.Display = ValidatorDisplay.Dynamic;
+ }
+
+ private class DefaultWebValidator
+ : System.Web.UI.WebControls.BaseValidator
+ {
+ protected override bool EvaluateIsValid()
+ {
+ return false;
+ }
+ }
+
+ protected virtual System.Web.UI.WebControls.BaseValidator CreateWebValidator()
+ {
+ return null;
+ }
+
+ public string ErrorMessage
+ {
+ get
+ {
+ return webBaseValidator.ErrorMessage;
+ }
+ set
+ {
+ webBaseValidator.ErrorMessage = value;
+ }
+ }
+
+ public bool IsValid
+ {
+ get
+ {
+ return isValid;
+ }
+ set
+ {
+ isValid = value;
+ }
+ }
+
+ public void Validate()
+ {
+ if(Visible)
+ {
+ Control parent = Parent;
+ bool visible = true;
+ while(parent != null)
+ {
+ if(!parent.Visible)
+ {
+ visible = false;
+ break;
+ }
+ parent = parent.Parent;
+ }
+ if(visible)
+ EvaluateIsValid();
+ } else
+ {
+ IsValid = true;
+ }
+ }
+
+ protected abstract bool EvaluateIsValid();
+
+ public string ControlToValidate
+ {
+ get
+ {
+ return webBaseValidator.ControlToValidate;
+ }
+ set
+ {
+ webBaseValidator.ControlToValidate = value;
+ }
+ }
+
+ public ValidatorDisplay Display
+ {
+ get
+ {
+ return webBaseValidator.Display;
+ }
+ set
+ {
+ webBaseValidator.Display = value;
+ }
+ }
+
+ public override string StyleReference
+ {
+ get
+ {
+ return base.StyleReference;
+ }
+ set
+ {
+ base.StyleReference = value;
+ }
+ }
+
+ public override int VisibleWeight
+ {
+ get
+ {
+ return 0;
+ }
+ }
+
+ protected void CheckControlValidationProperty(string name,
+ string propertyName)
+ {
+ Control ctrl = NamingContainer.FindControl(name);
+ if(ctrl == null)
+ {
+ // FIXME
+ throw new ArgumentException("BaseValidator_ControlNotFound");
+ }
+ PropertyDescriptor pd = System.Web.UI.WebControls.BaseValidator.GetValidationProperty(ctrl);
+ if(pd == null)
+ {
+ // FIXME
+ throw new ArgumentException("BaseValidator_BadControlType");
+ }
+ }
+
+ protected virtual bool ControlPropertiesValid()
+ {
+ string ctrl = ControlToValidate;
+ if(ctrl.Length == 0)
+ {
+ // FIXME
+ throw new ArgumentException("BaseValidator_ControlToValidateBlank");
+ }
+ CheckControlValidationProperty(ctrl, "ControlToValidate");
+ return true;
+ }
+
+ internal bool EvaluateIsValidInternal()
+ {
+ try
+ {
+ webBaseValidator.Validate();
+ } catch(Exception)
+ {
+ string thisID = ID;
+ ID = webBaseValidator.ID;
+ webBaseValidator.ID = thisID;
+ try
+ {
+ webBaseValidator.Validate();
+ } finally
+ {
+ thisID = ID;
+ ID = webBaseValidator.ID;
+ webBaseValidator.ID = thisID;
+ }
+ }
+ return webBaseValidator.IsValid;
+ }
+
+ protected override void OnInit(EventArgs e)
+ {
+ Page.Validators.Add(this);
+ base.OnInit(e);
+ }
+
+ protected override void OnPreRender(EventArgs e)
+ {
+ if(MobilePage.ActiveForm == Form)
+ ControlPropertiesValid();
+ base.OnPreRender(e);
+ }
+ }
+}
diff --git a/mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/Calendar.cs b/mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/Calendar.cs
new file mode 100644
index 00000000000..ce6d2db5f3a
--- /dev/null
+++ b/mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/Calendar.cs
@@ -0,0 +1,164 @@
+/**
+ * Project : Mono
+ * Namespace : System.Web.UI.MobileControls
+ * Class : Calendar
+ * 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 Calendar : MobileControl, IPostBackEventHandler
+ {
+ private System.Web.UI.WebControls.Calendar webCal;
+ private static readonly object SelectionChangedEvent = new object();
+
+ public Calendar()
+ {
+ webCal = CreateWebCalendar();
+ webCal.Visible = false;
+ webCal.Controls.Add(webCal);
+ webCal.SelectionChanged += new EventHandler(WebSelectionChanged);
+ }
+
+ protected virtual System.Web.UI.WebControls.Calendar CreateWebCalendar()
+ {
+ return new System.Web.UI.WebControls.Calendar();
+ }
+
+ void IPostBackEventHandler.RaisePostBackEvent(string eventArgument)
+ {
+ if(MobilePage.ActiveForm != Form)
+ MobilePage.ActiveForm = Form;
+ Adapter.HandlePostBackEvent(eventArgument);
+ }
+
+ public event EventHandler SelectionChanged
+ {
+ add
+ {
+ Events.AddHandler(SelectionChangedEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(SelectionChangedEvent, value);
+ }
+ }
+
+ public string CalendarEntryText
+ {
+ get
+ {
+ object o = ViewState["CalendarEntryText"];
+ if(o != null)
+ return (string)o;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["CalendarEntryText"] = value;
+ }
+ }
+
+ public FirstDayOfWeek FirstDayOfWeek
+ {
+ get
+ {
+ return webCal.FirstDayOfWeek;
+ }
+ set
+ {
+ webCal.FirstDayOfWeek = value;
+ }
+ }
+
+ public DateTime SelectedDate
+ {
+ get
+ {
+ return webCal.SelectedDate;
+ }
+ set
+ {
+ webCal.SelectedDate = value;
+ }
+ }
+
+ public SelectedDatesCollection SelectedDates
+ {
+ get
+ {
+ return webCal.SelectedDates;
+ }
+ }
+
+ public CalendarSelectionMode SelectionMode
+ {
+ get
+ {
+ return webCal.SelectionMode;
+ }
+ set
+ {
+ webCal.SelectionMode = value;
+ }
+ }
+
+ public bool ShowDayHeader
+ {
+ get
+ {
+ return webCal.ShowDayHeader;
+ }
+ set
+ {
+ webCal.ShowDayHeader = value;
+ }
+ }
+
+ public DateTime VisibleDate
+ {
+ get
+ {
+ return webCal.VisibleDate;
+ }
+ set
+ {
+ webCal.VisibleDate = value;
+ }
+ }
+
+ public System.Web.UI.WebControls.Calendar WebCalendar
+ {
+ get
+ {
+ return webCal;
+ }
+ }
+
+ private void WebSelectionChanged(object sender, EventArgs e)
+ {
+ OnSelectionChanged();
+ }
+
+ protected virtual void OnSelectionChanged()
+ {
+ EventHandler eh = (EventHandler)(Events[SelectionChangedEvent]);
+ if(eh != null)
+ {
+ eh(this, new EventArgs());
+ }
+ }
+
+ public void RaiseSelectionChangedEvent()
+ {
+ WebSelectionChanged(this, new EventArgs());
+ }
+ }
+}
diff --git a/mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/ChangeLog b/mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/ChangeLog
index b3f86c23fdd..e52c4ca80a6 100644
--- a/mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/ChangeLog
+++ b/mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/ChangeLog
@@ -1,9 +1,9 @@
-2003-02-18 Gaurav Vaish <gvaish_mono AT lycos.com>
+2003-02-23 Gaurav Vaish <gvaish_mono AT lycos.com>
- * MobileListItem.cs : SetIndex(int) - Stubbed.
- * MobileListItemCollection.cs
- : Completed stub-ing.
+ * Calendar.cs : Completed.
+ * BaseValidator.cs : Completed.
+ * CompareValidator.cs : Completed.
2003-01-30 Gaurav Vaish <gvaish_mono AT lycos.com>
diff --git a/mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/CompareValidator.cs b/mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/CompareValidator.cs
new file mode 100644
index 00000000000..3391811515c
--- /dev/null
+++ b/mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/CompareValidator.cs
@@ -0,0 +1,109 @@
+/**
+ * Project : Mono
+ * Namespace : System.Web.UI.MobileControls
+ * Class : CompareValidator
+ * Author : Gaurav Vaish
+ *
+ * Copyright : 2003 with Gaurav Vaish, and with
+ * Ximian Inc
+ */
+
+using System.ComponentModel;
+using System.Web.UI;
+using System.Web.Mobile;
+using System.Web.UI.WebControls;
+
+namespace System.Web.UI.MobileControls
+{
+ public class CompareValidator : BaseValidator
+ {
+ private System.Web.UI.WebControls.CompareValidator webCmpVal;
+
+ public CompareValidator()
+ {
+ }
+
+ protected override System.Web.UI.WebControls.BaseValidator CreateWebValidator()
+ {
+ webCmpVal = new System.Web.UI.WebControls.CompareValidator();
+ return webCmpVal;
+ }
+
+ protected override bool EvaluateIsValid()
+ {
+ return base.EvaluateIsValidInternal();
+ }
+
+ protected override bool ControlPropertiesValid()
+ {
+ if(ControlToCompare.Length > 0)
+ {
+ base.CheckControlValidationProperty(ControlToCompare, "ControlToCompare");
+ if(String.Compare(ControlToCompare, ControlToValidate, true) == 0)
+ {
+ // FIXME
+ throw new ArgumentException("CompareValidator_BadCompareControl");
+ }
+ } else
+ {
+ if(Operator != ValidationCompareOperator.DataTypeCheck)
+ {
+ if(!BaseCompareValidator.CanConvert(ValueToCompare, Type))
+ {
+ // FIXME
+ throw new ArgumentException("Validator_ValueBadType");
+ }
+ }
+ }
+ return base.ControlPropertiesValid();
+ }
+
+ public string ControlToCompare
+ {
+ get
+ {
+ return webCmpVal.ControlToCompare;
+ }
+ set
+ {
+ webCmpVal.ControlToCompare = value;
+ }
+ }
+
+ public ValidationCompareOperator Operator
+ {
+ get
+ {
+ return webCmpVal.Operator;
+ }
+ set
+ {
+ webCmpVal.Operator = value;
+ }
+ }
+
+ public ValidationDataType Type
+ {
+ get
+ {
+ return webCmpVal.Type;
+ }
+ set
+ {
+ webCmpVal.Type = value;
+ }
+ }
+
+ public string ValueToCompare
+ {
+ get
+ {
+ return webCmpVal.ValueToCompare;
+ }
+ set
+ {
+ webCmpVal.ValueToCompare = value;
+ }
+ }
+ }
+}