/// ------------------------------------------------------------------------------------ /// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. /// Receives notification that the Add-in is being loaded. /// </summary> /// <param name="application">The application.</param> /// <param name="connectMode">The connect mode.</param> /// <param name="addInInst">The add in inst.</param> /// <param name="custom">The custom.</param> /// <seealso class="IDTExtensibility2"/> /// ------------------------------------------------------------------------------------ public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { try { CheckForUpdates(); m_dte = (DTE2)application; m_nantCommands = new CmdHandler(); m_nantCommands.DTE = m_dte; m_addInInstance = (AddIn)addInInst; EnvDTE.Events events = DTE.Events; OutputWindow outputWindow = (OutputWindow)DTE.Windows.Item(Constants.vsWindowKindOutput).Object; m_solutionEvents = (EnvDTE.SolutionEvents)events.SolutionEvents; // Get the commands of the Build group RegisterCommandHandler(882, // build solution new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnBuildSolution)); RegisterCommandHandler(883, // rebuild solution new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnBuildSolution)); RegisterCommandHandler(886, // build project new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnBuildProject)); RegisterCommandHandler(887, // rebuild project new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnBuildProject)); RegisterCommandHandler(890, // Build Cancel new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnBuildCancel)); RegisterCommandHandler(892, // build project (from context menu) new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnBuildProject)); RegisterCommandHandler(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++) { RegisterCommandHandler(i, new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnBuildProject)); } RegisterCommandHandler(295, // Debug Start new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnDebugStart)); RegisterCommandHandler(356, // Debug/Start new instance (from context menu) new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnDebugStart)); RegisterCommandHandler(368, // Debug Start without debugging new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnDebugStartWithoutDebugging)); // RegisterCommandHandler(248, // Debug Step into // new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnDebugStepInto)); // RegisterCommandHandler(357, // Debug Step into (from context menu) // new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnDebugStepInto)); // RegisterCommandHandler(249, // Debug Step over // new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnDebugStepOver)); // RegisterCommandHandler(251, // Debug Run to cursor // new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnDebugRunToCursor)); // TODO: need to handle 891 Batch build! m_buildEvents = (EnvDTE.BuildEvents)events.BuildEvents; m_solutionEvents.Opened += new _dispSolutionEvents_OpenedEventHandler(Opened); m_solutionEvents.ProjectAdded += new _dispSolutionEvents_ProjectAddedEventHandler(OnProjectAdded); m_buildEvents.OnBuildBegin += new _dispBuildEvents_OnBuildBeginEventHandler(OnBuildBegin); // try to add the commands AddToolbar(); } catch (Exception e) { System.Diagnostics.Debug.WriteLine("Got exception: " + e.Message); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Removes the toolbar. /// </summary> /// ------------------------------------------------------------------------------------ private void RemoveToolbar() { try { SaveToolbarSettings(); if (m_nantCommands != null) { if (m_btnEnableAddin != null) { m_btnEnableAddin.Delete(true); m_btnEnableAddin = null; } if (m_btnCancel != null) { m_btnCancel.Delete(true); m_btnCancel = null; } if (m_btnClean != null) { m_btnClean.Delete(true); m_btnClean = null; } if (m_btnTest != null) { m_btnTest.Delete(true); m_btnTest = null; } if (m_btnForceTests != null) { m_btnForceTests.Delete(true); m_btnForceTests = null; } if (m_btnNodep != null) { m_btnNodep.Delete(true); m_btnNodep = null; } if (m_nantCommands.m_cmbBuild != null) { m_nantCommands.m_cmbBuild.Delete(true); m_nantCommands.m_cmbBuild = null; } if (m_btnStartBuild != null) { m_btnStartBuild.Delete(true); m_btnStartBuild = null; } m_nantCommands.Dispose(); } m_nantCommands = null; DeleteToolbar(); } catch (Exception e) { #if DEBUG // m_nantCommands.OutputBuildDebug.WriteLine("Got exception in RemoveToolbar:" + e.Message); System.Diagnostics.Debug.WriteLine("Got exception in RemoveToolbar:" + e.Message); #endif } m_cmdBar = null; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. /// Receives notification that the Add-in is being loaded. /// </summary> /// <param name="application">The application.</param> /// <param name="connectMode">The connect mode.</param> /// <param name="addInInst">The add in inst.</param> /// <param name="custom">The custom.</param> /// <seealso class="IDTExtensibility2"/> /// ------------------------------------------------------------------------------------ public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { try { CheckForUpdates(); m_dte = (DTE2)application; m_nantCommands = new CmdHandler(); m_nantCommands.DTE = m_dte; m_addInInstance = (AddIn)addInInst; EnvDTE.Events events = DTE.Events; OutputWindow outputWindow = (OutputWindow)DTE.Windows.Item(Constants.vsWindowKindOutput).Object; m_solutionEvents = (EnvDTE.SolutionEvents)events.SolutionEvents; // Get the commands of the Build group RegisterCommandHandler(882, // build solution new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnBuildSolution)); RegisterCommandHandler(883, // rebuild solution new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnBuildSolution)); RegisterCommandHandler(886, // build project new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnBuildProject)); RegisterCommandHandler(887, // rebuild project new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnBuildProject)); RegisterCommandHandler(890, // Build Cancel new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnBuildCancel)); RegisterCommandHandler(892, // build project (from context menu) new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnBuildProject)); RegisterCommandHandler(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++) { RegisterCommandHandler(i, new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnBuildProject)); } RegisterCommandHandler(295, // Debug Start new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnDebugStart)); RegisterCommandHandler(356, // Debug/Start new instance (from context menu) new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnDebugStart)); RegisterCommandHandler(368, // Debug Start without debugging new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnDebugStartWithoutDebugging)); // RegisterCommandHandler(248, // Debug Step into // new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnDebugStepInto)); // RegisterCommandHandler(357, // Debug Step into (from context menu) // new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnDebugStepInto)); // RegisterCommandHandler(249, // Debug Step over // new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnDebugStepOver)); // RegisterCommandHandler(251, // Debug Run to cursor // new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnDebugRunToCursor)); // TODO: need to handle 891 Batch build! m_buildEvents = (EnvDTE.BuildEvents)events.BuildEvents; m_solutionEvents.Opened += new _dispSolutionEvents_OpenedEventHandler(Opened); m_solutionEvents.ProjectAdded += new _dispSolutionEvents_ProjectAddedEventHandler(OnProjectAdded); m_buildEvents.OnBuildBegin += new _dispBuildEvents_OnBuildBeginEventHandler(OnBuildBegin); // try to add the commands AddToolbar(); } catch(Exception e) { System.Diagnostics.Debug.WriteLine("Got exception: " + e.Message); } }