Пример #1
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            if (!AcceptTermsOfUseCheckBox.IsChecked ?? false)
            {
                return;
            }

            statusBar.ProgressIndicator.Text = resourceLoader.GetString(Constants.RESOURCEKEY_LOADINGSTATUS_LOGIN);
            await statusBar.ProgressIndicator.ShowAsync();

            SignInButton.IsEnabled             = false;
            AcceptTermsOfUseCheckBox.IsEnabled = false;
            bool isLoggedIn = await DataSourceFactory.Current.Login(true, true);

            if (!isLoggedIn)
            {
                await statusBar.HideAsync();

                SignInButton.IsEnabled             = true;
                AcceptTermsOfUseCheckBox.IsEnabled = true;
                var dialog = new MessageDialog(resourceLoader.GetString(Constants.RESOURCEKEY_DIALOG_LOGINNOTCOMPLETED));
                await dialog.ShowAsync();

                return;
            }

            var nextPage = await NavigationHelper.DetermineFirstPage();

            await statusBar.ProgressIndicator.HideAsync();

            if (!Frame.Navigate(nextPage))
            {
                throw new Exception(resourceLoader.GetString("NavigationFailedExceptionMessage"));
            }

            SignInButton.IsEnabled             = true;
            AcceptTermsOfUseCheckBox.IsEnabled = true;
        }
Пример #2
0
        private async Task CreateRootFrame(LaunchActivatedEventArgs e)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                // TODO: change this value to a cache size that is appropriate for your application
                rootFrame.CacheSize = 1;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                Type typeOfFirstPage = string.IsNullOrWhiteSpace(SettingsViewModel.Current.MobileServicesUserId)
                                        ? typeof(SplashPage)
                                        : await NavigationHelper.DetermineFirstPage();

                // If arguments have been passed, e.g. from an NFC tag, then navigate to the appropriate page.
                // Set up pages, like create/select baby, take precedence over NFC activation
                // but we still need to remember follow the NFC activation once set up is complete by passing
                // the existing navigation arguments
                if (typeOfFirstPage == typeof(MainPage))
                {
                    typeOfFirstPage = NavigationHelper.DeterminePageFromNavigationArguments(e.Arguments);
                }

#if WINDOWS_PHONE_APP
                // Removes the turnstile navigation for startup.
                if (rootFrame.ContentTransitions != null)
                {
                    this.transitions = new TransitionCollection();
                    foreach (var c in rootFrame.ContentTransitions)
                    {
                        this.transitions.Add(c);
                    }
                }

                rootFrame.ContentTransitions = null;
                rootFrame.Navigated         += this.RootFrame_FirstNavigated;
#endif

                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                if (!rootFrame.Navigate(typeOfFirstPage, e.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
        }