private void addCredentialToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (CredentialEditorForm frm = new CredentialEditorForm(CheckPrincipal))
            {
                if (frm.ShowDialog(this) == DialogResult.OK)
                {
                    AuthenticationCredentials creds = new AuthenticationCredentials(frm.Username, frm.Domain, frm.Password);

                    _credentials[frm.Principal] = creds;
                    UpdateCredentials();
                    OnCredentialsUpdated();
                }
            }
        }
        private void editCredentialToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (listViewCredentials.SelectedItems.Count > 0)
            {
                KeyValuePair<SecurityPrincipal, ICredentialObject> pair = (KeyValuePair<SecurityPrincipal, ICredentialObject>)listViewCredentials.SelectedItems[0].Tag;
                using (CredentialEditorForm frm = new CredentialEditorForm((p) => !p.Equals(pair.Key) && CheckPrincipal(p)))
                {
                    frm.Principal = pair.Key;
                    AuthenticationCredentials c = pair.Value as AuthenticationCredentials;
                    frm.Username = c.Username;
                    frm.Password = c.Password;
                    frm.Domain = c.Domain;

                    if (frm.ShowDialog(this) == DialogResult.OK)
                    {
                        SecurityPrincipal p = frm.Principal;

                        AuthenticationCredentials creds = new AuthenticationCredentials(frm.Username, frm.Domain, frm.Password);

                        _credentials[p] = creds;
                        UpdateCredentials();
                        OnCredentialsUpdated();
                    }
                }
            }
        }