public override IDisposable DatePrompt(DatePromptConfig config) { var picker = new DatePickerControl(); if (config.MinimumDate != null) { picker.DatePicker.MinDate = config.MinimumDate.Value; } if (config.MaximumDate != null) { picker.DatePicker.MaxDate = config.MaximumDate.Value; } var popup = this.CreatePopup(picker); if (!config.IsCancellable) { picker.CancelButton.Visibility = Visibility.Collapsed; } else { picker.CancelButton.Content = config.CancelText; picker.CancelButton.Click += (sender, args) => { var result = new DatePromptResult(false, this.GetDateForCalendar(picker.DatePicker)); config.OnAction?.Invoke(result); popup.IsOpen = false; }; } picker.OkButton.Content = config.OkText; picker.OkButton.Click += (sender, args) => { var result = new DatePromptResult(true, this.GetDateForCalendar(picker.DatePicker)); config.OnAction?.Invoke(result); popup.IsOpen = false; }; if (config.SelectedDate != null) { picker.DatePicker.SelectedDates.Add(config.SelectedDate.Value); picker.DatePicker.SetDisplayDate(config.SelectedDate.Value); } return(this.DispatchAndDispose( //config.UwpSubmitOnEnterKey, //config.UwpCancelOnEscKey, () => popup.IsOpen = true, () => popup.IsOpen = false )); }
public override IDisposable DatePrompt(DatePromptConfig config) { #if WINDOWS_PHONE_APP throw new NotImplementedException(); #else var picker = new DatePickerControl(); if (config.MinimumDate != null) { picker.DatePicker.MinDate = config.MinimumDate.Value; } if (config.MaximumDate != null) { picker.DatePicker.MaxDate = config.MaximumDate.Value; } var popup = this.CreatePopup(picker); if (!config.IsCancellable) { picker.CancelButton.Visibility = Visibility.Collapsed; } else { picker.CancelButton.Content = config.CancelText; picker.CancelButton.Click += (sender, args) => { var result = new DatePromptResult(false, this.GetDateForCalendar(picker.DatePicker)); config.OnResult?.Invoke(result); popup.IsOpen = false; }; } picker.OkButton.Content = config.OkText; picker.OkButton.Click += (sender, args) => { var result = new DatePromptResult(true, this.GetDateForCalendar(picker.DatePicker)); config.OnResult?.Invoke(result); popup.IsOpen = false; }; if (config.SelectedDate != null) { picker.DatePicker.SelectedDates.Add(config.SelectedDate.Value); picker.DatePicker.SetDisplayDate(config.SelectedDate.Value); } return(this.DispatchAndDispose( () => popup.IsOpen = true, () => popup.IsOpen = false )); #endif }
/// <summary> Date prompt asynchronous. </summary> /// <param name="title"> (Optional) The title. </param> /// <param name="selectedDate"> (Optional) The selected date. </param> /// <param name="cancelToken"> (Optional) The cancel token. </param> /// <returns> The asynchronous result that yields an UserDialogDatePromptResult. </returns> public async Task <UserDialogDatePromptResult> DatePromptAsync(string title = null, DateTime?selectedDate = null, CancellationToken?cancelToken = null) { AcrDialogs.DatePromptResult result = await AcrDialogs.UserDialogs.Instance.DatePromptAsync(title, selectedDate, cancelToken); return(ConvertDatePromptResult(result)); }
/// <summary> Date prompt asynchronous. </summary> /// <param name="config"> The configuration. </param> /// <param name="cancelToken"> (Optional) The cancel token. </param> /// <returns> The asynchronous result that yields an UserDialogDatePromptResult. </returns> public async Task <UserDialogDatePromptResult> DatePromptAsync(UserDialogDatePromptConfig config, CancellationToken?cancelToken = null) { AcrDialogs.DatePromptResult result = await AcrDialogs.UserDialogs.Instance.DatePromptAsync(GetDatePromptConfig(config), cancelToken); return(ConvertDatePromptResult(result)); }
/// <summary> Convert date prompt result. </summary> /// <param name="result"> The result. </param> /// <returns> The date converted prompt result. </returns> private UserDialogDatePromptResult ConvertDatePromptResult(AcrDialogs.DatePromptResult result) { return((result == null) ? null : new UserDialogDatePromptResult(result.Ok, result.SelectedDate)); }