Esempio n. 1
0
        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
                       ));
        }
Esempio n. 2
0
        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
        }
Esempio n. 3
0
        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.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(
                () => popup.IsOpen = true,
                () => popup.IsOpen = false
            );
            #endif
        }