Beispiel #1
0
        public void IntegrateWith(IAgent agent)
        {
            // TODO: Refactor this into shared code between iOS and Android.
            realAgent = agent as iOSAgent;

            if (realAgent == null)
            {
                return;
            }

            if (realAgent.ViewHierarchyHandlerManager == null)
            {
                return;
            }

            try {
                realAgent.ViewHierarchyHandlerManager.AddViewHierarchyHandler(HierarchyKind,
                                                                              new iOSFormsViewHierarchyHandler(realAgent));
                realAgent.RepresentationManager.AddProvider(new FormsRepresentationProvider());

                if (realAgent.ClientSessionUri.SessionKind == ClientSessionKind.Workbook)
                {
                    realAgent.RegisterResetStateHandler(ResetStateHandler);

                    Log.Debug(TAG, "Initializing Xamarin.Forms.");
                    Xamarin.Forms.Forms.Init();

                    Log.Debug(TAG, "Creating base Xamarin.Forms application.");
                    var app = new WorkbookApplication {
                        MainPage = new ContentPage()
                    };

                    Log.Debug(TAG, "Creating view controller for main page and setting it as root.");
                    UIApplication.SharedApplication.KeyWindow.RootViewController =
                        app.MainPage.CreateViewController();
                }

                Log.Info(TAG, "Registered Xamarin.Forms agent integration!");
            } catch (Exception e) {
                Log.Error(TAG, "Could not register Xamarin.Forms agent integration.", e);
            }
        }
Beispiel #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var agent = new iOSAgent();

            agent.IdentificationFailure += (sender, e) => {
                var alert = UIAlertController.Create(
                    "Error connecting to workbook",
                    "The workbook could not be reached. Please verify that this device has a " +
                    "working network connection. Visit http://xmn.io/workbooks-help for additional " +
                    "troubleshooting steps.",
                    UIAlertControllerStyle.Alert
                    );
                alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));

                PresentViewController(alert, true, null);
            };
            agent.Start();

            // TODO: Can we launch client app when debugging like we can for Mac?
        }
 public iOSFormsViewHierarchyHandler(iOSAgent agent)
 {
     this.agent = agent;
 }