public static DatePickerDialog Build(Activity activity, DatePromptConfig config) { var dateTime = config.SelectedDate ?? DateTime.Now; var dialog = new DatePickerDialog( IsBrokenSamsungDevice() ? new ContextThemeWrapper(activity, Resource.Style.ThemeHoloLightDialog) : activity, (sender, args) => { }, dateTime.Year, dateTime.Month - 1, dateTime.Day ); dialog.SetCancelable(false); if (!String.IsNullOrWhiteSpace(config.Title)) { dialog.SetTitle(config.Title); } if (config.MinimumDate != null) { dialog.DatePicker.MinDate = config.MinimumDate.Value.ToUnixTimestamp(); } if (config.MaximumDate != null) { dialog.DatePicker.MaxDate = config.MaximumDate.Value.ToUnixTimestamp(); } if (config.IsCancellable) { dialog.SetButton( (int)DialogButtonType.Negative, new SpannableString(config.CancelText), (sender, args) => config .OnAction? .Invoke(new DatePromptResult( false, dialog.DatePicker.DateTime.Date )) ); } dialog.SetButton( (int)DialogButtonType.Positive, new SpannableString(config.OkText), (sender, args) => config .OnAction? .Invoke(new DatePromptResult( true, dialog.DatePicker.DateTime.Date )) ); return(dialog); }
protected override DatePickerDialog CreateDatePickerDialog(int year, int month, int day) { var dialog = new DatePickerDialog(Context, (o, e) => { _element.Date = e.Date; ((IElementController)_element).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false); }, year, month, day); dialog.SetButton((int)DialogButtonType.Positive, Context.Resources.GetString(global::Android.Resource.String.Ok), OnOk); dialog.SetButton((int)DialogButtonType.Negative, Context.Resources.GetString(global::Android.Resource.String.Cancel), OnCancel); return(dialog); }
public static DatePickerDialog Build(Activity activity, DatePromptConfig config) { var dateTime = config.SelectedDate ?? DateTime.Now; var dialog = new DatePickerDialog( activity, (sender, args) => { }, dateTime.Year, dateTime.Month + 1, dateTime.Day ); dialog.SetCancelable(false); if (!String.IsNullOrWhiteSpace(config.Title)) { dialog.SetTitle(config.Title); } if (config.MinimumDate != null) { dialog.DatePicker.MinDate = config.MinimumDate.Value.ToUnixTimestamp(); } if (config.MaximumDate != null) { dialog.DatePicker.MaxDate = config.MaximumDate.Value.ToUnixTimestamp(); } if (config.IsCancellable) { dialog.SetButton( (int)DialogButtonType.Negative, new SpannableString(config.CancelText), (sender, args) => { config.OnResult?.Invoke(new DatePromptResult(false, dialog.DatePicker.DateTime.Date)); } ); } dialog.SetButton( (int)DialogButtonType.Positive, new SpannableString(config.OkText), (sender, args) => { config.OnResult?.Invoke(new DatePromptResult(true, dialog.DatePicker.DateTime.Date)); } ); return(dialog); }
public void OnClick(object sender, EventArgs e) { HideKeyboard(); _dialog = new DatePickerDialog(Context, this, blankPicker.Date.Year, blankPicker.Date.Month - 1, blankPicker.Date.Day); _dialog.DatePicker.MaxDate = UnixTimestampFromDateTime(blankPicker.MaximumDate); _dialog.DatePicker.MinDate = UnixTimestampFromDateTime(blankPicker.MinimumDate); _dialog.SetButton(blankPicker.DoneButtonText, (k, p) => { blankPicker.Text = _dialog.DatePicker.DateTime.ToString(blankPicker.Format); blankPicker.Date = _dialog.DatePicker.DateTime; blankPicker.SendDoneClicked(); EController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false); Control.ClearFocus(); HideKeyboard(); }); _dialog.SetButton2(blankPicker.CancelButtonText, (s, el) => { blankPicker.SendCancelClicked(); EController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false); Control.ClearFocus(); HideKeyboard(); }); _dialog.CancelEvent += _dialog_DismissEvent; _dialog.Show(); }
void CreateDatePickerDialog(int year, int month, int day) { NullableDatePicker view = Element; _dialog = new DatePickerDialog(Context, (o, e) => { view.Date = e.Date; ((IElementController)view).SetValueFromRenderer(VisualElement.IsFocusedProperty, false); Control.ClearFocus(); _dialog = null; }, year, month, day); _dialog.SetButton("OK", (sender, e) => { SetDate(_dialog.DatePicker.DateTime); this.Element.Format = this.Element._originalFormat; this.Element.AssignValue(); }); _dialog.SetButton2("Limpar", (sender, e) => { this.Element.CleanDate(); Control.Text = this.Element.Format.Replace("\'", ""); }); }
protected override DatePickerDialog CreateDatePickerDialog(int year, int month, int day) { var view = (ExtendedDatePicker)Element; var dialog = new DatePickerDialog( Context, Resource.Style.DatePickerSpinnerDialogStyle, (o, e) => { view.Date = e.Date; ((IElementController)view).SetValueFromRenderer(VisualElement.IsFocusedProperty, false); Control.ClearFocus(); }, year, month, day); dialog.SetButton("Done", (sender, e) => { Element.Format = view.OriginalFormat; Control.Text = dialog.DatePicker.DateTime.ToString(Element.Format); view.AssignValue(); }); dialog.SetButton2("Clear", (sender, e) => { view.CleanDate(); Control.Text = Element.Format; }); return(dialog); }
private void ShowDatePicker() { _isShowing = true; _dialog = new DatePickerDialog(Context, DatePicker_DateSet, Element.Date.Year, Element.Date.Month - 1, Element.Date.Day); _dialog.SetButton("Done", (sender, e) => { Element.SelectedDate = _dialog.DatePicker.DateTime; Element.UpdateDate(); SetText(); }); _dialog.SetButton2("Cancel", (sender, e) => { _dialog.Hide(); }); _dialog.SetButton3("Clear", (sender, e) => { Element.SelectedDate = null; Element.UpdateDate(); SetText(); }); _dialog.DatePicker.DateTime = Element.SelectedDate ?? DateTime.Now; _dialog.DismissEvent += (sender, args) => _isShowing = false; _dialog.Show(); }
public void OnPickerClick(object sender, EventArgs e) { Xamarin.Forms.DatePicker model = Element; _dialog = new DatePickerDialog(Context, (o, d) => { model.Date = d.Date; EController.SetValueFromRenderer(VisualElement.IsFocusedProperty, false); Control.ClearFocus(); _dialog = null; }, this.Element.Date.Year, this.Element.Date.Month - 1, this.Element.Date.Day); _dialog.DatePicker.MaxDate = UnixTimestampFromDateTime(Element.MaximumDate); _dialog.DatePicker.MinDate = UnixTimestampFromDateTime(Element.MinimumDate); _dialog.SetButton(blankPicker.DoneButtonText, (k, p) => { this.Control.Text = _dialog.DatePicker.DateTime.ToString(Element.Format); Element.Date = _dialog.DatePicker.DateTime; blankPicker.SendDoneClicked(); }); _dialog.SetButton2(blankPicker.CancelButtonText, (s, el) => { blankPicker.SendCancelClicked(); }); _dialog.Show(); }
void CreateDatePickerDialog(int year, int month, int day) { CustomDatePicker view = Element; _dialog = new DatePickerDialog(Context, (o, e) => { view.Date = e.Date; ((IElementController)view).SetValueFromRenderer(VisualElement.IsFocusedProperty, false); Control.ClearFocus(); _dialog = null; }, year, month, day); _dialog.SetButton("Done", (sender, e) => { this.ClearFocus(); SetDate(_dialog.DatePicker.DateTime); this.Element.Format = this.Element.OriginalFormat; this.Element.AssignValue(); Control.Parent.RequestLayout(); _dialog = null; }); _dialog.SetButton2("Clear", (sender, e) => { this.ClearFocus(); this.Element.ClearDate(); Control.Text = this.Element.PlaceHolder; Control.Invalidate(); Control.RequestLayout(); Control.ForceLayout(); _dialog = null; }); }
protected override DatePickerDialog CreateDatePickerDialog(int year, int month, int day) { m_dialog = base.CreateDatePickerDialog(year, month, day); if (!string.IsNullOrEmpty(m_datepickerWithExtraButton.ExtraButtonText)) { m_dialog.SetButton((int)DialogButtonType.Neutral, m_datepickerWithExtraButton.ExtraButtonText, this); } return(m_dialog); }
private void SetExtraButtonText() { if (m_dialog != null) { if (!string.IsNullOrEmpty(m_datepickerWithExtraButton.ExtraButtonText)) { m_dialog.GetButton((int)DialogButtonType.Neutral).Text = m_datepickerWithExtraButton.ExtraButtonText; } else { m_dialog.SetButton((int)DialogButtonType.Neutral, m_datepickerWithExtraButton.ExtraButtonText, this); } } }
//METHOD: Create dialog for Date Picker. #pragma warning disable protected override Dialog OnCreateDialog(int id) { #pragma warning restore DatePickerDialog dpd = new DatePickerDialog(this, HandleDateSet, todays_date.Year, todays_date.Month - 1, todays_date.Day); dpd.SetMessage("Requests issued within 2 days will add a $15.00 fee."); dpd.SetIcon(Resource.Drawable.ic_action_time); dpd.SetCanceledOnTouchOutside(false); dpd.SetCancelable(false); #pragma warning disable dpd.SetButton("Cancel", dpd); dpd.SetButton2("Confirm", dpd); #pragma warning restore return(dpd); }
public override Dialog OnCreateDialog(Bundle savedInstanceState) { if (this.Date == null) { this.Date = DateTime.Now; } DatePickerDialog dialog = new DatePickerDialog(Activity, this, this.Date.Value.Year, this.Date.Value.Month, this.Date.Value.Day); dialog.SetButton("Ok", OnOkEventHandling); dialog.SetButton2("Kein Datum", OnCancelEventHandling); return(dialog); }
void CreateDatePickerDialog(int year, int month, int day) { DatePickerXamDisableDates.DatePickerRender view = Element; _dialog = new DatePickerDialog(Context, (o, e) => { view.Date = e.Date; ((IElementController)view).SetValueFromRenderer(VisualElement.IsFocusedProperty, false); Control.ClearFocus(); _dialog = null; }, year, month, day); var languageDevice = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName; var done = "تم"; var cancel = "إلغاء"; var clear = "إعادة"; if (languageDevice.ToLower().Contains("en")) { done = "Done"; cancel = "Cancel"; clear = "Clear"; } _dialog.SetButton(done, (sender, e) => { SetDate(_dialog.DatePicker.DateTime); this.Element.Format = this.Element._originalFormat; this.Element.AssignValue(); // App.DateSelected = _dialog.DatePicker.DateTime; }); _dialog.SetButton2(cancel, (sender, e) => { }); _dialog.SetButton3(clear, (sender, e) => { this.Element.CleanDate(); Control.Text = this.Element.Format; //App.DateSelected = default(DateTime); }); }
void CreateDatePickerDialog(int year, int month, int day) { CustomDatePicker view = Element; _dialog = new DatePickerDialog(Context, callBack: (o, e) => { view.Date = e.Date; ((IElementController)view).SetValueFromRenderer(VisualElement.IsFocusedProperty, false); Control.ClearFocus(); _dialog = null; }, year: year, monthOfYear: month, dayOfMonth: day); //Show Done button by default _dialog.SetButton("Done", (sender, e) => { SetDate(_dialog.DatePicker.DateTime); this.Element.Format = this.Element._originalFormat; this.Element.AssignValue(); }); if (this.Element.ShowClearButton) { _dialog.SetButton2("Cancel", (sender, e) => { this.Element.Cancel(); Control.Text = this.Element.Format; }); _dialog.SetButton3("Remove Date", (sender, e) => { this.Element.CleanDate(); Control.Text = this.Element.Format; }); } else //Show Cancel button by default { _dialog.SetButton2("Cancel", (sender, e) => { this.Element.Cancel(); Control.Text = this.Element.Format; }); } }
void CreateDatePickerDialog(int year, int month, int day) { BioDivCollectorXamarin.Controls.CustomDatePicker view = Element; _dialog = new DatePickerDialog(Context, (o, e) => { view.Date = e.Date; ((IElementController)view).SetValueFromRenderer(VisualElement.IsFocusedProperty, false); Control.ClearFocus(); _dialog = null; }, year, month, day); _dialog.SetButton("Fertig", (sender, e) => { SetDate(_dialog.DatePicker.DateTime); this.Element.Format = this.Element._originalFormat; this.Element.AssignValue(); }); _dialog.SetButton2("Löschen", (sender, e) => { this.Element.CleanDate(); Control.Text = this.Element.Format; }); }
void CreateDatePickerDialog(int year, int month, int day) { GodAndMe.NullableDatePicker view = Element; _dialog = new DatePickerDialog(Context, (o, e) => { view.Date = e.Date; ((IElementController)view).SetValueFromRenderer(VisualElement.IsFocusedProperty, false); Control.ClearFocus(); _dialog = null; }, year, month, day); _dialog.SetButton(CommonFunctions.i18n("Done"), (sender, e) => { SetDate(_dialog.DatePicker.DateTime); this.Element.Format = this.Element._originalFormat; this.Element.AssignValue(); }); _dialog.SetButton2(CommonFunctions.i18n("Clear"), (sender, e) => { this.Element.CleanDate(); Control.Text = this.Element.Format; }); }
public void UpdateTextButton(int buttonIndex, string text, Action action = null) { _dialog?.SetButton(buttonIndex, text, (sender, e) => { action?.Invoke(); }); }
protected override void InitBindings() { Bindings.Add(this.SetBinding(() => ViewModel.LoadingGlobal).WhenSourceChanges(() => { try { if (!ViewModel.LoadingGlobal) { //left details AnimeDetailsPageGeneralTabFragmentType.Text = ViewModel.RightDetailsRow[0].Item2; AnimeDetailsPageGeneralTabFragmentStatus.Text = ViewModel.RightDetailsRow[1].Item2; AnimeDetailsPageGeneralTabFragmentEnd.Text = ViewModel.RightDetailsRow[2].Item2; AnimeDetailsPageGeneralTabFragmentMyStartButton.SetOnClickListener(new OnClickListener(view => { var date = ViewModel.StartDateValid ? ViewModel.StartDateTimeOffset : DateTimeOffset.Now; DatePickerDialog dpd = new DatePickerDialog(Activity, new DateSetListener((i, i1, arg3) => { ViewModel.StartDateTimeOffset = new DateTimeOffset(i, i1, arg3, 0, 0, 0, TimeSpan.Zero); AnimeDetailsPageGeneralTabFragmentMyStart.Text = ViewModel.MyStartDate; }), date.Year, date.Month - 1, date.Day); dpd.SetButton((int)DialogButtonType.Neutral, "Reset", (sender, args) => ViewModel.ResetStartDateCommand.Execute(null)); dpd.Show(); })); AnimeDetailsPageGeneralTabFragmentMyStartButton.SetOnLongClickListener(new OnLongClickListener(view => ViewModel.ResetStartDateCommand.Execute(null))); AnimeDetailsPageGeneralTabFragmentEpisodesLabel.Text = ViewModel.LeftDetailsRow[0].Item1; //right details AnimeDetailsPageGeneralTabFragmentEpisodes.Text = ViewModel.LeftDetailsRow[0].Item2; AnimeDetailsPageGeneralTabFragmentScore.Text = ViewModel.LeftDetailsRow[1].Item2; AnimeDetailsPageGeneralTabFragmentStart.Text = ViewModel.LeftDetailsRow[2].Item2; AnimeDetailsPageGeneralTabFragmentMyEndButton.SetOnClickListener(new OnClickListener(view => { var date = ViewModel.EndDateValid ? ViewModel.EndDateTimeOffset : DateTimeOffset.Now; DatePickerDialog dpd = new DatePickerDialog(Activity, new DateSetListener((i, i1, arg3) => { ViewModel.EndDateTimeOffset = new DateTimeOffset(i, i1, arg3, 0, 0, 0, TimeSpan.Zero); AnimeDetailsPageGeneralTabFragmentMyEnd.Text = ViewModel.MyEndDate; }), date.Year, date.Month - 1, date.Day); dpd.SetButton((int)DialogButtonType.Neutral, "Reset", (sender, args) => ViewModel.ResetEndDateCommand.Execute(null)); dpd.Show(); })); AnimeDetailsPageGeneralTabFragmentMyEndButton.SetOnLongClickListener(new OnLongClickListener(view => ViewModel.ResetEndDateCommand.Execute(null))); //rest if (!string.IsNullOrEmpty(ViewModel.Synopsis)) { AnimeDetailsPageGeneralTabFragmentSynopsis.Text = ViewModel.Synopsis; AnimeDetailsPageGeneralTabFragmentSynopsis.Gravity = GravityFlags.Left; } else { AnimeDetailsPageGeneralTabFragmentSynopsis.Text = "Synopsis unavailable..."; AnimeDetailsPageGeneralTabFragmentSynopsis.Gravity = GravityFlags.CenterHorizontal; } } } catch (Exception) { //data loading has failed } })); Bindings.Add(this.SetBinding(() => ViewModel.AddAnimeVisibility) .WhenSourceChanges(() => { if (ViewModel.AddAnimeVisibility) { AnimeDetailsPageGeneralTabFragmentMyStartButton.Visibility = AnimeDetailsPageGeneralTabFragmentMyEndButton.Visibility = ViewStates.Gone; } else { AnimeDetailsPageGeneralTabFragmentMyStartButton.Visibility = AnimeDetailsPageGeneralTabFragmentMyEndButton.Visibility = ViewStates.Visible; } })); Bindings.Add( this.SetBinding(() => ViewModel.MyStartDate, () => AnimeDetailsPageGeneralTabFragmentMyStart.Text)); Bindings.Add( this.SetBinding(() => ViewModel.MyEndDate, () => AnimeDetailsPageGeneralTabFragmentMyEnd.Text)); Bindings.Add(this.SetBinding(() => ViewModel.EndDateTimeOffset).WhenSourceChanges(() => { AnimeDetailsPageGeneralTabFragmentMyStart.Text = ViewModel.MyStartDate; AnimeDetailsPageGeneralTabFragmentMyEnd.Text = ViewModel.MyEndDate; })); }