public static async Task SetTime(this UITextField lbl, UIViewController controller,
                                         UIDatePickerMode mode = UIDatePickerMode.Date, string format = "dd.MM.yyyy",
                                         Action <UITextField, string> actionNew = default(Action <UITextField, string>), bool setIntern = false)
        {
            var modalPicker = new ModalPickerViewController(ModalPickerType.Date, "", controller)
            {
                HeaderBackgroundColor  = UIColor.Gray,
                HeaderTextColor        = UIColor.White,
                TransitioningDelegate  = new ModalPickerTransitionDelegate(),
                ModalPresentationStyle = UIModalPresentationStyle.Custom,
                DatePicker             = { Mode = mode }
            };


            if (setIntern)
            {
                modalPicker.DatePicker.Date = NSDate.Now.AddSeconds(3600);
            }

            modalPicker.OnModalPickerDismissed += (s, ea) =>
            {
                var dateFormatter = new NSDateFormatter
                {
                    DateFormat = format
                };

                if (!setIntern)
                {
                    lbl.Text = dateFormatter.ToString(modalPicker.DatePicker.Date);
                }
                actionNew?.Invoke(lbl, dateFormatter.ToString(modalPicker.DatePicker.Date));
            };

            await controller.PresentViewControllerAsync(modalPicker, true);
        }
#pragma warning disable RECS0165 // Asynchronous methods should return a Task instead of void
        public static async void SetTime(this UITextField txt, UIViewController controller,
                                         UIDatePickerMode mode = UIDatePickerMode.Date, string format = "dd.MM.yyyy")
#pragma warning restore RECS0165 // Asynchronous methods should return a Task instead of void
        {
            var modalPicker = new ModalPickerViewController(ModalPickerType.Date, "", controller)
            {
                HeaderBackgroundColor  = UIColor.Gray,
                HeaderTextColor        = UIColor.White,
                TransitioningDelegate  = new ModalPickerTransitionDelegate(),
                ModalPresentationStyle = UIModalPresentationStyle.Custom,
                DatePicker             = { Mode = mode }
            };


            modalPicker.OnModalPickerDismissed += (s, ea) =>
            {
                var dateFormatter = new NSDateFormatter
                {
                    DateFormat = format
                };

                txt.Text = dateFormatter.ToString(modalPicker.DatePicker.Date);
            };

            await controller.PresentViewControllerAsync(modalPicker, true);
        }
예제 #3
0
        /// <summary>
        /// Shows the dialog on a specific view
        /// </summary>
        /// <returns>The dialog async.</returns>
        /// <param name="view">The view</param>
        /// <param name="mode">Mode.</param>
        /// <param name="title">Title.</param>
        /// <param name="message">Message.</param>
        /// <param name="selectedDate">Selected date.</param>
        /// <param name="effectStyle">Effect style.</param>
        public static Task <DateTime?> ShowDialogAsync(UIView view, UIDatePickerMode mode, String title, String message, DateTime?selectedDate = null, UIBlurEffectStyle effectStyle = UIBlurEffectStyle.ExtraLight)
        {
            var tcs = new TaskCompletionSource <DateTime?> ();


            new NSObject().BeginInvokeOnMainThread(() => {
                var dialog = new XamDatePickerDialog(mode)
                {
                    Title           = title,
                    Message         = message,
                    BlurEffectStyle = effectStyle,
                    ConstantUpdates = false,
                };

                if (selectedDate.HasValue)
                {
                    dialog.SelectedDate = selectedDate.Value;
                }

                dialog.OnCancel += (object sender, EventArgs e) =>
                {
                    tcs.SetResult(null);
                };

                dialog.OnSelectedDateChanged += (object s, DateTime e) =>
                {
                    tcs.SetResult(dialog.SelectedDate);
                };

                dialog.Show(view);
            });

            return(tcs.Task);
        }
예제 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PickerCells.DatePickerCell"/> class.
        /// </summary>
        public DatePickerCell(UIDatePickerMode mode, DateTime?defaultDate = null)
            : base()
        {
            mMode = mode;

            SelectedDate = defaultDate;

            SecondarySetup();
        }
예제 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PickerCells.DatePickerCell"/> class.
        /// </summary>
        public DatePickerCell(UIDatePickerMode mode, DateTime? defaultDate = null)
            : base()
        {
            mMode = mode;

            SelectedDate = defaultDate;

            SecondarySetup();
        }
