public KeyChain() { _groups = new List<Group>(); _filename = DefaultFilename;// "?\\NEWFILE\\?"; _currentGroup = null; _currentKey = null; }
public void AddGroup(Group g) { _keyChain.Groups.Add(g); _keyChain.CurrentGroup = g; _keyChain.Saved = false; newHistory("Add Group: " + g.Title, CloudKeysModel.Action.Create); }
public void OpenGroupDailog(Group g = null) { GroupDialog gd = new GroupDialog(); gd.Group = g; DialogResult dialogResult = gd.ShowDialog(); if (dialogResult == DialogResult.OK) { Group newGroup = gd.Group; if (g == null) //Means "new" mode. { _mgr.AddGroup(newGroup); TreeNode newNode = new TreeNode(); newNode.Tag = newGroup; newNode.Text = newGroup.Title; newNode.ForeColor = newGroup.Color; _treeview.Nodes.Add(newNode); _treeview.SelectedNode = newNode; } else { _treeview.SelectedNode.Text = newGroup.Title; _treeview.SelectedNode.ForeColor = newGroup.Color; _mgr.EditGroup(newGroup); } _mgr.KeyChain.Saved = false; } }
public Group Clone() { Group g = new Group(); g.Keys = new List<Key>(); foreach (Key k in _keys) { Key newKey = k.Clone(); // newKey.Group = g; g.Keys.Add(newKey); } g.Title = _title; g._color = _color; return g; }
public void DeleteGroup(Group g) { int index = _keyChain.Groups.IndexOf(g); _keyChain.Groups.Remove(g); if (index >= _keyChain.Groups.Count) { _keyChain.CurrentGroup = null; } else { _keyChain.CurrentGroup = _keyChain.Groups[index]; } _keyChain.Saved = false; newHistory("Delete Group: " + g.Title, CloudKeysModel.Action.Delete); }
public List<Key> SearchKey(string keyword, bool useTempGroup = false) { keyword = keyword.ToLower(); List<Key> keys = new List<Key>(); foreach (Group g in _keyChain.Groups) { foreach (Key k in g.Keys) { if (k.Title.ToLower().Contains(keyword) || k.Username.ToLower().Contains(keyword) || k.URL.ToLower().Contains(keyword) || k.Notes.ToLower().Contains(keyword) || k.Password.ToLower().Contains(keyword)) { keys.Add(k); } } } if (useTempGroup) { Group newg = new Group(); newg.Keys = keys; newg.Color = Color.Red; newg.Title = _foundKeysGroup; _keyChain.Groups.Add(newg); } return keys; }
public void EditGroup(Group g) { //Group thisGroup = _keyChain.CurrentGroup; //int index = _keyChain.Groups.IndexOf(thisGroup); //_keyChain.Groups.Remove(thisGroup); //_keyChain.Groups.Insert(index, g); _keyChain.Saved = false; newHistory("Edit Group: " + g.Title, CloudKeysModel.Action.Update); }
private void OnLoad(object sender, EventArgs e) { if (_group == null) { _group = new Group(); } _textboxGroupName.Text = _group.Title; int colorArgbValue = _group.Color.ToArgb(); int index = 0; foreach (ComboBoxItem i in _colorPicker.Items) { if (i.Value == colorArgbValue) { index = _colorPicker.Items.IndexOf(i); break; } } _colorPicker.SelectedIndex = index; }