public override bool Validate(string stringValue) { CancelEventArgs e = new CancelEventArgs(); this.Owner.CallValueChanging(e); if (e.Cancel) { return(false); } this.MaskFromFormat = MaskDateTimeProvider.GetSpecificFormat(this.Mask, this.Culture.DateTimeFormat); DateTime?date = this.Parser.ParseDate(stringValue, new DateTime?()); if (date.HasValue) { this.TextBoxItem.Text = date.Value.ToString(this.MaskFromFormat, (IFormatProvider)this.Culture); this.Value = (object)date.Value; this.List = MaskDateTimeProvider.FillCollection(this.MaskFromFormat, this.Culture.DateTimeFormat); this.FillCollectionWithValues(this.List, this.value, this.Mask); this.SelectCurrentItemWithSelectedItem(); } else { this.Owner.Value = (object)null; } return(false); }
public MaskDateTimeProvider(string mask, CultureInfo culture, RadMaskedEditBoxElement owner) { this.owner = owner; this.textBoxItem = owner.TextBoxItem; this.mask = mask; this.culture = culture; this.textBoxItem = owner.TextBoxItem; this.dateTimeFormatInfo = culture.DateTimeFormat; this.maskFromFormat = MaskDateTimeProvider.GetSpecificFormat(mask, culture.DateTimeFormat); this.list = MaskDateTimeProvider.FillCollection(this.maskFromFormat, culture.DateTimeFormat); this.FillCollectionWithValues(list, this.value, this.mask); this.selectedItemIndex = 0; this.SelectFirstEditableItem(); }
public void TryParse() { ParsingDateTimeEventArgs e = new ParsingDateTimeEventArgs(this.TextBoxItem.Text, this.Parser.ParseDate(this.TextBoxItem.Text, new DateTime?())); this.OnParsingDateTime(e); if (e.Cancel) { return; } DateTime?nullable1 = e.Result; DateTime?nullable2 = nullable1; DateTime minDate = this.MinDate; if ((nullable2.HasValue ? (nullable2.GetValueOrDefault() < minDate ? 1 : 0) : 0) != 0) { nullable1 = new DateTime?(this.MinDate); } else { DateTime?nullable3 = nullable1; DateTime maxDate = this.MaxDate; if ((nullable3.HasValue ? (nullable3.GetValueOrDefault() > maxDate ? 1 : 0) : 0) != 0) { nullable1 = new DateTime?(this.MaxDate); } } if (nullable1.HasValue) { this.TextBoxItem.Text = nullable1.Value.ToString(this.MaskFromFormat, (IFormatProvider)this.Culture); this.value = nullable1.Value; this.Owner.Value = (object)nullable1.Value; this.List = MaskDateTimeProvider.FillCollection(this.MaskFromFormat, this.Culture.DateTimeFormat); this.FillCollectionWithValues(this.List, this.value, this.Mask); this.SelectCurrentItemWithSelectedItem(); } else { this.Owner.Value = (object)null; } this.OnParsedDateTime(); }