예제 #6
0
 public XamDatePickerDialog(UIDatePickerMode mode)
     : base(XamDialogType.DatePicker)
 {
     mDatePicker               = new UIDatePicker(CGRect.Empty);
     mDatePicker.Mode          = mode;
     mDatePicker.TimeZone      = NSTimeZone.LocalTimeZone;
     mDatePicker.Calendar      = NSCalendar.CurrentCalendar;
     mDatePicker.ValueChanged += OnValueChanged;
 }
예제 #7
0
        public static void ShowDatePicker(this UIView view, DateTime date, UIDatePickerMode mode, EventHandler valueChangedHandler)
        {
            var actionSheetDatePicker = new ActionSheetDatePicker(view);

            actionSheetDatePicker.DatePicker.Date           = date.ToNSDate();
            actionSheetDatePicker.DatePicker.Mode           = mode;
            actionSheetDatePicker.DatePicker.MinuteInterval = 15;
            actionSheetDatePicker.DatePicker.ValueChanged  += valueChangedHandler;
            actionSheetDatePicker.Show();
        }
예제 #8
0
		/// <summary>
		/// Initializes a new instance of the <see cref="XamDialogs.DHDatePickerDialog"/> class.
		/// </summary>
		/// <param name="mode">Mode.</param>
		public XamDatePickerDialog (UIDatePickerMode mode) 
			: base(XamDialogType.DatePicker)
		{
			mDatePicker = new UIDatePicker (CGRect.Empty);
			mDatePicker.Mode = mode;
			mDatePicker.TimeZone = NSTimeZone.LocalTimeZone;
			mDatePicker.Calendar = NSCalendar.CurrentCalendar;

			mDatePicker.ValueChanged += OnValueChanged;
		}
        private void ShowDatePicker(DateTime date, UIDatePickerMode mode, EventHandler valueChangedHandler)
        {
            var    actionSheetDatePicker = new ActionSheetDatePicker(this.View);
            NSDate nsDate = (NSDate)DateTime.SpecifyKind(date.AddHours(5), DateTimeKind.Utc);              // Adjust for central.

            actionSheetDatePicker.DatePicker.Date          = nsDate;
            actionSheetDatePicker.DatePicker.Mode          = mode;
            actionSheetDatePicker.DatePicker.ValueChanged += valueChangedHandler;
            actionSheetDatePicker.Show();
        }
예제 #10
0
        protected void SetDatePicker(UITextField field, UIDatePickerMode mode = UIDatePickerMode.Time, String format = "{0: d MMMM yyyy}", bool futureDatesOnly = true, DateTime?minimumDateTime = null, bool changeOnEdit = false)
        {
            UIDatePicker picker = new UIDatePicker();

            picker.Mode = UIDatePickerMode.Date;

            picker.MaximumDate = ToNSDate(DateTime.Now.AddYears(1));
            if (minimumDateTime != null)
            {
                NSDate nsMinDateTime = ToNSDate((DateTime)minimumDateTime);
                picker.MinimumDate = nsMinDateTime;
            }
            if (futureDatesOnly)
            {
                NSDate nsMinDateTime = ToNSDate(DateTime.Now);
                //picker.SetDate
                picker.MinimumDate = nsMinDateTime;
            }

            picker.ValueChanged += (object s, EventArgs e) =>
            {
                if (futureDatesOnly)
                {
                    NSDate nsMinDateTime = ToNSDate(DateTime.Now);
                    picker.MinimumDate = nsMinDateTime;
                }
                if (changeOnEdit)
                {
                    updateSetupDateTimePicker(field, picker.Date, format, s, e);
                }
            };

            // Setup the toolbar
            UIToolbar toolbar = new UIToolbar();

            toolbar.BarStyle    = UIBarStyle.Black;
            toolbar.Translucent = true;
            toolbar.SizeToFit();

            // Create a 'done' button for the toolbar and add it to the toolbar
            UIBarButtonItem doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) =>
            {
                updateSetupDateTimePicker(field, picker.Date, format, s, e, true);
            });

            toolbar.SetItems(new UIBarButtonItem[] { doneButton }, true);

            field.InputView          = picker;
            field.InputAccessoryView = toolbar;

            field.ShouldChangeCharacters = new UITextFieldChange(delegate(UITextField textField, NSRange range, string replacementString)
            {
                return(false);
            });
        }
