/// <summary> /// Retrieves the VCProjectEngine from the given project and registers the handlers for VCProjectEngineEvents. /// </summary> void RegisterVCProjectEngineEvents(Project p) { if (vcProjectEngineEvents != null) { return; } VCProject vcPrj = p.Object as VCProject; VCProjectEngine prjEngine = vcPrj.VCProjectEngine as VCProjectEngine; if (prjEngine != null) { vcProjectEngineEvents = prjEngine.Events as VCProjectEngineEvents; if (vcProjectEngineEvents != null) { try { vcProjectEngineEvents.ItemPropertyChange += new _dispVCProjectEngineEvents_ItemPropertyChangeEventHandler(OnVCProjectEngineItemPropertyChange); } catch { Messages.DisplayErrorMessage("VCProjectEngine events could not be registered."); } } } }
void InitializeVCProject(Project p) { ThreadHelper.ThrowIfNotOnUIThread(); if (vcProjectEngineEvents != null) { return; } var vcPrj = p.Object as VCProject; if (vcPrj == null) { return; } // Retrieves the VCProjectEngine from the given project and registers the handlers for VCProjectEngineEvents. if (vcPrj.VCProjectEngine is VCProjectEngine prjEngine) { vcProjectEngineEvents = prjEngine.Events as VCProjectEngineEvents; if (vcProjectEngineEvents != null) { try { vcProjectEngineEvents.ItemPropertyChange += OnVCProjectEngineItemPropertyChange; } catch { Messages.DisplayErrorMessage("VCProjectEngine events could not be registered."); } } } }
private void OnSolutionChanged() { if (dte.Solution.Projects.Count == 0) { return; } Project p = dte.Solution.Projects.Item(1); var cfg = dte.Solution.SolutionBuild.ActiveConfiguration as EnvDTE80.SolutionConfiguration2; Debug.WriteLine(cfg.Name + "|" + cfg.PlatformName); VCProjectShim vcproject = (p.Object as VCProjectShim); //vcproject.ProjectGUID = "{612873E4-B1DE-4814-9477-864DDFDD40DA}"; projectEvents = (VCProjectEngineEvents)dte.Events.GetObject("VCProjectEngineEventsObject"); projectEvents.ItemPropertyChange2 += ProjectEvents_ItemPropertyChange2; var prjCfg = vcproject.ActiveConfiguration as VCConfiguration3; String platformName = ((VCPlatform)prjCfg.Platform).Name; Debug.WriteLine(prjCfg.ConfigurationName + "|" + platformName); IEnumerable projectTools = prjCfg.Tools as IEnumerable; foreach (var tobj in projectTools) { VCCLCompilerTool compilerTool = tobj as VCCLCompilerTool; if (compilerTool == null) { continue; } Debug.WriteLine("Include directories:" + compilerTool.AdditionalIncludeDirectories); } }
public void removeDocumentEvents() { // Csharp project item events. if(_csProjectItemsEvents != null) { _csProjectItemsEvents.ItemAdded -= new _dispProjectItemsEvents_ItemAddedEventHandler(csharpItemAdded); _csProjectItemsEvents.ItemRemoved -= new _dispProjectItemsEvents_ItemRemovedEventHandler(csharpItemRemoved); _csProjectItemsEvents = null; } // Cpp project item events. if(_vcProjectItemsEvents != null) { _vcProjectItemsEvents.ItemAdded -= new _dispVCProjectEngineEvents_ItemAddedEventHandler(cppItemAdded); _vcProjectItemsEvents.ItemRemoved -= new _dispVCProjectEngineEvents_ItemRemovedEventHandler(cppItemRemoved); _vcProjectItemsEvents = null; } // Visual Studio document events. if(_docEvents != null) { _docEvents.DocumentSaved -= new _dispDocumentEvents_DocumentSavedEventHandler(documentSaved); _docEvents.DocumentOpened -= new _dispDocumentEvents_DocumentOpenedEventHandler(documentOpened); _docEvents = null; } }
public void initDocumentEvents() { // Csharp project item events. _csProjectItemsEvents = (EnvDTE.ProjectItemsEvents)_applicationObject.Events.GetObject("CSharpProjectItemsEvents"); if(_csProjectItemsEvents != null) { _csProjectItemsEvents.ItemAdded += new _dispProjectItemsEvents_ItemAddedEventHandler(csharpItemAdded); _csProjectItemsEvents.ItemRemoved += new _dispProjectItemsEvents_ItemRemovedEventHandler(csharpItemRemoved); } // Cpp project item events. _vcProjectItemsEvents = (VCProjectEngineEvents)_applicationObject.Events.GetObject("VCProjectEngineEventsObject"); if(_vcProjectItemsEvents != null) { _vcProjectItemsEvents.ItemAdded += new _dispVCProjectEngineEvents_ItemAddedEventHandler(cppItemAdded); _vcProjectItemsEvents.ItemRemoved += new _dispVCProjectEngineEvents_ItemRemovedEventHandler(cppItemRemoved); } // Visual Studio document events. _docEvents = _applicationObject.Events.get_DocumentEvents(null); if(_docEvents != null) { _docEvents.DocumentSaved += new _dispDocumentEvents_DocumentSavedEventHandler(documentSaved); _docEvents.DocumentOpened += new _dispDocumentEvents_DocumentOpenedEventHandler(documentOpened); } }
public void CreateTestCocoonConfig(String config, string project, List <string> additionalParamsList, List <string> additiona_includes, bool QtConfiguration) { bool foundProject = false; IEnumerator ProjectsEnumaror = GetVCProjectRefs(); ProjectsEnumaror.Reset(); // traverse all projects to find the right one while (ProjectsEnumaror.MoveNext()) { VCProject actVCP = (VCProject)ProjectsEnumaror.Current; if (actVCP.Name == project) { foundProject = true; VCConfiguration vcC = null; //vcC = (VCConfiguration)(((IVCCollection)actVCP.Configurations).Item(config)); IEnumerator ConfigurationEnumarator = ((IVCCollection)actVCP.Configurations).GetEnumerator(); for (ConfigurationEnumarator.Reset(); ConfigurationEnumarator.MoveNext();) { vcC = ConfigurationEnumarator.Current as VCConfiguration; if ((vcC != null) && (vcC.ConfigurationName == config)) { Log("Modifying configuration '" + config + "' for the project '" + project + "' for the platform '" + vcC.Name + "'"); // change settings for sepcified compiler IVCCollection ctools = (IVCCollection)vcC.Tools; VCActiveXReference cVCActiveXReference = ctools.Item("VCActiveXReference") as VCActiveXReference; VCALinkTool cVCALinkTool = ctools.Item("VCALinkTool") as VCALinkTool; VCAppVerifierTool cVCAppVerifierTool = ctools.Item("VCAppVerifierTool") as VCAppVerifierTool; VCAssemblyReference cVCAssemblyReference = ctools.Item("VCAssemblyReference") as VCAssemblyReference; VCBscMakeTool cVCBscMakeTool = ctools.Item("VCBscMakeTool") as VCBscMakeTool; VCCLCompilerTool cVCCLCompilerTool = ctools.Item("VCCLCompilerTool") as VCCLCompilerTool; VCConfiguration cVCConfiguration = ctools.Item("VCConfiguration") as VCConfiguration; VCCustomBuildRule cVCCustomBuildRule = ctools.Item("VCCustomBuildRule") as VCCustomBuildRule; VCCustomBuildTool cVCCustomBuildTool = ctools.Item("VCCustomBuildTool") as VCCustomBuildTool; VCDebugSettings cVCDebugSettings = ctools.Item("VCDebugSettings") as VCDebugSettings; VCFile cVCFile = ctools.Item("VCFile") as VCFile; VCFileConfiguration cVCFileConfiguration = ctools.Item("VCFileConfiguration") as VCFileConfiguration; VCFilter cVCFilter = ctools.Item("VCFilter") as VCFilter; VCFxCopTool cVCFxCopTool = ctools.Item("VCFxCopTool") as VCFxCopTool; VCLibrarianTool cVCLibrarianTool = ctools.Item("VCLibrarianTool") as VCLibrarianTool; VCLinkerTool cVCLinkerTool = ctools.Item("VCLinkerTool") as VCLinkerTool; VCManagedResourceCompilerTool cVCManagedResourceCompilerTool = ctools.Item("VCManagedResourceCompilerTool") as VCManagedResourceCompilerTool; VCManifestTool cVCManifestTool = ctools.Item("VCManifestTool") as VCManifestTool; VCMidlTool cVCMidlTool = ctools.Item("VCMidlTool") as VCMidlTool; VCNMakeTool cVCNMakeTool = ctools.Item("VCNMakeTool") as VCNMakeTool; VCPlatform cVCPlatform = ctools.Item("VCPlatform") as VCPlatform; VCPostBuildEventTool cVCPostBuildEventTool = ctools.Item("VCPostBuildEventTool") as VCPostBuildEventTool; VCPreBuildEventTool cVCPreBuildEventTool = ctools.Item("VCPreBuildEventTool") as VCPreBuildEventTool; VCPreLinkEventTool cVCPreLinkEventTool = ctools.Item("VCPreLinkEventTool") as VCPreLinkEventTool; VCProject cVCProject = ctools.Item("VCProject") as VCProject; VCProjectEngine cVCProjectEngine = ctools.Item("VCProjectEngine") as VCProjectEngine; VCProjectEngineEvents cVCProjectEngineEvents = ctools.Item("VCProjectEngineEvents") as VCProjectEngineEvents; VCProjectEngineObject cVCProjectEngineObject = ctools.Item("VCProjectEngineObject") as VCProjectEngineObject; VCProjectItem cVCProjectItem = ctools.Item("VCProjectItem") as VCProjectItem; VCProjectReference cVCProjectReference = ctools.Item("VCProjectReference") as VCProjectReference; VCPropertySheet cVCPropertySheet = ctools.Item("VCPropertySheet") as VCPropertySheet; VCReference cVCReference = ctools.Item("VCReference") as VCReference; VCReferences cVCReferences = ctools.Item("VCReferences") as VCReferences; VCResourceCompilerTool cVCResourceCompilerTool = ctools.Item("VCResourceCompilerTool") as VCResourceCompilerTool; VCRuntimeBooleanProperty cVCRuntimeBooleanProperty = ctools.Item("VCRuntimeBooleanProperty") as VCRuntimeBooleanProperty; VCRuntimeEnumProperty cVCRuntimeEnumProperty = ctools.Item("VCRuntimeEnumProperty") as VCRuntimeEnumProperty; VCRuntimeEnumValue cVCRuntimeEnumValue = ctools.Item("VCRuntimeEnumValue") as VCRuntimeEnumValue; VCRuntimeIntegerProperty cVCRuntimeIntegerProperty = ctools.Item("VCRuntimeIntegerProperty") as VCRuntimeIntegerProperty; VCRuntimeProperty cVCRuntimeProperty = ctools.Item("VCRuntimeProperty") as VCRuntimeProperty; VCRuntimeStringProperty cVCRuntimeStringProperty = ctools.Item("VCRuntimeStringProperty") as VCRuntimeStringProperty; VCToolFile cVCToolFile = ctools.Item("VCToolFile") as VCToolFile; VCUserMacro cVCUserMacro = ctools.Item("VCUserMacro") as VCUserMacro; VCWebDeploymentTool cVCWebDeploymentTool = ctools.Item("VCWebDeploymentTool") as VCWebDeploymentTool; VCWebServiceProxyGeneratorTool cVCWebServiceProxyGeneratorTool = ctools.Item("VCWebServiceProxyGeneratorTool") as VCWebServiceProxyGeneratorTool; VCXDCMakeTool cVCXDCMakeTool = ctools.Item("VCXDCMakeTool") as VCXDCMakeTool; VCXMLDataGeneratorTool cVCXMLDataGeneratorTool = ctools.Item("VCXMLDataGeneratorTool") as VCXMLDataGeneratorTool; VCLinkerTool linkerTool = ctools.Item("VCLinkerTool") as VCLinkerTool; VCLibrarianTool librarianTool = ctools.Item("VCLibrarianTool") as VCLibrarianTool; VCCLCompilerTool compilerTool = ctools.Item("VCCLCompilerTool") as VCCLCompilerTool; VCCustomBuildTool customBuildTool = ctools.Item("VCCustomBuildTool") as VCCustomBuildTool; string libgen = FindCslibConfig(ref compilerTool); List <string> additionalParamsListLink = new List <string>(additionalParamsList); List <string> additionalParamsListLibrarian = new List <string>(additionalParamsList); if (libgen != null) { additionalParamsListLink.Add("--cs-libgen=" + libgen); additionalParamsListLibrarian.Add("--cs-libgen=" + libgen); } if (compilerTool != null) { CreateClConfig(ref compilerTool, additionalParamsList, additiona_includes, actVCP.ProjectDirectory, config); } if (linkerTool != null) { CreateLinkConfig(ref linkerTool, additionalParamsListLink, config); } if (customBuildTool != null) { CreateCustomBuildConfig(ref customBuildTool, additionalParamsList, config); } if (librarianTool != null) { CreateLibrarianConfig(ref librarianTool, additionalParamsListLibrarian, config); } if (actVCP != null) { CreateConfigForEachFile(ref actVCP, additionalParamsList, config); } } } } } if (!foundProject) { ShowMessageBox("Could not find the project", "Warning"); } }
/// <summary> /// Retrieves the VCProjectEngine from the given project and registers the handlers for VCProjectEngineEvents. /// </summary> void RegisterVCProjectEngineEvents(Project p) { if (vcProjectEngineEvents != null) return; VCProject vcPrj = p.Object as VCProject; VCProjectEngine prjEngine = vcPrj.VCProjectEngine as VCProjectEngine; if (prjEngine != null) { vcProjectEngineEvents = prjEngine.Events as VCProjectEngineEvents; if (vcProjectEngineEvents != null) { try { vcProjectEngineEvents.ItemPropertyChange += new _dispVCProjectEngineEvents_ItemPropertyChangeEventHandler(OnVCProjectEngineItemPropertyChange); } catch { Messages.DisplayErrorMessage("VCProjectEngine events could not be registered."); } } } }