Esempio n. 1
0
        public void BindEvents()
        {
            EnvDTE.Events events = m_applicationObject.Events;

            m_solutionEvents = (EnvDTE.SolutionEvents)events.SolutionEvents;
            m_buildEvents    = (EnvDTE.BuildEvents)events.BuildEvents;
            m_dteEvents      = (EnvDTE.DTEEvents)events.DTEEvents;
            m_debuggerEvents = (EnvDTE.DebuggerEvents)events.DebuggerEvents;

            m_solutionEvents.AfterClosing       += new _dispSolutionEvents_AfterClosingEventHandler(this.AfterClosing);
            m_solutionEvents.BeforeClosing      += new _dispSolutionEvents_BeforeClosingEventHandler(this.BeforeClosing);
            m_solutionEvents.Opened             += new _dispSolutionEvents_OpenedEventHandler(this.Opened);
            m_solutionEvents.ProjectAdded       += new _dispSolutionEvents_ProjectAddedEventHandler(this.ProjectAdded);
            m_solutionEvents.ProjectRemoved     += new _dispSolutionEvents_ProjectRemovedEventHandler(this.ProjectRemoved);
            m_solutionEvents.ProjectRenamed     += new _dispSolutionEvents_ProjectRenamedEventHandler(this.ProjectRenamed);
            m_solutionEvents.QueryCloseSolution += new _dispSolutionEvents_QueryCloseSolutionEventHandler(this.QueryCloseSolution);
            m_solutionEvents.Renamed            += new _dispSolutionEvents_RenamedEventHandler(this.Renamed);

            m_buildEvents.OnBuildBegin           += new _dispBuildEvents_OnBuildBeginEventHandler(this.OnBuildBegin);
            m_buildEvents.OnBuildDone            += new _dispBuildEvents_OnBuildDoneEventHandler(this.OnBuildDone);
            m_buildEvents.OnBuildProjConfigBegin += new _dispBuildEvents_OnBuildProjConfigBeginEventHandler(this.OnBuildProjConfigBegin);
            m_buildEvents.OnBuildProjConfigDone  += new _dispBuildEvents_OnBuildProjConfigDoneEventHandler(this.OnBuildProjConfigDone);

            m_dteEvents.ModeChanged += new _dispDTEEvents_ModeChangedEventHandler(this.DTEModeChanged);

            m_debuggerEvents.OnEnterRunMode    += new _dispDebuggerEvents_OnEnterRunModeEventHandler(DebuggerOnEnterRunMode);
            m_debuggerEvents.OnEnterDesignMode += new _dispDebuggerEvents_OnEnterDesignModeEventHandler(DebuggerOnEnterDesignMode);
        }
Esempio n. 2
0
 public void UnbindEvents()
 {
     if (m_solutionEvents != null)
     {
         m_solutionEvents.AfterClosing       -= new _dispSolutionEvents_AfterClosingEventHandler(this.AfterClosing);
         m_solutionEvents.BeforeClosing      -= new _dispSolutionEvents_BeforeClosingEventHandler(this.BeforeClosing);
         m_solutionEvents.Opened             -= new _dispSolutionEvents_OpenedEventHandler(this.Opened);
         m_solutionEvents.ProjectAdded       -= new _dispSolutionEvents_ProjectAddedEventHandler(this.ProjectAdded);
         m_solutionEvents.ProjectRemoved     -= new _dispSolutionEvents_ProjectRemovedEventHandler(this.ProjectRemoved);
         m_solutionEvents.ProjectRenamed     -= new _dispSolutionEvents_ProjectRenamedEventHandler(this.ProjectRenamed);
         m_solutionEvents.QueryCloseSolution -= new _dispSolutionEvents_QueryCloseSolutionEventHandler(this.QueryCloseSolution);
         m_solutionEvents.Renamed            -= new _dispSolutionEvents_RenamedEventHandler(this.Renamed);
         m_solutionEvents = null;
     }
     if (m_buildEvents != null)
     {
         m_buildEvents.OnBuildBegin           -= new _dispBuildEvents_OnBuildBeginEventHandler(this.OnBuildBegin);
         m_buildEvents.OnBuildDone            -= new _dispBuildEvents_OnBuildDoneEventHandler(this.OnBuildDone);
         m_buildEvents.OnBuildProjConfigBegin -= new _dispBuildEvents_OnBuildProjConfigBeginEventHandler(this.OnBuildProjConfigBegin);
         m_buildEvents.OnBuildProjConfigDone  -= new _dispBuildEvents_OnBuildProjConfigDoneEventHandler(this.OnBuildProjConfigDone);
         m_buildEvents = null;
     }
     if (m_dteEvents != null)
     {
         m_dteEvents.ModeChanged -= new _dispDTEEvents_ModeChangedEventHandler(this.DTEModeChanged);
         m_dteEvents              = null;
     }
     if (m_debuggerEvents != null)
     {
         m_debuggerEvents.OnEnterRunMode    -= new _dispDebuggerEvents_OnEnterRunModeEventHandler(DebuggerOnEnterRunMode);
         m_debuggerEvents.OnEnterDesignMode -= new _dispDebuggerEvents_OnEnterDesignModeEventHandler(DebuggerOnEnterDesignMode);
         m_debuggerEvents = null;
     }
 }
Esempio n. 3
0
        public MyControlViewModel()
        {
            // Subscribe to the options updated event
            Singleton.GetObject().OptionsUpdatedEvent += MyControlViewModel_OptionsUpdatedEvent;

            tfsController = new TFSItemController();

            // Sign up for solution events
            DTE dte = Common.GetApplicationReference();

            solutionEvents               = ((Events)dte.Events).SolutionEvents;
            solutionEvents.Opened       += solutionEvents_Opened;
            solutionEvents.AfterClosing += solutionEvents_AfterClosing;

            // Initially filter is empty
            searchText = "";

            // Setup the background worker for running the slower code
            FileLoadingWorker = new BackgroundWorker();
            FileLoadingWorker.WorkerSupportsCancellation = true;
            FileLoadingWorker.DoWork += FileLoadingWorker_DoWork;

            if (!tfsController.Connected)
            {
                return;
            }

            ReadFilesFromPath();
        }
Esempio n. 4
0
        /// <summary>
        /// Occurs whenever an add-in, which is set to load when Visual Studio starts, loads.
        /// </summary>
        /// <param name="custom">An empty array that you can use to pass host-specific data for use when the add-in loads.</param>
        void IDTExtensibility2.OnStartupComplete(ref Array custom)
        {
            this.solutionEvents = dte.Events.SolutionEvents;

            this.hOpened = new _dispSolutionEvents_OpenedEventHandler(SolutionEvents_Opened);// 为什么要这样?

            this.solutionEvents.Opened += this.hOpened;
        }
        private void AddApplicationObjectHandlers(EnvDTE80.DTE2 _applicationObject)
        {
            // Setup all the solution events
            solutionEvents = (EnvDTE.SolutionEvents)_applicationObject.Events.SolutionEvents;
            solutionEvents.BeforeClosing += new _dispSolutionEvents_BeforeClosingEventHandler(solutionEvents_BeforeClosing);
            solutionEvents.Opened        += new _dispSolutionEvents_OpenedEventHandler(solutionEvents_Opened);

            // Setup all text editor events
            textEditorEvents              = (EnvDTE.TextEditorEvents)_applicationObject.Events.TextEditorEvents;
            textEditorEvents.LineChanged += new _dispTextEditorEvents_LineChangedEventHandler(textEditorEvents_LineChanged);

            // Setup all window events
            windowEvents = (EnvDTE.WindowEvents)_applicationObject.Events.WindowEvents;
            windowEvents.WindowActivated += new _dispWindowEvents_WindowActivatedEventHandler(windowEvents_WindowActivated);
        }
        public VisualStudioHelper(CmdArgsPackage package)
        {
            this.package = package;
            this.appObject = package.GetService<SDTE, EnvDTE.DTE>();

            // see: https://support.microsoft.com/en-us/kb/555430
            this.solutionEvents = this.appObject.Events.SolutionEvents;
            this.commandEvents = this.appObject.Events.CommandEvents;

            this.solutionEvents.Opened += SolutionEvents_Opened;
            this.solutionEvents.AfterClosing += SolutionEvents_AfterClosing;
            this.solutionEvents.BeforeClosing += SolutionEvents_BeforeClosing;
            this.solutionEvents.ProjectAdded += SolutionEvents_ProjectAdded;
            this.solutionEvents.ProjectRemoved += SolutionEvents_ProjectRemoved;
            this.solutionEvents.ProjectRenamed += SolutionEvents_ProjectRenamed;
        }
        public VisualStudioHelper(CmdArgsPackage package)
        {
            this.package   = package;
            this.appObject = package.GetService <SDTE, EnvDTE.DTE>();

            // see: https://support.microsoft.com/en-us/kb/555430
            this.solutionEvents = this.appObject.Events.SolutionEvents;
            this.commandEvents  = this.appObject.Events.CommandEvents;

            this.solutionEvents.Opened         += SolutionEvents_Opened;
            this.solutionEvents.AfterClosing   += SolutionEvents_AfterClosing;
            this.solutionEvents.BeforeClosing  += SolutionEvents_BeforeClosing;
            this.solutionEvents.ProjectAdded   += SolutionEvents_ProjectAdded;
            this.solutionEvents.ProjectRemoved += SolutionEvents_ProjectRemoved;
            this.solutionEvents.ProjectRenamed += SolutionEvents_ProjectRenamed;
        }
