/// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. /// Receives notification that the Add-in is being loaded. /// </summary> /// <param term='application'> /// Root object of the host application. /// </param> /// <param term='connectMode'> /// Describes how the Add-in is being loaded. /// </param> /// <param term='addInInst'> /// Object representing this Add-in. /// </param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { if (!(application is PowerPoint.Application)) throw new ArgumentException("must be a PowerPoint Application object.. perhaps you are running the add-in with the wrong application?", "application"); // Start PPT. this.myPPT = new PPTLibrary.PPT((PowerPoint.Application)application); this.myPPT.CloseOnExit = PPTLibrary.PPT.CloseConditions.Never; // I don't trust PPT objects to close PowerPoint correctly. this.myPaneManager = new PPTPaneManagement.PPTPaneManager(this.myPPT); this.myDeckBuilder = new PPTDeckBuilder.PPTDeckBuilder(this.myPPT, this.myPaneManager); applicationObject = application; addInInstance = addInInst; }
/// <summary> /// Implements the OnDisconnection method of the IDTExtensibility2 interface. /// Receives notification that the Add-in is being unloaded. /// </summary> /// <param term='disconnectMode'> /// Describes how the Add-in is being unloaded. /// </param> /// <param term='custom'> /// Array of parameters that are host application specific. /// </param> /// <seealso class='IDTExtensibility2' /> public void OnDisconnection(Extensibility.ext_DisconnectMode disconnectMode, ref System.Array custom) { if (this.myPaneManager != null) this.myPaneManager.Hide(); this.myPaneManager = null; this.myDeckBuilder = null; this.myPPT = null; }