Exemple #1
0
        public void OnDisconnection(Extensibility.ext_DisconnectMode disconnectMode, ref System.Array custom)
        {
            this.logger.WriteLine("OnDisconnection: Begin");

            if (disconnectMode != Extensibility.ext_DisconnectMode.ext_dm_HostShutdown)
            {
                OnBeginShutdown(ref custom);
            }

            GC.WaitForPendingFinalizers();
            GC.Collect();

            try
            {
                this.objOutlook    = null;
                this.addInInstance = null;

                GC.WaitForPendingFinalizers();
                GC.Collect();
            }
            catch (Exception ex)
            {
                this.logger.WriteLine("OnDisconnection (1): Exception");
                this.logger.WriteLine(ex.Message);
                this.logger.WriteLine(ex.StackTrace);
            }

            GC.WaitForPendingFinalizers();
            GC.Collect();

            this.logger.WriteLine("OnDisconnection: End");
            this.logger.Dispose();
        }
Exemple #2
0
 /// <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)
 {
     try
     {
         if (disconnectMode != Extensibility.ext_DisconnectMode.ext_dm_HostShutdown)
         {
             OnBeginShutdown(ref custom);
         }
         if (ContactsFolder != null)
         {
             // Unregister Events
             // ContactsFolder.Items.ItemAdd -= new Microsoft.Office.Interop.Outlook.ItemsEvents_ItemAddEventHandler(Items_ItemAdd);
             // Release Reference to COM Object
             ContactsFolder = null;
         }
         myAddInInstance     = null;
         myApplicationObject = null;
     }
     catch (System.Exception ex)
     {
         logger.Error(ex.Message);
         logger.Debug(ex.StackTrace.ToString());
         MessageBox.Show(ex.Message);
     }
 }
 public void OnDisconnection(Extensibility.ext_DisconnectMode disconnectMode, ref System.Array custom)
 {
     if (disconnectMode != Extensibility.ext_DisconnectMode.ext_dm_HostShutdown)
     {
         OnBeginShutdown(ref custom);
     }
 }
Exemple #4
0
 /// <summary>
 ///  实现 IDTExtensibility2 接口的OnDisconnection 方法.
 ///  当外接程序被卸载时,接收通知.
 /// </summary>
 /// <param term='disconnectMode'>
 ///  描述外接程序正在被卸载的情况.
 /// </param>
 /// <param term='custom'>
 ///  宿主应用程序特定的参数的数组.
 /// </param>
 /// <seealso class='IDTExtensibility2' />
 public void OnDisconnection(Extensibility.ext_DisconnectMode disconnectMode,
                             ref System.Array custom)
 {
     MessageBox.Show("CSOneNoteRibbonAddIn OnDisconnection");
     this.applicationObject = null;
     GC.Collect();
     GC.WaitForPendingFinalizers();
 }
 /// <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 (disconnectMode != Extensibility.ext_DisconnectMode.ext_dm_HostShutdown)
     {
         OnBeginShutdown(ref custom); // call this method if the addin is disconnecting but ppt is not shutting down
     }
     applicationObject = null;
 }
        }         // end onConnection method

        /// <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 (disconnectMode != Extensibility.ext_DisconnectMode.ext_dm_HostShutdown)
            {
                OnBeginShutdown(ref custom);
            }
            applicationObject = null;
        }         // end OnDisconnection method
Exemple #7
0
 /// <summary>
 /// When we disconnect - remove everything - clean up
 /// </summary>
 /// <param name="disconnectMode"></param>
 /// <param name="custom"></param>
 public void OnDisconnection(Extensibility.ext_DisconnectMode disconnectMode, ref System.Array custom)
 {
     // clean up
     Marshal.ReleaseComObject(Application);
     Application = null;
     ThisAddIn   = null;
     GC.Collect();
     GC.Collect();
     GC.WaitForPendingFinalizers();
 }
Exemple #8
0
 /// <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)
 {
     try
     {
         //TODO: Disconnect the add-in
     }
     catch (System.Exception e)
     {
         Mindjet.Utility.HandleError(e);
     }
 }
