private Task <int> ShowDialog(string message, IDialogButton positive, IDialogButton negative = null, IDialogButton neutral = null) { var tsc = new TaskCompletionSource <int>(); string cancelButtonTitle = positive.Caption; var otherButtons = new List <string>(2); if (negative != null) { otherButtons.Add(negative.Caption); } if (neutral != null) { otherButtons.Add(neutral.Caption); } var alertView = new UIAlertView("", message, null, cancelButtonTitle, otherButtons.ToArray()); alertView.Delegate = new AlertViewDelegate(_alertViews, tsc); alertView.Show(); _alertViews.Add(alertView); return(tsc.Task); }
private async Task <DialogButton> ShowDialog(string caption, string message , IDialogButton positive, IDialogButton negative = null, IDialogButton neutral = null) { string negativeCaption = negative != null ? negative.Caption : null; string neutralCaption = neutral != null ? neutral.Caption : null; return(await ShowDialog(caption, message, positive.Caption, negativeCaption, neutralCaption)); }
private Task <IDialogAnswer <object> > ShowSelectionDialog(string caption, KeyValuePair <object, string>[] items, IDialogButton positive, IDialogButton negative) { var tcs = new TaskCompletionSource <IDialogAnswer <object> >(); string[] rows = items.Select(val => val.Value).ToArray(); var actionSheet = new UIActionSheet(caption, null, negative.Caption, null, rows); actionSheet.Delegate = new ActionSheetDelegate(items, _actionSheets, tcs); actionSheet.ShowInView(_context.MainController.View); _actionSheets.Add(actionSheet); return(tcs.Task); }
public override void Initialize(IDialogButton argument) { _model = argument; if (_model == null) { return; } _text.text = _model.Name; _button.OnClickAsObservable().Subscribe(_ => { _model.Owner.Click(_model); }).AddTo(this); }
public Task <IDialogAnswer <object> > Choose(string caption, KeyValuePair <object, string>[] items, int index, IDialogButton positive, IDialogButton negative) { return(ShowSelectionDialog(caption, items, positive, negative)); }
public Task <IDialogAnswer <DateTime> > Time(string caption, DateTime current, IDialogButton positive, IDialogButton negative) { return(ShowDateTimeDialog(caption, UIDatePickerMode.Time, current, positive, negative)); }
public async Task <bool> Ask(string message, IDialogButton positive, IDialogButton negative) { int result = await ShowDialog(message, positive, negative); return(result == 0); }
public Task Message(string message, IDialogButton ok) { return(ShowDialog(message, ok)); }
public Task <int> Alert(string message, IDialogButton positive, IDialogButton negative, IDialogButton neutral) { return(ShowDialog(message, positive, negative, neutral)); }
public void Click(IDialogButton button) { _clickStream.OnNext(button); }
public Task <IDialogAnswer <DateTime> > Time(string caption, DateTime current, IDialogButton positive, IDialogButton negative) { return(ShowDateTimeDialog(caption, current, false, true, positive, negative)); }
public async Task <bool> Ask(string message, IDialogButton positive, IDialogButton negative) { DialogButton button = await ShowDialog(null, message, positive, negative); return(button == DialogButton.Positive); }
public async Task Message(string message, IDialogButton ok) { await ShowDialog(null, message, ok); }
public async Task <int> Alert(string message, IDialogButton positive, IDialogButton negative, IDialogButton neutral) { return((int) await ShowDialog(null, message, positive, negative, neutral)); }
private Task <IDialogAnswer <object> > ShowSelectionDialog(string caption, KeyValuePair <object, string>[] items, int index, IDialogButton positive, IDialogButton negative) { var tcs = new TaskCompletionSource <IDialogAnswer <object> >(); var builder = CreateBuilder(); builder.SetTitle(caption); var rows = new string[items.Length]; for (int i = 0; i < items.Length; i++) { rows[i] = items[i].Value; } var adapt = new ArrayAdapter <string>(_activity, Android.Resource.Layout.SelectDialogSingleChoice, rows); builder.SetSingleChoiceItems(adapt, index, (e, args) => { }); builder.SetPositiveButton(positive.Caption, (sender, e) => { int pos = ((AlertDialog)sender).ListView.CheckedItemPosition; if (pos < items.Length) { object result = items[pos].Key; tcs.SetResult(new DialogAnswer <object>(true, result)); } }); builder.SetNegativeButton(negative.Caption, (sender, e) => tcs.SetResult(new DialogAnswer <object>(false, null))); builder.SetCancelable(false); ShowDialog(builder); return(tcs.Task); }
private Task <IDialogAnswer <DateTime> > ShowDateTimeDialog(string caption, DateTime current, bool date, bool time , IDialogButton positive, IDialogButton negative) { var tsc = new TaskCompletionSource <IDialogAnswer <DateTime> >(); var builder = CreateBuilder(); builder.SetTitle(caption); using (var th = new TabHost(_activity)) { th.Id = Android.Resource.Id.TabHost; var widget = new TabWidget(_activity) { Id = Android.Resource.Id.Tabs }; var fl = new FrameLayout(_activity) { Id = Android.Resource.Id.TabContent }; var rll = new LinearLayout(_activity) { Orientation = Orientation.Vertical }; rll.SetBackgroundColor(new Color(50, 100, 145)); rll.AddView(widget); rll.AddView(fl); fl.LayoutParameters.Width = ViewGroup.LayoutParams.MatchParent; th.AddView(rll); th.Setup(); var tabContentFactory = new TabContentFactory(); if (date) { var dp = new DatePicker(_activity) { Id = DatePicker }; var minDate = new DateTime(1900, 1, 1); current = current > minDate ? current : minDate; dp.DateTime = current; tabContentFactory.Add("date", dp); var spec = th.NewTabSpec("date"); spec.SetContent(tabContentFactory); spec.SetIndicator(CreateTabIndicator(D.DATE)); th.AddTab(spec); } if (time) { var tp = new TimePicker(_activity) { Id = TimePicker }; tp.SetIs24HourView(new Java.Lang.Boolean(true)); tp.CurrentHour = new Java.Lang.Integer(current.Hour); tp.CurrentMinute = new Java.Lang.Integer(current.Minute); tabContentFactory.Add("time", tp); var spec = th.NewTabSpec("time"); spec.SetContent(tabContentFactory); spec.SetIndicator(CreateTabIndicator(D.TIME)); th.AddTab(spec); } widget.SetCurrentTab(0); builder.SetView(th); } builder.SetPositiveButton(positive.Caption, (sender, e) => { DateTime result = DateTimeFromDialog(sender, current, date, time); tsc.SetResult(new DialogAnswer <DateTime>(true, result)); }); builder.SetNegativeButton(negative.Caption, (sender, e) => { DateTime result = DateTimeFromDialog(sender, current, date, time); tsc.SetResult(new DialogAnswer <DateTime>(false, result)); }); builder.SetCancelable(false); ShowDialog(builder); return(tsc.Task); }
private Task <IDialogAnswer <DateTime> > ShowDateTimeDialog(string caption, UIDatePickerMode mode, DateTime current, IDialogButton positive, IDialogButton negative) { var tcs = new TaskCompletionSource <IDialogAnswer <DateTime> >(); var version = new Version(UIDevice.CurrentDevice.SystemVersion); if (version.Major >= 7) { var picker = new DatePicker(); picker.Title = caption; picker.NativeDatePicker.Mode = mode; picker.NativeDatePicker.Date = current; picker.DoneTitle = positive.Caption; picker.CancelTitle = negative.Caption; picker.Click += (sender, e) => { if (tcs.Task.Status < TaskStatus.RanToCompletion) { NSDate dateTime = (sender as DatePicker).NativeDatePicker.Date; DateTime result = dateTime != null ? System.DateTime.SpecifyKind(dateTime, DateTimeKind.Utc).ToLocalTime() : System.DateTime.MinValue; if (e.ButtonIndex == 0) { tcs.SetResult(new DialogAnswer <DateTime>(true, result)); } else if (e.ButtonIndex == 1) { tcs.SetResult(new DialogAnswer <DateTime>(false, result)); } } }; picker.Show(_context.MainController.View, (ScreenController)_context.MainController.VisibleViewController); } else { var alertView = new UIAlertView(caption, "", null, positive.Caption, negative.Caption); alertView.Show(); _alertViews.Add(alertView); var datePicker = new UIDatePicker(); datePicker.Frame = new RectangleF(10, alertView.Bounds.Size.Height, 270, 150); datePicker.Mode = UIDatePickerMode.Date; datePicker.Date = current; alertView.AddSubview(datePicker); var timePicker = new UIDatePicker(); timePicker.Frame = new RectangleF(10, alertView.Bounds.Size.Height + 150 + 20, 270, 150); timePicker.Mode = UIDatePickerMode.Time; timePicker.Date = current; alertView.AddSubview(timePicker); alertView.Clicked += (sender, e) => { DateTime date = System.DateTime.SpecifyKind(datePicker.Date, DateTimeKind.Unspecified); DateTime time = System.DateTime.SpecifyKind(timePicker.Date, DateTimeKind.Utc).ToLocalTime(); var result = new DateTime(date.Year, date.Month, date.Day, time.Hour, time.Minute, time.Second); if (e.ButtonIndex == 0) { tcs.SetResult(new DialogAnswer <DateTime>(true, result)); } else if (e.ButtonIndex == 1) { tcs.SetResult(new DialogAnswer <DateTime>(false, result)); } var av = (UIAlertView)sender; _alertViews.Remove(av); av.Dispose(); }; alertView.Bounds = new RectangleF(0, 0, 290, alertView.Bounds.Size.Height + 150 + 150 + 20 + 30); } return(tcs.Task); }
public virtual void Initialize(IDialogButton argument) { }