Exemple #1
0
        /// <summary>
        /// Dismisses the specified picker.
        /// </summary>
        /// <param name="picker">The picker.</param>
        /// <param name="onDismiss">The on dismiss.</param>
        private void Dismiss(UIImagePickerController picker, Action onDismiss)
        {
            if (_viewController == null)
            {
                onDismiss();
            }
            else
            {
                NSNotificationCenter.DefaultCenter.RemoveObserver(_observer);
                UIDevice.CurrentDevice.EndGeneratingDeviceOrientationNotifications();

                _observer.Dispose();

                if (Popover != null)
                {
                    Popover.Dismiss(true);
                    Popover.Dispose();
                    Popover = null;

                    onDismiss();
                }
                else
                {
                    picker.DismissViewController(true, onDismiss);
                    picker.Dispose();
                }
            }
        }
Exemple #2
0
            public DatePickerController(DateTime date)
            {
                Title = "Pick a Date";

                if (date < Pilot.WrightBrosFirstFlight)
                {
                    date = Pilot.WrightBrosFirstFlight;
                }

                View = picker = new UIDatePicker(new RectangleF(PointF.Empty, DatePickerSize))
                {
                    AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight,
                    MinimumDate      = (NSDate)Pilot.WrightBrosFirstFlight,
                    MaximumDate      = NSDate.Now,
                    Mode             = UIDatePickerMode.Date,
                    Date             = date,
                };

                cancel = new UIBarButtonItem(UIBarButtonSystemItem.Cancel);
                NavigationItem.LeftBarButtonItem = cancel;
                cancel.Clicked += (sender, e) => Popover.Dismiss(true);

                //editTime = new UIBarButtonItem ("Time", UIBarButtonItemStyle.Plain, OnEditClicked);
                //NavigationItem.RightBarButtonItem = editTime;

                done = new UIBarButtonItem(UIBarButtonSystemItem.Done);
                NavigationItem.RightBarButtonItem = done;
                done.Clicked += OnDoneClicked;
            }
        private void Dismiss(UIImagePickerController picker, NSAction onDismiss)
        {
            if (this.viewController == null)
            {
                onDismiss();
                tcs = new TaskCompletionSource <MediaFile>();
            }
            else
            {
                NSNotificationCenter.DefaultCenter.RemoveObserver(this.observer);
                UIDevice.CurrentDevice.EndGeneratingDeviceOrientationNotifications();

                this.observer.Dispose();

                if (Popover != null)
                {
                    Popover.Dismiss(animated: true);
                    Popover.Dispose();
                    Popover = null;

                    onDismiss();
                }
                else
                {
                    picker.DismissViewController(true, onDismiss);
                    picker.Dispose();
                }
            }
        }
Exemple #4
0
            public void OnDoneClicked(object sender, EventArgs args)
            {
                //DateValue = timePicker.DateValue;
                Popover.Dismiss(true);

                if (DatePicked != null)
                {
                    DatePicked(this, EventArgs.Empty);
                }
            }
        public void DisplayPopover(bool hideFirst = false)
        {
            if (Popover == null)
            {
                return;
            }

            var swidth  = UIScreen.MainScreen.Bounds.Width;
            var sheight = UIScreen.MainScreen.Bounds.Height;

            nfloat width  = 400;
            nfloat height = 300;


            if (orientation == null)
            {
                if (IsValidInterfaceOrientation(UIDevice.CurrentDevice.Orientation))
                {
                    orientation = UIDevice.CurrentDevice.Orientation;
                }
                else
                {
                    orientation = GetDeviceOrientation(this.viewController.InterfaceOrientation);
                }
            }

            nfloat x, y;

            if (orientation == UIDeviceOrientation.LandscapeLeft || orientation == UIDeviceOrientation.LandscapeRight)
            {
                y = (swidth / 2) - (height / 2);
                x = (sheight / 2) - (width / 2);
            }
            else
            {
                x = (swidth / 2) - (width / 2);
                y = (sheight / 2) - (height / 2);
            }

            if (hideFirst && Popover.PopoverVisible)
            {
                Popover.Dismiss(animated: false);
            }

            Popover.PresentFromRect(new CGRect(x, y, width, height), View, 0, animated: true);
        }
Exemple #6
0
        /// <summary>
        /// Displays the popover.
        /// </summary>
        /// <param name="hideFirst">if set to <c>true</c> [hide first].</param>
        public void DisplayPopover(bool hideFirst = false)
        {
            if (Popover == null)
            {
                return;
            }

            var swidth  = UIScreen.MainScreen.Bounds.Width;
            var sheight = UIScreen.MainScreen.Bounds.Height;

            float width  = 400;
            float height = 300;

            if (_orientation == null)
            {
                if (IsValidInterfaceOrientation(UIDevice.CurrentDevice.Orientation))
                {
                    _orientation = UIDevice.CurrentDevice.Orientation;
                }
                else
                {
                    _orientation = GetDeviceOrientation(_viewController.InterfaceOrientation);
                }
            }

            float x, y;

            if (_orientation == UIDeviceOrientation.LandscapeLeft || _orientation == UIDeviceOrientation.LandscapeRight)
            {
                y = (float)(swidth / 2) - (height / 2);
                x = (float)(sheight / 2) - (width / 2);
            }
            else
            {
                x = (float)(swidth / 2) - (width / 2);
                y = (float)(sheight / 2) - (height / 2);
            }

            if (hideFirst && Popover.PopoverVisible)
            {
                Popover.Dismiss(false);
            }
            var rec = new RectangleF(x, y, width, height);

            Popover.PresentFromRect(rec, View, 0, true);
        }
Exemple #7
0
 public CustomerInformationViewController()
 {
     this.PreferredContentSize = new System.Drawing.SizeF(700, 400);
     this.NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Save, async(s, e) => {
         view.DismisKeyboard();
         BigTed.BTProgressHUD.Show();
         bool success = false;
         if (string.IsNullOrEmpty(Customer.CustomerId))
         {
             success = await InsertCustomer();
         }
         else
         {
             success = await UpdateCustomer();
         }
         BigTed.BTProgressHUD.Dismiss();
         if (!success)
         {
             new SimpleAlertView("Error", "There was an error saving the customer. Please try again.").Show();
             return;
         }
         if (Created != null)
         {
             Created(Customer);
         }
         if (!IsCreate)
         {
             Popover.Dismiss(true);
         }
     });
     this.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Cancel, (s, e) => {
         view.DismisKeyboard();
         if (IsCreate)
         {
             NavigationController.PopViewControllerAnimated(true);
         }
         else
         {
             Popover.Dismiss(true);
         }
     });
 }
        private void Dismiss(UIImagePickerController picker, NSAction onDismiss)
        {
            if (viewController == null)
            {
                onDismiss();
                tcs = new TaskCompletionSource <MediaFile>();
            }
            else
            {
                if (Popover != null)
                {
                    Popover.Dismiss(animated: true);
                    Popover.Dispose();
                    Popover = null;

                    onDismiss();
                }
                else
                {
                    picker.DismissViewController(true, onDismiss);
                    picker.Dispose();
                }
            }
        }