Esempio n. 8
0
        public AddInEventHandler(DTE _dte)
        {
            simpleThreadMessenger = new SimpleThreadMessenger(this);
            dte = _dte;
            var events = dte.Events as Events;

            buildEvents = (EnvDTE.BuildEvents)events.BuildEvents;
            buildEvents.OnBuildBegin           += new _dispBuildEvents_OnBuildBeginEventHandler(buildEvents_OnBuildBegin);
            buildEvents.OnBuildProjConfigBegin += new _dispBuildEvents_OnBuildProjConfigBeginEventHandler(this.OnBuildProjConfigBegin);
            buildEvents.OnBuildDone            += new _dispBuildEvents_OnBuildDoneEventHandler(this.buildEvents_OnBuildDone);

            documentEvents = (EnvDTE.DocumentEvents)events.get_DocumentEvents(null);
            documentEvents.DocumentSaved += new _dispDocumentEvents_DocumentSavedEventHandler(this.DocumentSaved);

            projectItemsEvents              = events.SolutionItemsEvents;
            projectItemsEvents.ItemAdded   += new _dispProjectItemsEvents_ItemAddedEventHandler(this.ProjectItemsEvents_ItemAdded);
            projectItemsEvents.ItemRemoved += new _dispProjectItemsEvents_ItemRemovedEventHandler(this.ProjectItemsEvents_ItemRemoved);
            projectItemsEvents.ItemRenamed += new _dispProjectItemsEvents_ItemRenamedEventHandler(this.ProjectItemsEvents_ItemRenamed);

            solutionEvents = (SolutionEvents)events.SolutionEvents;
            solutionEvents.ProjectAdded   += new _dispSolutionEvents_ProjectAddedEventHandler(this.SolutionEvents_ProjectAdded);
            solutionEvents.ProjectRemoved += new _dispSolutionEvents_ProjectRemovedEventHandler(this.SolutionEvents_ProjectRemoved);
            solutionEvents.Opened         += new _dispSolutionEvents_OpenedEventHandler(SolutionEvents_Opened);
            solutionEvents.AfterClosing   += new _dispSolutionEvents_AfterClosingEventHandler(SolutionEvents_AfterClosing);

            const string debugCommandsGUID = "{5EFC7975-14BC-11CF-9B2B-00AA00573819}";

            debugStartEvents = events.get_CommandEvents(debugCommandsGUID, 295);
            debugStartEvents.BeforeExecute += new _dispCommandEvents_BeforeExecuteEventHandler(debugStartEvents_BeforeExecute);

            debugStartWithoutDebuggingEvents = events.get_CommandEvents(debugCommandsGUID, 368);
            debugStartWithoutDebuggingEvents.BeforeExecute += new _dispCommandEvents_BeforeExecuteEventHandler(debugStartWithoutDebuggingEvents_BeforeExecute);

            dispId_VCFileConfiguration_ExcludedFromBuild         = GetPropertyDispId(typeof(VCFileConfiguration), "ExcludedFromBuild");
            dispId_VCCLCompilerTool_UsePrecompiledHeader         = GetPropertyDispId(typeof(VCCLCompilerTool), "UsePrecompiledHeader");
            dispId_VCCLCompilerTool_PrecompiledHeaderThrough     = GetPropertyDispId(typeof(VCCLCompilerTool), "PrecompiledHeaderThrough");
            dispId_VCCLCompilerTool_PreprocessorDefinitions      = GetPropertyDispId(typeof(VCCLCompilerTool), "PreprocessorDefinitions");
            dispId_VCCLCompilerTool_AdditionalIncludeDirectories = GetPropertyDispId(typeof(VCCLCompilerTool), "AdditionalIncludeDirectories");
            RegisterVCProjectEngineEvents();

            appWrapperProcess = new System.Diagnostics.Process();
            appWrapperProcess.StartInfo.FileName = VSPackage.appWrapperPath;
            appWrapperThread      = new System.Threading.Thread(new System.Threading.ThreadStart(ListenForRequests));
            appWrapperThread.Name = "QtAppWrapperListener";
            appWrapperThread.Start();
        }
Esempio n. 9
0
        /// <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, ext_ConnectMode connectMode, object addInInst, ref Array custom)
        {
            _applicationObject = (DTE2)application;
            _addInInstance     = (AddIn)addInInst;

            globalSolutionEvents                = (EnvDTE.SolutionEvents)((Events2)_applicationObject.Events).SolutionEvents;
            globalSolutionEvents.Opened        += new _dispSolutionEvents_OpenedEventHandler(SolutionOpened);
            globalSolutionEvents.BeforeClosing += new _dispSolutionEvents_BeforeClosingEventHandler(SolutionBeforeClosing);
            globalBuildEvents              = (EnvDTE.BuildEvents)((Events2)_applicationObject.Events).BuildEvents;
            globalBuildEvents.OnBuildDone += new _dispBuildEvents_OnBuildDoneEventHandler(SolutionBuildDone);

            //if (connectMode == ext_ConnectMode.ext_cm_UISetup)
            //{
            //    object[] contextGUIDS = new object[] { };
            //    Commands2 commands = (Commands2)_applicationObject.Commands;
            //    string toolsMenuName = "Tools";

            //    //Place the command on the tools menu.
            //    //Find the MenuBar command bar, which is the top-level command bar holding all the main menu items:
            //    Microsoft.VisualStudio.CommandBars.CommandBar menuBarCommandBar = ((Microsoft.VisualStudio.CommandBars.CommandBars)_applicationObject.CommandBars)["MenuBar"];

            //    //Find the Tools command bar on the MenuBar command bar:
            //    CommandBarControl toolsControl = menuBarCommandBar.Controls[toolsMenuName];
            //    CommandBarPopup toolsPopup = (CommandBarPopup)toolsControl;

            //    //This try/catch block can be duplicated if you wish to add multiple commands to be handled by your Add-in,
            //    //  just make sure you also update the QueryStatus/Exec method to include the new command names.
            //    try
            //    {
            //        //Add a command to the Commands collection:
            //        Command command = commands.AddNamedCommand2(_addInInstance, "Coding4Fun.CleanTamagotchi", "CleanTamagotchi", "Executes the command for CleanTamagotchi", true, 59, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton);

            //        //Add a control for the command to the tools menu:
            //        if ((command != null) && (toolsPopup != null))
            //        {
            //            command.AddControl(toolsPopup.CommandBar, 1);
            //        }
            //    }
            //    catch (System.ArgumentException ex)
            //    {
            //        //If we are here, then the exception is probably because a command with that name
            //        //  already exists. If so there is no need to recreate the command and we can
            //        //  safely ignore the exception.
            //    }
            //}
        }
