protected override void OnNavigatedTo( bool cancelled, NavigationEventArgs e) { if (cancelled) return; var database = Cache.Database; DateTime convertedDate; if ((Cache.DbInfo != null) && (Cache.DbInfo.Details.Modified != null)) { convertedDate = DateTime.Parse(Cache.DbInfo.Details.Modified); ApplicationTitle.Text = "WinPass - " + Cache.DbInfo.Details.Name + " (" + convertedDate + ")"; } if (database == null) { this.BackToDBs(); return; } //if (Cache.DbInfo != null && Cache.DbInfo.Details.Type.ToString() == "OneTime") // mnuSync.IsEnabled = false; _group = GetGroup(database); lstHistory.ItemsSource = null; pivotGroup.Header = _group.Name; ThreadPool.QueueUserWorkItem(_ => ListItems(_group, database.RecycleBin)); ThreadPool.QueueUserWorkItem(_ => ListHistory(database)); ItemRemovedAction(); }
protected override void OnNavigatedTo( bool cancelled, NavigationEventArgs e) { if (cancelled) return; _database = Cache.Database; if (_database == null) { this.BackToDBs(); return; } string id; var queries = NavigationContext.QueryString; if (queries.TryGetValue("entry", out id)) _entry = _database.GetEntry(id); else { id = queries["group"]; _group = _database.GetGroup(id); } _target = _database.Root; Refresh(); }
private static bool IsRelated(Group group, Group target) { if (group == target) return true; var parent = group.Parent; if (parent == null) return false; return IsRelated(parent, target); }
public Database(Group root, IDictionary<string, ImageSource> customIcons) { if (root == null) throw new ArgumentNullException("root"); if (customIcons == null) throw new ArgumentNullException("customIcons"); _root = root; _customIcons = customIcons; _groups = new Dictionary<string, Group>(); _entries = new Dictionary<string, Entry>(); Index(root); }
/// <summary> /// Deletes the specified group. /// </summary> /// <param name="group">The group.</param> public void Delete(Group group) { if (group == null) throw new ArgumentNullException("group"); var time = GetTime(DateTime.Now); _deletedObjs.Add(new XElement("DeletedObject", new XElement("UUID", group.ID), new XElement("DeletionTime", time))); _groups[group.ID].Remove(); Remove(group); }
public GroupItem(Group group, Dispatcher dispatcher) { if (group == null) throw new ArgumentNullException("group"); if (dispatcher == null) throw new ArgumentNullException("dispatcher"); Title = group.Name; Icon = ThemeData.GetImage("folder"); Overlay = Cache.GetOverlay( dispatcher, group.Icon); _data = group; _targetUri = Navigation.GetPathTo <GroupDetails>("id={0}", group.ID); }
public Database(Group root, IDictionary<string, ImageSource> customIcons) { if (root == null) throw new ArgumentNullException("root"); if (customIcons == null) throw new ArgumentNullException("customIcons"); _root = root; // RecycleBin = _root.Entries.FirstOrDefault(p=>p.Group.Icon == 43) _customIcons = customIcons; Configuration = new DatabaseConfiguration(); _groups = new Dictionary<string, Group>(); _entries = new Dictionary<string, Entry>(); Index(root); }
private static string GetPath(Group group) { var sb = new StringBuilder( group.Name); while (group.Parent != null) { group = group.Parent; sb.Insert(0, " � "); sb.Insert(0, group.Name); } return sb.ToString(); }
protected override void OnNavigatedTo( bool cancelled, NavigationEventArgs e) { if (cancelled) return; var database = Cache.Database; if (database == null) { GoBack<MainPage>(); return; } _group = GetGroup(database); lstHistory.ItemsSource = null; pivotGroup.Header = _group.Name; ThreadPool.QueueUserWorkItem(_ => ListItems(_group, database.RecycleBin)); ThreadPool.QueueUserWorkItem(_ => ListHistory(database)); }
/// <summary> /// Adds the new group. /// </summary> /// <param name="parent">The parent.</param> /// <param name="name">The name.</param> public Group AddNew(Group parent, string name) { if (parent == null) throw new ArgumentNullException("parent"); var group = new Group { Name = name, }; parent.Add(group); group.ID = Uuid.NewUuid(); _groups.Add(group.ID, group); return group; }
private static bool Matches( Group group, string text) { return Matches(text, new[] { group.Name, group.Notes, }); }
private void Remove(Group group) { foreach (var entry in group.Entries) _entries.Remove(entry.ID); foreach (var child in group.Groups) Remove(child); _groups.Remove(group.ID); }
private void SetRecycleBin(Group recycleBin) { var recycleBinId = recycleBin != null ? recycleBin.ID : EMPTY_ID; var meta = _doc.Root .Element("Meta"); var idElement = meta .Element("RecycleBinUUID"); if (idElement.Value == recycleBinId) return; idElement.Value = recycleBinId; meta.Element("RecycleBinChanged") .Value = GetTime(DateTime.Now); }
/// <summary> /// Updates the details of the specified group. /// </summary> /// <param name="group">The group.</param> public void Details(Group group) { _xmlWriter.Details(group); }
/// <summary> /// Removes the specified entry. /// </summary> /// <param name="group">The group.</param> public void Remove(Group group) { foreach (var entry in group.Entries.ToList()) Remove(entry); foreach (var child in group.Groups.ToList()) Remove(child); group.Remove(); _groups.Remove(group.ID); }
public void Save(Stream stream, Group recycleBin) { if (stream == null) throw new ArgumentNullException("stream"); // Encrypt protected fields var crypto = CryptoSerializer .Create(_headers); _xmlWriter.Encrypt(crypto); // Headers var bw = new BinaryWriter(stream); new HeadersWriter(bw) .Write(_headers, _version); // Main XML using (var encrypted = Encrypt(stream, _headers, _masterKey)) { _xmlWriter.Save(encrypted, recycleBin); } }
private Group ParseGroup(XmlReader reader) { var id = ReadId(reader); if (reader.Name != "Name") reader.ReadToNextSibling("Name"); var name = reader .ReadElementContentAsString(); var notes = string.Empty; if (reader.Name == "Notes" || reader.ReadToNextSibling("Notes")) { notes = reader.ReadElementContentAsString(); } var icon = ParseIcon(reader); var lastModified = ReadLastModified(reader); var group = new Group { ID = id, Name = name, Icon = icon, Notes = notes, LastModified = lastModified, }; ParseChildren(reader, group); return group; }
private void lst_SelectionChanged(object sender, NavigationListControl.NavigationEventArgs e) { var item = e.Item as GroupItem; if (item == null) return; _target = (Group)item.Data; Refresh(); }
private void ListItems(Group group, Group recycleBin) { var dispatcher = Dispatcher; var groups = group.Groups.AsEnumerable(); if (recycleBin != null) { var settings = AppSettings.Instance; if (settings.HideRecycleBin) groups = groups.Except(new[] {recycleBin}); } var items = new List<GroupItem>(); items.AddRange(groups .OrderBy(x => x.Name) .Select(x => new GroupItem(x, dispatcher))); items.AddRange(group.Entries .OrderBy(x => x.Title) .Select(x => new GroupItem(x, dispatcher))); lstGroup.SetItems(items); }
private void Index(Group group) { _groups.AddOrSet(group.ID, group); foreach (var entry in group.Entries) _entries.AddOrSet(entry.ID, entry); foreach (var child in group.Groups) Index(child); }
private void ListItems(Group group, Group recycleBin) { var dispatcher = Dispatcher; var groups = group.Groups.ToList(); if (recycleBin != null) { var settings = AppSettings.Instance; if (settings.HideRecycleBin) groups.Remove(recycleBin); } if (IsSameData(groups, group.Entries)) return; var items = new List<GroupItem>(); items.AddRange(groups .OrderBy(x => x.Name) .Select(x => new GroupItem(x, dispatcher))); items.AddRange(group.Entries .OrderBy(x => x.Title) .Select(x => new GroupItem(x, dispatcher))); lstGroup.SetItems(items); }
private void ParseChildren(XmlReader reader, Group group) { while (reader.NodeType == XmlNodeType.Element) { switch (reader.Name) { case "Group": using (var subReader = reader.ReadSubtree()) group.Add(ParseGroup(subReader)); reader.ReadEndElement(); break; case "Entry": using (var subReader = reader.ReadSubtree()) { var entry = ParseEntry(subReader); if (entry != null) group.Add(entry); } reader.ReadEndElement(); break; default: reader.Skip(); break; } } group.Sort(); }
private void Delete(Group group) { var database = Cache.Database; var pernament = IsPernamentDelete(); if (!ConfirmDelete(pernament, Properties.Resources.Group, group.Name)) { return; } if (!pernament) { MoveToRecycleBin((writer, recycleBin) => { group.Remove(); recycleBin.Add(group); writer.Location(group); }); } else { Save(x => { x.Delete(group); database.Remove(group); }); } }
/// <summary> /// Updates the details of the specified group. /// </summary> /// <param name="group">The group.</param> public void Details(Group group) { if (group == null) throw new ArgumentNullException("group"); var element = _groups[group.ID]; element .Element("Name") .Value = group.Name; var time = DateTime.Now; group.LastModified = time; element .Element("Times") .Element("LastModificationTime") .Value = GetTime(time); }
/// <summary> /// Saves the new group. /// </summary> /// <param name="group">The group.</param> public void New(Group group) { _xmlWriter.New(group); }
/// <summary> /// Updates the location of the specified group. /// </summary> /// <param name="group">The group.</param> public void Location(Group group) { if (group == null) throw new ArgumentNullException("group"); var element = _groups[group.ID]; element.Remove(); var parent = _groups[group.Parent.ID]; parent.Add(element); var time = DateTime.Now; group.LastModified = time; element .Element("Times") .Element("LocationChanged") .Value = GetTime(time); }
/// <summary> /// Deletes the specified group. /// </summary> /// <param name="group">The group.</param> public void Delete(Group group) { _xmlWriter.Delete(group); }
/// <summary> /// Saves the new group. /// </summary> /// <param name="group">The group.</param> public void New(Group group) { if (group == null) throw new ArgumentNullException("group"); var time = DateTime.Now; group.LastModified = time; var timeValue = GetTime(time); var element = new XElement("Group", new XElement("UUID", group.ID), new XElement("Name", group.Name), new XElement("Notes"), new XElement("IconID", group.Icon.Standard), new XElement("Times", new XElement("LastModificationTime", timeValue), new XElement("CreationTime", timeValue), new XElement("LastAccessTime", timeValue), new XElement("ExpiryTime", timeValue), new XElement("Expires", "False"), new XElement("UsageCount", 0), new XElement("LocationChanged", timeValue)), new XElement("IsExpanded", "True"), new XElement("DefaultAutoTypeSequence"), new XElement("EnableAutoType", "null"), new XElement("EnableSearching", "null"), new XElement("LastTopVisibleEntry", EMPTY_ID)); var parent = _groups[group.Parent.ID]; parent.Add(element); parent .Element("Times") .Element("LastModificationTime") .Value = timeValue; _groups.Add(group.ID, element); }
/// <summary> /// Updates the location of the specified group. /// </summary> /// <param name="group">The group.</param> public void Location(Group group) { _xmlWriter.Location(group); }
/// <summary> /// Saves the updated XML to the specified stream. /// </summary> /// <param name="xml">The XML.</param> /// <param name="recycleBin">The recycle bin.</param> public void CreateRecycleBin(Stream xml, Group recycleBin) { if (xml == null) throw new ArgumentNullException("xml"); SetRecycleBin(recycleBin); _doc.Save(xml); }