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

40 lines
773 B
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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);
}
}