Пример #1
0
        private static string ShowKeyboardInput(
            string title, string description, string defaultText, Object state, bool usePasswordMode)
        {
            string result = null;

            IsVisible = true;
            EventWaitHandle waitHandle = new EventWaitHandle(false, EventResetMode.AutoReset);

            keyboardViewController = new KeyboardInputViewController(
                title, description, defaultText, usePasswordMode, _gameViewController);

            UIApplication.SharedApplication.InvokeOnMainThread(delegate
            {
                _gameViewController.PresentViewController(keyboardViewController, true, null);

                keyboardViewController.View.InputAccepted += (sender, e) =>
                {
                    _gameViewController.DismissViewController(true, null);
                    result = keyboardViewController.View.Text;
                    waitHandle.Set();
                };

                keyboardViewController.View.InputCanceled += (sender, e) =>
                {
                    _gameViewController.DismissViewController(true, null);
                    waitHandle.Set();
                };
            });
            waitHandle.WaitOne();

            IsVisible = false;
            return(result);
        }
Пример #2
0
 public override void DidScanBarcode(SIOverlayController overlayController, NSDictionary barcode)
 {
     this._loadPop = new LoadingOverlay(UIScreen.MainScreen.Bounds);
     this.presentingViewController.View.Add(this._loadPop);
     picker.StopScanning();
     presentingViewController.DismissViewController(true, null);
     Task.Factory.StartNew(
         () => {
         System.Threading.Thread.Sleep(1 * 1000);
     }
         ).ContinueWith(
         t => {
         if (barcode["symbology"].ToString().Equals("QR"))
         {
             newsListView = new NewsListView();
             newsListView.setStoreId(barcode["barcode"].ToString());
             presentingViewController.NavigationController.PushViewController(newsListView, true);
             this._loadPop.Hide();
         }
         else
         {
             pdView = new ProductStoresListView();
             pdView.setProduct(barcode["barcode"].ToString(), 0);
             presentingViewController.NavigationController.PushViewController(pdView, true);
             this._loadPop.Hide();
         }
     }, TaskScheduler.FromCurrentSynchronizationContext()
         );
 }
        public override void DidCropToImage(TOCropViewController cropViewController, UIImage image, CoreGraphics.CGRect cropRect, nint angle)
        {
            DidCrop = true;

            try
            {
                if (image != null)
                {
                    App.CroppedImage = image.AsPNG().ToArray();
                }
            }
            catch (Exception ex) {
                Debug.WriteLine(ex.Message);
            }
            finally
            {
                if (image != null)
                {
                    image.Dispose();
                    image = null;
                }
            }

            parent.DismissViewController(true, App.PopModal);
        }
