internal bool RemovePage(TaggedPage pg) { bool removed = _pages.Remove(pg); if (removed) { firePropertyChanged(PAGES); } return(removed); }
internal bool AddPage(TaggedPage pg) { bool added = _pages.Add(pg); if (added) { firePropertyChanged(PAGES); } return(added); }
/// <summary> /// Extract tags from page descriptors. /// </summary> /// <param name="pageDescriptors"> /// XML document describing pages in the OneNote hierarchy or search result. /// </param> /// <param name="selectedPagesOnly">true to process only pages selected by user</param> /// <param name="omitUntaggedPages">drip untagged pages</param> internal void ExtractTags(XDocument pageDescriptors, bool selectedPagesOnly, bool omitUntaggedPages = false) { // parse the search results _tags.Clear(); _pages.Clear(); try { XNamespace one = pageDescriptors.Root.GetNamespaceOfPrefix("one"); Dictionary <string, TagPageSet> tags = new Dictionary <string, TagPageSet>(); foreach (XElement page in pageDescriptors.Descendants(one.GetName("Page"))) { TaggedPage tp = new TaggedPage(page); if (selectedPagesOnly && !tp.IsSelected) { continue; } // assign Tags int tagcount = 0; foreach (string tagname in tp.TagNames) { tagcount++; TagPageSet t; if (!tags.TryGetValue(tagname, out t)) { t = new TagPageSet(tagname); tags.Add(tagname, t); } t.AddPage(tp); tp.Tags.Add(t); } if (!omitUntaggedPages || tagcount > 0) { _pages.Add(tp.Key, tp); } } // bulk update for performance reasons _tags.UnionWith(tags.Values); TraceLogger.Log(TraceCategory.Info(), "Extracted {0} tags from {1} pages.", _tags.Count, _pages.Count); } catch (Exception ex) { TraceLogger.Log(TraceCategory.Error(), "Parsing Hierarchy data failed: {0}", ex); TraceLogger.Flush(); } }
/// <summary> /// Check two page objects for equality /// </summary> /// <param name="obj">other page object</param> /// <returns>true if equal; false otherwise</returns> public override bool Equals(object obj) { TaggedPage tp = obj as TaggedPage; return(tp == null ? false : ID.Equals(tp.ID)); }