public void TryPresentImageCropper( )
        {
            // if the image cropper is pending, launch it now.
            if (ImageCropperPendingImage != null)
            {
                ImageCropViewController.Begin(ImageCropperPendingImage, 1.0f, HandleImageCropRequest);
                PresentModalViewController(ImageCropViewController, true);

                ImageCropperPendingImage = null;
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            ImageCropViewController = new ImageCropViewController( );
            LoginViewController     = new LoginViewController(this);
            ContainerViewController = new ContainerViewController(this);
            FirstRunViewController  = new FirstRunViewController(this);

            // load any current cached config
            Config.Instance.LoadFromDevice( );

            // color it with whatever we currently have.
            if (Config.Instance.VisualSettings.TopHeaderBGColor != null && Config.Instance.VisualSettings.BackgroundColor != null)
            {
                ColorNavBar(Config.Instance.VisualSettings.TopHeaderBGColor);
                View.BackgroundColor = Theme.GetColor(Config.Instance.VisualSettings.BackgroundColor);
            }
            else
            {
                // if either of our colors are null, this is probably our first run, so just use black.

                ColorNavBar("#000000FF");
                View.BackgroundColor = Theme.GetColor("#000000FF");
            }

            // create a simple centered label (slightly above center, actually) that lets the user know we're trying to connect
            ConnectingLabel = new UILabel();
            ConnectingLabel.Layer.AnchorPoint = CGPoint.Empty;
            ConnectingLabel.Font      = ConnectingLabel.Font.WithSize(32);
            ConnectingLabel.Text      = "Connecting to Rock";
            ConnectingLabel.TextColor = Theme.GetColor("#6A6A6AFF");
            ConnectingLabel.SizeToFit( );
            ConnectingLabel.Layer.Position = new CGPoint((View.Bounds.Width - ConnectingLabel.Bounds.Width) / 2,
                                                         ((View.Bounds.Height - ConnectingLabel.Bounds.Height) / 2) - ConnectingLabel.Bounds.Height);
            View.AddSubview(ConnectingLabel);

            // show a spinner so the user feels like there's activity happening
            ProgressIndicator = new UIActivityIndicatorView();
            ProgressIndicator.Layer.AnchorPoint          = CGPoint.Empty;
            ProgressIndicator.ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.WhiteLarge;
            ProgressIndicator.Color = UIColor.Gray;
            ProgressIndicator.StartAnimating( );
            ProgressIndicator.Layer.Position = new CGPoint((View.Bounds.Width - ProgressIndicator.Bounds.Width) / 2, ConnectingLabel.Frame.Bottom + 30);
            View.AddSubview(ProgressIndicator);

            LockTimer = DateTime.Now;
        }
        object HandleImageCropRequest(ImageCropViewController.Request request, object context)
        {
            switch (request)
            {
            case ImageCropViewController.Request.SupportedInterfaceOrientations:
            {
                return((object)(UIInterfaceOrientationMask.LandscapeLeft | UIInterfaceOrientationMask.LandscapeRight));
            }

            case ImageCropViewController.Request.ShouldAutorotate:
            {
                return((object)false);
            }

            case ImageCropViewController.Request.PreferStatusBarHidden:
            {
                return((object)PrefersStatusBarHidden( ));
            }

            case ImageCropViewController.Request.IsDeviceLandscape:
            {
                return((object)true);
            }

            case ImageCropViewController.Request.CropperDone:
            {
                // if croppedImage is null, they simply cancelled
                UIImage croppedImage = (UIImage)context;

                if (croppedImage != null)
                {
                    NSData croppedImageData = croppedImage.AsJPEG( );

                    // notify the initial caller we're done.
                    OnCaptureCompleteDelegate(croppedImageData);
                    OnCaptureCompleteDelegate = null;
                }

                ImageCropViewController.DismissModalViewController(true);
                break;
            }
            }

            return(null);
        }