Esempio n. 1
0
        /// <summary>
        /// Handle the connection to the OneNote application.
        /// </summary>
        /// <param name="app">        The instance of OneNote which added the add-in</param>
        /// <param name="ConnectMode">
        /// Enumeration value that indicates the way the add-in was loaded.
        /// </param>
        /// <param name="AddInInst">  Reference to the add-in's own instance</param>
        /// <param name="custom">
        /// An empty array that you can use to pass host-specific data for use in the add-in
        /// </param>
        public void OnConnection(object app, ext_ConnectMode ConnectMode, object AddInInst, ref Array custom)
        {
            try {
                TraceLogger.Log(TraceCategory.Info(), "Connection mode '{0}'", ConnectMode);

                _onProxy       = new OneNoteProxy(app as Microsoft.Office.Interop.OneNote.Application);
                _dialogmanager = new AddInDialogManager();
                TraceLogger.Flush();
            } catch (Exception ex) {
                TraceLogger.Log(TraceCategory.Error(), "Connecting {0} failed: {1}", Properties.Resources.TaggingKit_About_Appname, ex);
                TraceLogger.Flush();
                throw;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Occurs whenever OneNote shuts down while an add-in is running.
        /// </summary>
        /// <param name="custom">
        /// An empty array that you can use to pass host-specific data for use in the add-in.
        /// </param>
        public void OnBeginShutdown(ref Array custom)
        {
            TraceLogger.Log(TraceCategory.Info(), "Beginning {0} shutdown; Arguments '{1}'", Properties.Resources.TaggingKit_About_Appname, custom);
            if (_dialogmanager != null)
            {
                _dialogmanager.Dispose();
                _dialogmanager = null;
            }

            if (_onProxy != null)
            {
                _onProxy.Dispose();
                _onProxy = null;
            }
        }
Esempio n. 3
0
 /// <summary>
 /// handle disconnection of the OneNote application.
 /// </summary>
 /// <param name="RemoveMode">
 /// Enumeration value that informs an add-in why it was unloaded
 /// </param>
 /// <param name="custom">
 /// An empty array that you can use to pass host-specific data for use after the
 /// add-in unloads.
 /// </param>
 public void OnDisconnection(ext_DisconnectMode RemoveMode, ref Array custom)
 {
     TraceLogger.Log(TraceCategory.Info(), "Disconnecting; mode='{0}'; Arguments: '{1}'", RemoveMode, custom);
     if (_dialogmanager != null)
     {
         _dialogmanager.Dispose();
         _dialogmanager = null;
     }
     Trace.Flush();
     GC.Collect();
     GC.WaitForPendingFinalizers();
     if (RemoveMode == ext_DisconnectMode.ext_dm_HostShutdown ||
         RemoveMode == ext_DisconnectMode.ext_dm_UserClosed)
     {
         // a dirty hack to make sure the ddlhost shuts down after an exception
         // occurred. This is necessary to allow the add-in to be loaded
         // successfully next time OneNote starts (a zombie dllhost would prevent that)
         TraceLogger.Log(TraceCategory.Info(), "Forcing COM Surrogate shutdown");
         Trace.Flush();
         Environment.Exit(0);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Action to open a tag management dialog.
 /// </summary>
 /// <param name="ribbon"></param>
 public void manageTags(IRibbonControl ribbon)
 {
     TraceLogger.Log(TraceCategory.Info(), "Show settings editor");
     AddInDialogManager.ShowDialog <TagManager, TagManagerModel>(() => new TagManagerModel(_onProxy));
 }