public static bool AddKey(Group group, Key key) { group.Keys.Add(key); if (KeyAdded != null) { KeyAdded.Invoke(key); } FireDocumentChanged(); return true; }
private void AuditKeyUpdated(Key currentKey) { Audit("Modify Key: " + currentKey.ToString()); }
private void AuditKeyDeleted(Key currentKey) { Audit("Delete Key: " + currentKey.ToString()); }
private void AuditKeyAdded(Key currentKey) { Audit("Add Key to Group "+ ContextMgr.CurrentGroup.ToString() +": " + currentKey.ToString()); }
private void UpdateGrid(Key k, bool editMode = false) { ListViewItem lvi; if (!editMode) { lvi = _lvwKeys.Items.Add(k.Title); // returns the "row" object lvi.SubItems.Add(k.UserName); // add items to subitems for subsequent column values lvi.SubItems.Add(k.Password); lvi.SubItems.Add(k.Notes); } else { lvi = _lvwKeys.SelectedItems[0]; lvi.Text = k.Title; lvi.SubItems[0].Text = k.Title; lvi.SubItems[1].Text = k.UserName; lvi.SubItems[2].Text = k.Password; lvi.SubItems[3].Text = k.Notes; } lvi.Tag = k; // resize the _lvwKeys.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); }
private void OnOK(object sender, EventArgs e) { if (!ValidateInput()) return; if (_key == null) _key = new Key(); _key.Title = _txtTitle.Text; _key.UserName = _txtUsername.Text; _key.Notes = _txtComment.Text; _key.Password = _txtPassword.Text; _key.Url = _txtURL.Text; _group = (Group)_cbxGroups.SelectedItem; DialogResult = DialogResult.OK; Close(); }
public KeyPropertiesForm(Group group, Key key) : this() { _group = group; _key = key; }
public static void ModifyKey(Group group, Key k) { // find the group associated to the key k Group oldGroup = FindGroupForKey(k); // if the group is different from the group param, then remove from old group and add to new one if (oldGroup != group) { DeleteKey(oldGroup, k); AddKey(group, k); } if (KeyModified != null) { KeyModified.Invoke(k); } FireDocumentChanged(); }
public static Group FindGroupForKey(Key key) { foreach (Group g in _document.Groups) { Key k = g.Keys.Find(s => s == key); if (k != null) return g; } return null; }
public static void DeleteKey(Group g, Key k) { g.Keys.Remove(k); if (KeyDeleted != null) { KeyDeleted.Invoke(k); } FireDocumentChanged(); }
public static void CloneKey(Key key) { Key clone = null; using (var ms = new MemoryStream()) { // serialize group object, then rehydrate as new object graph var bf = new BinaryFormatter(); bf.Serialize(ms, key); ms.Position = 0; clone = (Key)bf.Deserialize(ms); } KeyPassMgr.AddKey(ContextMgr.CurrentGroup, clone); }