/// <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; } }
/// <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; } }