Esempio n. 10
0
        private void registerEvents()
        {
            solutionEvents         = (SolutionEvents)environment.ApplicationObject.Events.SolutionEvents;
            solutionEvents.Opened += new _dispSolutionEvents_OpenedEventHandler(this.opened);

            /*
             * solutionEvents.AfterClosing += new _dispSolutionEvents_AfterClosingEventHandler(this.AfterClosing);
             * solutionEvents.ProjectAdded += new _dispSolutionEvents_ProjectAddedEventHandler(this.ProjectAdded);
             * solutionEvents.QueryCloseSolution += new _dispSolutionEvents_QueryCloseSolutionEventHandler(this.QueryCloseSolution);
             * solutionEvents.AfterClosing += new _dispSolutionEvents_AfterClosingEventHandler(this.AfterClosing);
             * solutionEvents.BeforeClosing += new _dispSolutionEvents_BeforeClosingEventHandler(this.BeforeClosing);
             * solutionEvents.Opened += new _dispSolutionEvents_OpenedEventHandler(this.Opened);
             * solutionEvents.ProjectAdded += new _dispSolutionEvents_ProjectAddedEventHandler(this.ProjectAdded);
             * solutionEvents.ProjectRemoved += new _dispSolutionEvents_ProjectRemovedEventHandler(this.ProjectRemoved);
             * solutionEvents.ProjectRenamed += new _dispSolutionEvents_ProjectRenamedEventHandler(this.ProjectRenamed);
             * solutionEvents.QueryCloseSolution += new _dispSolutionEvents_QueryCloseSolutionEventHandler(this.QueryCloseSolution);
             * solutionEvents.Renamed += new _dispSolutionEvents_RenamedEventHandler(this.Renamed);
             */
        }
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            _instance = this;
            _dte      = GetService(typeof(DTE)) as DTE2;
            Package   = this;
            EnvDTE80.Events2 events = _dte.Events as Events2;
            Helper.Logger.Initialize(this, "NFinalCompiler");
            _documentEvents = events.DocumentEvents;
            _solutionEvents = events.SolutionEvents;
            events.BuildEvents.OnBuildBegin          += BuildEvents_OnBuildBegin;
            events.BuildEvents.OnBuildDone           += BuildEvents_OnBuildDone;
            events.BuildEvents.OnBuildProjConfigDone += BuildEvents_OnBuildProjConfigDone;
            _documentEvents.DocumentSaved            += DocumentEvents_DocumentSaved;
            _solutionEvents.AfterClosing             += _solutionEvents_AfterClosing;
            _solutionEvents.ProjectRemoved           += _solutionEvents_ProjectRemoved;

            componentModel =
                (IComponentModel)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SComponentModel));

            base.Initialize();
        }
Esempio n. 12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PBMCommand"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        private PBMCommand(Microsoft.VisualStudio.Shell.Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            this.package = package;

            CreateMenu();

            DTE2 dte = (DTE2)(package as IServiceProvider).GetService(typeof(SDTE));

            solutionEvents = dte.Events.SolutionEvents;
            solutionEvents.AfterClosing += new _dispSolutionEvents_AfterClosingEventHandler(solutionEvents_AfterClosing);
            buildEvents = dte.Events.BuildEvents;
            buildEvents.OnBuildBegin           += new _dispBuildEvents_OnBuildBeginEventHandler(BuildEvents_OnBuildBegin);
            buildEvents.OnBuildDone            += new _dispBuildEvents_OnBuildDoneEventHandler(BuildEvents_OnBuildDone);
            buildEvents.OnBuildProjConfigBegin += new _dispBuildEvents_OnBuildProjConfigBeginEventHandler(BuildEvents_OnBuildProjConfigBegin);
            buildEvents.OnBuildProjConfigDone  += new _dispBuildEvents_OnBuildProjConfigDoneEventHandler(BuildEvents_OnBuildProjConfigDone);
        }
Esempio n. 13
0
		/// <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)
		{
			try
			{
				// Application object
				applicationObject = (_DTE)application;
				addInInstance = (AddIn)addInInst;

				// Events we're interested in.
				EnvDTE.Events events = applicationObject.Events;
				buildEvents = (EnvDTE.BuildEvents)events.BuildEvents;
				solutionEvents = (EnvDTE.SolutionEvents)events.SolutionEvents;

				buildEvents.OnBuildDone += new _dispBuildEvents_OnBuildDoneEventHandler(this.OnBuildDone);
				solutionEvents.Opened += new _dispSolutionEvents_OpenedEventHandler(this.Opened);

				OutputWindow		outputWindow;

				// Get the IDE's Output Window, Build Pane
				if (buildPane == null)
				{
					outputWindow = (OutputWindow)applicationObject.Windows.Item(EnvDTE.Constants.vsWindowKindOutput).Object;
					buildPane = outputWindow.OutputWindowPanes.Item("Build");
				}

				// Set up some filenames and paths that we're going to need.
				SetPathsAndFilenames();
	
				// Add our add-in commands
				AddCommand ("Build", "NDoc Build Solution Documentation", "Builds MSDN help for C# projects in the solution", "", "Tools");
				AddCommand ("SolutionProperties", "NDoc Edit Solution Properties", "Set NDoc Solution Properties", "", "Tools");
				AddCommand ("View", "NDoc View Solution Documentation", "View NDoc Solution Documentation", "", "Tools");
			}
			catch(Exception e)
			{
				Trace.WriteLine(e.Message);
			}
			
		}
Esempio n. 14
0
    public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom)
    {
        applicationObject = (_DTE)application;
        addInInstance     = (AddIn)addInInst;

        // Add code for How-To.
        // Initialize all the variables that contain the events we're looking for.
        // Get the events object that contains information about all of the
        //   extensibility events.
        m_Events = ((DTE)(application)).Events;
        // Initialize a variable to track SolutionEvents
        m_SolutionEvents = m_Events.SolutionEvents;
        // Initialize a variable to track BuildEvents
        m_BuildEvents = m_Events.BuildEvents;

        m_BuildEvents.OnBuildBegin      += new _dispBuildEvents_OnBuildBeginEventHandler(m_BuildEvents_OnBuildBegin);
        m_SolutionEvents.AfterClosing   += new _dispSolutionEvents_AfterClosingEventHandler(m_SolutionEvents_AfterClosing);
        m_SolutionEvents.Opened         += new _dispSolutionEvents_OpenedEventHandler(m_SolutionEvents_Opened);
        m_SolutionEvents.ProjectAdded   += new _dispSolutionEvents_ProjectAddedEventHandler(m_SolutionEvents_ProjectAdded);
        m_SolutionEvents.ProjectRemoved += new _dispSolutionEvents_ProjectRemovedEventHandler(m_SolutionEvents_ProjectRemoved);
        m_SolutionEvents.ProjectRenamed += new _dispSolutionEvents_ProjectRenamedEventHandler(m_SolutionEvents_ProjectRenamed);
    }
Esempio n. 15
0
        /// <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, ext_ConnectMode connectMode, object addInInst, ref Array custom)
        {
            _applicationObject = (DTE2)application;
            _addInInstance     = (AddIn)addInInst;

            // Setup all the solution events
            solutionEvents = (EnvDTE.SolutionEvents)_applicationObject.Events.SolutionEvents;
            solutionEvents.BeforeClosing += new _dispSolutionEvents_BeforeClosingEventHandler(solutionEvents_BeforeClosing);
            solutionEvents.Opened        += new _dispSolutionEvents_OpenedEventHandler(solutionEvents_Opened);

            // Setup all text editor events
            textEditorEvents              = (EnvDTE.TextEditorEvents)_applicationObject.Events.TextEditorEvents;
            textEditorEvents.LineChanged += new _dispTextEditorEvents_LineChangedEventHandler(textEditorEvents_LineChanged);

            // Setup all window events
            windowEvents = (EnvDTE.WindowEvents)_applicationObject.Events.WindowEvents;
            windowEvents.WindowActivated += new _dispWindowEvents_WindowActivatedEventHandler(windowEvents_WindowActivated);

            switch (connectMode)
            {
            case ext_ConnectMode.ext_cm_UISetup:
                // We should never get here, this is temporary UI
                break;

            case ext_ConnectMode.ext_cm_Startup:
                // The add-in was marked to load on startup
                AddToolWindow();
                AddToolWindowMenuItem();
                break;

            case ext_ConnectMode.ext_cm_AfterStartup:
                // The add-in was loaded by hand after startup using the Add-In Manager
                // Initialize it in the same way that when is loaded on startup
                AddToolWindow();
                AddToolWindowMenuItem();
                break;
            }
        }