Пример #4
0
        public override void DidCropToImage(TOCropViewController cropViewController, UIImage image, CoreGraphics.CGRect cropRect, nint angle)
        {
            DidCrop = true;

            try
            {
                if (image != null)
                {
                    CroppedImage = image.AsPNG().ToArray();
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
            finally
            {
                if (image != null)
                {
                    image.Dispose();
                    image = null;
                }
            }

            parent.DismissViewController(true, () => { Xamarin.Forms.Application.Current.MainPage.Navigation.PopModalAsync(); });
        }
Пример #5
0
        public static IAsyncResult BeginShowKeyboardInput(
            PlayerIndex player, string title, string description, string defaultText,
            AsyncCallback callback, Object state, bool usePasswordMode)
        {
            AssertInitialised();

            int requestCount = Interlocked.Increment(ref _showKeyboardInputRequestCount);

            if (requestCount != 1)
            {
                Interlocked.Decrement(ref _showKeyboardInputRequestCount);
                // FIXME: Return the in-progress IAsyncResult?
                return(null);
            }

            isVisible = true;
            var viewController = new KeyboardInputViewController(
                title, description, defaultText, usePasswordMode);

            _gameViewController.PresentViewController(viewController, true, () => {});

            viewController.View.InputAccepted += (sender, e) => {
                _gameViewController.DismissViewController(true, () => {});
                Interlocked.Decrement(ref _showKeyboardInputRequestCount);
            };

            viewController.View.InputCanceled += (sender, e) => {
                _gameViewController.DismissViewController(true, () => {});
                Interlocked.Decrement(ref _showKeyboardInputRequestCount);
            };

            return(new KeyboardInputAsyncResult(viewController, callback, state));
        }
Пример #6
0
        UIViewController CreateControllerForConversation(ConversationItem[] items, int currentItem, Entity speaker)
        {
            var item = items [currentItem];

            /*
             * if (item.DependencyScripts != null) {
             *  foreach (var script in item.DependencyScripts) {
             *      LuaEngine.ExecuteScript (script, item);
             *  }
             * }
             */
            var text  = string.Join("\n", item.Character);
            var alert = UIAlertController.Create(speaker.Model.Name, text, UIAlertControllerStyle.Alert);

            // Don't want to evaluate the ids everytime
            var ids = item.ResponseIds;

            if (ids == null || ids.Length == 0)
            {
                Console.WriteLine("No responses");
                return(alert);
            }

            foreach (var responseId in ids)
            {
                var localResponseId = responseId - 1;
                var responseItem    = items [localResponseId];

                var a = UIAlertAction.Create(responseItem.Player[0], 0, async(obj) => {
                    controller.DismissViewController(false, null);

                    if (responseItem.ActionScripts != null)
                    {
                        foreach (var script in responseItem.ActionScripts)
                        {
                            LuaEngine.ExecuteScript(script, responseItem);
                        }
                    }

                    if (responseItem.Character == null)
                    {
                        return;
                    }

                    controller.PresentViewController(CreateControllerForConversation(items, localResponseId, speaker), false, null);

                    if (responseItem.ResponseIds == null)
                    {
                        await Task.Delay(2500);

                        controller.DismissViewController(false, null);
                    }
                });
                alert.AddAction(a);
            }

            return(alert);
        }
Пример #7
0
        void OnAuthError(object sender, AuthErrorType authErrorType)
        {
            _viewModel.Cleanup();

            Debug.Print("OnAuthError");
            LogInWithIDPortenBtn.HideSpinner();
            Utils.AuthErrorUtils.GoToErrorPageForAuthErrorType(this, authErrorType);
            _authViewController.DismissViewController(true, null);
        }
Пример #8
0
        public void FacebookAuth_Completed(object sender, AuthenticatorCompletedEventArgs e)
        {
            if (!e.IsAuthenticated)
                return;

            var credential = AGCFacebookAuthProvider.CredentialWithToken(e.Account.Properties["access_token"]);
            authorizationCompleted.Invoke(credential);
            parent.DismissViewController(true, null);

        }
        void OnAuthError(object sender, AuthErrorType authErrorType)
        {
            _viewModel.Cleanup();

            Debug.Print("OnAuthError");
            LogUtils.LogMessage(LogSeverity.INFO, "Authentication failed.");
            LogInWithIDPortenBtn.HideSpinner();
            Utils.AuthErrorUtils.GoToErrorPageForAuthErrorType(this, authErrorType);
            _authViewController.DismissViewController(true, null);
        }
Пример #10
0
 public static GistCreateView Show(UIViewController parent)
 {
     var ctrl = new GistCreateView();
     var weakVm = new WeakReference<GistCreateViewModel>(ctrl.ViewModel);
     ctrl.ViewModel.SaveCommand.Subscribe(_ => parent.DismissViewController(true, null));
     ctrl.NavigationItem.LeftBarButtonItem = new UIBarButtonItem { Image = Images.Buttons.CancelButton };
     ctrl.NavigationItem.LeftBarButtonItem.GetClickedObservable().Subscribe(_ => {
         weakVm.Get()?.CancelCommand.Execute(null);
         parent.DismissViewController(true, null);
     });
     parent.PresentViewController(new ThemedNavigationController(ctrl), true, null);
     return ctrl;
 }
Пример #11
0
        private static void DoTransition(UIViewController fromViewController, IBaseViewModel fromViewModel,
                                         UIViewController toViewController, IBaseViewModel toViewModel)
        {
            var toViewDismissCommand = toViewModel.DismissCommand;

            if (toViewController is LoginViewController)
            {
                toViewDismissCommand.Subscribe(_ => fromViewController.DismissViewController(true, null));
                fromViewController.PresentViewController(new UINavigationController(toViewController), true, null);
            }
            else if (toViewController is MainViewController)
            {
                var nav = ((UINavigationController)UIApplication.SharedApplication.Delegate.Window.RootViewController);
                UIView.Transition(nav.View, 0.6f,
                                  UIViewAnimationOptions.BeginFromCurrentState | UIViewAnimationOptions.TransitionCrossDissolve,
                                  () => nav.PushViewController(toViewController, false), null);
            }
            else if (toViewController is AddInterestViewController)
            {
                toViewDismissCommand.Subscribe(_ => fromViewController.DismissViewController(true, null));
                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Cancel, (s, e) => toViewDismissCommand.ExecuteIfCan());
                fromViewController.PresentViewController(new UINavigationController(toViewController), true, null);
            }
            else if (toViewController is StumbleViewController || toViewController is RepositoryViewController ||
                     toViewController is StumbledRepositoryViewController || toViewController is SettingsViewController)
            {
                toViewDismissCommand.Subscribe(_ => fromViewController.DismissViewController(true, null));
                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, (s, e) => toViewDismissCommand.ExecuteIfCan());
                fromViewController.PresentViewController(new UINavigationController(toViewController), true, null);
            }
            else if (toViewController is LanguagesViewController && fromViewController is TrendingViewController)
            {
                toViewDismissCommand.Subscribe(_ => fromViewController.DismissViewController(true, null));
                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, (s, e) => toViewDismissCommand.ExecuteIfCan());
                var ctrlToPresent = new UINavigationController(toViewController);
                ctrlToPresent.TransitioningDelegate = new SlideDownTransition();
                fromViewController.PresentViewController(ctrlToPresent, true, null);
            }
            else if (toViewController is PurchaseProViewController)
            {
                toViewDismissCommand.Subscribe(_ => fromViewController.DismissViewController(true, null));
                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, (s, e) => toViewDismissCommand.ExecuteIfCan());
                fromViewController.PresentViewController(toViewController, true, null);
            }
            else
            {
                toViewDismissCommand.Subscribe(
                    _ => toViewController.NavigationController.PopToViewController(fromViewController, true));
                fromViewController.NavigationController.PushViewController(toViewController, true);
            }
        }
        private static void DoTransition(UIViewController fromViewController, IBaseViewModel fromViewModel,
            UIViewController toViewController, IBaseViewModel toViewModel)
        {
            var toViewDismissCommand = toViewModel.DismissCommand;

            if (toViewController is LoginViewController)
            {
                toViewDismissCommand.Subscribe(_ => fromViewController.DismissViewController(true, null));
                fromViewController.PresentViewController(new UINavigationController(toViewController), true, null);
            }
            else if (toViewController is MainViewController)
            {
                var nav = ((UINavigationController)UIApplication.SharedApplication.Delegate.GetWindow().RootViewController);
                UIView.Transition(nav.View, 0.6f,
                    UIViewAnimationOptions.BeginFromCurrentState | UIViewAnimationOptions.TransitionCrossDissolve,
                    () => nav.PushViewController(toViewController, false), null);
            }
            else if (toViewController is AddInterestViewController)
            {
                toViewDismissCommand.Subscribe(_ => fromViewController.DismissViewController(true, null));
                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Cancel, (s, e) => toViewDismissCommand.ExecuteIfCan());
                fromViewController.PresentViewController(new UINavigationController(toViewController), true, null);
            }
            else if (toViewController is StumbleViewController || toViewController is RepositoryViewController ||
                     toViewController is StumbledRepositoryViewController || toViewController is SettingsViewController)
            {
                toViewDismissCommand.Subscribe(_ => fromViewController.DismissViewController(true, null));
                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, (s, e) => toViewDismissCommand.ExecuteIfCan());
                fromViewController.PresentViewController(new UINavigationController(toViewController), true, null);
            }
            else if (toViewController is LanguagesViewController && fromViewController is TrendingViewController)
            {
                toViewDismissCommand.Subscribe(_ => fromViewController.DismissViewController(true, null));
                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, (s, e) => toViewDismissCommand.ExecuteIfCan());
                var ctrlToPresent = new UINavigationController(toViewController);
                ctrlToPresent.TransitioningDelegate = new SlideDownTransition();
                fromViewController.PresentViewController(ctrlToPresent, true, null);
            }
            else if (toViewController is PurchaseProViewController)
            {
                toViewDismissCommand.Subscribe(_ => fromViewController.DismissViewController(true, null));
                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, (s, e) => toViewDismissCommand.ExecuteIfCan());
                fromViewController.PresentViewController(toViewController, true, null);
            }
            else
            {
                toViewDismissCommand.Subscribe(
                    _ => toViewController.NavigationController.PopToViewController(fromViewController, true));
                fromViewController.NavigationController.PushViewController(toViewController, true);
            }
        }
