private void SaveProfileButton_Click(object sender, EventArgs e) { string qualifiedUserName = GetQualifiedUserName(UserNameTextBox.Text, DomainTextBox.Text); using (SaveCredentialsDialog saveCredentialsDialog = new SaveCredentialsDialog(_file, qualifiedUserName)) { if (saveCredentialsDialog.ShowDialog() == DialogResult.OK) { ProfileScope profileScope = saveCredentialsDialog.ProfileScope; CredentialsStore credentialsProfiles = Program.CredentialsProfiles; if (profileScope == ProfileScope.File) { credentialsProfiles = _file.CredentialsProfiles; } qualifiedUserName = saveCredentialsDialog.ProfileName; bool flag = !credentialsProfiles.Contains(qualifiedUserName); CredentialsProfile credentialsProfile2 = credentialsProfiles[qualifiedUserName] = new CredentialsProfile(qualifiedUserName, profileScope, UserNameTextBox.Text, PasswordTextBox.Text, DomainTextBox.Text); string qualifiedName = credentialsProfile2.QualifiedName; if (flag) { ProfileComboBox.AddItem(qualifiedName, credentialsProfile2); } else { ProfileComboBox.ReplaceItem(qualifiedName, credentialsProfile2); } ProfileComboBox.SelectedValue = credentialsProfile2; } } ProfileComboBox.Focus(); }
private void PopulateComboFromStore(CredentialsStore store) { foreach (CredentialsProfile profile in store.Profiles) { string qualifiedName = profile.QualifiedName; ProfileComboBox.AddItem(qualifiedName, profile); } }
private void PopulateCredentialsProfilesWorker() { CredentialsProfile selectedValue = ProfileComboBox.SelectedValue; ProfileComboBox.ClearItems(); ProfileComboBox.AddItem("Custom", new CredentialsProfile("Custom", ProfileScope.Local, string.Empty, string.Empty, string.Empty)); ProfileComboBox.SelectedIndex = 0; PopulateComboFromStore(Program.CredentialsProfiles); _globalStoreChangeId = Program.CredentialsProfiles.ChangeId; if (_file != null) { PopulateComboFromStore(_file.CredentialsProfiles); _fileStoreChangeId = _file.CredentialsProfiles.ChangeId; } ProfileComboBox.SelectedValue = selectedValue; }