private async void AccountCommandsRequested(AccountsSettingsPane accountsSettingsPane, AccountsSettingsPaneCommandsRequestedEventArgs eventArgs) { AccountsSettingsPaneEventDeferral deferral = eventArgs.GetDeferral(); HttpResult <ExternalLogin[]> result; using (AccountClient accountClient = ClientFactory.CreateAccountClient()) { result = await accountClient.GetExternalLoginsAsync(); } if (result.Succeeded) { eventArgs.HeaderText = "Please select a login provider."; WebAccountProviderCommandInvokedHandler providerCmdHandler = new WebAccountProviderCommandInvokedHandler(WebAccountProviderInvokedHandler); foreach (ExternalLogin externalLogin in result.Content) { WebAccountProvider provider = new WebAccountProvider(externalLogin.Url, externalLogin.Name, App.LoginIcons[externalLogin.Name]); WebAccountProviderCommand providerCommand = new WebAccountProviderCommand(provider, providerCmdHandler); eventArgs.WebAccountProviderCommands.Add(providerCommand); } } else { await ErrorDialog.ShowErrorsAsync("Error connecting to external accounts.", result.Errors); } deferral.Complete(); }
/// <summary> /// This event is generated when the user clicks on Accounts command in settings pane. During this event, add your /// WebAccountProviderCommand, WebAccountCommand, CredentialCommand and SettingsCommand objects to make them available to the /// AccountsSettingsPane UI. /// </summary> /// <param name="accountsSettingsPane">Instance that triggered the event.</param> /// <param name="eventArgs">Event data describing the conditions that led to the event.</param> private void AccountCommandsRequested(AccountsSettingsPane accountsSettingsPane, AccountsSettingsPaneCommandsRequestedEventArgs eventArgs) { var deferral = eventArgs.GetDeferral(); //Add header text. eventArgs.HeaderText = "This is sample text. You can put a message here to give context to user. This section is optional."; //Add WebAccountProviders WebAccountProviderCommandInvokedHandler providerCmdHandler = new WebAccountProviderCommandInvokedHandler(WebAccountProviderInvokedHandler); WebAccountProviderCommand facebookProviderCommand = new WebAccountProviderCommand(facebookProvider, WebAccountProviderInvokedHandler); eventArgs.WebAccountProviderCommands.Add(facebookProviderCommand); WebAccountProviderCommand twitterProviderCommand = new WebAccountProviderCommand(twitterProvider, WebAccountProviderInvokedHandler); eventArgs.WebAccountProviderCommands.Add(twitterProviderCommand); //Add WebAccounts if available. WebAccountCommandInvokedHandler accountCmdHandler = new WebAccountCommandInvokedHandler(WebAccountInvokedHandler); if (isFacebookUserLoggedIn) { facebookAccount = new WebAccount(facebookProvider, facebookUserName, WebAccountState.Connected); WebAccountCommand facebookAccountCommand = new WebAccountCommand( facebookAccount, WebAccountInvokedHandler, SupportedWebAccountActions.Remove | SupportedWebAccountActions.Manage); eventArgs.WebAccountCommands.Add(facebookAccountCommand); } if (isTwitterUserLoggedIn) { twitterAccount = new WebAccount(twitterProvider, twitterUserName, WebAccountState.Connected); WebAccountCommand twitterAccountCommand = new WebAccountCommand( twitterAccount, WebAccountInvokedHandler, SupportedWebAccountActions.Remove | SupportedWebAccountActions.Manage); eventArgs.WebAccountCommands.Add(twitterAccountCommand); } // Add links if needed. Object commandID = 1; UICommandInvokedHandler globalLinkInvokedHandler = new UICommandInvokedHandler(GlobalLinkInvokedhandler); SettingsCommand command = new SettingsCommand( commandID, "More details", globalLinkInvokedHandler); eventArgs.Commands.Add(command); SettingsCommand command1 = new SettingsCommand( commandID, "Privacy policy", globalLinkInvokedHandler); eventArgs.Commands.Add(command1); deferral.Complete(); }
public async void AccountCommandsRequested(AccountsSettingsPane accountsSettingsPane, AccountsSettingsPaneCommandsRequestedEventArgs eventArgs) { AccountsSettingsPaneEventDeferral deferral = eventArgs.GetDeferral(); HttpResult<ManageInfo> result; using (AccountClient accountClient = ClientFactory.CreateAccountClient()) { result = await accountClient.GetManageInfoAsync(); } if (!result.Succeeded) { await ErrorDialog.ShowErrorsAsync(result.Errors); // The log off command is not available on the account settings page if there are no accounts, so log off now LogOff(); deferral.Complete(); return; } ManageInfo manageInfo = result.Content; this.username = manageInfo.UserName; this.localProvider = manageInfo.LocalLoginProvider; eventArgs.HeaderText = "Manage your account logins"; ////Add WebAccountProviders Dictionary<string, WebAccountProvider> webProviders = new Dictionary<string, WebAccountProvider>(); WebAccountProviderCommandInvokedHandler providerCommandHandler = new WebAccountProviderCommandInvokedHandler(WebAccountProviderInvokedHandler); foreach (ExternalLogin externalLogin in manageInfo.ExternalLoginProviders) { WebAccountProvider provider = new WebAccountProvider(externalLogin.Url, externalLogin.Name, App.LoginIcons[externalLogin.Name]); WebAccountProviderCommand providerCommand = new WebAccountProviderCommand(provider, providerCommandHandler); eventArgs.WebAccountProviderCommands.Add(providerCommand); webProviders[provider.DisplayName] = provider; } WebAccountProvider localLoginProvider = new WebAccountProvider(manageInfo.LocalLoginProvider, manageInfo.LocalLoginProvider, null); webProviders[manageInfo.LocalLoginProvider] = localLoginProvider; ////Add WebAccounts and local accounts if available. bool hasLocalLogin = false; foreach (UserLoginInfo userLoginInfo in manageInfo.Logins) { WebAccountCommandInvokedHandler accountCommandHandler; SupportedWebAccountActions supportedActions = SupportedWebAccountActions.None; if (manageInfo.Logins.Length > 1) { supportedActions |= SupportedWebAccountActions.Remove; } if (userLoginInfo.LoginProvider == manageInfo.LocalLoginProvider) { hasLocalLogin = true; supportedActions |= SupportedWebAccountActions.Manage; accountCommandHandler = new WebAccountCommandInvokedHandler(LocalWebAccountInvokedHandler); } else { accountCommandHandler = new WebAccountCommandInvokedHandler(WebAccountInvokedHandler); } WebAccount webAccount = new WebAccount(webProviders[userLoginInfo.LoginProvider], userLoginInfo.ProviderKey, WebAccountState.Connected); WebAccountCommand webAccountCommand = new WebAccountCommand(webAccount, accountCommandHandler, supportedActions); eventArgs.WebAccountCommands.Add(webAccountCommand); } if (!hasLocalLogin) { WebAccountProviderCommandInvokedHandler localProviderCmdHandler = new WebAccountProviderCommandInvokedHandler(LocalProviderInvokedHandler); WebAccountProviderCommand localProviderCommand = new WebAccountProviderCommand(localLoginProvider, localProviderCmdHandler); eventArgs.WebAccountProviderCommands.Add(localProviderCommand); } SettingsCommand logOffCommand = new SettingsCommand("Logoff", "Log off", new UICommandInvokedHandler(LogOffHandler)); eventArgs.Commands.Add(logOffCommand); deferral.Complete(); }
/// <summary> /// This event is generated when the user clicks on Accounts command in settings pane. During this event, add your /// WebAccountProviderCommand, WebAccountCommand, CredentialCommand and SettingsCommand objects to make them available to the /// AccountsSettingsPane UI. /// </summary> /// <param name="accountsSettingsPane">Instance that triggered the event.</param> /// <param name="eventArgs">Event data describing the conditions that led to the event.</param> private void AccountCommandsRequested(AccountsSettingsPane accountsSettingsPane, AccountsSettingsPaneCommandsRequestedEventArgs eventArgs) { var deferral = eventArgs.GetDeferral(); //Add header text. eventArgs.HeaderText = "This is sample text. You can put a message here to give context to user. This section is optional."; //Add WebAccountProviders WebAccountProviderCommandInvokedHandler providerCmdHandler = new WebAccountProviderCommandInvokedHandler(WebAccountProviderInvokedHandler); WebAccountProviderCommand facebookProviderCommand = new WebAccountProviderCommand(facebookProvider, WebAccountProviderInvokedHandler); eventArgs.WebAccountProviderCommands.Add(facebookProviderCommand); WebAccountProviderCommand twitterProviderCommand = new WebAccountProviderCommand(twitterProvider, WebAccountProviderInvokedHandler); eventArgs.WebAccountProviderCommands.Add(twitterProviderCommand); //Add WebAccounts if available. WebAccountCommandInvokedHandler accountCmdHandler = new WebAccountCommandInvokedHandler(WebAccountInvokedHandler); if (isFacebookUserLoggedIn) { facebookAccount = new WebAccount(facebookProvider, facebookUserName, WebAccountState.Connected); WebAccountCommand facebookAccountCommand = new WebAccountCommand( facebookAccount, WebAccountInvokedHandler, SupportedWebAccountActions.Remove | SupportedWebAccountActions.Manage); eventArgs.WebAccountCommands.Add(facebookAccountCommand); } if (isTwitterUserLoggedIn) { twitterAccount = new WebAccount(twitterProvider, twitterUserName, WebAccountState.Connected); WebAccountCommand twitterAccountCommand = new WebAccountCommand( twitterAccount, WebAccountInvokedHandler, SupportedWebAccountActions.Remove | SupportedWebAccountActions.Manage); eventArgs.WebAccountCommands.Add(twitterAccountCommand); } // Add links if needed. Object commandID = 1; UICommandInvokedHandler globalLinkInvokedHandler = new UICommandInvokedHandler(GlobalLinkInvokedhandler); SettingsCommand command = new SettingsCommand( commandID, "More details", globalLinkInvokedHandler); eventArgs.Commands.Add(command); SettingsCommand command1 = new SettingsCommand( commandID, "Privacy policy", globalLinkInvokedHandler); eventArgs.Commands.Add(command1); deferral.Complete(); }
private async void AccountCommandsRequested(AccountsSettingsPane accountsSettingsPane, AccountsSettingsPaneCommandsRequestedEventArgs eventArgs) { AccountsSettingsPaneEventDeferral deferral = eventArgs.GetDeferral(); HttpResult<ExternalLogin[]> result; using (AccountClient accountClient = ClientFactory.CreateAccountClient()) { result = await accountClient.GetExternalLoginsAsync(); } if (result.Succeeded) { eventArgs.HeaderText = "Please select a login provider."; WebAccountProviderCommandInvokedHandler providerCmdHandler = new WebAccountProviderCommandInvokedHandler(WebAccountProviderInvokedHandler); foreach (ExternalLogin externalLogin in result.Content) { WebAccountProvider provider = new WebAccountProvider(externalLogin.Url, externalLogin.Name, App.LoginIcons[externalLogin.Name]); WebAccountProviderCommand providerCommand = new WebAccountProviderCommand(provider, providerCmdHandler); eventArgs.WebAccountProviderCommands.Add(providerCommand); } } else { await ErrorDialog.ShowErrorsAsync("Error connecting to external accounts.", result.Errors); } deferral.Complete(); }
public async void AccountCommandsRequested(AccountsSettingsPane accountsSettingsPane, AccountsSettingsPaneCommandsRequestedEventArgs eventArgs) { AccountsSettingsPaneEventDeferral deferral = eventArgs.GetDeferral(); HttpResult <ManageInfo> result; using (AccountClient accountClient = ClientFactory.CreateAccountClient()) { result = await accountClient.GetManageInfoAsync(); } if (!result.Succeeded) { await ErrorDialog.ShowErrorsAsync(result.Errors); // The log off command is not available on the account settings page if there are no accounts, so log off now LogOff(); deferral.Complete(); return; } ManageInfo manageInfo = result.Content; this.username = manageInfo.UserName; this.localProvider = manageInfo.LocalLoginProvider; eventArgs.HeaderText = "Manage your account logins"; ////Add WebAccountProviders Dictionary <string, WebAccountProvider> webProviders = new Dictionary <string, WebAccountProvider>(); WebAccountProviderCommandInvokedHandler providerCommandHandler = new WebAccountProviderCommandInvokedHandler(WebAccountProviderInvokedHandler); foreach (ExternalLogin externalLogin in manageInfo.ExternalLoginProviders) { WebAccountProvider provider = new WebAccountProvider(externalLogin.Url, externalLogin.Name, App.LoginIcons[externalLogin.Name]); WebAccountProviderCommand providerCommand = new WebAccountProviderCommand(provider, providerCommandHandler); eventArgs.WebAccountProviderCommands.Add(providerCommand); webProviders[provider.DisplayName] = provider; } WebAccountProvider localLoginProvider = new WebAccountProvider(manageInfo.LocalLoginProvider, manageInfo.LocalLoginProvider, null); webProviders[manageInfo.LocalLoginProvider] = localLoginProvider; ////Add WebAccounts and local accounts if available. bool hasLocalLogin = false; foreach (UserLoginInfo userLoginInfo in manageInfo.Logins) { WebAccountCommandInvokedHandler accountCommandHandler; SupportedWebAccountActions supportedActions = SupportedWebAccountActions.None; if (manageInfo.Logins.Length > 1) { supportedActions |= SupportedWebAccountActions.Remove; } if (userLoginInfo.LoginProvider == manageInfo.LocalLoginProvider) { hasLocalLogin = true; supportedActions |= SupportedWebAccountActions.Manage; accountCommandHandler = new WebAccountCommandInvokedHandler(LocalWebAccountInvokedHandler); } else { accountCommandHandler = new WebAccountCommandInvokedHandler(WebAccountInvokedHandler); } WebAccount webAccount = new WebAccount(webProviders[userLoginInfo.LoginProvider], userLoginInfo.ProviderKey, WebAccountState.Connected); WebAccountCommand webAccountCommand = new WebAccountCommand(webAccount, accountCommandHandler, supportedActions); eventArgs.WebAccountCommands.Add(webAccountCommand); } if (!hasLocalLogin) { WebAccountProviderCommandInvokedHandler localProviderCmdHandler = new WebAccountProviderCommandInvokedHandler(LocalProviderInvokedHandler); WebAccountProviderCommand localProviderCommand = new WebAccountProviderCommand(localLoginProvider, localProviderCmdHandler); eventArgs.WebAccountProviderCommands.Add(localProviderCommand); } SettingsCommand logOffCommand = new SettingsCommand("Logoff", "Log off", new UICommandInvokedHandler(LogOffHandler)); eventArgs.Commands.Add(logOffCommand); deferral.Complete(); }