Пример #13
0
        public static GistCreateViewController Show(UIViewController parent)
        {
            var ctrl   = new GistCreateViewController();
            var weakVm = new WeakReference <GistCreateViewModel>(ctrl.ViewModel);

            ctrl.ViewModel.SaveCommand.Subscribe(_ => parent.DismissViewController(true, null));
            ctrl.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Cancel);
            ctrl.NavigationItem.LeftBarButtonItem.GetClickedObservable().Subscribe(_ => {
                weakVm.Get()?.CancelCommand.Execute().Subscribe();
                parent.DismissViewController(true, null);
            });
            parent.PresentViewController(new ThemedNavigationController(ctrl), true, null);
            return(ctrl);
        }
        private static async void Finalize(ImageCropper imageCropper, UIImage image)
        {
            string  documentsDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            string  jpgFilename        = System.IO.Path.Combine(documentsDirectory, Guid.NewGuid().ToString() + ".jpg");
            NSData  imgData            = image.AsJPEG();
            NSError err;

            // small delay
            await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(100));

            if (imgData.Save(jpgFilename, false, out err))
            {
                imageCropper.Success?.Invoke(jpgFilename);
            }
            else
            {
                Debug.WriteLine("NOT saved as " + jpgFilename + " because" + err.LocalizedDescription);
                imageCropper.Faiure?.Invoke();
            }
            //UIApplication.SharedApplication.KeyWindow.RootViewController.DismissViewController(true, null);
            UIWindow         window         = UIApplication.SharedApplication.KeyWindow;
            UIViewController viewController = window.RootViewController;

            while (viewController.PresentedViewController != null)
            {
                viewController = viewController.PresentedViewController;
            }
            viewController.DismissViewController(true, null);
        }