Exemple #9
0
        /// <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 (disconnectMode != Extensibility.ext_DisconnectMode.ext_dm_HostShutdown)
            {
                Debug.WriteLine("OnDisconnection");

                if (button != null)
                {
                    try
                    {
                        // We must unhook the event delegate, otherwise we'd end up
                        // with multiple invocations if the user disconnects/reconnects
                        // the add-in.
                        button.Click -=
                            new _CommandBarButtonEvents_ClickEventHandler(button_Click);

                        // We must delete the button when the user disconnects the add-in
                        // during a session. We don't need to do this when the host shuts
                        // down because we create the button as temporary (so it gets
                        // deleted on shutdown anyway).

                        // Deleting the button works fine for most Office apps.
                        // However, there's a race condition in Word.
                        // Unhooking the event delegate always works, but _any_
                        // subsequent access to the button sometimes throws 0x800A01A8,
                        // regardless of whether or not a shim is used. The workaround
                        // is to get the button again so that we can delete it.

                        if (hostName == "Microsoft Word")
                        {
                            object missing = Type.Missing;
                            button = (CommandBarButton)
                                     bar.FindControl(MsoControlType.msoControlButton,
                                                     missing, buttonName, true, true);
                        }

                        // We do this for all Office hosts.
                        button.Delete(false);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }
            }
            else
            {
                Debug.WriteLine("OnDisconnection - ext_dm_HostShutdown");
            }
            applicationObject = null;
        }
Exemple #10
0
        public void OnDisconnection(Extensibility.ext_DisconnectMode RemoveMode, ref System.Array custom)
        {
            #region command bar
            m_pbControl.Delete();
            m_pbControlAlign.Delete();
            m_pbControlUOM.Delete();
            m_pbControlAlarm.Delete();
            m_pbControlReplace.Delete();
            m_pbControlSearch.Delete();
            m_pbControlScript.Delete();
            #endregion

            System.GC.Collect();
        }
Exemple #11
0
        /// <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)
        {
            addInInstance = null;
            PLACES.Destroy();
            MAPS.Destroy();
            PROJECTS.Destroy();
            ABOUT.Destroy();
            DocumentStorage.Destroy();
            MMUtils.MindManager = null;
            m_myTab.Delete();
            m_myTab = null;

            System.GC.Collect();
        }
Exemple #12
0
        /// <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)
        {
            Commands     commands        = applicationObject.Commands;
            _CommandBars commandBars     = applicationObject.CommandBars;
            CommandBar   cmdBarMonoBarra = (CommandBar)commandBars["MonoBarra"];

            try
            {
                cmdBarMonoBarra.Visible = false;
            }
            catch (Exception)
            {
            }
        }
 /// <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)
 {
     // Allow each of the components to unregister.
     foreach (IAddInCommand command in m_Commands)
     {
         try
         {
             command.OnDisconnection(m_applicationObject, disconnectMode, m_addInInstance);
         }
         catch (System.Exception e)
         {
             System.Diagnostics.Debug.WriteLine("Error: " + e.Message);
         }
     }
 }
Exemple #14
0
        void IDTExtensibility2.OnDisconnection(Extensibility.ext_DisconnectMode dmDisconnectMode, ref System.Array arrCustom)
        {
            // Remove command handlers
            _cmdevDebugStart.BeforeExecute -= new EnvDTE._dispCommandEvents_BeforeExecuteEventHandler(OnBeforeRun);
            _cmdevDebugStart.AfterExecute  -= new EnvDTE._dispCommandEvents_AfterExecuteEventHandler(OnAfterRun);
            _cmdevDebugStart = null;

            _cmdevNoDebugStart.BeforeExecute -= new EnvDTE._dispCommandEvents_BeforeExecuteEventHandler(OnBeforeRun);
            _cmdevNoDebugStart.AfterExecute  -= new EnvDTE._dispCommandEvents_AfterExecuteEventHandler(OnAfterRun);
            _cmdevNoDebugStart = null;

            _pApplication   = null;
            _pAddInInstance = null;

            _pf = null;
        }
Exemple #15
0
 public void OnDisconnection(Extensibility.ext_DisconnectMode disconnectMode, ref System.Array custom)
 {
     try
     {
         if (tachyThread != null)
         {
             stopTachyThreadProc = true;
             tachyThread.Interrupt();
             if (!tachyThread.Join(5000))
             {
                 tachyThread.Abort();
             }
         }
     }
     catch (System.Exception e)
     {
         MessageBox.Show(e.Message + "\r\n\r\n" + e.InnerException + "\r\n\r\n" + e.StackTrace);
     }
 }
