예제 #1
0
 internal TagEditorModel(OneNoteProxy onenote) : base(onenote)
 {
     _taggingScopes = new TaggingScopeDescriptor[] {
         new TaggingScopeDescriptor(TaggingScope.CurrentNote, Properties.Resources.TagEditor_ComboBox_Scope_CurrentNote),
         new TaggingScopeDescriptor(TaggingScope.SelectedNotes, Properties.Resources.TagEditor_ComboBox_Scope_SelectedNotes),
         new TaggingScopeDescriptor(TaggingScope.CurrentSection, Properties.Resources.TagEditor_ComboBox_Scope_CurrentSection),
     };
 }
        /// <summary>
        /// create a new instance of the view model.
        /// </summary>
        /// <param name="tp">a OneNote page object</param>
        /// <param name="highlighter">object to generate a highlight description of the link title</param>
        /// <param name="onenote">OneNote application object proxy</param>
        internal HitHighlightedPageLinkModel(TaggedPage tp, TextSplitter highlighter, OneNoteProxy onenote)
            : base(tp.Title, tp.ID)
        {
            IsSelected  = false;
            _page       = tp;
            _highlights = highlighter.SplitText(_page.Title);

            HitCount = _highlights.Count((f) => f.IsMatch);
            _onenote = onenote;
        }
        internal FindTaggedPagesModel(OneNoteProxy onenote) : base(onenote)
        {
            _searchResult = new FilterablePageCollection(OneNoteApp);
            _searchResult.Tags.CollectionChanged          += HandleTagCollectionChanges;
            _searchResult.FilteredPages.CollectionChanged += HandlePageCollectionChanges;

            CurrentPageTitle = Properties.Resources.TagSearch_CheckBox_Tracking_Text;
            // load the search history
            if (!string.IsNullOrEmpty(Properties.Settings.Default.SearchHistory))
            {
                string[] searches = Properties.Settings.Default.SearchHistory.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < searches.Length && i < Properties.Settings.Default.SearchHistory_Size; i++)
                {
                    SearchHistory.Add(searches[i].Trim());
                }
            }
        }
예제 #4
0
        internal OneNotePageProxy(OneNoteProxy onenoteApp, string pageID)
        {
            _onenote = onenoteApp;
            PageID   = pageID;
            LoadOneNotePage();
            var tagset = new HashSet <string>();

            // collect tags from various sources on the page
            if (_meta != null)    // the meta tags
            {
                foreach (string t in ParseTags(_meta.Attribute("content").Value))
                {
                    tagset.Add(t);
                }
            }

            if (_markerTagDef != null && "99".Equals(_markerTagDef.Attribute("type").Value))   // use the in-title tag
            {
                foreach (string t in ParseTags(_markerTagDef.Attribute("name").Value))
                {
                    tagset.Add(t);
                }
            }

            // get all tag definitions which could be page tags from.
            var indexmap = new Dictionary <string, XElement>();

            foreach (XElement tagDef in from td in _page.Elements(_one.GetName("TagDef"))
                     where "0".Equals(td.Attribute("symbol").Value)
                     select td)
            {
                indexmap[tagDef.Attribute("index").Value] = tagDef;
            }
            // get all the hidden title tags
            foreach (XElement t in _titleOE.Elements(_one.GetName("Tag")))
            {
                XElement tagdef;
                if (indexmap.TryGetValue(t.Attribute("index").Value, out tagdef))
                {
                    tagset.Add(tagdef.Attribute("name").Value);
                }
            }
            _originalTags = tagset.ToArray();
        }
예제 #5
0
        /// <summary>
        /// Tag a singe OneNote page
        /// </summary>
        /// <remarks>
        /// A tagged page is not saved immediately. The caller can hold on to a previously
        /// returned page and pass it into this method again. This avoids saving a page
        /// multiple times, if there are subsequent tagging jobs for the same page. If the
        /// ID of the page passed into this method does not match the ID of this job, the
        /// passed in page is saved.
        /// </remarks>
        /// <param name="onenote">OneNote application proxy object</param>
        /// <param name="page">   an unsaved OneNote page which has been tagged previously</param>
        /// <returns>Unsaved, tagged OneNote page.</returns>
        internal OneNotePageProxy Execute(OneNoteProxy onenote, OneNotePageProxy page)
        {
            if (page == null)
            {
                page = new OneNotePageProxy(onenote, _pageid);
                if (page.IsDeleted)
                {
                    return(null);
                }
            }
            else if (!_pageid.Equals(page.PageID))
            {  // cannot continue with the given page
                page.Update();
                page = new OneNotePageProxy(onenote, _pageid);
            }
            HashSet <string> pagetags = new HashSet <string>(page.PageTags);

            int countBefore = pagetags.Count;

            switch (_op)
            {
            case TagOperation.SUBTRACT:
                pagetags.ExceptWith(_tags);
                break;

            case TagOperation.UNITE:
                pagetags.UnionWith(_tags);
                break;

            case TagOperation.REPLACE:
                pagetags.Clear();
                pagetags.UnionWith(_tags);
                break;
            }
            if ((pagetags.Count != countBefore) || _op == TagOperation.REPLACE)
            {
                string[] sortedTags = pagetags.ToArray();
                Array.Sort <string>(sortedTags, (x, y) => string.Compare(x, y, true));

                page.PageTags = sortedTags;
            }
            return(page);
        }
예제 #6
0
 internal OneNotePageProxy(OneNoteProxy onenoteApp, string pageID)
 {
     _onenote = onenoteApp;
     PageID   = pageID;
     LoadOneNotePage();
     if (_pageTagsOE != null)
     {
         if (_meta != null)
         {
             _originalTags = ParseTags(_meta.Attribute("content").Value);
         }
         else
         {
             _originalTags = ParseTags(_pageTagsOE.Value);
         }
     }
     if (_originalTags == null)
     {
         _originalTags = new string[0];
     }
 }
예제 #7
0
 /// <summary>
 /// Initialize this base class
 /// </summary>
 /// <param name="app">OneNote application object</param>
 protected WindowViewModelBase(OneNoteProxy app)
 {
     OneNoteApp = app;
 }
예제 #8
0
 /// <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);
 }
예제 #9
0
 /// <summary>
 /// Create a new instance of a background page tagger.
 /// </summary>
 /// <param name="onenote">OneNote application proxy object</param>
 public BackgroundTagger(OneNoteProxy onenote)
 {
     _onenote = onenote;
     _cancel  = new CancellationTokenSource();
 }
예제 #10
0
 /// <summary>
 /// Create a new instance of the tag collection
 /// </summary>
 /// <param name="onenote">OneNote application object</param>
 internal TagsAndPages(OneNoteProxy onenote)
 {
     _onenote = onenote;
 }
예제 #11
0
 internal RelatedPagesModel(OneNoteProxy app) : base(app)
 {
     _taggedPagesCollection = new TagsAndPages(OneNoteApp);
 }
예제 #12
0
 internal FilterablePageCollection(OneNoteProxy onenote) : base(onenote)
 {
 }
예제 #13
0
 internal AggregatedPageCollection(OneNoteProxy onenote)
     : base(onenote)
 {
     _aggregationTags.CollectionChanged += OnTagsCollectionChanged;
 }