Esempio n. 16
0
        /// ------------------------------------------------------------------------------------
        /// <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);
            }
        }
Esempio n. 17
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));
			}

		}
Esempio n. 18
0
        /// <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, ext_ConnectMode connectMode, object addInInst, ref Array custom)
        {
            _applicationObject = (DTE2)application;
              _addInInstance = (AddIn)addInInst;

              solutionEvents = _applicationObject.Events.SolutionEvents;
              solutionEvents.AfterClosing += new _dispSolutionEvents_AfterClosingEventHandler(solutionEvents_AfterClosing);

              buildEvents = _applicationObject.Events.BuildEvents;

              if (connectMode == ext_ConnectMode.ext_cm_Startup)
              {
            buildEvents.OnBuildBegin += new _dispBuildEvents_OnBuildBeginEventHandler(BuildEvents_OnBuildBegin);
            buildEvents.OnBuildDone += new _dispBuildEvents_OnBuildDoneEventHandler(BuildEvents_OnBuildDone);
            buildEvents.OnBuildProjConfigBegin += new _dispBuildEvents_OnBuildProjConfigBeginEventHandler(BuildEvents_OnBuildProjConfigBegin);
            buildEvents.OnBuildProjConfigDone += new _dispBuildEvents_OnBuildProjConfigDoneEventHandler(BuildEvents_OnBuildProjConfigDone);
              }

              if (connectMode != ext_ConnectMode.ext_cm_CommandLine)
              {
            paneWindow = _applicationObject.ToolWindows.OutputWindow.OutputWindowPanes.Add(addinName);

            string guid = "{bd488241-6ff7-4f10-98b7-e40a1ebbd4ae}";
            Windows2 win = (Windows2)_applicationObject.Windows;
            object ctl = null;
            System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
            Window toolWindow = win.CreateToolWindow2(_addInInstance, asm.Location, addinName + ".ChartsControl", addinName, guid, ref ctl);
            toolWindow.Visible = true;
            //toolWindow.SetTabPicture(Properties.Resources.TabIcon.ToBitmap().GetHbitmap());
            controlWindow = (ChartsControl)ctl;
            controlWindow.host = this;
              }

              if (connectMode == ext_ConnectMode.ext_cm_AfterStartup)
              {
            // The add-in was loaded by hand after startup using the Add-In Manager
            // Initialize it in the same way that when is loaded on startup
            AddMenuCommands();
              }
        }
Esempio n. 19
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));
            }
        }
Esempio n. 20
0
 private SettingsManager(_DTE application)
 {
     this.application       = application;
     this.solutionEvents    = application.Events.SolutionEvents;
     solutionEvents.Opened += new _dispSolutionEvents_OpenedEventHandler(Solution_Opened);
 }
Esempio n. 21
0
        public AddInEventHandler(DTE _dte)
        {
            simpleThreadMessenger = new SimpleThreadMessenger(this);
            dte = _dte;
            Events2 events = dte.Events as Events2;

            buildEvents = (EnvDTE.BuildEvents)events.BuildEvents;
            buildEvents.OnBuildBegin += new _dispBuildEvents_OnBuildBeginEventHandler(buildEvents_OnBuildBegin);
            buildEvents.OnBuildProjConfigBegin += new _dispBuildEvents_OnBuildProjConfigBeginEventHandler(this.OnBuildProjConfigBegin);
            buildEvents.OnBuildDone += new _dispBuildEvents_OnBuildDoneEventHandler(this.buildEvents_OnBuildDone);

            documentEvents = (EnvDTE.DocumentEvents)events.get_DocumentEvents(null);
            documentEvents.DocumentSaved += new _dispDocumentEvents_DocumentSavedEventHandler(this.DocumentSaved);

            projectItemsEvents = (ProjectItemsEvents)events.ProjectItemsEvents;
            projectItemsEvents.ItemAdded += new _dispProjectItemsEvents_ItemAddedEventHandler(this.ProjectItemsEvents_ItemAdded);
            projectItemsEvents.ItemRemoved += new _dispProjectItemsEvents_ItemRemovedEventHandler(this.ProjectItemsEvents_ItemRemoved);
            projectItemsEvents.ItemRenamed += new _dispProjectItemsEvents_ItemRenamedEventHandler(this.ProjectItemsEvents_ItemRenamed);

            solutionEvents = (SolutionEvents)events.SolutionEvents;
            solutionEvents.ProjectAdded += new _dispSolutionEvents_ProjectAddedEventHandler(this.SolutionEvents_ProjectAdded);
            solutionEvents.ProjectRemoved += new _dispSolutionEvents_ProjectRemovedEventHandler(this.SolutionEvents_ProjectRemoved);
            solutionEvents.Opened += new _dispSolutionEvents_OpenedEventHandler(SolutionEvents_Opened);
            solutionEvents.AfterClosing += new _dispSolutionEvents_AfterClosingEventHandler(SolutionEvents_AfterClosing);

            const string debugCommandsGUID = "{5EFC7975-14BC-11CF-9B2B-00AA00573819}";
            debugStartEvents = events.get_CommandEvents(debugCommandsGUID, 295);
            debugStartEvents.BeforeExecute += new _dispCommandEvents_BeforeExecuteEventHandler(debugStartEvents_BeforeExecute);

            debugStartWithoutDebuggingEvents = events.get_CommandEvents(debugCommandsGUID, 368);
            debugStartWithoutDebuggingEvents.BeforeExecute += new _dispCommandEvents_BeforeExecuteEventHandler(debugStartWithoutDebuggingEvents_BeforeExecute);

            dispId_VCFileConfiguration_ExcludedFromBuild = GetPropertyDispId(typeof(VCFileConfiguration), "ExcludedFromBuild");
            dispId_VCCLCompilerTool_UsePrecompiledHeader = GetPropertyDispId(typeof(VCCLCompilerTool), "UsePrecompiledHeader");
            dispId_VCCLCompilerTool_PrecompiledHeaderThrough = GetPropertyDispId(typeof(VCCLCompilerTool), "PrecompiledHeaderThrough");
            dispId_VCCLCompilerTool_PreprocessorDefinitions = GetPropertyDispId(typeof(VCCLCompilerTool), "PreprocessorDefinitions");
            dispId_VCCLCompilerTool_AdditionalIncludeDirectories = GetPropertyDispId(typeof(VCCLCompilerTool), "AdditionalIncludeDirectories");
            RegisterVCProjectEngineEvents();

            if (Connect.Instance().AppWrapperPath == null)
            {
                Messages.DisplayCriticalErrorMessage("QtAppWrapper can't be found in the installation directory.");
            }
            else
            {
                appWrapperProcess = new System.Diagnostics.Process();
                appWrapperProcess.StartInfo.FileName = Connect.Instance().AppWrapperPath;
            }
            appWrapperThread = new System.Threading.Thread(new System.Threading.ThreadStart(ListenForRequests));
            appWrapperThread.Name = "QtAppWrapperListener";
            appWrapperThread.Start();
        }
Esempio n. 22
0
		/// ------------------------------------------------------------------------------------
		/// <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);
			}
		}
