Ejemplo n.º 1
0
        public override IDisposable TimePrompt(TimePromptConfig config)
        {
            var picker = new TimePickerControl();

            picker.TimePicker.MinuteIncrement = config.MinuteInterval;

            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 TimePromptResult(false, picker.TimePicker.Time);
                    config.OnAction?.Invoke(result);
                    popup.IsOpen = false;
                };
            }

            if (config.Use24HourClock == true)
            {
                picker.TimePicker.ClockIdentifier = "24HourClock";
            }

            picker.OkButton.Content = config.OkText;
            picker.OkButton.Click  += (sender, args) =>
            {
                var result = new TimePromptResult(true, picker.TimePicker.Time);
                config.OnAction?.Invoke(result);
                popup.IsOpen = false;
            };
            if (config.SelectedTime != null)
            {
                picker.TimePicker.Time = config.SelectedTime.Value;
            }
            return(this.DispatchAndDispose(
                       //config.UwpSubmitOnEnterKey,
                       //config.UwpCancelOnEscKey,
                       () => popup.IsOpen = true,
                       () => popup.IsOpen = false
                       ));
        }
Ejemplo n.º 2
0
        public override IDisposable TimePrompt(TimePromptConfig config)
        {
#if WINDOWS_PHONE_APP
            throw new NotImplementedException();
#else
            var picker = new TimePickerControl();
            picker.TimePicker.MinuteIncrement = config.MinuteInterval;
            if (config.Use24HourClock.HasValue && config.Use24HourClock.Value)
            {
                picker.TimePicker.ClockIdentifier = "24HourClock";
            }

            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 TimePromptResult(false, picker.TimePicker.Time);
                    config.OnAction?.Invoke(result);
                    popup.IsOpen = false;
                };
            }

            picker.OkButton.Content = config.OkText;
            picker.OkButton.Click  += (sender, args) =>
            {
                var result = new TimePromptResult(true, picker.TimePicker.Time);
                config.OnAction?.Invoke(result);
                popup.IsOpen = false;
            };
            if (config.SelectedTime != null)
            {
                picker.TimePicker.Time = config.SelectedTime.Value;
            }
            return(this.DispatchAndDispose(
                       () => popup.IsOpen = true,
                       () => popup.IsOpen = false
                       ));
#endif
        }
Ejemplo n.º 3
0
        /// <summary> Time prompt asynchronous. </summary>
        /// <param name="title"> (Optional) The title. </param>
        /// <param name="selectedTime"> (Optional) The selected time. </param>
        /// <param name="cancelToken"> (Optional) The cancel token. </param>
        /// <returns> The asynchronous result that yields an UserDialogTimePromptResult. </returns>
        public async Task <UserDialogTimePromptResult> TimePromptAsync(string title = null, TimeSpan?selectedTime = null, CancellationToken?cancelToken = null)
        {
            AcrDialogs.TimePromptResult result = await AcrDialogs.UserDialogs.Instance.TimePromptAsync(title, selectedTime, cancelToken);

            return(ConvertTimePromptResult(result));
        }
Ejemplo n.º 4
0
        /// <summary> Time prompt asynchronous. </summary>
        /// <param name="config"> The configuration. </param>
        /// <param name="cancelToken"> (Optional) The cancel token. </param>
        /// <returns> The asynchronous result that yields an UserDialogTimePromptResult. </returns>
        public async Task <UserDialogTimePromptResult> TimePromptAsync(UserDialogTimePromptConfig config, CancellationToken?cancelToken = null)
        {
            AcrDialogs.TimePromptResult result = await AcrDialogs.UserDialogs.Instance.TimePromptAsync(GetTimePromptConfig(config), cancelToken);

            return(ConvertTimePromptResult(result));
        }
Ejemplo n.º 5
0
 /// <summary> Convert time prompt result. </summary>
 /// <param name="result"> The result. </param>
 /// <returns> The time converted prompt result. </returns>
 private UserDialogTimePromptResult ConvertTimePromptResult(AcrDialogs.TimePromptResult result)
 {
     return((result == null) ? null : new UserDialogTimePromptResult(result.Ok, result.SelectedTime));
 }