internal int EnqueuePagesForTagging(TagOperation op) { // bring suggestions up-to-date with new tags that may have been entered TagSuggestions.AddAll(from t in _pageTags where !TagSuggestions.ContainsKey(t.Key) select new HitHighlightedTagButtonModel() { TagName = t.TagName }); TagSuggestions.Save(); // covert scope to context TagContext ctx; switch (Scope) { default: case TaggingScope.CurrentNote: ctx = TagContext.CurrentNote; break; case TaggingScope.SelectedNotes: ctx = TagContext.SelectedNotes; break; case TaggingScope.CurrentSection: ctx = TagContext.CurrentSection; break; } IEnumerable <string> pageIDs = null; if (ScopesEnabled) { TagsAndPages tc = new TagsAndPages(OneNoteApp); tc.LoadPageTags(ctx); pageIDs = tc.Pages.Select(p => p.Key); } else { pageIDs = PagesToTag; } int enqueuedPages = 0; string[] pageTags = (from t in _pageTags.Values select t.TagName).ToArray(); foreach (string pageID in pageIDs) { OneNoteApp.TaggingService.Add(new TaggingJob(pageID, pageTags, op)); enqueuedPages++; } TraceLogger.Log(TraceCategory.Info(), "{0} page(s) enqueued for tagging with '{1}' using {2}", enqueuedPages, string.Join(";", pageTags), op); TraceLogger.Flush(); return(enqueuedPages); }
private IEnumerable <TagPageSet> GetContextTagsAction(TagContext filter, TagsAndPages tagSource) { tagSource.LoadPageTags(filter); if (filter == TagContext.SelectedNotes) { HashSet <TagPageSet> tags = new HashSet <TagPageSet>(); foreach (var p in (from pg in tagSource.Pages where pg.Value.IsSelected select pg.Value)) { tags.UnionWith(p.Tags); } return(tags); } return(tagSource.Tags.Values); }
private void TrackCurrentPage(object state) { if (!_currentPageID.Equals(OneNoteApp.CurrentPageID)) { _currentPageID = OneNoteApp.CurrentPageID; TagsAndPages tap = new TagsAndPages(OneNoteApp); tap.LoadPageTags(TagContext.CurrentNote); TaggedPage tp = tap.Pages.Values.FirstOrDefault(); if (tp != null) { Dispatcher.Invoke(() => { CurrentTags = from t in tp.Tags select t.TagName; CurrentPageTitle = tp.Title; }); } } }