Esempio n. 23
0
        public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
        {
            if (connectMode == ext_ConnectMode.ext_cm_Startup)
            {
                _app   = (DTE2)application;
                _addIn = (AddIn)addInInst;
                CommandBarPopup depMainPop = null;
                cmdHt    = new Hashtable();
                commands = (Commands2)_app.Commands;

                solevt = _app.Events.SolutionEvents;
                solevt.AfterClosing += new _dispSolutionEvents_AfterClosingEventHandler(solevt_AfterClosing);
                solevt.ProjectAdded += new _dispSolutionEvents_ProjectAddedEventHandler(solevt_ProjectAdded);
                solevt.Opened       += new _dispSolutionEvents_OpenedEventHandler(solevt_Opened);
                Hashtable ht = new Hashtable();
                foreach (Command c in commands)
                {
                    if (c.Name.Contains("DeployAddIn"))
                    {
                        cmdHt.Add(c.Name, c);
                    }
                }

                object[] contextGUIDS = new object[] { };
                string   toolsMenuName;

                try {
                    ResourceManager resourceManager = new ResourceManager("DeployAddIn.CommandBar", Assembly.GetExecutingAssembly());
                    CultureInfo     cultureInfo     = new System.Globalization.CultureInfo(_app.LocaleID);
                    string          resourceName    = String.Concat(cultureInfo.TwoLetterISOLanguageName, "Tools");
                    toolsMenuName = resourceManager.GetString(resourceName);
                }
                catch {
                    //We tried to find a localized version of the word Tools, but one was not found.
                    //  Default to the en-US word, which may work for the current culture.
                    toolsMenuName = "Tools";
                }

                //Place the command on the tools menu.
                //Find the MenuBar command bar, which is the top-level command bar holding all the main menu items:
                Microsoft.VisualStudio.CommandBars.CommandBar menuBar = ((Microsoft.VisualStudio.CommandBars.CommandBars)_app.CommandBars)["MenuBar"];

                //Find the Tools command bar on the MenuBar command bar:
                CommandBarControl toolsControl = menuBar.Controls[toolsMenuName];

                CommandBarPopup toolsPopup = (CommandBarPopup)toolsControl;
                try {
                    depMainPop            = (CommandBarPopup)toolsPopup.Controls.Add(vsCommandBarType.vsCommandBarTypePopup, 1, "", 1, true);
                    depMainPop.Caption    = "SQL CLR Deployment";
                    depMainPop.BeginGroup = true;
                    depMainPop.Visible    = true;



                    //Add a command to the Commands collection:
                    AddCmd(depMainPop.CommandBar, "DepProp", "Deployment Properties", "Allows you to set properties for the deployment task.", 1);
                }


                catch (Exception ex1) {
                    MessageBox.Show(ex1.Message, "Error");
                }


                try {
                    CommandBarPopup depSubPop = (CommandBarPopup)depMainPop.Controls.Add(vsCommandBarType.vsCommandBarTypePopup, 1, "", 2, true);
                    depSubPop.Caption    = "Deploy/Drop Assemblies";
                    depSubPop.BeginGroup = true;
                    depSubPop.Visible    = true;



                    AddCmd(depSubPop.CommandBar, "DepAll", "Deploy All (assembly, methods etc)", "Deploys the assembly and all the procedures, functions etc.", 1);
                    AddCmd(depSubPop.CommandBar, "DepAsm", "Deploy Assembly", "Deploys the assembly.", 2);
                    AddCmd(depSubPop.CommandBar, "DepUdt", "Create UDT's", "Creates the user defined types in the assembly.", 3);
                    AddCmd(depSubPop.CommandBar, "DepMeth", "Create Methods", "Creates the procedures, functions etc, in the assembly", 4);
                    AddCmd(depSubPop.CommandBar, "DropAll", "Drop All (assembly, methods etc)", "Drops the assembly and all the procedures, functions etc.", 5);
                    AddCmd(depMainPop.CommandBar, "Debug", "Debug", "Debug the assembly.", 3);
                }
                catch (Exception ex2) {
                    MessageBox.Show(ex2.Message, "Error");
                }
            }
        }
Esempio n. 24
0
        public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
        {
            if (connectMode == ext_ConnectMode.ext_cm_Startup) {

            _app = (DTE2)application;
            _addIn = (AddIn)addInInst;
            CommandBarPopup depMainPop = null;
            cmdHt = new Hashtable();
            commands = (Commands2)_app.Commands;

            solevt = _app.Events.SolutionEvents;
            solevt.AfterClosing += new _dispSolutionEvents_AfterClosingEventHandler(solevt_AfterClosing);
            solevt.ProjectAdded += new _dispSolutionEvents_ProjectAddedEventHandler(solevt_ProjectAdded);
            solevt.Opened += new _dispSolutionEvents_OpenedEventHandler(solevt_Opened);
            Hashtable ht = new Hashtable();
            foreach (Command c in commands) {
              if (c.Name.Contains("DeployAddIn"))
            cmdHt.Add(c.Name, c);
            }

            object[] contextGUIDS = new object[] { };
            string toolsMenuName;

            try {

              ResourceManager resourceManager = new ResourceManager("DeployAddIn.CommandBar", Assembly.GetExecutingAssembly());
              CultureInfo cultureInfo = new System.Globalization.CultureInfo(_app.LocaleID);
              string resourceName = String.Concat(cultureInfo.TwoLetterISOLanguageName, "Tools");
              toolsMenuName = resourceManager.GetString(resourceName);
            }
            catch {
              //We tried to find a localized version of the word Tools, but one was not found.
              //  Default to the en-US word, which may work for the current culture.
              toolsMenuName = "Tools";
            }

            //Place the command on the tools menu.
            //Find the MenuBar command bar, which is the top-level command bar holding all the main menu items:
            Microsoft.VisualStudio.CommandBars.CommandBar menuBar = ((Microsoft.VisualStudio.CommandBars.CommandBars)_app.CommandBars)["MenuBar"];

            //Find the Tools command bar on the MenuBar command bar:
            CommandBarControl toolsControl = menuBar.Controls[toolsMenuName];

            CommandBarPopup toolsPopup = (CommandBarPopup)toolsControl;
            try {
              depMainPop = (CommandBarPopup)toolsPopup.Controls.Add(vsCommandBarType.vsCommandBarTypePopup, 1, "", 1, true);
              depMainPop.Caption = "SQL CLR Deployment";
              depMainPop.BeginGroup = true;
              depMainPop.Visible = true;

              //Add a command to the Commands collection:
              AddCmd(depMainPop.CommandBar, "DepProp", "Deployment Properties", "Allows you to set properties for the deployment task.", 1);
            }

            catch (Exception ex1) {
              MessageBox.Show(ex1.Message, "Error");

            }

            try {

              CommandBarPopup depSubPop = (CommandBarPopup)depMainPop.Controls.Add(vsCommandBarType.vsCommandBarTypePopup, 1, "", 2, true);
              depSubPop.Caption = "Deploy/Drop Assemblies";
              depSubPop.BeginGroup = true;
              depSubPop.Visible = true;

              AddCmd(depSubPop.CommandBar, "DepAll", "Deploy All (assembly, methods etc)", "Deploys the assembly and all the procedures, functions etc.", 1);
              AddCmd(depSubPop.CommandBar, "DepAsm", "Deploy Assembly", "Deploys the assembly.", 2);
              AddCmd(depSubPop.CommandBar, "DepUdt", "Create UDT's", "Creates the user defined types in the assembly.", 3);
              AddCmd(depSubPop.CommandBar, "DepMeth", "Create Methods", "Creates the procedures, functions etc, in the assembly", 4);
              AddCmd(depSubPop.CommandBar, "DropAll", "Drop All (assembly, methods etc)", "Drops the assembly and all the procedures, functions etc.", 5);
              AddCmd(depMainPop.CommandBar, "Debug", "Debug", "Debug the assembly.", 3);

            }
            catch (Exception ex2) {
              MessageBox.Show(ex2.Message, "Error");

            }

              }
        }
