internal int EnqueuePagesForTagging(TagOperation op, TaggingScope scope) { // 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(); TagsAndPages tc = new TagsAndPages(OneNoteApp); // 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; } tc.LoadPageTags(ctx); string[] pageTags = (from t in _pageTags.Values select t.TagName).ToArray(); int enqueuedPages = 0; foreach (string pageID in (from p in tc.Pages select p.Key)) { 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 void ApplyPageTags(TagOperation op) { tagInput.FocusInput(); try { TaggingScope scope = ((TaggingScopeDescriptor)taggingScope.SelectedItem).Scope; int pagesTagged = _model.EnqueuePagesForTagging(op, scope); taggingScope.SelectedIndex = 0; tagInput.Clear(); suggestedTags.Highlighter = new TextSplitter(); suggestedTags.Notification = pagesTagged == 0 ? Properties.Resources.TagEditor_Popup_NothingTagged : string.Format(Properties.Resources.TagEditor_Popup_TaggingInProgress, pagesTagged); } catch (Exception xe) { TraceLogger.Log(TraceCategory.Error(), "Applying tags to page failed: {0}", xe); TraceLogger.ShowGenericErrorBox(Properties.Resources.TagEditor_TagUpdate_Error, xe); } }
internal TaggingScopeDescriptor(TaggingScope scope, string label) { Scope = scope; Label = label; }