Пример #15
0
        public void StartPressed40911()
        {
            var loginViewController = new UIViewController {
                View = { BackgroundColor = UIColor.White }
            };
            var button = UIButton.FromType(UIButtonType.System);

            button.SetTitle("Login", UIControlState.Normal);
            button.Frame = new CGRect(20, 100, 200, 44);
            loginViewController.View.AddSubview(button);

            button.TouchUpInside += (sender, e) =>
            {
                Maui.Controls.Application.Current.MainPage = new ContentPage {
                    Content = new Label {
                        Text = "40911 Success"
                    }
                };
                loginViewController.DismissViewController(true, null);
            };

            var window = UIApplication.SharedApplication.KeyWindow;
            var vc     = window.RootViewController;

            while (vc.PresentedViewController != null)
            {
                vc = vc.PresentedViewController;
            }

            vc.PresentViewController(loginViewController, true, null);
        }
        public override void Close(IMvxViewModel toClose)
        {
            if (_currentModalViewController != null)
            {
                var touchView = _currentModalViewController as IMvxTouchView;
                if (touchView == null)
                {
                    MvxTrace.Error(
                        "Unable to close view - modal is showing but not an IMvxTouchView");
                    return;
                }

                var viewModel = touchView.ReflectionGetViewModel();
                if (viewModel != toClose)
                {
                    MvxTrace.Error(
                        "Unable to close view - modal is showing but is not the requested viewmodel");
                    return;
                }

                _currentModalViewController.DismissViewController(true, () => { });
                _currentModalViewController = null;
                return;
            }

            base.Close(toClose);
        }
Пример #17
0
        private void handleGesture(UIPanGestureRecognizer recognizer)
        {
            var translation = recognizer.TranslationInView(recognizer.View.Superview);
            var percent     = translation.Y / recognizer.View.Superview.Bounds.Size.Height;

            switch (recognizer.State)
            {
            case Began:
                InteractionInProgress = true;
                viewController.DismissViewController(true, null);
                break;

            case Changed:
                shouldCompleteTransition = percent > 0.2;
                UpdateInteractiveTransition(percent);
                break;

            case Cancelled:
                InteractionInProgress = false;
                CancelInteractiveTransition();
                break;

            case Ended:
                InteractionInProgress = false;
                if (!shouldCompleteTransition)
                {
                    CancelInteractiveTransition();
                    return;
                }

                FinishInteractiveTransition();
                break;
            }
        }
Пример #18
0
        private void loadImage(string jpgFileName)
        {
            UIImageView imageView = new UIImageView(new CGRect(0, 0, 150, 150));

            imageView.Image = UIImage.FromFile(jpgFileName);
            imageView.UserInteractionEnabled = true;
            imageView.ContentMode            = UIViewContentMode.ScaleAspectFit;
            // Create a view controller to act as the popover
            UIViewController popover = new UIViewController();

            popover.View = imageView;
            popover.ModalPresentationStyle = UIModalPresentationStyle.Popover;

            // Grab Image
            var image = UIImage.FromFile("close.png");

            // Add a close button
            var closeButton = new ImageButton(new CGRect(340, 30, image.Size.Width, image.Size.Height));

            closeButton.UserInteractionEnabled = true;
            closeButton.Image = image;
            imageView.AddSubview(closeButton);

            // Wireup the close button
            closeButton.Touched += (button) =>
            {
                popover.DismissViewController(true, null);
            };

            // Present the popover
            owner.PresentViewController(popover, true, null);
        }
Пример #19
0
 /// <summary>
 /// Dismisses ViewController if touch out view.
 /// </summary>
 /// <param name="touch">Touch.</param>
 /// <param name="view">View.</param>
 /// <param name="viewContr">View Controller.</param>
 public static void DismissIfTouchOutView(UITouch touch, UIView view, UIViewController viewContr)
 {
     if (IsTouchOutView(touch, view))
     {
         viewContr.DismissViewController(true, null);
     }
 }
Пример #20
0
        private void loadPDF(string pdfFileName)
        {
            UIWebView pdfView = new UIWebView(UIScreen.MainScreen.Bounds);

            pdfView.LoadRequest(new NSUrlRequest(NSUrl.FromFilename(pdfFileName)));
            pdfView.ScalesPageToFit = true;

            UIViewController popover = new UIViewController();

            popover.View = pdfView;
            popover.ModalPresentationStyle = UIModalPresentationStyle.Popover;

            // Grab Image
            var image = UIImage.FromFile("close.png");

            // Add a close button
            var closeButton = new ImageButton(new CGRect(340, 30, image.Size.Width, image.Size.Height));

            closeButton.UserInteractionEnabled = true;
            closeButton.Image = image;
            pdfView.AddSubview(closeButton);

            // Wireup the close button
            closeButton.Touched += (button) =>
            {
                popover.DismissViewController(true, null);
            };

            // Present the popover
            owner.PresentViewController(popover, true, null);
        }
 internal static void Dismiss(this UIViewController viewController)
 {
     if (viewController.PresentingViewController != null)
     {
         viewController.DismissViewController(true, null);
     }
 }
Пример #22
0
 private void CloseView()
 {
     _parent.DismissViewController(true, () =>
     {
         Xamarin.Forms.Application.Current.MainPage.Navigation.PopModalAsync();
     });
 }
