Example #1
0
        public App()
        {
            _protocolsPage = new ProtocolsPage();

            MainPage = new NavigationPage(_protocolsPage);
        }
Example #2
0
        public static void DisplayAndStartAsync(Protocol protocol)
        {
            new Thread(() =>
                {
                    if (protocol == null)
                        SensusServiceHelper.Get().FlashNotificationAsync("Protocol is empty. Cannot display or start it.");
                    else if (protocol.Running)
                        SensusServiceHelper.Get().FlashNotificationAsync("You are already participating in \"" + protocol.Name + "\".");
                    else
                    {                        
                        Device.BeginInvokeOnMainThread(async () =>
                            {
                                // display the protocols page if it isn't already up
                                ProtocolsPage protocolsPage = null;
                                Page topPage = App.Current.MainPage.Navigation.NavigationStack.Last();
                                if (topPage is ProtocolsPage)
                                    protocolsPage = topPage as ProtocolsPage;
                                else
                                {
                                    protocolsPage = new ProtocolsPage();
                                    await App.Current.MainPage.Navigation.PushAsync(protocolsPage);
                                }

                                // ask user to start protocol
                                protocol.StartWithUserAgreementAsync("You just opened \"" + protocol.Name + "\" within Sensus.", () =>
                                    {
                                        Device.BeginInvokeOnMainThread(() =>
                                            {
                                                // rebind to pick up any color changes
                                                protocolsPage.Bind();
                                            });
                                    });
                            });
                    }

                }).Start();
        }