Ejemplo n.º 1
0
        /// <summary>
        /// The function that will be called when this frame is navigated to.
        ///
        /// Checks to see if Microsoft Passport is available and checks to see if an
        /// account was passed in.
        ///
        /// If an account was passed, check if it uses Microsoft Passport.
        /// and set the "adding user" flag so we don't add a new account
        /// to the list of users.
        /// </summary>
        /// <param name="e"></param>
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            rootPage = MainPage.Current;

            if (e.Parameter != null)
            {
                m_account                  = (Account)e.Parameter;
                textbox_Username.Text      = m_account.Email;
                textbox_Username.IsEnabled = false;
                if (this.m_account.UsesPassport)
                {
                    LoginHelp loginHelp = new LoginHelp(this.m_account);
                    bool      rev       = await loginHelp.SignInPassport();

                    if (rev)
                    {
                        this.Frame.Navigate(typeof(AccountDetails), this.m_account);
                    }
                }
            }
            var accountList = await AccountsHelper.LoadAccountList();

            if (accountList.Count > 1)
            {
                this.btnSelectUser.Visibility = Visibility.Visible;
            }
            else
            {
                this.btnSelectUser.Visibility = Visibility.Collapsed;
            }
        }
        /// <summary>
        /// Uses the AccountsHelper to load the list of accounts from a saved local app file,
        /// then checks to see if it was empty or not. If it is empty then just go to the sign in form.
        /// </summary>
        private async void SetUpAccounts()
        {
            accountList = await AccountsHelper.LoadAccountList();

            this.listUser.ItemsSource = accountList;
            if (accountList.Count > 0)
            {
                if (accountList.Count == 1)
                {
                    this.Frame.Navigate(typeof(SignIn));
                }
                else
                {
                    this.listUser.SelectedIndex = 0;
                }
            }
        }