Пример #23
0
        public void LoginAsync(Action <bool, Dictionary <string, string> > loginCallback)
        {
            var controller = UIApplication.SharedApplication.KeyWindow.RootViewController;
            var auth       = new OAuth2Authenticator(MeetupService.ClientId, MeetupService.ClientSecret, string.Empty, new Uri(MeetupService.AuthorizeUrl), new Uri(MeetupService.RedirectUrl), new Uri(MeetupService.AccessTokenUrl));

            auth.AllowCancel = true;
            //auth.ShowUIErrors = false;
            // If authorization succeeds or is canceled, .Completed will be fired.
            auth.Completed += (s, ee) => {
                vc.DismissViewController(true, null);
                if (loginCallback != null)
                {
                    loginCallback(ee.IsAuthenticated, ee.Account == null ? null : ee.Account.Properties);
                }
            };

            auth.Error += (sender, e) =>
            {
                //vc.DismissViewController(true, null);
                //if (loginCallback != null)
                //    loginCallback (false, null);
            };

            vc = (UIViewController)auth.GetUI();
            controller.PresentViewControllerAsync(vc, true);
        }
Пример #24
0
            public void PresentViewController(SignIn signIn, UIViewController viewController)
            {
                if (Google.PresentViewController != null)
                {
                    Google.PresentViewController(SignIn, viewController);
                    return;
                }

                var window = UIApplication.SharedApplication.KeyWindow;
                var root   = window.RootViewController;

                if (root != null)
                {
                    var current = root;
                    while (current.PresentedViewController != null)
                    {
                        current = current.PresentedViewController;
                    }
                    var authenticator = (authenticatorReference.Target as GoogleAuthenticator);
                    viewController.Title = authenticator.Title;
                    if (authenticator.AllowsCancel)
                    {
                        viewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(
                            UIBarButtonSystemItem.Cancel,
                            delegate {
                            Cancel();
                            viewController.DismissViewController(true, null);
                        });
                    }
                    current.PresentViewControllerAsync(new UIKit.UINavigationController(viewController), true);
                }
            }
Пример #25
0
        static public async Task <MenuOption> ShowContextMenu(UIView anchorView, IEnumerable <MenuOption> menuOptions)
        {
            var selectSignal = new ManualResetEventSlim();

            var options = menuOptions.ToArray();
            // create menu (segmented control)
            var segmentedControl = new UISegmentedControl(options.Select(o => o.Title).ToArray());

            var cta = segmentedControl.GetTitleTextAttributes(UIControlState.Normal);

            var ta = new UITextAttributes();

            ta.Font             = cta.Font;
            ta.TextColor        = UIColor.White;
            ta.TextShadowColor  = UIColor.White;
            ta.TextShadowOffset = cta.TextShadowOffset;

            segmentedControl.TintColor = UIColor.Clear;
            segmentedControl.SetTitleTextAttributes(ta, UIControlState.Normal);

            var controller = new UIViewController();

            controller.ModalPresentationStyle = UIModalPresentationStyle.Popover;
            controller.View = segmentedControl;
            segmentedControl.Layer.BorderWidth = 0;


            int selectedIndex = -1;

            segmentedControl.ValueChanged += (object sender, EventArgs e) => {
                selectedIndex = (int)segmentedControl.SelectedSegment;
                controller.DismissViewController(true, selectSignal.Set);
            };
            var fitSize = segmentedControl.SizeThatFits(CGSize.Empty);

            controller.PreferredContentSize = fitSize;
            var topMost = Tools.iOSTool.GetTopMostController();

            controller.PopoverPresentationController.BackgroundColor          = UIColor.Black;
            controller.PopoverPresentationController.SourceView               = anchorView;
            controller.PopoverPresentationController.SourceRect               = anchorView.Bounds;
            controller.PopoverPresentationController.PermittedArrowDirections = UIPopoverArrowDirection.Any;

            controller.PopoverPresentationController.Delegate = new ActionPopoverPresentationDelegate(
                () => {
                if (!selectSignal.IsSet)
                {
                    selectSignal.Set();
                }
            },
                (arg) => UIModalPresentationStyle.None
                );
            topMost.PresentViewController(controller, true, null);
            await Task.Run(() => selectSignal.Wait());

            var result = selectedIndex != -1 ? options[selectedIndex] : null;

            return(result);
        }
Пример #26
0
 public void Dismiss()
 {
     vc?.DismissViewController(true, () =>
     {
         vc.Dispose();
         vc = null;
     });
 }
Пример #27
0
 public void NSAction_Null()
 {
     using (var vc = new UIViewController())
         using (var child = new UIViewController()) {
             vc.PresentViewController(child, false, null);
             child.DismissViewController(false, null);
         }
 }
Пример #28
0
        protected virtual IDisposable Present(UIViewController controller)
        {
            var app = UIApplication.SharedApplication;
            var top = this.viewControllerFunc();

            app.SafeInvokeOnMainThread(() => top.PresentViewController(controller, true, null));
            return(new DisposableAction(() => app.SafeInvokeOnMainThread(() => controller.DismissViewController(true, null))));
        }
        private void OnCloseInboxClick(object sender, EventArgs args)
        {
            UIViewController topViewController = FindRootViewController();

            if (topViewController is UINavigationController && (((UINavigationController)topViewController).ViewControllers[0] is PWIInboxViewController))
            {
                topViewController.DismissViewController(true, null);
            }
        }