Exemple #16
0
        /// <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 (logger != null)
            {
                logger.LogMessage("Disconnecting from Host Application");
            }

            if (disconnectMode !=
                ext_DisconnectMode.ext_dm_HostShutdown)
            {
                OnBeginShutdown(ref custom);
            }
            appOutlook = null;

            // we need to ensure all resources are released, otherwise, the primary process
            // will fail to exit.
            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
        /// <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)
        {
            // Allow each of the components to unregister.
            foreach (IAddInCommand command in m_Commands)
            {
                try
                {
                    command.OnDisconnection(m_applicationObject, disconnectMode, m_addInInstance);
                }
                catch (System.Exception e)
                {
                    System.Diagnostics.Debug.WriteLine("Error: " + e.Message);
                }
            }

            //Remove the Folder
//			try
//			{
//				((CommandBar)officeCommandBars["Assignment Manager &Faculty"]).Delete();
//			}
//			catch
//			{
//			}
        }
 public void OnDisconnection(Extensibility.ext_DisconnectMode RemoveMode, ref System.Array custom)
 {
 }
Exemple #19
0
 /// <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)
 {
     Debug.WriteLine("DemoAddin: OnDisconnection() method called");
 }
Exemple #20
0
 /// <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)
 {
     stopServer();
 }
 /// <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)
 {
     UnregisterEvents((Application)this.applicationObject);
 }
Exemple #22
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Implements the OnDisconnection method of the IDTExtensibility2 interface.
        /// Receives notification that the Add-in is being unloaded.
        /// </summary>
        /// <param name="disconnectMode">The disconnect mode.</param>
        /// <param name="custom">unused</param>
        /// <seealso class="IDTExtensibility2"/>
        /// ------------------------------------------------------------------------------------
        public void OnDisconnection(Extensibility.ext_DisconnectMode disconnectMode,
                                    ref System.Array custom)
        {
            RemoveToolbar();

            try
            {
                UnregisterCommandHandler(882,                 // build solution
                                         new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnBuildSolution));
                UnregisterCommandHandler(883,                 // rebuild solution
                                         new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnBuildSolution));
                UnregisterCommandHandler(886,                 // build project
                                         new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnBuildProject));
                UnregisterCommandHandler(887,                 // rebuild project
                                         new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnBuildProject));
                UnregisterCommandHandler(890,                 // Build Cancel
                                         new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnBuildCancel));
                UnregisterCommandHandler(892,                 // build project (from context menu)
                                         new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnBuildProject));
                UnregisterCommandHandler(893,                 // rebuild project (from context menu)
                                         new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnBuildProject));
                // 979-988 build project (from menu when no project item is selected)
                // 989-998 rebuild project (from menu when no project item is selected)
                for (int i = 979; i < 999; i++)
                {
                    UnregisterCommandHandler(i,
                                             new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnBuildProject));
                }
                UnregisterCommandHandler(295,                 // Debug Start
                                         new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnDebugStart));
                UnregisterCommandHandler(356,                 // Debug/Start new instance (from context menu)
                                         new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnDebugStart));
                UnregisterCommandHandler(368,                 // Debug Start without debugging
                                         new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnDebugStartWithoutDebugging));
//				UnregisterCommandHandler(248, // Debug Step into
//					new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnDebugStepInto));
//				UnregisterCommandHandler(357, // Debug Step into (from context menu)
//					new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnDebugStepInto));
//				UnregisterCommandHandler(249, // Debug Step over
//					new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnDebugStepOver));
//				UnregisterCommandHandler(251, // Debug Run to cursor
//					new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnDebugRunToCursor));

                if (m_solutionEvents != null)
                {
                    m_solutionEvents.Opened       -= new _dispSolutionEvents_OpenedEventHandler(Opened);
                    m_solutionEvents.ProjectAdded -= new _dispSolutionEvents_ProjectAddedEventHandler(OnProjectAdded);
                    m_solutionEvents = null;
                }
                if (m_buildEvents != null)
                {
                    m_buildEvents.OnBuildBegin -= new _dispBuildEvents_OnBuildBeginEventHandler(OnBuildBegin);
                    m_buildEvents = null;
                }
                m_commandHandler.Clear();
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(string.Format("Got exception: {0}", e.Message));
            }
        }
Exemple #23
0
 /// <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)
 {
     Debug.WriteLine("CodeModelWalker: Connect.OnDisconnection() called.");
 }
Exemple #24
0
 public void OnDisconnection(Extensibility.ext_DisconnectMode mode, ref System.Array custom)
 {
     events_.WindowActivated -= handler_;
 }
Exemple #25
0
 /// <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)
 {
     long a = 0;
 }