private static void OnAllowFutureDateChanged(BindableObject bindable, object oldValue, object newValue) { ESINullableDateTime thisctrl = (ESINullableDateTime)bindable; if (thisctrl != null) { if (newValue != null && oldValue != newValue && thisctrl.modelDateTime != null && thisctrl.dpicker != null) { try { if (!(bool)newValue) { DateTime utcNow = DateTime.UtcNow; thisctrl.dpicker.MaximumDate = utcNow; } else { thisctrl.dpicker.MaximumDate = new DateTime(2100, 12, 31); } } catch { // swallow a UI crash here } } } }
private static void OnTimeDisplayChanged(BindableObject bindable, object oldValue, object newValue) { ESINullableDateTime thisctrl = (ESINullableDateTime)bindable; if (thisctrl != null) { thisctrl.timeLabel.Text = newValue.ToString(); } }
private static void OnDateFormatChanged(BindableObject bindable, object oldValue, object newValue) { ESINullableDateTime thisctrl = (ESINullableDateTime )bindable; if (thisctrl != null && oldValue != newValue) { thisctrl.dpicker.Format = (string)newValue; } }
private static void OnControlDateChanged(BindableObject bindable, object oldValue, object newValue) { ESINullableDateTime thisctrl = (ESINullableDateTime)bindable; if (thisctrl != null) { thisctrl.modelDateTime = (DateTime?)newValue; if (thisctrl.dpicker != null) { thisctrl.dpicker.Format = thisctrl.DateFormat; if (newValue != null && oldValue != newValue && thisctrl.modelDateTime != null && thisctrl.dpicker != null) { try { thisctrl.timePicker.Time = thisctrl.modelDateTime.Value.TimeOfDay; thisctrl.dpicker.Date = thisctrl.modelDateTime.Value; bool allowFutureDate = GetAllowFutureDate(thisctrl); if (!allowFutureDate) { DateTime utcNow = DateTime.UtcNow; thisctrl.dpicker.MaximumDate = utcNow; } else { thisctrl.dpicker.MaximumDate = new DateTime(2100, 12, 31); } } catch { // swallow a UI crash here } } } thisctrl.timePickerDisplay.IsVisible = thisctrl.datePickerDisplay.IsVisible = thisctrl.modelDateTime == null ? true : false; } }