Пример #30
0
 private void NavigateFromParentPage(UIViewController returnToViewController)
 {
     if (returnToViewController != null)
     {
         log.Debug("Dismissing Parent Page: " + returnToViewController.Class.Name);
         this.previousViewController = returnToViewController;
         returnToViewController.DismissViewController(false, null);
     }
 }
        private void DoTransition(UIViewController fromViewController, IBaseViewModel fromViewModel, UIViewController toViewController, IBaseViewModel toViewModel)
        {
            var toViewDismissCommand = toViewModel.DismissCommand;

            if (toViewController is SettingsViewController)
            {
                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(CodeFramework.iOS.Images.Cancel, UIBarButtonItemStyle.Plain, (s, e) => toViewDismissCommand.ExecuteIfCan());
                toViewDismissCommand.Subscribe(__ => toViewController.DismissViewController(true, null));
                fromViewController.PresentViewController(new UINavigationController(toViewController), true, null);
            }
            else if (toViewController is AccountsView)
            {
                var rootNav = (UINavigationController)UIApplication.SharedApplication.Delegate.Window.RootViewController;
                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(CodeFramework.iOS.Images.Cancel, UIBarButtonItemStyle.Plain, (s, e) => toViewDismissCommand.ExecuteIfCan());
                toViewDismissCommand.Subscribe(_ => rootNav.DismissViewController(true, null));
                rootNav.PresentViewController(new UINavigationController(toViewController), true, null);
            }
            else if (fromViewController is RepositoriesViewController)
            {
                fromViewController.NavigationController.PresentViewController(toViewController, true, null);
            }
            else if (toViewController is MainViewController)
            {
                var nav = ((UINavigationController)UIApplication.SharedApplication.Delegate.Window.RootViewController);
                UIView.Transition(nav.View, 0.1, UIViewAnimationOptions.BeginFromCurrentState | UIViewAnimationOptions.TransitionCrossDissolve,
                                  () => nav.PushViewController(toViewController, false), null);
            }
            else if (toViewController is LoginViewController && fromViewController is StartupView)
            {
                toViewDismissCommand.Subscribe(_ => toViewController.DismissViewController(true, null));
                fromViewController.PresentViewController(new UINavigationController(toViewController), true, null);
            }
            else if (fromViewController is MainViewController)
            {
                var slideout = ((MainViewController)fromViewController);
                slideout.MainViewController = new MainNavigationController(toViewController, slideout,
                                                                           new UIBarButtonItem(CodeFramework.iOS.Images.MenuButton, UIBarButtonItemStyle.Plain, (s, e) => slideout.Open(true)));
            }
            else
            {
                toViewDismissCommand.Subscribe(_ => toViewController.NavigationController.PopToViewController(fromViewController, true));
                fromViewController.NavigationController.PushViewController(toViewController, true);
            }
        }
        public override void CloseModalViewController()
        {
            if (_currentModalViewController != null)
            {
                var nav = _currentModalViewController.ParentViewController as UINavigationController;
                if (nav != null)
                {
                    nav.DismissViewController(true, () => { });
                }
                else
                {
                    _currentModalViewController.DismissViewController(true, () => { });
                }
                _currentModalViewController = null;
                return;
            }

            base.CloseModalViewController();
        }
        private void DoTransition(UIViewController fromViewController, IBaseViewModel fromViewModel, UIViewController toViewController, IBaseViewModel toViewModel)
        {
            var toViewDismissCommand = toViewModel.DismissCommand;

//            if (toViewController is SettingsViewController)
//            {
//                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(CodeFramework.iOS.Images.Cancel, UIBarButtonItemStyle.Plain, (s, e) => toViewDismissCommand.ExecuteIfCan());
//                toViewDismissCommand.Subscribe(__ => toViewController.DismissViewController(true, null));
//                fromViewController.PresentViewController(new UINavigationController(toViewController), true, null);
//            }
            if (toViewController is AccountsView)
            {
                var rootNav = (UINavigationController)UIApplication.SharedApplication.Delegate.Window.RootViewController;
                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(Images.Cancel, UIBarButtonItemStyle.Plain, (s, e) => toViewDismissCommand.ExecuteIfCan());
                toViewDismissCommand.Subscribe(_ => rootNav.DismissViewController(true, null));
                rootNav.PresentViewController(new UINavigationController(toViewController), true, null);
            }
//            else if (fromViewController is RepositoriesViewController)
//            {
//                fromViewController.NavigationController.PresentViewController(toViewController, true, null);
//            }
            else if (toViewController is MenuView)
            {
                var nav = ((UINavigationController)UIApplication.SharedApplication.Delegate.Window.RootViewController);
                var slideout = new SlideoutNavigationController();
                slideout.MenuViewController = new MenuNavigationController(toViewController, slideout);
                UIView.Transition(nav.View, 0.1, UIViewAnimationOptions.BeginFromCurrentState | UIViewAnimationOptions.TransitionCrossDissolve,
                    () => nav.PushViewController(slideout, false), null);
            }
            else if (toViewController is NewAccountView && fromViewController is StartupView)
            {
                toViewDismissCommand.Subscribe(_ => toViewController.DismissViewController(true, null));
                fromViewController.PresentViewController(new UINavigationController(toViewController), true, null);
            }
            else if (fromViewController is MenuView)
            {
                fromViewController.NavigationController.PushViewController(toViewController, true);
            }
            else if (toViewController is LanguagesView && fromViewController is RepositoriesTrendingView)
            {
                toViewDismissCommand.Subscribe(_ => fromViewController.DismissViewController(true, null));
                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, (s, e) => toViewDismissCommand.ExecuteIfCan());
                var ctrlToPresent = new UINavigationController(toViewController);
                ctrlToPresent.TransitioningDelegate = new SlideDownTransition();
                fromViewController.PresentViewController(ctrlToPresent, true, null);
            }
            else
            {
                toViewDismissCommand.Subscribe(_ => toViewController.NavigationController.PopToViewController(fromViewController, true));
                fromViewController.NavigationController.PushViewController(toViewController, true);
            }
        }
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			// Wireup Show button
			ShowButton.TouchUpInside += (sender, e) => {
				// Create a UIImage view to show in the popover
				UIImageView  monkeyIcon = new UIImageView(new CGRect(0,0,256,256));
				monkeyIcon.Image = UIImage.FromFile("MonkeyIcon.png");
				monkeyIcon.UserInteractionEnabled = true;

				// Create a view controller to act as the popover
				UIViewController popover = new UIViewController();
				popover.View = monkeyIcon;
				popover.ModalPresentationStyle = UIModalPresentationStyle.Popover;

				// Grab Image
				var image = UIImage.FromFile("298-circlex.png");

				// Add a close button
				var closeButton = new ImageButton(new CGRect(popover.View.Frame.Size.Width,20,image.Size.Width,image.Size.Height));
				closeButton.UserInteractionEnabled = true;
				closeButton.Image = image;
				monkeyIcon.AddSubview(closeButton);

				// Wireup the close button
				closeButton.Touched += (button) => {
					popover.DismissViewController(true,null);
				};

				// Present the popover
				PresentViewController(popover,true,null);

				// Configure the popover for the iPad, the popover displays as a modal view on the
				// iPhone
				UIPopoverPresentationController presentationPopover = popover.PopoverPresentationController;
				if (presentationPopover!=null) {
					presentationPopover.SourceView = this.View;
					presentationPopover.PermittedArrowDirections = UIPopoverArrowDirection.Up;
					presentationPopover.SourceRect = ShowButton.Frame;
				}

			};
		}
