Beispiel #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
                       ));
        }
        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
        }
        public override IDisposable TimePrompt(TimePromptConfig config)
        {
            #if WINDOWS_PHONE_APP
            throw new NotImplementedException();
            #else
            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;
                };
            }

            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
        }