/// <summary> /// Create a new instance of a design time view model /// </summary> public FindTaggedPagesDesignerModel() { _scopes = new List <SearchScopeFacade> { new SearchScopeFacade() { Scope = SearchScope.AllNotebooks, ScopeLabel = "All Notebooks" }, new SearchScopeFacade() { Scope = SearchScope.Notebook, ScopeLabel = "Notebooks" } }; _selectedScope = _scopes[0]; TagsAndPages c = new TagsAndPages(null); c.ExtractTags(XDocument.Parse(_strXml), false); TextSplitter splitter = new TextSplitter("Cool"); _pages.AddAll(from TaggedPage tp in c.Pages.Values select new HitHighlightedPageLinkModel(tp, splitter, null)); _tags.AddAll(from t in c.Tags.Values select new TagSelectorModel(t)); }
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; }); } } }
/// <summary> /// Create a new instance of the view model backing the <see cref="TagManager" /> dialog. /// </summary> /// <param name="onenote">OneNote application object</param> internal TagManagerModel(OneNoteProxy onenote) : base(onenote) { _tags = new TagsAndPages(OneNoteApp); }
private Task <IEnumerable <TagPageSet> > GetContextTagsAsync(TagContext filter) { TagsAndPages tagSource = ContextTagsSource; // must be assigned here to avoid access from another thread return(Task <IEnumerable <TagPageSet> > .Run(() => { return GetContextTagsAction(filter, tagSource); })); }
internal RelatedPagesModel(OneNoteProxy app) : base(app) { _taggedPagesCollection = new TagsAndPages(OneNoteApp); }