public DteEventsHandler(DTE _dte) { dte = _dte; var events = dte.Events as Events2; buildEvents = events.BuildEvents; buildEvents.OnBuildBegin += buildEvents_OnBuildBegin; buildEvents.OnBuildProjConfigBegin += OnBuildProjConfigBegin; buildEvents.OnBuildDone += buildEvents_OnBuildDone; documentEvents = events.get_DocumentEvents(null); documentEvents.DocumentSaved += DocumentSaved; projectItemsEvents = events.ProjectItemsEvents; projectItemsEvents.ItemAdded += ProjectItemsEvents_ItemAdded; projectItemsEvents.ItemRemoved += ProjectItemsEvents_ItemRemoved; projectItemsEvents.ItemRenamed += ProjectItemsEvents_ItemRenamed; solutionEvents = events.SolutionEvents; solutionEvents.ProjectAdded += SolutionEvents_ProjectAdded; solutionEvents.ProjectRemoved += SolutionEvents_ProjectRemoved; solutionEvents.Opened += SolutionEvents_Opened; solutionEvents.AfterClosing += SolutionEvents_AfterClosing; var debugCommandsGUID = "{5EFC7975-14BC-11CF-9B2B-00AA00573819}"; debugStartEvents = events.get_CommandEvents(debugCommandsGUID, 295); debugStartEvents.BeforeExecute += debugStartEvents_BeforeExecute; debugStartWithoutDebuggingEvents = events.get_CommandEvents(debugCommandsGUID, 368); debugStartWithoutDebuggingEvents.BeforeExecute += 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(); DefaultEditorsClient.Initialize(this); DefaultEditorsClient.Instance.Listen(); }
public static void Initialize(DteEventsHandler handler) { Instance = new DefaultEditorsClient(handler); }
protected override async Task InitializeAsync( CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) #endif { try { var timeInitBegin = initTimer.Elapsed; VsServiceProvider.Instance = instance = this; QtProject.ProjectTracker = this; #if !VS2013 /////////////////////////////////////////////////////////////////////////////////// // Switch to main (UI) thread await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); var timeUiThreadBegin = initTimer.Elapsed; #endif if ((Dte = VsServiceProvider.GetService <DTE>()) == null) { throw new Exception("Unable to get service: DTE"); } VsShellSettings.Manager = new ShellSettingsManager(this as IServiceProvider); eventHandler = new DteEventsHandler(Dte); DefaultEditorsClient.Initialize(eventHandler); DefaultEditorsClient.Instance.Listen(); Qml.Debug.Launcher.Initialize(); QtMainMenu.Initialize(this); QtSolutionContextMenu.Initialize(this); QtProjectContextMenu.Initialize(this); QtItemContextMenu.Initialize(this); DefaultEditorsHandler.Initialize(Dte); QtHelpMenu.Initialize(this); if (!string.IsNullOrEmpty(VsShell.InstallRootDir)) { HelperFunctions.VCPath = Path.Combine(VsShell.InstallRootDir, "VC"); } #if !VS2013 /////////////////////////////////////////////////////////////////////////////////// // Switch to background thread await TaskScheduler.Default; var timeUiThreadEnd = initTimer.Elapsed; #endif var vm = QtVersionManager.The(initDone); var error = string.Empty; if (vm.HasInvalidVersions(out error)) { Messages.PaneMessageSafe(Dte, error, 5000); } // determine the package installation directory var uri = new Uri(System.Reflection.Assembly .GetExecutingAssembly().EscapedCodeBase); PkgInstallPath = Path.GetDirectoryName( Uri.UnescapeDataString(uri.AbsolutePath)) + @"\"; var QtMsBuildDefault = Path.Combine( Environment.GetEnvironmentVariable("LocalAppData"), "QtMsBuild"); try { var qtMsBuildDefaultUri = new Uri(QtMsBuildDefault + "\\"); var qtMsBuildVsixPath = Path.Combine(PkgInstallPath, "QtMsBuild"); var qtMsBuildVsixUri = new Uri(qtMsBuildVsixPath + "\\"); if (qtMsBuildVsixUri != qtMsBuildDefaultUri) { var qtMsBuildVsixFiles = Directory .GetFiles(qtMsBuildVsixPath, "*", SearchOption.AllDirectories) .Select(x => qtMsBuildVsixUri.MakeRelativeUri(new Uri(x))); foreach (var qtMsBuildFile in qtMsBuildVsixFiles) { var sourcePath = new Uri(qtMsBuildVsixUri, qtMsBuildFile).LocalPath; var targetPath = new Uri(qtMsBuildDefaultUri, qtMsBuildFile).LocalPath; var targetPathTemp = targetPath + ".tmp"; Directory.CreateDirectory(Path.GetDirectoryName(targetPath)); File.Copy(sourcePath, targetPathTemp, overwrite: true); if (File.Exists(targetPath)) { File.Replace(targetPathTemp, targetPath, null); } else { File.Move(targetPathTemp, targetPath); } } } } catch { QtMsBuildDefault = Path.Combine(PkgInstallPath, "QtMsBuild"); } var QtMsBuildPath = Environment.GetEnvironmentVariable("QtMsBuild"); if (string.IsNullOrEmpty(QtMsBuildPath)) { Environment.SetEnvironmentVariable( "QtMsBuild", QtMsBuildDefault, EnvironmentVariableTarget.User); Environment.SetEnvironmentVariable( "QtMsBuild", QtMsBuildDefault, EnvironmentVariableTarget.Process); } CopyTextMateLanguageFiles(); UpdateDefaultEditors(Mode.Startup); CopyNatvisFile(); var modules = QtModules.Instance.GetAvailableModuleInformation(); foreach (var module in modules) { if (!string.IsNullOrEmpty(module.ResourceName)) { var translatedName = SR.GetString(module.ResourceName, this); if (!string.IsNullOrEmpty(translatedName)) { module.Name = translatedName; } } } Messages.PaneMessageSafe(Dte, string.Format("\r\n" + "== Qt Visual Studio Tools version {0}\r\n" + "\r\n" + " Initialized in: {1:0.##} msecs\r\n" #if !VS2013 + " Main (UI) thread: {2:0.##} msecs\r\n" #endif , Version.USER_VERSION , (initTimer.Elapsed - timeInitBegin).TotalMilliseconds #if !VS2013 , (timeUiThreadEnd - timeUiThreadBegin).TotalMilliseconds #endif ), 5000); } catch (Exception e) { Messages.PaneMessageSafe(Dte, e.Message + "\r\n\r\nStacktrace:\r\n" + e.StackTrace, 5000); } finally { initDone.Set(); initTimer.Stop(); } }