Esempio n. 25
0
        public void BindEvents()
        {
            EnvDTE.Events events = m_applicationObject.Events;

            m_solutionEvents = (EnvDTE.SolutionEvents)events.SolutionEvents;
            m_buildEvents = (EnvDTE.BuildEvents)events.BuildEvents;
            m_dteEvents = (EnvDTE.DTEEvents)events.DTEEvents;
            m_debuggerEvents = (EnvDTE.DebuggerEvents)events.DebuggerEvents;

            m_solutionEvents.AfterClosing += new _dispSolutionEvents_AfterClosingEventHandler(this.AfterClosing);
            m_solutionEvents.BeforeClosing += new _dispSolutionEvents_BeforeClosingEventHandler(this.BeforeClosing);
            m_solutionEvents.Opened += new _dispSolutionEvents_OpenedEventHandler(this.Opened);
            m_solutionEvents.ProjectAdded += new _dispSolutionEvents_ProjectAddedEventHandler(this.ProjectAdded);
            m_solutionEvents.ProjectRemoved += new _dispSolutionEvents_ProjectRemovedEventHandler(this.ProjectRemoved);
            m_solutionEvents.ProjectRenamed += new _dispSolutionEvents_ProjectRenamedEventHandler(this.ProjectRenamed);
            m_solutionEvents.QueryCloseSolution += new _dispSolutionEvents_QueryCloseSolutionEventHandler(this.QueryCloseSolution);
            m_solutionEvents.Renamed += new _dispSolutionEvents_RenamedEventHandler(this.Renamed);

            m_buildEvents.OnBuildBegin += new _dispBuildEvents_OnBuildBeginEventHandler(this.OnBuildBegin);
            m_buildEvents.OnBuildDone += new _dispBuildEvents_OnBuildDoneEventHandler(this.OnBuildDone);
            m_buildEvents.OnBuildProjConfigBegin += new _dispBuildEvents_OnBuildProjConfigBeginEventHandler(this.OnBuildProjConfigBegin);
            m_buildEvents.OnBuildProjConfigDone += new _dispBuildEvents_OnBuildProjConfigDoneEventHandler(this.OnBuildProjConfigDone);

            m_dteEvents.ModeChanged += new _dispDTEEvents_ModeChangedEventHandler(this.DTEModeChanged);

            m_debuggerEvents.OnEnterRunMode += new _dispDebuggerEvents_OnEnterRunModeEventHandler(DebuggerOnEnterRunMode);
            m_debuggerEvents.OnEnterDesignMode += new _dispDebuggerEvents_OnEnterDesignModeEventHandler(DebuggerOnEnterDesignMode);
        }
        protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            App.Initialize(GetDialogPage(typeof(OptionsPage)) as OptionsPage);

            Instance = this;

            //var componentModel = (IComponentModel)GetService(typeof(SComponentModel));

            // Add our command handlers for menu (commands must exist in the .vsct file)

            if (await GetServiceAsync(typeof(IMenuCommandService)) is OleMenuCommandService menuCommandService)
            {
                // //var mainMenu = new CommandID(GuidList.GuidGeeksProductivityToolsCmdSet, (int)PkgCmdIDList.CmdidMainMenu);
                // //var founded = menuCommandService.FindCommand(mainMenu);
                // //if (founded == null)
                // //{
                // //    var menuCommand2 = new OleMenuCommand(null, mainMenu);
                // //    menuCommandService.AddCommand(menuCommand2);
                // //    menuCommand2.BeforeQueryStatus += MenuCommand2_BeforeQueryStatus;
                // //    menuCommand2.Visible = false;
                // //}
                var menuCommand = new OleMenuCommand(CallWebFileToggle, new CommandID(GuidList.GuidGeeksProductivityToolsCmdSet, (int)PkgCmdIDList.CmdidWebFileToggle));
                menuCommand.BeforeQueryStatus += MenuCommand_BeforeQueryStatus;

                menuCommandService.AddCommand(menuCommand);

                menuCommandService.AddCommand(new MenuCommand(CallFixtureFileToggle,
                                                              new CommandID(GuidList.GuidGeeksProductivityToolsCmdSet,
                                                                            (int)PkgCmdIDList.CmdidFixtureFileToggle)));

                menuCommandService.AddCommand(new MenuCommand(CallFileFinder,
                                                              new CommandID(GuidList.GuidGeeksProductivityToolsCmdSet,
                                                                            (int)PkgCmdIDList.CmdidFileFinder)));

                menuCommandService.AddCommand(new MenuCommand(CallMemberFinder,
                                                              new CommandID(GuidList.GuidGeeksProductivityToolsCmdSet,
                                                                            (int)PkgCmdIDList.CmdidMemberFinder)));

                menuCommandService.AddCommand(new MenuCommand(CallCssFinder,
                                                              new CommandID(GuidList.GuidGeeksProductivityToolsCmdSet,
                                                                            (int)PkgCmdIDList.CmdidCSSFinder)));

                menuCommandService.AddCommand(new MenuCommand(CallGotoNextFoundItem,
                                                              new CommandID(GuidList.GuidGeeksProductivityToolsCmdSet,
                                                                            (int)PkgCmdIDList.CmdidGotoNextFoundItem)));

                menuCommandService.AddCommand(new MenuCommand(CallGotoPreviousFoundItem,
                                                              new CommandID(GuidList.GuidGeeksProductivityToolsCmdSet,
                                                                            (int)PkgCmdIDList.CmdidGotoPreviousFoundItem)));
            }

            SetCommandBindings();

            // Hook up event handlers
            events            = App.DTE.Events;
            docEvents         = events.DocumentEvents;
            solEvents         = events.SolutionEvents;
            solEvents.Opened += delegate { App.Initialize(GetDialogPage(typeof(OptionsPage)) as OptionsPage); };

            // //ServiceCreatorCallback callback = new ServiceCreatorCallback(CreateService);

            // //((IServiceContainer)this).AddService(typeof(SMyService), callback);
        }
Esempio n. 27
0
        /// <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, ext_ConnectMode connectMode, object addInInst, ref Array custom)
        {
            _applicationObject = (DTE2)application;
            _addInInstance = (AddIn)addInInst;

            globalSolutionEvents = (EnvDTE.SolutionEvents)((Events2)_applicationObject.Events).SolutionEvents;
            globalSolutionEvents.Opened += new _dispSolutionEvents_OpenedEventHandler(SolutionOpened);
            globalSolutionEvents.BeforeClosing += new _dispSolutionEvents_BeforeClosingEventHandler(SolutionBeforeClosing);
            globalBuildEvents = (EnvDTE.BuildEvents)((Events2)_applicationObject.Events).BuildEvents;
            globalBuildEvents.OnBuildDone += new _dispBuildEvents_OnBuildDoneEventHandler(SolutionBuildDone);

            //if (connectMode == ext_ConnectMode.ext_cm_UISetup)
            //{
            //    object[] contextGUIDS = new object[] { };
            //    Commands2 commands = (Commands2)_applicationObject.Commands;
            //    string toolsMenuName = "Tools";

            //    //Place the command on the tools menu.
            //    //Find the MenuBar command bar, which is the top-level command bar holding all the main menu items:
            //    Microsoft.VisualStudio.CommandBars.CommandBar menuBarCommandBar = ((Microsoft.VisualStudio.CommandBars.CommandBars)_applicationObject.CommandBars)["MenuBar"];

            //    //Find the Tools command bar on the MenuBar command bar:
            //    CommandBarControl toolsControl = menuBarCommandBar.Controls[toolsMenuName];
            //    CommandBarPopup toolsPopup = (CommandBarPopup)toolsControl;

            //    //This try/catch block can be duplicated if you wish to add multiple commands to be handled by your Add-in,
            //    //  just make sure you also update the QueryStatus/Exec method to include the new command names.
            //    try
            //    {
            //        //Add a command to the Commands collection:
            //        Command command = commands.AddNamedCommand2(_addInInstance, "Coding4Fun.CleanTamagotchi", "CleanTamagotchi", "Executes the command for CleanTamagotchi", true, 59, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton);

            //        //Add a control for the command to the tools menu:
            //        if ((command != null) && (toolsPopup != null))
            //        {
            //            command.AddControl(toolsPopup.CommandBar, 1);
            //        }
            //    }
            //    catch (System.ArgumentException ex)
            //    {
            //        //If we are here, then the exception is probably because a command with that name
            //        //  already exists. If so there is no need to recreate the command and we can
            //        //  safely ignore the exception.
            //    }
            //}
        }
