/// <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() { Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", ToString())); base.Initialize(); IDEBuildLogger.UserRegistryRoot = UserRegistryRoot; solutionEventsListener = new SolutionEventsListener(this); solutionEventsListener.AfterSolutionBackgroundLoadComplete += solutionEventsListener_AfterSolutionBackgroundLoadComplete; // Initialize the build monitor, that will display BuildEngine results in the Build Output pane. buildLogPipeGenerator = new BuildLogPipeGenerator(this); dte2 = GetGlobalService(typeof(SDTE)) as DTE2; // Register the C# language service var serviceContainer = this as IServiceContainer; var langService = new NShaderLanguageService(); langService.SetSite(this); serviceContainer.AddService(typeof(NShaderLanguageService), langService, true); // Add our command handlers for menu (commands must exist in the .vsct file) var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null != mcs) { ParadoxCommands.ServiceProvider = this; ParadoxCommands.RegisterCommands(mcs); } // Get General Output pane (for error logging) var generalOutputPane = GetGeneralOutputPane(); var paradoxSdkDir = ParadoxCommandsProxy.ParadoxSdkDir; if (paradoxSdkDir == null) { generalOutputPane.OutputStringThreadSafe("Could not find Paradox SDK directory.\r\n"); generalOutputPane.Activate(); } // Start PackageBuildMonitorRemote in a separate app domain buildMonitorDomain = ParadoxCommandsProxy.CreateAppDomain(); try { var remoteCommands = ParadoxCommandsProxy.CreateProxy(buildMonitorDomain); remoteCommands.StartRemoteBuildLogServer(new BuildMonitorCallback(dte2), buildLogPipeGenerator.LogPipeUrl); } catch (Exception e) { generalOutputPane.OutputStringThreadSafe(string.Format("Error loading Paradox SDK: {0}\r\n", e)); generalOutputPane.Activate(); // Unload domain right away AppDomain.Unload(buildMonitorDomain); buildMonitorDomain = null; } }
/// <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() { Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", ToString())); base.Initialize(); IDEBuildLogger.UserRegistryRoot = UserRegistryRoot; solutionEventsListener = new SolutionEventsListener(this); solutionEventsListener.AfterSolutionBackgroundLoadComplete += solutionEventsListener_AfterSolutionBackgroundLoadComplete; // Initialize the build monitor, that will display BuildEngine results in the Build Output pane. buildLogPipeGenerator = new BuildLogPipeGenerator(this); dte2 = GetGlobalService(typeof(SDTE)) as DTE2; // Register the C# language service var serviceContainer = this as IServiceContainer; var errorListProvider = new ErrorListProvider(this) { ProviderGuid = new Guid("ad1083c5-32ad-403d-af3d-32fee7abbdf1"), ProviderName = "Paradox Shading Language" }; var langService = new NShaderLanguageService(errorListProvider); langService.SetSite(this); langService.InitializeColors(); // Make sure to initialize colors before registering! serviceContainer.AddService(typeof(NShaderLanguageService), langService, true); // Add our command handlers for menu (commands must exist in the .vsct file) var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null != mcs) { ParadoxCommands.ServiceProvider = this; ParadoxCommands.RegisterCommands(mcs); } // Get General Output pane (for error logging) var generalOutputPane = GetGeneralOutputPane(); var paradoxSdkDir = ParadoxCommandsProxy.ParadoxSdkDir; if (paradoxSdkDir == null) { generalOutputPane.OutputStringThreadSafe("Could not find Paradox SDK directory.\r\n"); generalOutputPane.Activate(); } // Start PackageBuildMonitorRemote in a separate app domain buildMonitorDomain = ParadoxCommandsProxy.CreateParadoxDomain(); try { var remoteCommands = ParadoxCommandsProxy.CreateProxy(buildMonitorDomain); remoteCommands.StartRemoteBuildLogServer(new BuildMonitorCallback(dte2), buildLogPipeGenerator.LogPipeUrl); } catch (Exception e) { generalOutputPane.OutputStringThreadSafe(string.Format("Error loading Paradox SDK: {0}\r\n", e)); generalOutputPane.Activate(); // Unload domain right away AppDomain.Unload(buildMonitorDomain); buildMonitorDomain = null; } // Preinitialize the parser in a separate thread var thread = new System.Threading.Thread( () => { try { ParadoxCommandsProxy.GetProxy().Initialize(null); } catch (Exception ex) { generalOutputPane.OutputStringThreadSafe(string.Format("Error Initializing Paradox Language Service: {0}\r\n", ex.InnerException ?? ex)); generalOutputPane.Activate(); errorListProvider.Tasks.Add(new ErrorTask(ex.InnerException ?? ex)); } }); thread.Start(); // Register a timer to call our language service during // idle periods. var mgr = GetService(typeof(SOleComponentManager)) as IOleComponentManager; if (m_componentID == 0 && mgr != null) { OLECRINFO[] crinfo = new OLECRINFO[1]; crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO)); crinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime | (uint)_OLECRF.olecrfNeedPeriodicIdleTime; crinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal | (uint)_OLECADVF.olecadvfRedrawOff | (uint)_OLECADVF.olecadvfWarningsOff; crinfo[0].uIdleTimeInterval = 1000; int hr = mgr.FRegisterComponent(this, crinfo, out m_componentID); } }
private void InitializeCommandProxy() { // Initialize the command proxy from the current solution's package var dte = (DTE)GetService(typeof(DTE)); var solutionPath = dte.Solution.FullName; ParadoxCommandsProxy.InitialzeFromSolution(solutionPath); // Get General Output pane (for error logging) var generalOutputPane = GetGeneralOutputPane(); // If a package is associated with the solution, check if the correct version was found var paradoxPackageInfo = ParadoxCommandsProxy.ParadoxPackageInfo; if (paradoxPackageInfo.ExpectedVersion != null && paradoxPackageInfo.ExpectedVersion != paradoxPackageInfo.LoadedVersion) { if (paradoxPackageInfo.ExpectedVersion < ParadoxCommandsProxy.MinimumVersion) { // The package version is deprecated generalOutputPane.OutputStringThreadSafe(string.Format("Could not initialize Paradox extension for package with version {0}. Versions earlier than {1} are not supported. Loading latest version {2} instead.\r\n", paradoxPackageInfo.ExpectedVersion, ParadoxCommandsProxy.MinimumVersion, paradoxPackageInfo.LoadedVersion)); generalOutputPane.Activate(); } else if (paradoxPackageInfo.LoadedVersion == null) { // No version found generalOutputPane.OutputStringThreadSafe("Could not find Paradox SDK directory."); generalOutputPane.Activate(); } else { // The package version was not found generalOutputPane.OutputStringThreadSafe(string.Format("Could not find SDK directory for Paradox version {0}. Loading latest version {1} instead.\r\n", paradoxPackageInfo.ExpectedVersion, paradoxPackageInfo.LoadedVersion)); generalOutputPane.Activate(); } } // Initialize the build monitor, that will display BuildEngine results in the Build Output pane. // Seems like VS2015 display <Exec> output directly without waiting end of execution, so no need for all this anymore! // TODO: Need to find a better way to detect VS version? int visualStudioVersion; if (!int.TryParse(dte2.Version.Split('.')[0], out visualStudioVersion)) { visualStudioVersion = 12; } if (visualStudioVersion < 14) { buildLogPipeGenerator = new BuildLogPipeGenerator(this); try { // Start PackageBuildMonitorRemote in a separate app domain if (buildMonitorDomain != null) { AppDomain.Unload(buildMonitorDomain); } buildMonitorDomain = ParadoxCommandsProxy.CreateParadoxDomain(); ParadoxCommandsProxy.InitialzeFromSolution(solutionPath, buildMonitorDomain); var remoteCommands = ParadoxCommandsProxy.CreateProxy(buildMonitorDomain); remoteCommands.StartRemoteBuildLogServer(new BuildMonitorCallback(), buildLogPipeGenerator.LogPipeUrl); } catch (Exception e) { generalOutputPane.OutputStringThreadSafe(string.Format("Error loading Paradox SDK: {0}\r\n", e)); generalOutputPane.Activate(); // Unload domain right away AppDomain.Unload(buildMonitorDomain); buildMonitorDomain = null; } } // Preinitialize the parser in a separate thread var thread = new System.Threading.Thread( () => { try { ParadoxCommandsProxy.GetProxy(); } catch (Exception ex) { generalOutputPane.OutputStringThreadSafe(string.Format("Error Initializing Paradox Language Service: {0}\r\n", ex.InnerException ?? ex)); generalOutputPane.Activate(); errorListProvider.Tasks.Add(new ErrorTask(ex.InnerException ?? ex)); } }); thread.Start(); }
private void InitializeCommandProxy() { // Initialize the command proxy from the current solution's package var dte = (DTE)GetService(typeof(DTE)); var solutionPath = dte.Solution.FullName; ParadoxCommandsProxy.InitialzeFromSolution(solutionPath); // Get General Output pane (for error logging) var generalOutputPane = GetGeneralOutputPane(); // If a package is associated with the solution, check if the correct version was found var paradoxPackageInfo = ParadoxCommandsProxy.ParadoxPackageInfo; if (paradoxPackageInfo.ExpectedVersion != null && paradoxPackageInfo.ExpectedVersion != paradoxPackageInfo.LoadedVersion) { if (paradoxPackageInfo.ExpectedVersion < ParadoxCommandsProxy.MinimumVersion) { // The package version is deprecated generalOutputPane.OutputStringThreadSafe(string.Format("Could not initialize Paradox extension for package with version {0}. Versions earlier than {1} are not supported. Loading latest version {2} instead.\r\n", paradoxPackageInfo.ExpectedVersion, ParadoxCommandsProxy.MinimumVersion, paradoxPackageInfo.LoadedVersion)); generalOutputPane.Activate(); } else if (paradoxPackageInfo.LoadedVersion == null) { // No version found generalOutputPane.OutputStringThreadSafe("Could not find Paradox SDK directory."); generalOutputPane.Activate(); } else { // The package version was not found generalOutputPane.OutputStringThreadSafe(string.Format("Could not find SDK directory for Paradox version {0}. Loading latest version {1} instead.\r\n", paradoxPackageInfo.ExpectedVersion, paradoxPackageInfo.LoadedVersion)); generalOutputPane.Activate(); } } // Initialize the build monitor, that will display BuildEngine results in the Build Output pane. // Seems like VS2015 display <Exec> output directly without waiting end of execution, so no need for all this anymore! // TODO: Need to find a better way to detect VS version? int visualStudioVersion; if (!int.TryParse(dte2.Version.Split('.')[0], out visualStudioVersion)) visualStudioVersion = 12; if (visualStudioVersion < 14) { buildLogPipeGenerator = new BuildLogPipeGenerator(this); try { // Start PackageBuildMonitorRemote in a separate app domain if (buildMonitorDomain != null) AppDomain.Unload(buildMonitorDomain); buildMonitorDomain = ParadoxCommandsProxy.CreateParadoxDomain(); ParadoxCommandsProxy.InitialzeFromSolution(solutionPath, buildMonitorDomain); var remoteCommands = ParadoxCommandsProxy.CreateProxy(buildMonitorDomain); remoteCommands.StartRemoteBuildLogServer(new BuildMonitorCallback(), buildLogPipeGenerator.LogPipeUrl); } catch (Exception e) { generalOutputPane.OutputStringThreadSafe(string.Format("Error loading Paradox SDK: {0}\r\n", e)); generalOutputPane.Activate(); // Unload domain right away AppDomain.Unload(buildMonitorDomain); buildMonitorDomain = null; } } // Preinitialize the parser in a separate thread var thread = new System.Threading.Thread( () => { try { ParadoxCommandsProxy.GetProxy().Initialize(null); } catch (Exception ex) { generalOutputPane.OutputStringThreadSafe(string.Format("Error Initializing Paradox Language Service: {0}\r\n", ex.InnerException ?? ex)); generalOutputPane.Activate(); errorListProvider.Tasks.Add(new ErrorTask(ex.InnerException ?? ex)); } }); thread.Start(); }
/// <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() { Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", ToString())); base.Initialize(); IDEBuildLogger.UserRegistryRoot = UserRegistryRoot; solutionEventsListener = new SolutionEventsListener(this); solutionEventsListener.AfterSolutionBackgroundLoadComplete += solutionEventsListener_AfterSolutionBackgroundLoadComplete; // Initialize the build monitor, that will display BuildEngine results in the Build Output pane. buildLogPipeGenerator = new BuildLogPipeGenerator(this); dte2 = GetGlobalService(typeof(SDTE)) as DTE2; // Register the C# language service var serviceContainer = this as IServiceContainer; errorListProvider = new ErrorListProvider(this) { ProviderGuid = new Guid("ad1083c5-32ad-403d-af3d-32fee7abbdf1"), ProviderName = "Paradox Shading Language" }; var langService = new NShaderLanguageService(errorListProvider); langService.SetSite(this); langService.InitializeColors(); // Make sure to initialize colors before registering! serviceContainer.AddService(typeof(NShaderLanguageService), langService, true); // Add our command handlers for menu (commands must exist in the .vsct file) var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null != mcs) { ParadoxCommands.ServiceProvider = this; ParadoxCommands.RegisterCommands(mcs); } // Register a timer to call our language service during // idle periods. var mgr = GetService(typeof(SOleComponentManager)) as IOleComponentManager; if (m_componentID == 0 && mgr != null) { OLECRINFO[] crinfo = new OLECRINFO[1]; crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO)); crinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime | (uint)_OLECRF.olecrfNeedPeriodicIdleTime; crinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal | (uint)_OLECADVF.olecadvfRedrawOff | (uint)_OLECADVF.olecadvfWarningsOff; crinfo[0].uIdleTimeInterval = 1000; int hr = mgr.FRegisterComponent(this, crinfo, out m_componentID); } }