private void MainPage_AccountCommandsRequested(AccountsSettingsPane sender, AccountsSettingsPaneCommandsRequestedEventArgs args) { var credDeletedHandler = new CredentialCommandCredentialDeletedHandler(h => AccountsSettingsPane.Show()); var vault = new PasswordVault(); var creds = vault.RetrieveAll(); foreach (PasswordCredential c in creds) { var credCommand1 = new CredentialCommand(c, credDeletedHandler); args.CredentialCommands.Add(credCommand1); } }
void CredentialDeletedHandler(CredentialCommand sender) { try { // callback invoked when the user requests deletion of the credential in the accounts flyout // System will invoke this callback after successfully deleting the credential from the vault // do post delete work // show accounts settings pane to reflect the new state AccountsSettingsPane.Show(); DebugPrint("Your credential is removed from PasswordVault"); } catch (Exception Error) // No stored credentials, so none to delete { DebugPrint(Error.Message); } }
private CredentialForServerVM() { //clickSaveButton += SetCredentials; на знаю зачем я всё это реализовывал SaveCredentialCommand = new CredentialCommand(SetCredentials); }
void MainPage_AccountCommandsRequested(AccountsSettingsPane sender, AccountsSettingsPaneCommandsRequestedEventArgs args) { // Callback invoked to request the app for accounts when the accounts flyout is about to be displayed // Get the Deferral object and do some async operation if needed var Deferral = args.GetDeferral(); // do some async operation //Uri uri = new Uri("ms-appx:///Assets/Smalllogo.png"); //StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(uri); // Add CredLocker Credentials CredentialCommandCredentialDeletedHandler credDeletedHandler = new CredentialCommandCredentialDeletedHandler(CredentialDeletedHandler); Windows.Security.Credentials.PasswordVault vault = new Windows.Security.Credentials.PasswordVault(); IReadOnlyList<PasswordCredential> creds = vault.RetrieveAll(); if (creds.Count == 0) args.HeaderText = "There is not credential saved by the sample app, please go to Scenario 1 and add some credential, then try again."; else args.HeaderText = "Here are the credentials saved by sample app in Scenario 1."; foreach (PasswordCredential c in creds) { try { CredentialCommand credCommand1 = new CredentialCommand(c, credDeletedHandler); // Deleted is invoked after the system deletes the credential args.CredentialCommands.Add(credCommand1); } catch (Exception Error) // Stored credential was deleted { DebugPrint(Error.ToString()); } } try { // Add Global commands Object commandID = 1; UICommandInvokedHandler appCmdInvokedHandler = new UICommandInvokedHandler(CommandInvokedHandler); // SettingsCommand is an existing WinRT class used in the SettingsPane SettingsCommand command = new SettingsCommand( commandID, "App Specific Command Label...", appCmdInvokedHandler); args.Commands.Add(command); // Add more commands here } catch (Exception Error) // No stored credentials, so none to delete { DebugPrint(Error.Message); } // Complete the Deferral() Deferral.Complete(); }
void MainPage_AccountCommandsRequested(AccountsSettingsPane sender, AccountsSettingsPaneCommandsRequestedEventArgs args) { // Callback invoked to request the app for accounts when the accounts flyout is about to be displayed // Get the Deferral object and do some async operation if needed var Deferral = args.GetDeferral(); // do some async operation //Uri uri = new Uri("ms-appx:///Assets/Smalllogo.png"); //StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(uri); // Add CredLocker Credentials CredentialCommandCredentialDeletedHandler credDeletedHandler = new CredentialCommandCredentialDeletedHandler(CredentialDeletedHandler); Windows.Security.Credentials.PasswordVault vault = new Windows.Security.Credentials.PasswordVault(); IReadOnlyList <PasswordCredential> creds = vault.RetrieveAll(); if (creds.Count == 0) { args.HeaderText = "There is not credential saved by the sample app, please go to Scenario 1 and add some credential, then try again."; } else { args.HeaderText = "Here are the credentials saved by sample app in Scenario 1."; } foreach (PasswordCredential c in creds) { try { CredentialCommand credCommand1 = new CredentialCommand(c, credDeletedHandler); // Deleted is invoked after the system deletes the credential args.CredentialCommands.Add(credCommand1); } catch (Exception Error) // Stored credential was deleted { DebugPrint(Error.ToString()); } } try { // Add Global commands Object commandID = 1; UICommandInvokedHandler appCmdInvokedHandler = new UICommandInvokedHandler(CommandInvokedHandler); // SettingsCommand is an existing WinRT class used in the SettingsPane SettingsCommand command = new SettingsCommand( commandID, "App Specific Command Label...", appCmdInvokedHandler); args.Commands.Add(command); // Add more commands here } catch (Exception Error) // No stored credentials, so none to delete { DebugPrint(Error.Message); } // Complete the Deferral() Deferral.Complete(); }