Exemplo n.º 1
0
 protected virtual void OnConvertFreeTextEntry(FreeTextEntryConversionEventArgs e)
 {
     FreeTextEntryConversionEventHandler handler = this.ConvertFreeTextEntry;
     if (handler != null) handler(this, e);
 }
Exemplo n.º 2
0
 protected override void ApplyFreeTextValue()
 {
     if (_FreeTextEntryBox == null) return;
     if (string.IsNullOrEmpty(_FreeTextEntryBox.Text))
         this.ValueObject = null;
     else
     {
         int value;
         if (int.TryParse(_FreeTextEntryBox.Text, out value) && AutoResolveFreeTextEntries)
         {
             this.Value = value;
         }
         else
         {
             FreeTextEntryConversionEventArgs eventArgs = new FreeTextEntryConversionEventArgs(_FreeTextEntryBox.Text);
             OnConvertFreeTextEntry(eventArgs);
             if (eventArgs.IsValueConverted)
             {
                 if (eventArgs.ControlValue is int)
                     this.Value = (int)eventArgs.ControlValue;
                 else if (eventArgs.ControlValue == null)
                     this.ValueObject = null;
                 else
                     throw new ArgumentException("ControlValue assigned is not int type.");
             }
             else
             {
                 //if (_AutoResolveFreeTextEntries)
                 //{
                 //    value = DateTime.MinValue;
                 //    string text = _FreeTextEntryBox.Text.ToLower();
                 //    if (text == "now")
                 //        value = DateTime.Now;
                 //    else if (text == "today")
                 //        value = DateTime.Today;
                 //    else if (text == "tomorrow")
                 //        value = DateTime.Today.AddDays(1);
                 //    else if (text == "yesterday")
                 //        value = DateTime.Today.AddDays(-1);
                 //    if (value == DateTime.MinValue)
                 //        this.ValueObject = null;
                 //    else
                 //        this.Value = value;
                 //}
                 this.Value = 0;
             }
         }
     }
 }
 /// <summary>
 /// ConvertFreeTextEntry
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void ConvertFreeTextEntry(object sender, FreeTextEntryConversionEventArgs e)
 {
     ((DataGridViewDateTimeInputColumn)OwningColumn).DoConvertFreeTextEntry(sender, e);
 }
 /// <summary>
 /// DoConvertFreeTextEntry
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 internal void DoConvertFreeTextEntry(object sender, FreeTextEntryConversionEventArgs e)
 {
     if (ConvertFreeTextEntry != null)
         ConvertFreeTextEntry(this, e);
 }
Exemplo n.º 5
0
 private void ApplyFreeTextValue(object sender, EventArgs e)
 {
     if (_FreeTextEntryBox == null) return;
     if (string.IsNullOrEmpty(_FreeTextEntryBox.Text))
         this.Value = null;
     else if (_IpGroup.IsValueValid(_FreeTextEntryBox.Text) && _AutoResolveFreeTextEntries)
         this.Value = _FreeTextEntryBox.Text;
     else
     {
         FreeTextEntryConversionEventArgs eventArgs = new FreeTextEntryConversionEventArgs(_FreeTextEntryBox.Text);
         OnConvertFreeTextEntry(eventArgs);
         if (eventArgs.IsValueConverted)
         {
             if (eventArgs.ControlValue is string && _IpGroup.IsValueValid((string)eventArgs.ControlValue))
                 this.Value = (string)eventArgs.ControlValue;
             else
                 throw new ArgumentException("ControlValue assigned is not recognized as valid IP value.");
         }
         else
         {
             string ipValue = null;
             if (_AutoResolveFreeTextEntries)
             {
                 try
                 {
                     System.Net.IPAddress[] addresses = System.Net.Dns.GetHostAddresses(_FreeTextEntryBox.Text);
                     if (addresses != null && addresses.Length > 0)
                     {
                         ipValue = addresses[0].ToString();
                         if (!_IpGroup.IsValueValid(ipValue))
                             ipValue = null;
                     }
                 }
                 catch
                 {
                     ipValue = null;
                 }
             }
             this.Value = ipValue;
         }
     }
 }