private void SetSelectedCredential(CacheCredential credential) { txtAccessKey.Text = credential.AccessKey; txtEndpoint.Text = credential.EndpointName; txtFriendyName.Text = credential.FriendlyName; btnDelete.Enabled = true; btnAdd.Text = "Edit"; }
private void btnDelete_Click(object sender, EventArgs e) { CacheCredential cred = GetSelectedCredential(); if (MessageBox.Show(string.Format("Are you sure you want to delete the stored credentials '{0}'?", cred.FriendlyName), "Delete stored credential?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { _credentials.Credentials.Remove(cred); lvwCredentials.Items.RemoveAt(lvwCredentials.SelectedIndices[0]); } }
private void lvwCredentials_SelectedIndexChanged(object sender, EventArgs e) { CacheCredential credential = GetSelectedCredential(); if (credential == null) { ClearSelectedCredential(); } else { SetSelectedCredential(credential); } CheckRemoveButton(); }
private void btnAdd_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(txtFriendyName.Text)) { MessageBox.Show("Please provide a friendly name.", "Cannot add stored credential", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (string.IsNullOrWhiteSpace(txtEndpoint.Text)) { MessageBox.Show("Please provide an endpoint.", "Cannot add stored credential", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (string.IsNullOrWhiteSpace(txtAccessKey.Text)) { MessageBox.Show("Please provide an access key.", "Cannot add stored credential", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } bool addMode = false; CacheCredential cred = GetSelectedCredential(); if (cred == null) { addMode = true; cred = new CacheCredential(); } cred.AccessKey = txtAccessKey.Text.Trim(); cred.EndpointName = txtEndpoint.Text.Trim(); cred.FriendlyName = txtFriendyName.Text.Trim(); if (addMode) { _credentials.Credentials.Add(cred); ListViewItem lvi = new ListViewItem(cred.FriendlyName); lvi.SubItems.Add(cred.EndpointName); lvwCredentials.Items.Add(lvi); lvwCredentials.Items[lvwCredentials.Items.Count - 1].Selected = true; } else { lvwCredentials.SelectedItems[0].SubItems[0].Text = cred.FriendlyName; lvwCredentials.SelectedItems[0].SubItems[1].Text = cred.EndpointName; } }
private bool CheckItemDirty() { CacheCredential credential = GetSelectedCredential(); if (credential == null) { return(!string.IsNullOrWhiteSpace(txtAccessKey.Text) || !string.IsNullOrWhiteSpace(txtEndpoint.Text) || !string.IsNullOrWhiteSpace(txtFriendyName.Text)); } if (txtAccessKey.Text != credential.AccessKey) { return(true); } if (txtEndpoint.Text != credential.EndpointName) { return(true); } if (txtFriendyName.Text != credential.FriendlyName) { return(true); } return(false); }
public DataCacheFactoryConfiguration GetDataCacheConfiguration(int index) { CacheCredential credential = _credentials.Credentials[index]; return(GetDataCacheConfiguration(credential.EndpointName, credential.AccessKey)); }