Пример #35
0
 public static void DismissModalAndOpen(UIViewController current, UIViewController next)
 {
     current.DismissViewController (true, delegate {
         Deck.CenterController = new UINavigationController (next);
     });
 }
        public void ResignModelViewController( UIViewController modelViewController, object context )
        {
            // if the image cropper is resigning
            if ( modelViewController == ImageCropViewController )
            {
                // if croppedImage is null, they simply cancelled
                UIImage croppedImage = (UIImage)context;
                if ( croppedImage != null )
                {
                    NSData croppedImageData = croppedImage.AsJPEG( );

                    // if the image converts, we're good.
                    if ( croppedImageData != null )
                    {
                        MemoryStream memStream = new MemoryStream();

                        Stream nsDataStream = croppedImageData.AsStream( );

                        nsDataStream.CopyTo( memStream );
                        memStream.Position = 0;

                        RockMobileUser.Instance.SaveProfilePicture( memStream );
                        RockMobileUser.Instance.UploadSavedProfilePicture( null ); // we don't care about the response. just do it.

                        nsDataStream.Dispose( );
                    }
                    else
                    {
                        // notify them about a problem saving the profile picture
                        DisplayError( SpringboardStrings.ProfilePicture_Error_Title, SpringboardStrings.ProfilePicture_Error_Message );
                    }
                }
            }
            else if ( modelViewController == ProfileViewController )
            {
                // make sure we update the UI if they just finished editing their profile
                View.SetNeedsLayout( );
            }

            modelViewController.DismissViewController( true, delegate
                    {
                        // if this resign is while the OOBE is running, it was the register or login finishing up, 
                        // so wrap up the OOBE
                        if ( IsOOBERunning == true )
                        {
                            CompleteOOBE( );
                        }
                        ModalControllerVisible = false;
                        View.SetNeedsLayout( );
                    } );
        }
