Exemple #1
0
 private void ApplyFreeTextValue(object sender, EventArgs e)
 {
     if (_FreeTextEntryBox == null) return;
     if (string.IsNullOrEmpty(_FreeTextEntryBox.Text))
         this.ValueObject = null;
     else
     {
         DateTime date;
         if (ParseFreeTextValue(out date))
         {
             this.Value = date;
         }
         else
         {
             FreeTextEntryConversionEventArgs eventArgs = new FreeTextEntryConversionEventArgs(_FreeTextEntryBox.Text);
             OnConvertFreeTextEntry(eventArgs);
             if (eventArgs.IsValueConverted)
             {
                 if (eventArgs.ControlValue is DateTime)
                     this.Value = (DateTime)eventArgs.ControlValue;
                 else if (eventArgs.ControlValue == null)
                     this.ValueObject = null;
                 else
                     throw new ArgumentException("ControlValue assigned is not DateTime type.");
             }
             else
             {
                 if (_AutoResolveFreeTextEntries)
                 {
                     date=DateTime.MinValue;
                     string text = _FreeTextEntryBox.Text.ToLower();
                     if (text == "now")
                         date = DateTime.Now;
                     else if (text == "today")
                         date = DateTime.Today;
                     else if (text == "tomorrow")
                         date = DateTime.Today.AddDays(1);
                     else if (text == "yesterday")
                         date = DateTime.Today.AddDays(-1);
                     if (date == DateTime.MinValue)
                         this.ValueObject = null;
                     else
                         this.Value = date;
                 }
             }
         }
     }
 }
Exemple #2
0
 protected virtual void OnConvertFreeTextEntry(FreeTextEntryConversionEventArgs e)
 {
     FreeTextEntryConversionEventHandler handler = this.ConvertFreeTextEntry;
     if (handler != null) handler(this, e);
 }