void OnMainDisplayInfoChanged(object?sender, DisplayInfoChangedEventArgs e) { DatePickerDialog?currentDialog = _dialog; if (currentDialog != null && currentDialog.IsShowing) { currentDialog.Dismiss(); ShowPickerDialog(currentDialog.DatePicker.Year, currentDialog.DatePicker.Month, currentDialog.DatePicker.DayOfMonth); } }
protected override void DisconnectHandler(MauiDatePicker nativeView) { if (_dialog != null) { _dialog.Hide(); _dialog.Dispose(); _dialog = null; } base.DisconnectHandler(nativeView); }
protected void CallBack(object o, DatePickerDialog.DateSetEventArgs e) { _DatePickerCell.Date = e.Date; ClearFocus(); if (_Dialog != null) { _Dialog.CancelEvent -= OnCancelButtonClicked; } _Dialog = null; }
void ShowPickerDialog(int year, int month, int day) { if (_dialog == null) { _dialog = CreateDatePickerDialog(year, month, day); } else { _dialog.UpdateDate(year, month, day); } _dialog.Show(); }
protected override void DisconnectHandler(MauiDatePicker platformView) { if (_dialog != null) { _dialog.Hide(); _dialog.Dispose(); _dialog = null; } DeviceDisplay.MainDisplayInfoChanged -= OnMainDisplayInfoChanged; base.DisconnectHandler(platformView); }
protected override void Dispose(bool disposing) { if (disposing) { if (_Dialog != null) { _Dialog.CancelEvent -= OnCancelButtonClicked; _Dialog?.Dispose(); _Dialog = null; } } base.Dispose(disposing); }
void ShowPickerDialog(int year, int month, int day) { if (_dialog == null) { _dialog = CreateDatePickerDialog(year, month, day); } else { EventHandler?setDateLater = null; setDateLater = (sender, e) => { _dialog !.UpdateDate(year, month, day); _dialog.ShowEvent -= setDateLater; }; _dialog.ShowEvent += setDateLater; } _dialog.Show(); }
protected override void DisconnectHandler(MauiDatePicker platformView) { if (_dialog != null) { _dialog.Hide(); _dialog.Dispose(); _dialog = null; } platformView.ViewAttachedToWindow -= OnViewAttachedToWindow; platformView.ViewDetachedFromWindow -= OnViewDetachedFromWindow; OnViewDetachedFromWindow(); base.DisconnectHandler(platformView); }
protected override MauiDatePicker CreateNativeView() { var mauiDatePicker = new MauiDatePicker(Context) { ShowPicker = ShowPickerDialog, HidePicker = HidePickerDialog }; var date = VirtualView?.Date; if (date != null) { _dialog = CreateDatePickerDialog(date.Value.Year, date.Value.Month, date.Value.Day); } return(mauiDatePicker); }
protected void ShowDialog() { _Dialog = CreateDatePickerDialog(_DatePickerCell.Date.Year, _DatePickerCell.Date.Month - 1, _DatePickerCell.Date.Day); UpdateMinimumDate(); UpdateMaximumDate(); if (_DatePickerCell.MinimumDate > _DatePickerCell.MaximumDate) { throw new ArgumentOutOfRangeException(nameof(DatePickerCell.MaximumDate), "MaximumDate must be greater than or equal to MinimumDate."); } if (_Dialog is null) { return; } _Dialog.CancelEvent += OnCancelButtonClicked; _Dialog.Show(); }
public static void UpdateMaximumDate(this MauiDatePicker platformDatePicker, IDatePicker datePicker, DatePickerDialog?datePickerDialog) { if (datePickerDialog != null) { datePickerDialog.DatePicker.MaxDate = (long)datePicker.MaximumDate.ToUniversalTime().Subtract(DateTime.MinValue.AddYears(1969)).TotalMilliseconds; } }