Пример #37
0
        public static void Show (UIViewController controller, string email, AuthResult res, Mode mode, bool googleAuth=false)
        {
            switch (res) {
            case AuthResult.InvalidCredentials:
                if (mode == Mode.Login && !googleAuth) {
                    new UIAlertView (
                        "AuthErrorLoginTitle".Tr (),
                        "AuthErrorLoginMessage".Tr (),
                        null, "AuthErrorOk".Tr ()).Show ();
                } else if (mode == Mode.Login && googleAuth) {
                    new UIAlertView (
                        "AuthErrorGoogleLoginTitle".Tr (),
                        "AuthErrorGoogleLoginMessage".Tr (),
                        null, "AuthErrorOk".Tr ()).Show ();
                } else if (mode == Mode.Signup) {
                    new UIAlertView (
                        "AuthErrorSignupTitle".Tr (),
                        "AuthErrorSignupMessage".Tr (),
                        null, "AuthErrorOk".Tr ()).Show ();
                }
                break;
            case AuthResult.NoDefaultWorkspace:
                if (MFMailComposeViewController.CanSendMail) {
                    var dia = new UIAlertView (
                        "AuthErrorNoWorkspaceTitle".Tr (),
                        "AuthErrorNoWorkspaceMessage".Tr (),
                        null, "AuthErrorNoWorkspaceCancel".Tr (),
                        "AuthErrorNoWorkspaceOk".Tr ());
                    dia.Clicked += (sender, e) => {
                        if (e.ButtonIndex == 1) {
                            var mail = new MFMailComposeViewController ();
                            mail.SetToRecipients (new[] { "AuthErrorNoWorkspaceEmail".Tr () });
                            mail.SetSubject ("AuthErrorNoWorkspaceSubject".Tr ());
                            mail.SetMessageBody (String.Format ("AuthErrorNoWorkspaceBody".Tr (), email), false);
                            mail.Finished += delegate {
                                controller.DismissViewController (true, null);
                            };

                            controller.PresentViewController (mail, true, null);
                        }
                    };
                    dia.Show ();
                } else {
                    new UIAlertView (
                        "AuthErrorNoWorkspaceTitle".Tr (),
                        "AuthErrorNoWorkspaceMessage".Tr (),
                        null, "AuthErrorOk".Tr ()).Show();
                }
                break;
            case AuthResult.NetworkError:
                new UIAlertView (
                    "AuthErrorNetworkTitle".Tr (),
                    "AuthErrorNetworkMessage".Tr (),
                    null, "AuthErrorOk".Tr ()).Show ();
                break;
            default:
                new UIAlertView (
                    "AuthErrorSystemTitle".Tr (),
                    "AuthErrorSystemMessage".Tr (),
                    null, "AuthErrorOk".Tr ()).Show ();
                break;
            }
        }
		void TryDismiss(UIViewController controller, Action completionHandler)
		{
			if (controller != null)
				controller.DismissViewController (false, completionHandler);
			else if(completionHandler != null)
				completionHandler ();
		}
        /// <summary>
        /// Presents a new color picker.
        /// </summary>
        /// <param name="parent">The parent <see cref="UIViewController"/>.</param>
        /// <param name="title">The picker title.</param>
        /// <param name="initialColor">The initial selected color.</param>
        /// <param name="done">The method invoked when the picker closes.</param>
        /// <param name="colorPicked">The method invoked as colors are picked.</param>
        public static void Present(UIViewController parent, string title, UIColor initialColor, Action<UIColor> done, Action<UIColor> colorPicked)
        {
            if (parent == null)
            {
                throw new ArgumentNullException("parent");
            }

            var picker = new ColorPickerViewController
            {
                Title = title,
                SelectedColor = initialColor
            };
            picker.ColorPicked += (_, args) =>
            {
                if (colorPicked != null)
                {
                    colorPicked(args.SelectedColor);
                }
            };

            var pickerNav = new UINavigationController(picker);
            pickerNav.ModalPresentationStyle = UIModalPresentationStyle.FormSheet;
            pickerNav.NavigationBar.Translucent = false;

            var doneBtn = new UIBarButtonItem(UIBarButtonSystemItem.Done);
            picker.NavigationItem.RightBarButtonItem = doneBtn;
            doneBtn.Clicked += delegate
            {
                if (done != null)
                {
                    done(picker.SelectedColor);
                }

                // hide the picker
                parent.DismissViewController(true, null);
            };

            // show the picker
            parent.PresentViewController(pickerNav, true, null);
        }
Пример #40
0
        protected virtual IDisposable Present(UIViewController controller)
        {
            var app = UIApplication.SharedApplication;
            var top = this.viewControllerFunc();

            app.InvokeOnMainThread(() => top.PresentViewController(controller, true, null));
            return new DisposableAction(() =>
            {
                try
                {
                    app.InvokeOnMainThread(() => controller.DismissViewController(true, null));
                }
                catch { }
            });
        }
Пример #41
0
        private static void HideViewController(UIViewController viewController)
        {
            if (!UIDevice.CurrentDevice.CheckSystemVersion(6, 0))
            {
#pragma warning disable 618
                // Disable DismissModalViewControllerAnimated warning, still need to support iOS 5 and older
				viewController.DismissModalViewController(true);
#pragma warning restore 618
            }
            else
            {
                // Dismiss view controller for iOS 6+
                viewController.DismissViewController(true, delegate {});
            }

            IsVisible = false;
            TouchPanel.EnabledGestures = prevGestures;
        }
Пример #42
0
 public static void DismissModal(UIViewController current)
 {
     current.DismissViewController (true, null);
 }
Пример #43
0
		public void showSplash (RootViewController rootController)
		{
			var splashView = new UIImageView (UIScreen.MainScreen.Bounds);// (new RectangleF (0f, 0f, 320f, 480f));
			splashView.Image = UIImage.FromFile ("Default.png");
			
			UIViewController modalViewController = new UIViewController ();
			modalViewController.View = splashView;
			modalViewController.ModalTransitionStyle = UIModalTransitionStyle.FlipHorizontal;
			rootController.PresentViewController (modalViewController, false, null);
			NSTimer.CreateScheduledTimer (new TimeSpan (0, 0, 3), 
	                                delegate { 
				modalViewController.DismissViewController(true, null);
				UIApplication.SharedApplication.SetStatusBarHidden (false, false);
					
			});
		}