예제 #11
0
        public void Show(string title, string doneButtonTitle, string cancelButtonTitle, UIDatePickerMode datePickerMode, Action <DateTime> callback, DateTime defaultDate, DateTime?maximumDate = null, DateTime?minimumDate = null, Action cancelCallback = null)
        {
            if (_isDialogShown)
            {
                return;            // if already dialog is shown, do not open another dialog
            }
            _isDialogShown = true; // update the flag

            _title             = title;
            _doneButtonTitle   = doneButtonTitle;
            _cancelButtonTitle = cancelButtonTitle;
            _datePickerMode    = datePickerMode;
            _callback          = callback;
            _defaultDate       = defaultDate;
            _maximumDate       = maximumDate;
            _minimumDate       = minimumDate;
            _cancelCallback    = cancelCallback;

            _dialogView = createContainerView();

            _dialogView.Layer.ShouldRasterize    = true;
            _dialogView.Layer.RasterizationScale = UIScreen.MainScreen.Scale;

            Layer.ShouldRasterize    = true;
            Layer.RasterizationScale = UIScreen.MainScreen.Scale;

            _dialogView.Layer.Opacity   = 0.5f;
            _dialogView.Layer.Transform = CATransform3D.MakeScale(1.3f, 1.3f, 1);

            BackgroundColor = UIColor.FromRGBA(0, 0, 0, 0);

            AddSubview(_dialogView);

            var widthHeight = Frame.Width > Frame.Height ? Frame.Width : Frame.Height; // check if width is greator than width, return whever is greator

            Frame = new CGRect(0, 0, widthHeight, widthHeight);                        // create overlay with max value from height and width so that on rotaion whole screen is covered

            UIApplication.SharedApplication.Windows[0].AddSubview(this);

            UIView.Animate(0.2, 0d, UIViewAnimationOptions.CurveEaseInOut, () =>
            {
                BackgroundColor             = UIColor.Black.ColorWithAlpha(0.4f);
                _dialogView.Layer.Opacity   = 1;
                _dialogView.Layer.Transform = CATransform3D.MakeScale(1, 1, 1);
            }, () =>
            {
            });
        }
        /// <summary>
        /// Display the DatePicker with Title, Done, Cancel Button titles, Default Date, Minimum Date, Maximum Date and Date Picker Mode.
        /// </summary>
        /// <param name="title">Title of the Modal Window.</param>
        /// <param name="doneButtonTitle">Title of the Done Button.</param>
        /// <param name="cancelButtonTitle">Title of Cancel Button.</param>
        /// <param name="defaultDateValue">Default date of the DatePicker.</param>
        /// <param name="minDate">Minimum Date of the DatePicker.</param>
        /// <param name="maxDate">Maxium Date of the DatePicker.</param>
        /// <param name="datePickerMode">Mode of DatePicker.</param>
        /// <param name="callback">Callback, will return a NSDate Object.</param>
        public void Show(string title, string doneButtonTitle, string cancelButtonTitle, NSDate defaultDateValue, NSDate minDate, NSDate maxDate, UIDatePickerMode datePickerMode, Action <NSDate> callback)
        {
            this.datePickerMode     = datePickerMode;
            this.defaultDate        = defaultDateValue;
            this.picker.MaximumDate = maxDate;
            this.picker.MinimumDate = minDate;
            this.picker.Mode        = datePickerMode;
            this.picker.Date        = this.defaultDate ?? NSDate.Now;

            if (this.locale != null)
            {
                this.picker.Locale = this.locale;
            }

            base.Show(title, doneButtonTitle, cancelButtonTitle, callback);
        }
예제 #13
0
        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);
        }
예제 #14
0
 public void Show(String title, Action <DateTime> callback, UIDatePickerMode datePickerMode = UIDatePickerMode.DateAndTime, Action cancelCallback = null)
 {
     Show(title, doneButtonTitle: "Done", cancelButtonTitle: "Cancel", datePickerMode: datePickerMode, callback: callback, defaultDate: DateTime.Now, cancelCallback: cancelCallback);
 }
 public UIPopoverController Initialize(CGRect anchorRect,UIView view, UIDatePickerMode type, DateTime date)
 {
     // This will run the popover UI
     _type = type;
     _date = date;
     _mainUI = new UIPopoverController(this);
     _mainUI.PopoverContentSize = new CGSize(320, 320);
     _mainUI.PresentFromRect(anchorRect, view, UIPopoverArrowDirection.Any, true);
     return _mainUI;
 }
