public void OnDisconnection(ext_DisconnectMode RemoveMode, ref Array custom) { //OneNoteApplication = null; oneNoteProvider = null; GC.Collect(); GC.WaitForPendingFinalizers(); }
public OneNoteNavigationProvider( OneNoteProvider oneNoteProvider, INotebookIterator notebookIterator, ITrackingDbContext dbContext) : base(dbContext) { Parameters = new OneNoteNavigationProviderParameters(); this.oneNoteProvider = oneNoteProvider; this.notebookIterator = notebookIterator; }
/// <summary> /// Cleanup /// </summary> /// <param name="custom"></param> public void OnBeginShutdown(ref Array custom) { //this.mainForm?.Invoke(new Action(() => //{ // // close the form on the forms thread // this.mainForm?.Close(); // this.mainForm = null; //})); oneNoteProvider = null; }
public void Pages() { // Arrange var oneNoteProvider = new OneNoteProvider(); // Act var pages = oneNoteProvider.PageItems; // Arrange Assert.IsTrue(pages.Count() > 0); }
public void Notebooks() { // Arrange var oneNoteProvider = new OneNoteProvider(); // Act var notebooks = oneNoteProvider.NotebookItems; // Arrange Assert.IsTrue(notebooks.Count() > 0); }
/// <summary> /// Called upon startup. /// Keeps a reference to the current OneNote application object. /// </summary> /// <param name="application"></param> /// <param name="connectMode"></param> /// <param name="addInInst"></param> /// <param name="custom"></param> public void OnConnection(object Application, ext_ConnectMode ConnectMode, object AddInInst, ref Array custom) { //SetOneNoteApplication((Application)Application); try { //MessageBox.Show("Going in!"); oneNoteProvider = new OneNoteProvider(); //MessageBox.Show("JTools OnConnection successful", "JTools AddIn", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception e) { MessageBox.Show(string.Format("Error in JTools onConnection: {0}", e.Message), "JTools AddIn", MessageBoxButtons.OK, MessageBoxIcon.Error); LogAction(string.Format("Error in JTools onConnection: {0}", e.Message)); } }
/// <summary> /// Return a filtered list, based on the given query /// </summary> /// <param name="query">The query to filter the list</param> /// <param name="delayedExecution">False if this is the first pass through plugins, true otherwise. Slow plugins should run delayed.</param> /// <returns>A filtered list, can be empty when nothing was found</returns> public List <Result> Query(Query query, bool delayedExecution) { if (!delayedExecution || !_oneNoteInstalled || query is null || string.IsNullOrWhiteSpace(query.Search) || _cache is null) { return(new List <Result>(0)); } // Get results from cache if they already exist for this query, otherwise query OneNote. Results will be cached for 1 day. var results = _cache.GetOrAdd(query.Search, () => { var pages = OneNoteProvider.FindPages(query.Search); return(pages.Select(p => new Result { IcoPath = _iconPath, Title = p.Name, QueryTextDisplay = p.Name, SubTitle = @$ "{p.Notebook.Name}\{p.Section.Name}", Action = (_) => OpenPageInOneNote(p), ContextData = p, ToolTipData = new ToolTipData(Name, @$ "{p.Notebook.Name}\{p.Section.Name}\{p.Name}"),
/// <summary> /// Return a filtered list, based on the given query /// </summary> /// <param name="query">The query to filter the list</param> /// <returns>A filtered list, can be empty when nothing was found</returns> public List <Result> Query(Query query) { if (!_oneNoteInstalled || query is null || string.IsNullOrWhiteSpace(query.Search)) { return(new List <Result>(0)); } var pages = OneNoteProvider.FindPages(query.Search); return(pages.Select(p => new Result { IcoPath = _iconPath, Title = p.Name, QueryTextDisplay = p.Name, SubTitle = @$ "{p.Notebook.Name}\{p.Section.Name}", Action = (_) => { p.OpenInOneNote(); ShowOneNote(); return true; }, ContextData = p, ToolTipData = new ToolTipData(Name, @$ "{p.Notebook.Name}\{p.Section.Name}\{p.Name}"),