Esempio n. 28
0
        public void Attach(_DTE app)
        {
            applicationObject = app;

            EnvDTE.Events events       = applicationObject.Events;
            OutputWindow  outputWindow = (OutputWindow)applicationObject.Windows.Item(Constants.vsWindowKindOutput).Object;


            //IObjectExplorerService objectExplorer = ServiceCache.GetObjectExplorer();
            //var provider = (IObjectExplorerEventProvider)objectExplorer.GetService(typeof(IObjectExplorerEventProvider));

            //provider.SelectionChanged += new NodesChangedEventHandler(provider_SelectionChanged);

            _outputWindowPane = outputWindow.OutputWindowPanes.Add("DTE Event Information - C# Event Watcher");

            //Retrieve the event objects from the automation model
            _windowsEvents       = (EnvDTE.WindowEvents)events.get_WindowEvents(null);
            _textEditorEvents    = (EnvDTE.TextEditorEvents)events.get_TextEditorEvents(null);
            _taskListEvents      = (EnvDTE.TaskListEvents)events.get_TaskListEvents("");
            _solutionEvents      = (EnvDTE.SolutionEvents)events.SolutionEvents;
            _selectionEvents     = (EnvDTE.SelectionEvents)events.SelectionEvents;
            _outputWindowEvents  = (EnvDTE.OutputWindowEvents)events.get_OutputWindowEvents("");
            _findEvents          = (EnvDTE.FindEvents)events.FindEvents;
            _dteEvents           = (EnvDTE.DTEEvents)events.DTEEvents;
            _documentEvents      = (EnvDTE.DocumentEvents)events.get_DocumentEvents(null);
            _debuggerEvents      = (EnvDTE.DebuggerEvents)events.DebuggerEvents;
            _commandEvents       = (EnvDTE.CommandEvents)events.get_CommandEvents("{00000000-0000-0000-0000-000000000000}", 0);
            _buildEvents         = (EnvDTE.BuildEvents)events.BuildEvents;
            _miscFilesEvents     = (EnvDTE.ProjectItemsEvents)events.MiscFilesEvents;
            _solutionItemsEvents = (EnvDTE.ProjectItemsEvents)events.SolutionItemsEvents;

            _globalProjectItemsEvents           = ((EnvDTE80.Events2)events).ProjectItemsEvents;
            _globalProjectsEvents               = ((EnvDTE80.Events2)events).ProjectsEvents;
            _textDocumentKeyPressEvents         = ((EnvDTE80.Events2)events).get_TextDocumentKeyPressEvents(null);
            _codeModelEvents                    = ((EnvDTE80.Events2)events).get_CodeModelEvents(null);
            _windowVisibilityEvents             = ((EnvDTE80.Events2)events).get_WindowVisibilityEvents(null);
            _debuggerProcessEvents              = ((EnvDTE80.Events2)events).DebuggerProcessEvents;
            _debuggerExpressionEvaluationEvents = ((EnvDTE80.Events2)events).DebuggerExpressionEvaluationEvents;
            _publishEvents = ((EnvDTE80.Events2)events).PublishEvents;

            //Connect to each delegate exposed from each object retrieved above
            _windowsEvents.WindowActivated     += new _dispWindowEvents_WindowActivatedEventHandler(this.WindowActivated);
            _windowsEvents.WindowClosing       += new _dispWindowEvents_WindowClosingEventHandler(this.WindowClosing);
            _windowsEvents.WindowCreated       += new _dispWindowEvents_WindowCreatedEventHandler(this.WindowCreated);
            _windowsEvents.WindowMoved         += new _dispWindowEvents_WindowMovedEventHandler(this.WindowMoved);
            _textEditorEvents.LineChanged      += new _dispTextEditorEvents_LineChangedEventHandler(this.LineChanged);
            _taskListEvents.TaskAdded          += new _dispTaskListEvents_TaskAddedEventHandler(this.TaskAdded);
            _taskListEvents.TaskModified       += new _dispTaskListEvents_TaskModifiedEventHandler(this.TaskModified);
            _taskListEvents.TaskNavigated      += new _dispTaskListEvents_TaskNavigatedEventHandler(this.TaskNavigated);
            _taskListEvents.TaskRemoved        += new _dispTaskListEvents_TaskRemovedEventHandler(this.TaskRemoved);
            _solutionEvents.AfterClosing       += new _dispSolutionEvents_AfterClosingEventHandler(this.AfterClosing);
            _solutionEvents.BeforeClosing      += new _dispSolutionEvents_BeforeClosingEventHandler(this.BeforeClosing);
            _solutionEvents.Opened             += new _dispSolutionEvents_OpenedEventHandler(this.Opened);
            _solutionEvents.ProjectAdded       += new _dispSolutionEvents_ProjectAddedEventHandler(this.ProjectAdded);
            _solutionEvents.ProjectRemoved     += new _dispSolutionEvents_ProjectRemovedEventHandler(this.ProjectRemoved);
            _solutionEvents.ProjectRenamed     += new _dispSolutionEvents_ProjectRenamedEventHandler(this.ProjectRenamed);
            _solutionEvents.QueryCloseSolution += new _dispSolutionEvents_QueryCloseSolutionEventHandler(this.QueryCloseSolution);
            _solutionEvents.Renamed            += new _dispSolutionEvents_RenamedEventHandler(this.Renamed);
            _selectionEvents.OnChange          += new _dispSelectionEvents_OnChangeEventHandler(this.OnChange);
            _outputWindowEvents.PaneAdded      += new _dispOutputWindowEvents_PaneAddedEventHandler(this.PaneAdded);
            _outputWindowEvents.PaneClearing   += new _dispOutputWindowEvents_PaneClearingEventHandler(this.PaneClearing);
            _outputWindowEvents.PaneUpdated    += new _dispOutputWindowEvents_PaneUpdatedEventHandler(this.PaneUpdated);
            _findEvents.FindDone                       += new _dispFindEvents_FindDoneEventHandler(this.FindDone);
            _dteEvents.ModeChanged                     += new _dispDTEEvents_ModeChangedEventHandler(this.ModeChanged);
            _dteEvents.OnBeginShutdown                 += new _dispDTEEvents_OnBeginShutdownEventHandler(this.OnBeginShutdown);
            _dteEvents.OnMacrosRuntimeReset            += new _dispDTEEvents_OnMacrosRuntimeResetEventHandler(this.OnMacrosRuntimeReset);
            _dteEvents.OnStartupComplete               += new _dispDTEEvents_OnStartupCompleteEventHandler(this.OnStartupComplete);
            _documentEvents.DocumentClosing            += new _dispDocumentEvents_DocumentClosingEventHandler(this.DocumentClosing);
            _documentEvents.DocumentOpened             += new _dispDocumentEvents_DocumentOpenedEventHandler(this.DocumentOpened);
            _documentEvents.DocumentOpening            += new _dispDocumentEvents_DocumentOpeningEventHandler(this.DocumentOpening);
            _documentEvents.DocumentSaved              += new _dispDocumentEvents_DocumentSavedEventHandler(this.DocumentSaved);
            _debuggerEvents.OnContextChanged           += new _dispDebuggerEvents_OnContextChangedEventHandler(this.OnContextChanged);
            _debuggerEvents.OnEnterBreakMode           += new _dispDebuggerEvents_OnEnterBreakModeEventHandler(this.OnEnterBreakMode);
            _debuggerEvents.OnEnterDesignMode          += new _dispDebuggerEvents_OnEnterDesignModeEventHandler(this.OnEnterDesignMode);
            _debuggerEvents.OnEnterRunMode             += new _dispDebuggerEvents_OnEnterRunModeEventHandler(this.OnEnterRunMode);
            _debuggerEvents.OnExceptionNotHandled      += new _dispDebuggerEvents_OnExceptionNotHandledEventHandler(this.OnExceptionNotHandled);
            _debuggerEvents.OnExceptionThrown          += new _dispDebuggerEvents_OnExceptionThrownEventHandler(this.OnExceptionThrown);
            _commandEvents.AfterExecute                += new _dispCommandEvents_AfterExecuteEventHandler(this.AfterExecute);
            _commandEvents.BeforeExecute               += new _dispCommandEvents_BeforeExecuteEventHandler(this.BeforeExecute);
            _buildEvents.OnBuildBegin                  += new _dispBuildEvents_OnBuildBeginEventHandler(this.OnBuildBegin);
            _buildEvents.OnBuildDone                   += new _dispBuildEvents_OnBuildDoneEventHandler(this.OnBuildDone);
            _buildEvents.OnBuildProjConfigBegin        += new _dispBuildEvents_OnBuildProjConfigBeginEventHandler(this.OnBuildProjConfigBegin);
            _buildEvents.OnBuildProjConfigDone         += new _dispBuildEvents_OnBuildProjConfigDoneEventHandler(this.OnBuildProjConfigDone);
            _miscFilesEvents.ItemAdded                 += new _dispProjectItemsEvents_ItemAddedEventHandler(this.MiscFilesEvents_ItemAdded);
            _miscFilesEvents.ItemRemoved               += new _dispProjectItemsEvents_ItemRemovedEventHandler(this.MiscFilesEvents_ItemRemoved);
            _miscFilesEvents.ItemRenamed               += new _dispProjectItemsEvents_ItemRenamedEventHandler(this.MiscFilesEvents_ItemRenamed);
            _solutionItemsEvents.ItemAdded             += new _dispProjectItemsEvents_ItemAddedEventHandler(this.SolutionItemsEvents_ItemAdded);
            _solutionItemsEvents.ItemRemoved           += new _dispProjectItemsEvents_ItemRemovedEventHandler(this.SolutionItemsEvents_ItemRemoved);
            _solutionItemsEvents.ItemRenamed           += new _dispProjectItemsEvents_ItemRenamedEventHandler(this.SolutionItemsEvents_ItemRenamed);
            _globalProjectItemsEvents.ItemAdded        += new _dispProjectItemsEvents_ItemAddedEventHandler(GlobalProjectItemsEvents_ItemAdded);
            _globalProjectItemsEvents.ItemRemoved      += new _dispProjectItemsEvents_ItemRemovedEventHandler(GlobalProjectItemsEvents_ItemRemoved);
            _globalProjectItemsEvents.ItemRenamed      += new _dispProjectItemsEvents_ItemRenamedEventHandler(GlobalProjectItemsEvents_ItemRenamed);
            _globalProjectsEvents.ItemAdded            += new _dispProjectsEvents_ItemAddedEventHandler(GlobalProjectsEvents_ItemAdded);
            _globalProjectsEvents.ItemRemoved          += new _dispProjectsEvents_ItemRemovedEventHandler(GlobalProjectsEvents_ItemRemoved);
            _globalProjectsEvents.ItemRenamed          += new _dispProjectsEvents_ItemRenamedEventHandler(GlobalProjectsEvents_ItemRenamed);
            _textDocumentKeyPressEvents.AfterKeyPress  += new _dispTextDocumentKeyPressEvents_AfterKeyPressEventHandler(AfterKeyPress);
            _textDocumentKeyPressEvents.BeforeKeyPress += new _dispTextDocumentKeyPressEvents_BeforeKeyPressEventHandler(BeforeKeyPress);
            _codeModelEvents.ElementAdded              += new _dispCodeModelEvents_ElementAddedEventHandler(ElementAdded);
            _codeModelEvents.ElementChanged            += new _dispCodeModelEvents_ElementChangedEventHandler(ElementChanged);
            _codeModelEvents.ElementDeleted            += new _dispCodeModelEvents_ElementDeletedEventHandler(ElementDeleted);
            _windowVisibilityEvents.WindowHiding       += new _dispWindowVisibilityEvents_WindowHidingEventHandler(WindowHiding);
            _windowVisibilityEvents.WindowShowing      += new _dispWindowVisibilityEvents_WindowShowingEventHandler(WindowShowing);
            _debuggerExpressionEvaluationEvents.OnExpressionEvaluation += new _dispDebuggerExpressionEvaluationEvents_OnExpressionEvaluationEventHandler(OnExpressionEvaluation);
            _debuggerProcessEvents.OnProcessStateChanged += new _dispDebuggerProcessEvents_OnProcessStateChangedEventHandler(OnProcessStateChanged);
            _publishEvents.OnPublishBegin += new _dispPublishEvents_OnPublishBeginEventHandler(OnPublishBegin);
            _publishEvents.OnPublishDone  += new _dispPublishEvents_OnPublishDoneEventHandler(OnPublishDone);
        }
 /// <summary>
 /// Registers handlers for certain solution events.
 /// </summary>
 public void AddSolutionEvents()
 {
     _events = (EnvDTE80.Events2)_dte.Events;
     _solnEvents = (EnvDTE.SolutionEvents)_events.SolutionEvents;
     _solnEvents.QueryCloseSolution += new _dispSolutionEvents_QueryCloseSolutionEventHandler(solnEvents_QueryCloseSolution);
     _solnEvents.Opened += new _dispSolutionEvents_OpenedEventHandler(solnEvents_Opened);
 }