예제 #16
0
        public void Show(string title, string doneButtonTitle, string cancelButtonTitle, UIDatePickerMode datePickerMode, Action <DateTime> callback, DateTime defaultDate, DateTime?maximumDate = null, DateTime?minimumDate = null)
        {
            _title             = title;
            _doneButtonTitle   = doneButtonTitle;
            _cancelButtonTitle = cancelButtonTitle;
            _datePickerMode    = datePickerMode;
            _callback          = callback;
            _defaultDate       = defaultDate;
            _maximumDate       = maximumDate;
            _minimumDate       = minimumDate;

            _dialogView = createContainerView();

            _dialogView.Layer.ShouldRasterize    = true;
            _dialogView.Layer.RasterizationScale = UIScreen.MainScreen.Scale;

            Layer.ShouldRasterize    = true;
            Layer.RasterizationScale = UIScreen.MainScreen.Scale;

            _dialogView.Layer.Opacity   = 0.5f;
            _dialogView.Layer.Transform = CATransform3D.MakeScale(1.3f, 1.3f, 1);

            BackgroundColor = UIColor.FromRGBA(0, 0, 0, 0);

            AddSubview(_dialogView);

            /* Attached to the top most window (make sure we are using the right orientation) */
            var interfaceOrientation = UIApplication.SharedApplication.StatusBarOrientation;

            switch (interfaceOrientation)
            {
            case UIInterfaceOrientation.LandscapeLeft:
                var rotationLeft = Math.PI * 270 / 180;
                Transform = CGAffineTransform.MakeRotation((nfloat)rotationLeft);
                break;

            case UIInterfaceOrientation.LandscapeRight:
                var rotationRight = Math.PI * 90 / 180;
                Transform = CGAffineTransform.MakeRotation((nfloat)rotationRight);
                break;

            case UIInterfaceOrientation.PortraitUpsideDown:
                var rotationUpsideDown = Math.PI * 180 / 180;
                Transform = CGAffineTransform.MakeRotation((nfloat)rotationUpsideDown);
                break;

            default:
                break;
            }

            Frame = new CGRect(0, 0, Frame.Width, Frame.Size.Height);
            UIApplication.SharedApplication.Windows[0].AddSubview(this);

            UIView.Animate(0.2, 0d, UIViewAnimationOptions.CurveEaseInOut, () =>
            {
                BackgroundColor             = UIColor.Black.ColorWithAlpha(0.4f);
                _dialogView.Layer.Opacity   = 1;
                _dialogView.Layer.Transform = CATransform3D.MakeScale(1, 1, 1);
            }, () =>
            {
            });
        }
        public DatePickerElement(String caption, Section section, DateTime defaultDate, UIDatePickerMode datePickerMode)
            : base(caption)
        {
            //init
            this.Section = section;
            this.inEditMode = false;

            // init date picker
            this.DateElement = new CustomDateElement ();
            this.DateElement.DatePicker.Mode = datePickerMode;

            // Set date
            this.selectedDate = defaultDate;

            // init value
            this.updateLabel ();

            //Setup datepicker change event
            this.DateElement.DatePicker.ValueChanged += (object sender, EventArgs e) => {

                // set selected date
                this.selectedDate = ((DateTime)this.DateElement.DatePicker.Date).ToLocalTime ();

                // refresh label
                this.updateLabel ();
            };

            // setup label click
            this.Tapped += () => {
                if ((this.Section.Count == (int)this.IndexPath.Item + 1) || (this.Section [(int)this.IndexPath.Item + 1].GetType () != typeof(CustomDateElement))){

                    // Insert date picker element
                    this.Section.Insert ((int)this.IndexPath.Item + 1, UITableViewRowAnimation.Automatic, new Element[]{ this.DateElement });

                    //set edit mode
                    this.inEditMode = true;

                } else {

                    //remove
                    this.Section.Remove ((int)this.IndexPath.Item + 1);

                    // set edit mode
                    this.inEditMode = false;
                }

                //force cell refresh
                this.RootElement = this.GetImmediateRootElement ();
                this.RootElement.Reload (this, UITableViewRowAnimation.None);
            };
        }
예제 #18
0
 public Builder SetMode(UIDatePickerMode mode) 
 {
     DatePickerDialog.Mode = mode;
     return this;
 }
