Example #1
0
        public override void CloseModalViewController()
        {
            if (_currentModalViewController != null)
            {
                _currentModalViewController.DismissModalViewControllerAnimated(true);
                _currentModalViewController = null;
                return;
            }

            base.CloseModalViewController();
        }
        public override void CloseModalViewController()
        {
            if (_currentModalViewController != null)
            {
                UINavigationController nav = _currentModalViewController.ParentViewController as UINavigationController;
                if (nav != null)
                {
                    nav.DismissModalViewControllerAnimated(true);
                }
                else
                {
                    _currentModalViewController.DismissModalViewControllerAnimated(true);
                }
                _currentModalViewController = null;
                return;
            }

            base.CloseModalViewController();
        }
Example #3
0
        public static IAsyncResult BeginShowKeyboardInput(
            PlayerIndex player, string title, string description, string defaultText,
            AsyncCallback callback, Object state, bool usePasswordMode)
        {
            AssertInitialised();

            if (keyboardViewController != null)
            {
                return(null);
            }

            int requestCount = Interlocked.Increment(ref _showKeyboardInputRequestCount);

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

            IsVisible = true;

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

            (_gameViewController.View as iOSGameView).PreserveFrameBuffer = true;

            _gameViewController.PresentModalViewController(keyboardViewController, true);

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

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

            return(new KeyboardInputAsyncResult(keyboardViewController, callback, state));
        }
Example #4
0
        void CloseComposer(object sender, EventArgs a)
        {
            if (Picture != null)
            {
                Picture.Dispose();
                Picture = null;
            }

            sendItem.Enabled = true;
            previousController.DismissModalViewControllerAnimated(true);
            if (player != null)
            {
                player.Stop();
            }
        }
        public void Modal_3489()
        {
            using (UIViewController a = new UIViewController())
                using (UIViewController b = new UIViewController())
                    using (UIViewController c = new UIViewController()) {
                        a.PresentModalViewController(b, true);
                        b.PresentModalViewController(c, true);

#if XAMCORE_2_0
                        b.DismissModalViewController(true);
                        a.DismissModalViewController(true);          //error
#else
                        b.DismissModalViewControllerAnimated(true);
                        a.DismissModalViewControllerAnimated(true);          //error
#endif
                    }
        }
Example #6
0
        private static void HideViewController(UIViewController viewController)
        {
            if (osVersion < 6.0d)
            {
#pragma warning disable 618
                // Disable DismissModalViewControllerAnimated warning, still need to support iOS 5 and older
                viewController.DismissModalViewControllerAnimated(true);
#pragma warning restore 618
            }
            else
            {
                // Dismiss view controller for iOS 6+
                viewController.DismissViewController(true, delegate {});
            }

            IsVisible = false;
            TouchPanel.EnabledGestures = prevGestures;
        }
        public void Bug3189()
        {
            using (UIViewController a = new UIViewController())
                using (UIViewController b = new UIViewController())
                    using (UIViewController c = new UIViewController())
                        using (UIViewController wb = new UINavigationController(b))
                            using (UIViewController wc = new UINavigationController(c))
                            {
                                a.PresentModalViewController(wb, true);
                                b.PresentModalViewController(wc, true);

#if XAMCORE_2_0
                                c.DismissModalViewController(true);         //error
#else
                                c.DismissModalViewControllerAnimated(true); //error
#endif
                            }
        }
