private async void Account_Tapped(object sender, TappedRoutedEventArgs e)
        {
            NavigationViewItem item = sender as NavigationViewItem;
            var account             = await AccountProvider.GetActiveAccount();

            if (account != null)
            {
                txblDisplayNameFO.Text  = account.Name;
                spAccountFO.DisplayName = account.Name;
                txblEmailFO.Text        = account.Email;

                var availAccounts = await GetAvaibleAccounts();

                if (availAccounts.FirstOrDefault() != null) // there is an available account
                {
                    saFlyout.SetAccountPool(availAccounts);
                    pnlAvailableAccounts.Visibility = Visibility.Visible;
                }
                else
                {
                    pnlAvailableAccounts.Visibility = Visibility.Collapsed;
                }

                foAccount.ShowAt(item);
            }
            else
            {
                Frame.Navigate(typeof(LoginForm), null, new DrillInNavigationTransitionInfo());
            }
        }
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (!isAutoLogined)
            {
                // Auto-Login
                isAutoLogined = true;
                var activeAccount = await AccountProvider.GetActiveAccount();

                if (activeAccount != null)
                {
                    prSigningIn.IsActive = true;
                    LoginHelper.SetLoginCookies(activeAccount.Cookies);
                    wvAutoLogin.Navigate(new Uri(LoginHelper.GoogleLoginLink));
                }
                else
                {
                    await Task.Delay(100);

                    Frame.Navigate(typeof(LoginForm), CommonPageCommand.CannotGoBackLoginPage, new DrillInNavigationTransitionInfo());
                }
            }

            // Show tutorial
            if (string.IsNullOrEmpty(ApplicationData.Current.LocalSettings.Values["tut"]?.ToString()) || true) // test code
            {
                ttWelcomeTut.IsOpen = true;
            }
        }
示例#3
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected async override void OnLaunched(LaunchActivatedEventArgs e)
        {
            FeedbackProvider = new FeedbackEntryProvider(await AccountProvider.GetActiveAccount());
            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();

                rootFrame.NavigationFailed += OnNavigationFailed;

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

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

            // Set theme for our app
            switch (ApplicationData.Current.LocalSettings.Values["theme"]?.ToString())
            {
            case "1":
                rootFrame.RequestedTheme = ElementTheme.Light;
                break;

            case "2":
                rootFrame.RequestedTheme = ElementTheme.Dark;
                break;

            case "0":
                rootFrame.RequestedTheme = ElementTheme.Default;
                break;

            default:     // Our default theme is dark
                rootFrame.RequestedTheme = ElementTheme.Dark;
                ApplicationData.Current.LocalSettings.Values["theme"] = "2";
                break;
            }

            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                    rootFrame.Navigate(typeof(MainPage), "AutoLogin");
                }

                // Ensure the current window is active
                Window.Current.Activate();
            }
        }