예제 #19
0
        /// <summary>
        /// Creates a date/time picker.
        /// </summary>
        public PickerElement(string caption, DateTime value, UIDatePickerMode mode)
            : base(caption, FormatDate(value))
        {
            pickerType = PickerType.Date;
            dateTime = value;
            dateMode = mode;

            if (datePickerView == null)
            {
                datePickerView = new UIDatePicker(new RectangleF(0, 152, 320, 100));
            }

            datePickerView.ValueChanged += delegate(object sender, EventArgs e) {
                if (activeCell == cell)
                {
                    dateTime = datePickerView.Date;
                    Value = FormatDate(dateTime);
                    cell.DetailTextLabel.Text = Value;
                    cell.SetNeedsLayout();
                    cell.SetNeedsDisplay();
                }
            };

            if (toolBar == null)
            {
                toolBar = new UIToolbar(new RectangleF(0, 108, 320, 44));
                toolBar.BarStyle = UIBarStyle.Black;
            }
        }
예제 #20
0
		/// <summary>
		/// Shows the dialog.
		/// </summary>
		/// <returns>The dialog.</returns>
		/// <param name="title">Title.</param>
		/// <param name="message">Message.</param>
		/// <param name="selectedDate">Selected date.</param>
		/// <param name="effectStyle">Effect style.</param>
		public static Task<DateTime?> ShowDialogAsync(UIDatePickerMode mode, String title, String message, DateTime? selectedDate = null, UIBlurEffectStyle effectStyle = UIBlurEffectStyle.ExtraLight)
		{
			var tcs = new TaskCompletionSource<DateTime?> ();


			new NSObject ().BeginInvokeOnMainThread (() => {

				var dialog = new XamDatePickerDialog(mode)
				{
					Title = title,
					Message = message,
					BlurEffectStyle = effectStyle,
					ConstantUpdates = false,
				};

				if (selectedDate.HasValue)
					dialog.SelectedDate = selectedDate.Value;

				dialog.OnCancel += (object sender, EventArgs e) => 
				{
					tcs.SetResult(null);
				};

				dialog.OnSelectedDateChanged += (object s, DateTime e) => 
				{
					tcs.SetResult(dialog.SelectedDate);
				};

				dialog.Show();

			});

			return tcs.Task;
		}
예제 #21
0
        public void ShowDateTimeDialog(string caption, UIDatePickerMode mode, DateTime current, DialogButton <DateTime> positive, DialogButton <DateTime> negative)
        {
            Version version = new Version(UIDevice.CurrentDevice.SystemVersion);

            if (version.Major >= 7)
            {
                DatePicker picker = new DatePicker();
                picker.Title = caption;
                picker.NativeDatePicker.Mode = mode;
                picker.NativeDatePicker.Date = current;
                picker.DoneTitle             = positive.Caption;
                picker.CancelTitle           = negative.Caption;
                picker.Click += (object sender, UIButtonEventArgs e) => {
                    var      dateTime = (sender as DatePicker).NativeDatePicker.Date;
                    DateTime result   = dateTime != null?System.DateTime.SpecifyKind(dateTime, DateTimeKind.Utc).ToLocalTime() : System.DateTime.MinValue;

                    if (e.ButtonIndex == 0)
                    {
                        positive.Execute(result);
                    }
                    else if (e.ButtonIndex == 1)
                    {
                        negative.Execute(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);

                UIDatePicker datePicker = new UIDatePicker();
                datePicker.Frame = new System.Drawing.RectangleF(10, alertView.Bounds.Size.Height, 270, 150);
                datePicker.Mode  = UIDatePickerMode.Date;
                datePicker.Date  = current;
                alertView.AddSubview(datePicker);

                UIDatePicker timePicker = new UIDatePicker();
                timePicker.Frame = new System.Drawing.RectangleF(10, alertView.Bounds.Size.Height + 150 + 20, 270, 150);
                timePicker.Mode  = UIDatePickerMode.Time;
                timePicker.Date  = current;
                alertView.AddSubview(timePicker);

                alertView.Clicked += (object sender, UIButtonEventArgs e) => {
                    DateTime date   = System.DateTime.SpecifyKind(datePicker.Date, DateTimeKind.Unspecified);
                    DateTime time   = System.DateTime.SpecifyKind(timePicker.Date, DateTimeKind.Utc).ToLocalTime();
                    DateTime result = new DateTime(date.Year, date.Month, date.Day, time.Hour, time.Minute, time.Second);
                    if (e.ButtonIndex == 0)
                    {
                        positive.Execute(result);
                    }
                    else if (e.ButtonIndex == 1)
                    {
                        negative.Execute(result);
                    }

                    var av = (UIAlertView)sender;
                    _alertViews.Remove(av);
                    av.Dispose();
                };

                alertView.Bounds = new System.Drawing.RectangleF(0, 0, 290, alertView.Bounds.Size.Height + 150 + 150 + 20 + 30);
            }
        }