PIbd-32_Isaeva_A.I._COP_2/CustomDateTimePicker.cs

40 lines
773 B
C#
Raw Permalink Normal View History

namespace CustomsComponentsVar2;
public partial class CustomDateTimePicker : UserControl
{
public CustomDateTimePicker()
{
InitializeComponent();
}
public event EventHandler<DateTime> _dateChanged;
public DateTime dateStart;
public DateTime dateEnd;
public DateTime date
{
get
{
if (dateStart == null || dateEnd == null)
{
throw new RangeNotSetException("Не задан диапазон.");
}
if (date < dateStart && date > dateEnd)
{
throw new ValueNotInRangeException("Значение не входит в диапазон");
}
return date;
}
set
{
if (value >= dateStart && value <= dateEnd)
{
date = value;
}
}
}
public void dateChanged(DateTime date)
{
_dateChanged?.Invoke(this, date);
}
}