I would like to request 2 features/properties:
public class MyMaskDateTimeProvider : MaskDateTimeProvider
{
public MyMaskDateTimeProvider(string mask, CultureInfo culture, RadMaskedEditBoxElement owner)
: base(mask, culture, owner)
{
this.AutoSelectNextPart = true;
}
public override void SelectFirstItem() { } //base.SelectFirstItem(); //we do not want to go back to the days after the year part
protected override void HandleKeyPressDay(MaskPart part, KeyPressEventArgs e)
{
if(!int.TryParse(e.KeyChar.ToString(), out int result))
return;
string str = part.value.ToString();
int num1 = 0;
int num2;
if(part.hasZero)
{
if(num1 < part.min
|| num1 > part.max)
{
num2 = result;
}
else
{
if(str.Length > 1)
str = str.Substring(1);
num2 = int.Parse(str + e.KeyChar);
}
}
else
{
if(str.Length > 1)
str = str.Substring(1);
num2 = int.Parse(str + e.KeyChar);
}
if(part.day)
{
MyDayLogic(part, num2, result);
}
else
{
part.value = num2 < part.min || num2 > part.max
? result
: num2;
}
part.hasZero = result == 0;
}
private void MyDayLogic(MaskPart part, int num2, int result)
{
//logic for not continuing when changing days and current set month has less days then days needed, when that happens add one month to the current
if((num2 < part.min)
|| (num2 > part.max))
{
if((num2 > part.min)
&& (num2 <= 31))
{
SelectNextEditableItem();
Up(this.List[this.SelectedItemIndex], this.MinDate, this.MaxDate);
SelectPrevEditableItem();
SelectNextEditableItem();
part.value = num2;
}
else
{
part.value = result;
}
}
else
{
part.value = num2;
}
}
}