Example #8
0
		/// <summary>
		/// Starts the login process.
		/// </summary>
		public void Login(UIViewController parent, bool animate)
		{
			switch (Config.Network)
			{
				case SocialNetwork.Facebook:
					{
						var config = (FacebookConfig)Config;
						var authorizor = new FacebookAuthorizationViewController(config.AppID,
#if true // fel
							config.Permissions, FbDisplayType.Popup);
#else
							config.Permissions, FbDisplayType.Touch);
#endif
				
						authorizor.AccessToken += delegate(string accessToken, DateTime expires) {
							try
							{
								var wc = new System.Net.WebClient();
								var result = wc.DownloadData("https://graph.facebook.com/me?access_token="+accessToken);
								var stream = new MemoryStream(result);						
								var jsonArray = (System.Json.JsonObject)System.Json.JsonObject.Load(stream);
								string username = jsonArray["name"].ToString().Replace("\"", "");
								this.UserId = jsonArray["id"].ToString().Replace("\"", "");
								this.AccessToken = accessToken;
								this.Username = username;
#if true // fel
								this.ExpirationDate = expires;
#endif
								parent.BeginInvokeOnMainThread(delegate{
									parent.DismissModalViewControllerAnimated(animate);
									OnSuccess();
								});
							}
							catch (Exception ex)
							{
								OnFailure();
							}
						};
				
						authorizor.Canceled += delegate {
							OnFailure();
						};
				
						authorizor.AuthorizationFailed += delegate {
							OnFailure();
						};
				
						parent.BeginInvokeOnMainThread(delegate{
							parent.PresentModalViewController(authorizor,animate);
						});
					}
					break;
				case SocialNetwork.Twitter:
					{
						var config = (TwitterConfig)Config;
						var authorizor = new TweetStation.OAuthAuthorizer(new TweetStation.OAuthConfig(){
							ConsumerKey = config.ConsumerKey,
							ConsumerSecret = config.ConsumerSecret,
							Callback = config.Callback,
							RequestTokenUrl = "https://api.twitter.com/oauth/request_token",
							AccessTokenUrl = "https://api.twitter.com/oauth/access_token",
							AuthorizeUrl = "https://api.twitter.com/oauth/authorize"
						});
						parent.BeginInvokeOnMainThread(delegate {
							authorizor.AcquireRequestToken();
							authorizor.AuthorizeUser(parent,delegate(){
								if (authorizor.AccessScreenname != "")
								{
									this.Username = authorizor.AccessScreenname;
									this.AccessToken = authorizor.AccessToken;
									this.AccessTokenSecret = authorizor.AccessTokenSecret;
									OnSuccess();
								}
								else
								{
									OnFailure();
								}
							});
						});
					}
					break;
			}
		}
        internal Task <MobileServiceUser> SendLoginAsync(RectangleF rect, object view, MobileServiceAuthenticationProvider provider, JsonObject token = null)
        {
            if (this.LoginInProgress)
            {
                throw new InvalidOperationException(Resources.MobileServiceClient_Login_In_Progress);
            }

            if (!Enum.IsDefined(typeof(MobileServiceAuthenticationProvider), provider))
            {
                throw new ArgumentOutOfRangeException("provider");
            }

            string providerName = provider.ToString().ToLower();

            this.LoginInProgress = true;

            TaskCompletionSource <MobileServiceUser> tcs = new TaskCompletionSource <MobileServiceUser> ();

            if (token != null)
            {
                // Invoke the POST endpoint to exchange provider-specific token for a Windows Azure Mobile Services token

                this.RequestAsync("POST", LoginAsyncUriFragment + "/" + providerName, token)
                .ContinueWith(t =>
                {
                    this.LoginInProgress = false;

                    if (t.IsCanceled)
                    {
                        tcs.SetCanceled();
                    }
                    else if (t.IsFaulted)
                    {
                        tcs.SetException(t.Exception.InnerExceptions);
                    }
                    else
                    {
                        SetupCurrentUser(t.Result);
                        tcs.SetResult(this.CurrentUser);
                    }
                });
            }
            else
            {
                // Launch server side OAuth flow using the GET endpoint

                Uri startUri = new Uri(this.ApplicationUri, LoginAsyncUriFragment + "/" + providerName);
                Uri endUri   = new Uri(this.ApplicationUri, LoginAsyncDoneUriFragment);

                WebRedirectAuthenticator auth = new WebRedirectAuthenticator(startUri, endUri);
                auth.ClearCookiesBeforeLogin = false;

                UIViewController c = auth.GetUI();

                UIViewController    controller = null;
                UIPopoverController popover    = null;

                auth.Error += (o, e) =>
                {
                    this.LoginInProgress = false;

                    if (controller != null)
                    {
                        controller.DismissModalViewControllerAnimated(true);
                    }
                    if (popover != null)
                    {
                        popover.Dismiss(true);
                    }

                    Exception ex = e.Exception ?? new Exception(e.Message);
                    tcs.TrySetException(ex);
                };

                auth.Completed += (o, e) =>
                {
                    this.LoginInProgress = false;

                    if (controller != null)
                    {
                        controller.DismissModalViewControllerAnimated(true);
                    }
                    if (popover != null)
                    {
                        popover.Dismiss(true);
                    }

                    if (!e.IsAuthenticated)
                    {
                        tcs.TrySetCanceled();
                    }
                    else
                    {
                        SetupCurrentUser(JsonValue.Parse(e.Account.Properties["token"]));
                        tcs.TrySetResult(this.CurrentUser);
                    }
                };

                controller = view as UIViewController;
                if (controller != null)
                {
                    controller.PresentModalViewController(c, true);
                }
                else
                {
                    UIView          v         = view as UIView;
                    UIBarButtonItem barButton = view as UIBarButtonItem;

                    popover = new UIPopoverController(c);

                    if (barButton != null)
                    {
                        popover.PresentFromBarButtonItem(barButton, UIPopoverArrowDirection.Any, true);
                    }
                    else
                    {
                        popover.PresentFromRect(rect, v, UIPopoverArrowDirection.Any, true);
                    }
                }
            }

            return(tcs.Task);
        }
Example #10
0
 public void CloseComposer()
 {
     SendItem.Enabled = true;
     _previousController.DismissModalViewControllerAnimated(true);
 }
 public override void PhotoEditor(AFPhotoEditorController editor, UIImage image)
 {
     _parentController.DismissModalViewControllerAnimated(true);
 }