Esempio n. 30
0
 public void UnbindEvents()
 {
     if (m_solutionEvents != null)
     {
         m_solutionEvents.AfterClosing -= new _dispSolutionEvents_AfterClosingEventHandler(this.AfterClosing);
         m_solutionEvents.BeforeClosing -= new _dispSolutionEvents_BeforeClosingEventHandler(this.BeforeClosing);
         m_solutionEvents.Opened -= new _dispSolutionEvents_OpenedEventHandler(this.Opened);
         m_solutionEvents.ProjectAdded -= new _dispSolutionEvents_ProjectAddedEventHandler(this.ProjectAdded);
         m_solutionEvents.ProjectRemoved -= new _dispSolutionEvents_ProjectRemovedEventHandler(this.ProjectRemoved);
         m_solutionEvents.ProjectRenamed -= new _dispSolutionEvents_ProjectRenamedEventHandler(this.ProjectRenamed);
         m_solutionEvents.QueryCloseSolution -= new _dispSolutionEvents_QueryCloseSolutionEventHandler(this.QueryCloseSolution);
         m_solutionEvents.Renamed -= new _dispSolutionEvents_RenamedEventHandler(this.Renamed);
         m_solutionEvents = null;
     }
     if (m_buildEvents != null)
     {
         m_buildEvents.OnBuildBegin -= new _dispBuildEvents_OnBuildBeginEventHandler(this.OnBuildBegin);
         m_buildEvents.OnBuildDone -= new _dispBuildEvents_OnBuildDoneEventHandler(this.OnBuildDone);
         m_buildEvents.OnBuildProjConfigBegin -= new _dispBuildEvents_OnBuildProjConfigBeginEventHandler(this.OnBuildProjConfigBegin);
         m_buildEvents.OnBuildProjConfigDone -= new _dispBuildEvents_OnBuildProjConfigDoneEventHandler(this.OnBuildProjConfigDone);
         m_buildEvents = null;
     }
     if (m_dteEvents != null)
     {
         m_dteEvents.ModeChanged -= new _dispDTEEvents_ModeChangedEventHandler(this.DTEModeChanged);
         m_dteEvents = null;
     }
     if (m_debuggerEvents != null)
     {
         m_debuggerEvents.OnEnterRunMode -= new _dispDebuggerEvents_OnEnterRunModeEventHandler(DebuggerOnEnterRunMode);
         m_debuggerEvents.OnEnterDesignMode -= new _dispDebuggerEvents_OnEnterDesignModeEventHandler(DebuggerOnEnterDesignMode);
         m_debuggerEvents = null;
     }
 }