/// <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() { base.Initialize(); var componentModel = (IComponentModel)this.GetService(typeof(SComponentModel)); var workspace = componentModel.GetService <VisualStudioWorkspace>(); ExcessLanguageService langService = new ExcessLanguageService(workspace); langService.SetSite(this); IServiceContainer serviceContainer = this as IServiceContainer; serviceContainer.AddService(typeof(ExcessLanguageService), langService, true); // Register a timer to call our language service during // idle periods. IOleComponentManager mgr = GetService(typeof(SOleComponentManager)) as IOleComponentManager; if (_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 _componentID); } }
private void EnsureInit() { if (this._compId == VSConstants.VSCOOKIE_NIL) { lock (this) { if (this._compId == VSConstants.VSCOOKIE_NIL) { if (this._compMgr == null) { this._compMgr = (IOleComponentManager)this._serviceProvider.GetService(typeof(SOleComponentManager)); var crInfo = new OLECRINFO[1]; crInfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO)); crInfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime; crInfo[0].grfcadvf = (uint)0; crInfo[0].uIdleTimeInterval = 0; if (ErrorHandler.Failed(this._compMgr.FRegisterComponent(this, crInfo, out this._compId))) { this._compId = VSConstants.VSCOOKIE_NIL; } } } } } }
/// <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() { Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this)); var container = SetupAutofac(); // http://msdn.microsoft.com/en-us/library/bb166498.aspx // Proffer the service. var languageService = container.Resolve <LightLanguageService>(); languageService.SetSite(this); ((IServiceContainer)this).AddService(typeof(LightLanguageService), languageService, true); // Register a timer to call our language service during // idle periods. var oleManager = (IOleComponentManager)GetService(typeof(SOleComponentManager)); if (oleComponentID == 0 && oleManager != null) { var 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; oleManager.FRegisterComponent(this, crinfo, out oleComponentID); } base.Initialize(); }
protected override void Initialize() { Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString())); base.Initialize(); IServiceContainer sc = (IServiceContainer)this; // Register Language languageService = new NeoLuaLanguageService(); languageService.SetSite(this); sc.AddService(typeof(NeoLuaLanguageService), languageService, true); // Register timer for the language IOleComponentManager mgr = this.GetService(typeof(SOleComponentManager)) as IOleComponentManager; if (mgr != null && languageTimerComponent == 0) { OLECRINFO[] crinfo = new OLECRINFO[1]; crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO)); crinfo[0].grfcrf = (uint)(_OLECRF.olecrfNeedIdleTime | _OLECRF.olecrfNeedPeriodicIdleTime); crinfo[0].grfcadvf = (uint)(_OLECADVF.olecadvfModal | _OLECADVF.olecadvfRedrawOff | _OLECADVF.olecadvfWarningsOff); crinfo[0].uIdleTimeInterval = 1000; Marshal.ThrowExceptionForHR(mgr.FRegisterComponent(this, crinfo, out languageTimerComponent)); } } // proc Initialize
protected void Register() { Debug.Assert(!this.IsComponent); uiThread = Thread.CurrentThread; using (lockObject.Lock()) { var crinfo = new OLECRINFO[1]; oleComponentManager = (IOleComponentManager)Package.GetGlobalService(typeof(SOleComponentManager)); queuedActions = new Queue <GlobalCommandTargetAction>(); whenActions = new List <GlobalCommandTargetAction>(); 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 = 100; var hr = oleComponentManager.FRegisterComponent(this, crinfo, out componentId); if (ErrorHandler.Failed(hr)) { Marshal.ThrowExceptionForHR(hr); } } }
protected override void Initialize() { UIThread.EnsureService(this); base.Initialize(); this.RegisterProjectFactory(CreateProjectFactory()); var editFactory = CreateEditorFactory(); if (editFactory != null) { this.RegisterEditorFactory(editFactory); } var encodingEditorFactory = CreateEditorFactoryPromptForEncoding(); if (encodingEditorFactory != null) { RegisterEditorFactory(encodingEditorFactory); } var componentManager = this._compMgr = (IOleComponentManager)GetService(typeof(SOleComponentManager)); var crinfo = new OLECRINFO[1]; crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO)); crinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime; crinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal | (uint)_OLECADVF.olecadvfRedrawOff | (uint)_OLECADVF.olecadvfWarningsOff; crinfo[0].uIdleTimeInterval = 0; ErrorHandler.ThrowOnFailure(componentManager.FRegisterComponent(this, crinfo, out this._componentID)); }
/// <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() { base.Initialize(); var serviceContainer = this as IServiceContainer; var hspLangService = new HSPLanguageService(); hspLangService.SetSite(this); serviceContainer.AddService(typeof(HSPLanguageService), hspLangService, true); var manager = GetService(typeof(SOleComponentManager)) as IOleComponentManager; if (_componentId != 0 || manager == null) { return; } var 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; manager.FRegisterComponent(this, crinfo, out _componentId); }
///////////////////////////////////////////////////////////////////////////// // Overriden Package Implementation #region Package Members /// <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 initilaization code that rely on services provided by VisualStudio. /// </summary> protected override void Initialize() { Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString())); base.Initialize(); // required // Proffer the service. IServiceContainer serviceContainer = this as IServiceContainer; PascalLanguageService langService = new PascalLanguageService(); langService.SetSite(this); serviceContainer.AddService(typeof(PascalLanguageService), langService, true); // Register a timer to call our language service during // idle periods. IOleComponentManager 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); } }
public IdleManager(IServiceProvider serviceProvider) { _serviceProvider = serviceProvider; _compMgr = new Lazy <IOleComponentManager>(() => (IOleComponentManager)serviceProvider?.GetService(typeof(SOleComponentManager)) ); _compId = new Lazy <uint>(() => { var compMgr = _compMgr.Value; if (compMgr == null) { return(VSConstants.VSCOOKIE_NIL); } uint compId; OLECRINFO[] crInfo = new OLECRINFO[1]; crInfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO)); crInfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime; crInfo[0].grfcadvf = (uint)0; crInfo[0].uIdleTimeInterval = 0; if (ErrorHandler.Failed(compMgr.FRegisterComponent(this, crInfo, out compId))) { return(VSConstants.VSCOOKIE_NIL); } return(compId); }); }
protected override void Initialize() { if (GetService(typeof(UIThreadBase)) == null) { ((IServiceContainer)this).AddService(typeof(UIThreadBase), new UIThread(ThreadHelper.JoinableTaskFactory), true); } base.Initialize(); RegisterProjectFactory(CreateProjectFactory()); var editFactory = CreateEditorFactory(); if (editFactory != null) { RegisterEditorFactory(editFactory); } var encodingEditorFactory = CreateEditorFactoryPromptForEncoding(); if (encodingEditorFactory != null) { RegisterEditorFactory(encodingEditorFactory); } var componentManager = _compMgr = (IOleComponentManager)GetService(typeof(SOleComponentManager)); OLECRINFO[] crinfo = new OLECRINFO[1]; crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO)); crinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime; crinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal | (uint)_OLECADVF.olecadvfRedrawOff | (uint)_OLECADVF.olecadvfWarningsOff; crinfo[0].uIdleTimeInterval = 0; ErrorHandler.ThrowOnFailure(componentManager.FRegisterComponent(this, crinfo, out _componentID)); }
protected override async Task InitializeAsync( CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { await base.InitializeAsync(cancellationToken, progress).ConfigureAwait(false); await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); // Proffer the service. var serviceContainer = this as IAsyncServiceContainer; var langService = new XSharpLanguageService(); langService.SetSite(this); serviceContainer.AddService(typeof(XSharpLanguageService), (container, token, type) => Task.FromResult((object)langService), true); // Register a timer to call our language service during idle periods. if (mComponentID == 0 && (await GetServiceAsync(typeof(SOleComponentManager)).ConfigureAwait(true) is IOleComponentManager xMgr)) { var crinfo = new OLECRINFO { cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO)), grfcrf = (uint)(_OLECRF.olecrfNeedIdleTime | _OLECRF.olecrfNeedPeriodicIdleTime), grfcadvf = (uint)(_OLECADVF.olecadvfModal | _OLECADVF.olecadvfRedrawOff | _OLECADVF.olecadvfWarningsOff), uIdleTimeInterval = 1000 }; xMgr.FRegisterComponent(this, new OLECRINFO[] { crinfo }, out mComponentID); } }
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); _uiThread = (UIThreadBase)GetService(typeof(UIThreadBase)); if (_uiThread == null) { _uiThread = new UIThread(JoinableTaskFactory); AddService <UIThreadBase>(_uiThread, true); } AddService(GetLibraryManagerType(), CreateLibraryManager, true); var crinfo = new OLECRINFO { cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO)), grfcrf = (uint)_OLECRF.olecrfNeedIdleTime, grfcadvf = (uint)_OLECADVF.olecadvfModal | (uint)_OLECADVF.olecadvfRedrawOff | (uint)_OLECADVF.olecadvfWarningsOff, uIdleTimeInterval = 0 }; _compMgr = (IOleComponentManager)GetService(typeof(SOleComponentManager)); ErrorHandler.ThrowOnFailure(_compMgr.FRegisterComponent(this, new[] { crinfo }, out _componentID)); await base.InitializeAsync(cancellationToken, progress); }
public virtual int SetSite(Microsoft.VisualStudio.OLE.Interop.IServiceProvider site) { this.site = new ServiceProvider(site); // register our independent view with the IVsTextManager so that it knows // the user is working with a view over the text buffer. this will trigger // the text buffer to prompt the user whether to reload the file if it is // edited outside of the development Environment. IVsTextManager textManager = (IVsTextManager)this.site.QueryService(VsConstants.SID_SVsTextManager, typeof(IVsTextManager)); if (textManager != null) { IVsWindowPane windowPane = (IVsWindowPane)this; textManager.RegisterIndependentView(this, (VsTextBuffer)this.buffer); } //register with ComponentManager for Idle processing this.componentManager = (IOleComponentManager)this.site.QueryService(VsConstants.SID_SOleComponentManager, typeof(IOleComponentManager)); if (componentID == 0) { 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; this.componentManager.FRegisterComponent(this, crinfo, out this.componentID); } return(0); }
protected override void Initialize() { base.Initialize(); // Proffer the service. IServiceContainer serviceContainer = this as IServiceContainer; AdaLanguageService langService = new AdaLanguageService(); langService.SetSite(this); serviceContainer.AddService (typeof(AdaLanguageService), langService, true); // Now register the project factory this.RegisterProjectFactory(new AdaProjectFactory(this)); // Register a timer to call our language service during // idle periods. IOleComponentManager 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); } }
/// <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() { base.Initialize(); if (!SetupMode) { // Ensure our settings are loaded GetDialogPage(typeof(SnippetPreviewWindowSettings)); // Create the preview window myPreviewWindow = new SnippetPreviewWindow(this); // Enable idle handling IOleComponentManager componentManager; if (myComponentId == 0 && null != (componentManager = (IOleComponentManager)GetService(typeof(SOleComponentManager)))) { OLECRINFO[] pcrinfo = new OLECRINFO[1]; pcrinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO)); pcrinfo[0].grfcrf = (uint)(_OLECRF.olecrfNeedIdleTime | _OLECRF.olecrfNeedPeriodicIdleTime); pcrinfo[0].grfcadvf = (uint)(_OLECADVF.olecadvfModal | _OLECADVF.olecadvfRedrawOff); // Not sure why here, just following the Xml Editor Package pcrinfo[0].uIdleTimeInterval = 1000; componentManager.FRegisterComponent(this, pcrinfo, out myComponentId); } } }
/// <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 async Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress) { Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering InitializeAsync() of: {0}", ToString())); await base.InitializeAsync(cancellationToken, progress); IDEBuildLogger.UserRegistryRoot = UserRegistryRoot; // Switching to main thread to use GetService RPC and cast to service interface (which may involve COM operations) // Note: most of our work is not supposed to be heavy, mostly registration of services and callbacks await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); solutionEventsListener = new SolutionEventsListener(this); solutionEventsListener.BeforeSolutionClosed += solutionEventsListener_BeforeSolutionClosed; solutionEventsListener.AfterSolutionBackgroundLoadComplete += solutionEventsListener_AfterSolutionBackgroundLoadComplete; solutionEventsListener.AfterActiveConfigurationChange += SolutionEventsListener_AfterActiveConfigurationChange; solutionEventsListener.StartupProjectChanged += SolutionEventsListener_OnStartupProjectChanged; 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 = "Xenko 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 = await GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService; if (null != mcs) { XenkoCommands.ServiceProvider = this; XenkoCommands.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); } // Go back to async thread await TaskScheduler.Default; }
protected override void Initialize() { base.Initialize(); // Register the editor factory. RegisterEditorFactory(new CMakeEditorFactory(this)); // Register the language service. IServiceContainer container = this as IServiceContainer; CMakeLanguageService service = new CMakeLanguageService(); service.SetSite(this); container.AddService(typeof(CMakeLanguageService), service, true); // Register callbacks to respond to menu commands. OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (mcs != null) { RegisterMenuCallback(mcs, CMakeCmdIds.cmdidCMake, CMakeMenuCallback); RegisterHelpMenuCallback(mcs, CMakeCmdIds.cmdidCMakeHelp, "html\\index.html", "cmake.html"); RegisterHelpMenuCallback(mcs, CMakeCmdIds.cmdidCMakeHelpCommands, "html\\manual\\cmake-commands.7.html", "cmake-commands.html"); RegisterHelpMenuCallback(mcs, CMakeCmdIds.cmdidCMakeHelpModules, "html\\manual\\cmake-modules.7.html", "cmake-modules.html"); RegisterHelpMenuCallback(mcs, CMakeCmdIds.cmdidCMakeHelpProperties, "html\\manual\\cmake-properties.7.html", "cmake-properties.html"); RegisterHelpMenuCallback(mcs, CMakeCmdIds.cmdidCMakeHelpVariables, "html\\manual\\cmake-variables.7.html", "cmake-variables.html"); RegisterHelpMenuCallback(mcs, CMakeCmdIds.cmdidCMakeHelpCPack, "html\\manual\\cpack.1.html", "cpack.html"); RegisterHelpMenuCallback(mcs, CMakeCmdIds.cmdidCMakeHelpCTest, "html\\manual\\ctest.1.html", "ctest.html"); RegisterMenuCallback(mcs, CMakeCmdIds.cmdidCMakeHelpWebSite, CMakeHelpWebSiteMenuCallback); } // Register this object as an OLE component. This is boilerplate code that // every language service package must have in order for the language // service's OnIdle method to be called. IOleComponentManager manager = (IOleComponentManager)GetService(typeof(SOleComponentManager)); if (manager != 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 = 100; uint componentID = 0; manager.FRegisterComponent(this, crinfo, out componentID); } }
/// <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.BeforeSolutionClosed += solutionEventsListener_BeforeSolutionClosed; solutionEventsListener.AfterSolutionBackgroundLoadComplete += solutionEventsListener_AfterSolutionBackgroundLoadComplete; solutionEventsListener.AfterActiveConfigurationChange += SolutionEventsListener_AfterActiveConfigurationChange; solutionEventsListener.StartupProjectChanged += SolutionEventsListener_OnStartupProjectChanged; 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 = "Xenko 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) { XenkoCommands.ServiceProvider = this; XenkoCommands.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); } }
public int FRegisterComponent(IOleComponent piComponent, OLECRINFO[] pcrinfo, out uint pdwComponentID) { var flags = (_OLECRF)pcrinfo[0].grfcrf; if (flags.HasFlag(_OLECRF.olecrfNeedIdleTime)) { _idleComponents[++_idleCount] = piComponent; pdwComponentID = _idleCount; } else { throw new NotImplementedException(); } return VSConstants.S_OK; }
public IdleTimeSource() { var 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 = 200; var oleComponentManager = RPackage.GetGlobalService(typeof(SOleComponentManager)) as IOleComponentManager; oleComponentManager.FRegisterComponent(this, crinfo, out _componentID); }
public VsIdleTimeService(IOleComponentManager oleComponentManager) { var 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 = 200; oleComponentManager.FRegisterComponent(this, crinfo, out _componentID); }
public AppEventsSource() { 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 = 200; IOleComponentManager oleComponentManager = VsAppShell.Current.GetGlobalService<IOleComponentManager>(typeof(SOleComponentManager)); int hr = oleComponentManager.FRegisterComponent(this, crinfo, out _componentID); Debug.Assert(ErrorHandler.Succeeded(hr)); }
public AppEventsSource() { 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 = 200; IOleComponentManager oleComponentManager = VsAppShell.Current.GetGlobalService <IOleComponentManager>(typeof(SOleComponentManager)); int hr = oleComponentManager.FRegisterComponent(this, crinfo, out _componentID); Debug.Assert(ErrorHandler.Succeeded(hr)); }
protected override void Initialize() { var componentManager = _compMgr = (IOleComponentManager)GetService(typeof(SOleComponentManager)); OLECRINFO[] crinfo = new OLECRINFO[1]; crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO)); crinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime; crinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal | (uint)_OLECADVF.olecadvfRedrawOff | (uint)_OLECADVF.olecadvfWarningsOff; crinfo[0].uIdleTimeInterval = 0; ErrorHandler.ThrowOnFailure(componentManager.FRegisterComponent(this, crinfo, out _componentID)); base.Initialize(); }
/// <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 initilaization code that rely on services provided by VisualStudio. /// </summary> protected override void Initialize() { base.Initialize(); Log.Initialize(); ProbeEnvironment.Initialize(); TempManager.Init(TempDir); Snippets.SnippetDeploy.DeploySnippets(); CodeModel.SignatureDocumentor.Initialize(); ThreadHelper.ThrowIfNotOnUIThread(); // Proffer the service. http://msdn.microsoft.com/en-us/library/bb166498.aspx var langService = new ProbeLanguageService(this); langService.SetSite(this); (this as IServiceContainer).AddService(typeof(ProbeLanguageService), langService, true); // Register a timer to call our language service during idle periods. var mgr = GetService(typeof(SOleComponentManager)) as IOleComponentManager; if (_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 _componentId); } _errorTaskProvider = new ErrorTagging.ErrorTaskProvider(this); TaskListService.RegisterTaskProvider(_errorTaskProvider, out _errorTaskProviderCookie); var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (mcs != null) { Commands.InitCommands(mcs); } _functionScanner = new FunctionFileScanning.FFScanner(); // Need to keep a reference to Events and DocumentEvents in order for DocumentSaved to be triggered. _dteEvents = Shell.DTE.Events; _dteDocumentEvents = _dteEvents.DocumentEvents; _dteDocumentEvents.DocumentSaved += DocumentEvents_DocumentSaved; Microsoft.VisualStudio.PlatformUI.VSColorTheme.ThemeChanged += VSColorTheme_ThemeChanged; }
private void RegisterToComponentManager() { var componentManager = (IOleComponentManager)GetService(typeof(SOleComponentManager)); OLECRINFO[] crinfo = new OLECRINFO[1]; crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO)); crinfo[0].grfcrf = (uint)(_OLECRF.olecrfNeedIdleTime | _OLECRF.olecrfNeedPeriodicIdleTime); crinfo[0].grfcadvf = (uint)(_OLECADVF.olecadvfModal | _OLECADVF.olecadvfRedrawOff | _OLECADVF.olecadvfWarningsOff); crinfo[0].uIdleTimeInterval = 0; int hr = componentManager.FRegisterComponent(this, crinfo, out m_ComponentId); ErrorHandler.ThrowOnFailure(hr); }
private void RegisterOleComponent() { OleCom = new OleComponent(); var ocm = this.GetService(typeof(SOleComponentManager)) as IOleComponentManager; if (ocm != null) { uint pwdID; OLECRINFO[] crinfo = new OLECRINFO[1]; crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO)); crinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedAllActiveNotifs; ocm.FRegisterComponent(OleCom, crinfo, out pwdID); } }
private void RegisterForIdleTime() { IOleComponentManager mgr = GetIOleComponentManager(); if (_componentID == 0) { 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 | _OLECADVF.olecadvfRedrawOff | _OLECADVF.olecadvfWarningsOff); crinfo[0].uIdleTimeInterval = 1000; ErrorHandler.ThrowOnFailure(mgr.FRegisterComponent(this, crinfo, out _componentID)); } }
private void RegisterDummyComponent() { var component = new EmptyOleComponent(); var regInfo = new OLECRINFO { grfcrf = 0U, grfcadvf = 0U, uIdleTimeInterval = 0U }; regInfo.cbSize = (uint)Marshal.SizeOf(regInfo); int result = _manager.FRegisterComponent(component, new[] { regInfo }, out _componentCookie); if (!ErrorHandler.Succeeded(result)) { throw new InvalidOperationException("Could not register the OleComponent"); } _manager.FOnComponentActivate(_componentCookie); }
protected override void Initialize() { base.Initialize(); // --- Create and initialize the editor var componentManager = (IOleComponentManager)GetService(typeof(SOleComponentManager)); if (_componentId == 0 && componentManager != null) { var 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 = 100; var hr = componentManager.FRegisterComponent(this, crinfo, out _componentId); ErrorHandler.Succeeded(hr); } _undoManager = (IOleUndoManager)GetService(typeof(SOleUndoManager)); var linkCapableUndoMgr = (IVsLinkCapableUndoManager)_undoManager; linkCapableUndoMgr?.AdviseLinkedUndoClient(this); // This is the user control hosted by the tool window; Note that, even if this class implements IDisposable, // we are not calling Dispose on this object. This is because ToolWindowPane calls Dispose on // the object returned by the Content property. Content = EditorControl = new TControl(); OnEditorControlInitialized(); var mcs = GetService(typeof(IMenuCommandService)) as IMenuCommandService; if (null == mcs) { return; } // Now create one object derived from MenuCommnad for each command defined in // the CTC file and add it to the command service. // For each command we have to define its id that is a unique Guid/integer pair, then // create the OleMenuCommand object for this command. The EventHandler object is the // function that will be called when the user will select the command. Then we add the // OleMenuCommand to the menu service. The addCommand helper function does all this for us. AddCommand(mcs, VSConstants.GUID_VSStandardCommandSet97, (int)VSConstants.VSStd97CmdID.NewWindow, OnNewWindow, OnQueryNewWindow); }
private void RegisterForIdleTime() { IOleComponentManager mgr = GetService(typeof(SOleComponentManager)) as IOleComponentManager; if (_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 _componentID); } }
public void RegisterForIdleTimeCallbacks(IOleComponentManager cmService) { _cmService = cmService; if (_cmService != null) { OLECRINFO[] pcrinfo = new OLECRINFO[1]; pcrinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO)); pcrinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime | (uint)_OLECRF.olecrfNeedPeriodicIdleTime; pcrinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal | (uint)_OLECADVF.olecadvfRedrawOff | (uint)_OLECADVF.olecadvfWarningsOff; pcrinfo[0].uIdleTimeInterval = 100; _cmService.FRegisterComponent(this, pcrinfo, out _wComponentID); } }
protected override void Initialize() { var container = (IServiceContainer)this; UIThread.EnsureService(this); container.AddService(GetLibraryManagerType(), this.CreateService, true); var componentManager = this._compMgr = (IOleComponentManager)GetService(typeof(SOleComponentManager)); var crinfo = new OLECRINFO[1]; crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO)); crinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime; crinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal | (uint)_OLECADVF.olecadvfRedrawOff | (uint)_OLECADVF.olecadvfWarningsOff; crinfo[0].uIdleTimeInterval = 0; ErrorHandler.ThrowOnFailure(componentManager.FRegisterComponent(this, crinfo, out this._componentID)); base.Initialize(); }
protected override void Initialize() { base.Initialize(); this.RegisterProjectFactory(CreateProjectFactory()); var editFactory = CreateEditorFactory(); if (editFactory != null) { this.RegisterEditorFactory(editFactory); } var encodingEditorFactory = CreateEditorFactoryPromptForEncoding(); if (encodingEditorFactory != null) { RegisterEditorFactory(encodingEditorFactory); } var componentManager = _compMgr = (IOleComponentManager)GetService(typeof(SOleComponentManager)); OLECRINFO[] crinfo = new OLECRINFO[1]; crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO)); crinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime; crinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal | (uint)_OLECADVF.olecadvfRedrawOff | (uint)_OLECADVF.olecadvfWarningsOff; crinfo[0].uIdleTimeInterval = 0; ErrorHandler.ThrowOnFailure(componentManager.FRegisterComponent(this, crinfo, out _componentID)); }
private void EnsureInit() { if (_compId == VSConstants.VSCOOKIE_NIL) { lock (this) { if (_compId == VSConstants.VSCOOKIE_NIL) { if (_compMgr == null) { _compMgr = (IOleComponentManager)_serviceProvider.GetService(typeof(SOleComponentManager)); OLECRINFO[] crInfo = new OLECRINFO[1]; crInfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO)); crInfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime; crInfo[0].grfcadvf = (uint)0; crInfo[0].uIdleTimeInterval = 0; if (ErrorHandler.Failed(_compMgr.FRegisterComponent(this, crInfo, out _compId))) { _compId = VSConstants.VSCOOKIE_NIL; } } } } } }
/// 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 initilaization code that rely on services provided by VisualStudio. protected override void Initialize() { base.Initialize(); // Proffer the service. var serviceContainer = this as IServiceContainer; var langService = new XSharpLanguageService(); langService.SetSite(this); serviceContainer.AddService(typeof(XSharpLanguageService), langService, true); // Register a timer to call our language service during idle periods. var xMgr = GetService(typeof(SOleComponentManager)) as IOleComponentManager; if (mComponentID == 0 && xMgr != 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; xMgr.FRegisterComponent(this, crinfo, out mComponentID); } }
protected override void Initialize() { base.Initialize(); IServiceContainer serviceContainer = this as IServiceContainer; AphidLanguageService langService = new AphidLanguageService(); langService.SetSite(this); serviceContainer.AddService(typeof(AphidLanguageService), langService, true); IOleComponentManager manager = GetService(typeof(SOleComponentManager)) as IOleComponentManager; if (_componentID == 0 && manager != 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 = 500; int hr = manager.FRegisterComponent(this, crinfo, out _componentID); } }
protected BabelPackage() { ServiceCreatorCallback callback = new ServiceCreatorCallback( delegate(IServiceContainer container, Type serviceType) { if (typeof(BlenXLanguageService) == serviceType) { BlenXLanguageService language = new BlenXLanguageService(this); language.SetSite(this); // register for idle time callbacks IOleComponentManager mgr = GetService(typeof(SOleComponentManager)) as IOleComponentManager; if (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 componentID); } return language; } else { return null; } }); // proffer the LanguageService (this as IServiceContainer).AddService(typeof(BlenXLanguageService), callback, true); }
public virtual void OnActivationChange(Microsoft.VisualStudio.OLE.Interop.IOleComponent pic, int fSameComponent, OLECRINFO[] pcrinfo, int fHostIsActivating, OLECHOSTINFO[] pchostinfo, uint dwReserved) { }
public virtual int SetSite(Microsoft.VisualStudio.OLE.Interop.IServiceProvider site) { this.site = new ServiceProvider(site); if (this.buffer != null) { // register our independent view with the IVsTextManager so that it knows // the user is working with a view over the text buffer. this will trigger // the text buffer to prompt the user whether to reload the file if it is // edited outside of the development Environment. IVsTextManager textManager = (IVsTextManager)this.site.GetService(typeof(SVsTextManager)); // NOTE: NativeMethods.ThrowOnFailure is removed from this method because you are not allowed // to fail a SetSite call, see debug assert at f:\dd\env\msenv\core\docwp.cpp line 87. int hr = 0; if (textManager != null) { IVsWindowPane windowPane = (IVsWindowPane)this; hr = textManager.RegisterIndependentView(this, this.buffer); if (!NativeMethods.Succeeded(hr)) Debug.Assert(false, "RegisterIndependentView failed"); } } //register with ComponentManager for Idle processing this.componentManager = (IOleComponentManager)this.site.GetService(typeof(SOleComponentManager)); if (componentID == 0) { OLECRINFO[] crinfo = new OLECRINFO[1]; crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO)); crinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime | (uint)_OLECRF.olecrfNeedPeriodicIdleTime | (uint)_OLECRF.olecrfNeedAllActiveNotifs | (uint)_OLECRF.olecrfNeedSpecActiveNotifs; crinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal | (uint)_OLECADVF.olecadvfRedrawOff | (uint)_OLECADVF.olecadvfWarningsOff; crinfo[0].uIdleTimeInterval = 1000; int hr = this.componentManager.FRegisterComponent(this, crinfo, out this.componentID); if (!NativeMethods.Succeeded(hr)) Debug.Assert(false, "FRegisterComponent failed"); } return NativeMethods.S_OK; }
private void Start() { // Register a timer to call our language service during // idle periods. var mgr = Site.GetService(typeof(SOleComponentManager)) as IOleComponentManager; if (mComponentId == 0 && mgr != null) { var 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 = 100; mgr.FRegisterComponent(this, crinfo, out mComponentId); } }
protected override void Initialize() { var container = (IServiceContainer)this; UIThread.EnsureService(this); container.AddService(GetLibraryManagerType(), CreateService, true); var componentManager = _compMgr = (IOleComponentManager)GetService(typeof(SOleComponentManager)); OLECRINFO[] crinfo = new OLECRINFO[1]; crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO)); crinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime; crinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal | (uint)_OLECADVF.olecadvfRedrawOff | (uint)_OLECADVF.olecadvfWarningsOff; crinfo[0].uIdleTimeInterval = 0; ErrorHandler.ThrowOnFailure(componentManager.FRegisterComponent(this, crinfo, out _componentID)); base.Initialize(); }
/// <summary> /// Called after the WindowPane has been sited with an IServiceProvider from the environment /// protected override void Initialize() { base.Initialize(); // Create and initialize the editor #region Register with IOleComponentManager IOleComponentManager componentManager = (IOleComponentManager)GetService(typeof(SOleComponentManager)); if (this._componentId == 0 && componentManager != 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 = 100; int hr = componentManager.FRegisterComponent(this, crinfo, out this._componentId); ErrorHandler.Succeeded(hr); } #endregion System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EditorPane)); #region Hook Undo Manager // Attach an IOleUndoManager to our WindowFrame. Merely calling QueryService // for the IOleUndoManager on the site of our IVsWindowPane causes an IOleUndoManager // to be created and attached to the IVsWindowFrame. The WindowFrame automaticall // manages to route the undo related commands to the IOleUndoManager object. // Thus, our only responsibilty after this point is to add IOleUndoUnits to the // IOleUndoManager (aka undo stack). _undoManager = (IOleUndoManager)GetService(typeof(SOleUndoManager)); // In order to use the IVsLinkedUndoTransactionManager, it is required that you // advise for IVsLinkedUndoClient notifications. This gives you a callback at // a point when there are intervening undos that are blocking a linked undo. // You are expected to activate your document window that has the intervening undos. if (_undoManager != null) { IVsLinkCapableUndoManager linkCapableUndoMgr = (IVsLinkCapableUndoManager)_undoManager; if (linkCapableUndoMgr != null) { linkCapableUndoMgr.AdviseLinkedUndoClient(this); } } #endregion // hook up our XmlEditorService es = GetService(typeof(XmlEditorService)) as XmlEditorService; _store = es.CreateXmlStore(); _store.UndoManager = _undoManager; _model = _store.OpenXmlModel(new Uri(_fileName)); // This is the user control hosted by the tool window; Note that, even if this class implements IDisposable, // we are not calling Dispose on this object. This is because ToolWindowPane calls Dispose on // the object returned by the Content property. _vsDesignerControl = new VsDesignerControl(_service, new ViewModel(_store, _model, this, _textBuffer)); base.Content = _vsDesignerControl; RegisterIndependentView(true); IMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as IMenuCommandService; if (null != mcs) { // Now create one object derived from MenuCommnad for each command defined in // the CTC file and add it to the command service. // For each command we have to define its id that is a unique Guid/integer pair, then // create the OleMenuCommand object for this command. The EventHandler object is the // function that will be called when the user will select the command. Then we add the // OleMenuCommand to the menu service. The addCommand helper function does all this for us. AddCommand(mcs, VSConstants.GUID_VSStandardCommandSet97, (int)VSConstants.VSStd97CmdID.NewWindow, new EventHandler(OnNewWindow), new EventHandler(OnQueryNewWindow)); AddCommand(mcs, VSConstants.GUID_VSStandardCommandSet97, (int)VSConstants.VSStd97CmdID.ViewCode, new EventHandler(OnViewCode), new EventHandler(OnQueryViewCode)); } }
private void RegisterForIdleTime() { IOleComponentManager mgr = GetService(typeof(SOleComponentManager)) as IOleComponentManager; if (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 componentID); } }
/// <summary> /// Initializes the DTE and the code outline file manager, and hooks up events. /// </summary> private void InitializeSourceOutlinerToolWindow() { var dte = GetService(typeof(_DTE)) as DTE; sourceOutlinerWindow = (SourceOutlineToolWindow)FindToolWindow(typeof(SourceOutlineToolWindow), 0, true); sourceOutlinerWindow.Package = this; OLECRINFO[] crinfo = new OLECRINFO[1]; crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO)); crinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime | (uint)_OLECRF.olecrfNeedPeriodicIdleTime | (uint)_OLECRF.olecrfNeedAllActiveNotifs | (uint)_OLECRF.olecrfNeedSpecActiveNotifs; crinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal | (uint)_OLECADVF.olecadvfRedrawOff | (uint)_OLECADVF.olecadvfWarningsOff; crinfo[0].uIdleTimeInterval = 500; int hr = componentManager.FRegisterComponent(sourceOutlinerWindow, crinfo, out componentID); if (!ErrorHandler.Succeeded(hr)) { Trace.WriteLine("Initialize->IOleComponent registration failed"); } sourceOutlinerWindow.InitializeDTE(dte); sourceOutlinerWindow.AddWindowEvents(); sourceOutlinerWindow.AddSolutionEvents(); }
/// <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}", this.ToString())); base.Initialize(); // this.RegisterProjectFactory(new PieConsoleProjectFactory(this)); // Proffer the service. IServiceContainer serviceContainer = this as IServiceContainer; PieLanguageService langService = new PieLanguageService(); langService.SetSite(this); serviceContainer.AddService(typeof(PieLanguageService), langService, true); // Register a timer to call our language service during // idle periods. IOleComponentManager 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); } }
/// <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 initilaization code that rely on services provided by VisualStudio. /// </summary> protected override void Initialize() { Trace.WriteLine (string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString())); base.Initialize(); _languageService = new Babel.HLSLLanguageService(); _languageService.SetSite(this); IServiceContainer serviceContainer = (IServiceContainer)this; serviceContainer.AddService(typeof(Babel.HLSLLanguageService), _languageService, true); _languageService.Preferences.ParameterInformation = true; IOleComponentManager componentManager = (IOleComponentManager)this.GetService(typeof(SOleComponentManager)); if (componentID == 0 && componentManager != 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; componentManager.FRegisterComponent(this, crinfo, out componentID); } }
/// <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 initilaization code that rely on services provided by VisualStudio. /// </summary> protected override void Initialize() { Trace.WriteLine (string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString())); base.Initialize(); String installDir = System.Reflection.Assembly.GetExecutingAssembly().CodeBase; if (installDir.StartsWith("file:///")) { installDir = installDir.Remove(0, 8); } installDir = System.IO.Path.GetDirectoryName(installDir); //Trace.WriteLine(string.Format("Installation dir: {0}", installDir)); // Create our editor factory and register it this.editorFactory = new EditorFactory(this); base.RegisterEditorFactory(this.editorFactory); // Offer the language service. IServiceContainer serviceContainer = this as IServiceContainer; HaskellService haskellService = new HaskellService(installDir); haskellService.SetSite(this); serviceContainer.AddService(typeof(HaskellService), haskellService, true); // Register a timer to call our language service during // idle periods. IOleComponentManager 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); } }
public virtual int SetSite(Microsoft.VisualStudio.OLE.Interop.IServiceProvider site){ this.site = new ServiceProvider(site); // register our independent view with the IVsTextManager so that it knows // the user is working with a view over the text buffer. this will trigger // the text buffer to prompt the user whether to reload the file if it is // edited outside of the development Environment. IVsTextManager textManager = (IVsTextManager)this.site.QueryService(VsConstants.SID_SVsTextManager, typeof(IVsTextManager)); if (textManager != null) { IVsWindowPane windowPane = (IVsWindowPane)this; textManager.RegisterIndependentView(this, (VsTextBuffer)this.buffer); } //register with ComponentManager for Idle processing this.componentManager = (IOleComponentManager)this.site.QueryService(VsConstants.SID_SOleComponentManager, typeof(IOleComponentManager)); if (componentID == 0){ 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; this.componentManager.FRegisterComponent(this, crinfo, out this.componentID); } return 0; }
/// <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); } }
public virtual void SetSite(Microsoft.VisualStudio.OLE.Interop.IServiceProvider site){ this.site = new ServiceProvider(site); this.editorFactory = CreateEditorFactory(); if (this.editorFactory != null) { this.editorFactory.SetSite(site); Guid editorGuid = this.editorFactory.GetType().GUID; IVsRegisterEditors vre = (IVsRegisterEditors)this.site.QueryService( VsConstants.SID_SVsRegisterEditors, typeof(IVsRegisterEditors)); vre.RegisterEditor(ref editorGuid, editorFactory, out this.editorFactoryCookie); } this.projectFactory = CreateProjectFactory(); if (this.projectFactory != null) { this.projectFactory.SetSite(site); IVsRegisterProjectTypes rpt = (IVsRegisterProjectTypes)this.site.QueryService(VsConstants.SID_IVsRegisterProjectTypes, typeof(IVsRegisterProjectTypes)); if (rpt != null) { Guid projectType = this.projectFactory.GetType().GUID; rpt.RegisterProjectType(ref projectType, this.projectFactory, out this.projectFactoryCookie); } } uint lcid = VsShell.GetProviderLocale(this.site); languageServices = new Hashtable(); string thisPackage = "{"+this.GetType().GUID.ToString() + "}"; ServiceProvider thisSite = new ServiceProvider((Microsoft.VisualStudio.OLE.Interop.IServiceProvider)this); ILocalRegistry3 localRegistry = (ILocalRegistry3)this.site.QueryService( VsConstants.SID_SLocalRegistry, typeof(ILocalRegistry3)); string root = null; if (localRegistry != null) { localRegistry.GetLocalRegistryRoot(out root); } using (RegistryKey rootKey = Registry.LocalMachine.OpenSubKey(root)) { if (rootKey != null) { using (RegistryKey languages = rootKey.OpenSubKey("Languages\\Language Services")) { if (languages != null) { foreach (string languageName in languages.GetSubKeyNames()) { using (RegistryKey langKey = languages.OpenSubKey(languageName)) { object pkg = langKey.GetValue("Package"); if (pkg is string && (string)pkg == thisPackage) { object guid = langKey.GetValue(null); if (guid is string) { Guid langGuid = new Guid((string)guid); if (!this.languageServices.Contains(langGuid.ToString())){ LanguageService svc = CreateLanguageService(ref langGuid); if (svc != null) { svc.Init(thisSite, ref langGuid, lcid, GetFileExtensions(rootKey, (string)guid)); this.languageServices.Add(langGuid.ToString(), svc); } } } } } } } } } } //register with ComponentManager for Idle processing this.componentManager = (IOleComponentManager)this.site.QueryService(VsConstants.SID_SOleComponentManager, typeof(IOleComponentManager)); if (componentID == 0) { 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; this.componentManager.FRegisterComponent(this, crinfo, out componentID); } }
/// <summary> /// Notifies the component when a new object is being activated. /// </summary> /// <param name="dwReserved">Reserved for future use.</param> /// <param name="fHostIsActivating">TRUE (not zero) if the host is the object being activated, otherwise FALSE (zero).</param> /// <param name="fSameComponent">TRUE (not zero) if pic is the same component as the callee of this method, otherwise FALSE (zero).</param> /// <param name="pchostinfo">An OLECHOSTINFO that contains information about the host.</param> /// <param name="pcrinfo">An OLECRINFO that contains information about pic.</param> /// <param name="pic">The IOleComponent object to activate.</param> /// <remarks> /// If pic is non-NULL, then it is the component that is being activated. /// In this case, fSameComponent is true if pic is the same component as /// the callee of this method, and pcrinfo is the information about the pic. /// If pic is NULL and fHostIsActivating is true, then the host is the /// object being activated, and pchostinfo is its host info. /// If pic is NULL and fHostIsActivating is false, then there is no current /// active object. /// If pic is being activated and pcrinfo->grf has the olecrfExclusiveBorderSpace /// bit set, the component should hide its border space tools (toolbars, /// status bars, etc.), and it should also do this if the host is activating and /// pchostinfo->grfchostf has the olechostfExclusiveBorderSpace bit set. /// In either of these cases, the component should unhide its border space /// tools the next time it is activated. /// If pic is being activated and pcrinfo->grf has the olecrfExclusiveActivation /// bit is set, then pic is being activated in 'ExclusiveActive' mode. The /// component should retrieve the top frame window that is hosting pic /// (via pic->HwndGetWindow(olecWindowFrameToplevel, 0)). /// If this window is different from the component's own top frame window, /// the component should disable its windows and do the things it would do /// when receiving an OnEnterState(olecstateModal, true) notification. /// Otherwise, if the component is top-level, it should refuse to have its window /// activated by appropriately processing WM_MOUSEACTIVATE. /// The component should remain in one of these states until the /// ExclusiveActive mode ends, indicated by a future call to OnActivationChange /// with the ExclusiveActivation bit not set or with a NULL pcrinfo. /// </remarks> public void OnActivationChange(IOleComponent pic, int fSameComponent, OLECRINFO[] pcrinfo, int fHostIsActivating, OLECHOSTINFO[] pchostinfo, uint dwReserved) { }
private void RegisterLanguageService(Type languageServiceType) { ServiceCreatorCallback callback = new ServiceCreatorCallback( delegate (IServiceContainer container, Type serviceType) { if (languageServiceType == serviceType) { LanguageService language = (LanguageService)Activator.CreateInstance(languageServiceType); language.SetSite(this); // register for idle time callbacks IOleComponentManager mgr = GetService(typeof(SOleComponentManager)) as IOleComponentManager; uint componentID = 0; if (!this.componentIDs.TryGetValue(languageServiceType, out componentID) && 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 componentID); this.componentIDs.Add(languageServiceType, componentID); } return language; } else { return null; } }); (this as IServiceContainer).AddService(languageServiceType, callback, true); }
protected override void Initialize() { Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString())); base.Initialize(); IServiceContainer sc = (IServiceContainer)this; // Register Language languageService = new NeoLuaLanguageService(); languageService.SetSite(this); sc.AddService(typeof(NeoLuaLanguageService), languageService, true); // Register timer for the language IOleComponentManager mgr = this.GetService(typeof(SOleComponentManager)) as IOleComponentManager; if (mgr != null && languageTimerComponent == 0) { OLECRINFO[] crinfo = new OLECRINFO[1]; crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO)); crinfo[0].grfcrf = (uint)(_OLECRF.olecrfNeedIdleTime | _OLECRF.olecrfNeedPeriodicIdleTime); crinfo[0].grfcadvf = (uint)(_OLECADVF.olecadvfModal | _OLECADVF.olecadvfRedrawOff | _OLECADVF.olecadvfWarningsOff); crinfo[0].uIdleTimeInterval = 1000; Marshal.ThrowExceptionForHR(mgr.FRegisterComponent(this, crinfo, out languageTimerComponent)); } }
/// <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; 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); } }
private static uint RegisterIdleLoop(SVsServiceProvider serviceProvider, IOleComponent component) { var oleComponentManager = serviceProvider.GetService(typeof(SOleComponentManager)) as IOleComponentManager; if (oleComponentManager != null) { uint pwdId; 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; oleComponentManager.FRegisterComponent(component, crinfo, out pwdId); return pwdId; } return uint.MinValue; }
protected override void Initialize() { //Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString())); base.Initialize(); nspackage = this; #if ivslang LangInfo = new VSNLanguageInfo(); ((IServiceContainer)this).AddService(typeof(VSNLanguageInfo), LangInfo, true); #endif menucmds = new Dictionary<int, string>() { { 0x0100, "NSMenuCmdOptionsEdit"}, { 0x0101, "NSMenuCmdOptionsLoad"} }; // menu commands - .vsct file OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (mcs != null) { foreach (int dkey in menucmds.Keys) { CommandID cmdid = new CommandID(GuidList.NSMenuCmdTopGUID, dkey); MenuCommand menucmd = new MenuCommand(MenuItemCallback, cmdid); mcs.AddCommand(menucmd); } } IServiceContainer ServiceCnt = this as IServiceContainer; NSLangServ ServiceLng = new NSLangServ(); ServiceLng.SetSite(this); ServiceCnt.AddService(typeof(NSLangServ), ServiceLng, true); IOleComponentManager 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); } nimsettingsini = System.IO.Path.Combine(UserDataPath, "nimstudio.ini"); NSIni.Init(nimsettingsini); NSSugInit(); if (NSIni.Get("Main", "exttoolsadded") != "true") { NSIni.Add("Main", "exttoolsadded", "true"); NSIni.Write(); string reg_keyname = "HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\12.0\\External Tools"; object reg_ret; bool regstateok=false; reg_ret = Registry.GetValue(reg_keyname, "ToolNumKeys", -1); while (true) { if (reg_ret==null) break; if (reg_ret.GetType()!=typeof(int)) break; int totkeys = (int)reg_ret; if (totkeys==-1) break; for (int rloop = 0; rloop < totkeys; rloop++) { reg_ret = Registry.GetValue(reg_keyname, "ToolTitle" + rloop.ToString(), null); if (reg_ret==null) break; if (reg_ret.GetType()!=typeof(string)) break; if (reg_ret=="NimStudio Compile+Run") break; if (rloop==totkeys-1) regstateok=true; } if (regstateok) { Registry.SetValue(reg_keyname, "ToolTitle" + totkeys.ToString(), "NimStudio Compile+Run", RegistryValueKind.String); Registry.SetValue(reg_keyname, "ToolSourceKey" + totkeys.ToString(), "", RegistryValueKind.String); Registry.SetValue(reg_keyname, "ToolOpt" + totkeys.ToString(), 26, RegistryValueKind.DWord); Registry.SetValue(reg_keyname, "ToolDir" + totkeys.ToString(), "$(ItemDir)", RegistryValueKind.String); Registry.SetValue(reg_keyname, "ToolCmd" + totkeys.ToString(), "cmd.exe", RegistryValueKind.String); Registry.SetValue(reg_keyname, "ToolArg" + totkeys.ToString(), @"/c """"c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat"" & del $(ItemDir)$(ItemFileName).exe 2>nul & ""c:\Nim\bin\nim.exe"" c $(ItemPath) & echo ****Running**** & $(ItemDir)$(ItemFileName).exe""", RegistryValueKind.String); totkeys++; Registry.SetValue(reg_keyname, "ToolTitle" + totkeys.ToString(), "NimStudio Compile", RegistryValueKind.String); Registry.SetValue(reg_keyname, "ToolSourceKey" + totkeys.ToString(), "", RegistryValueKind.String); Registry.SetValue(reg_keyname, "ToolOpt" + totkeys.ToString(), 26, RegistryValueKind.DWord); Registry.SetValue(reg_keyname, "ToolDir" + totkeys.ToString(), "$(ItemDir)", RegistryValueKind.String); Registry.SetValue(reg_keyname, "ToolCmd" + totkeys.ToString(), "cmd.exe", RegistryValueKind.String); Registry.SetValue(reg_keyname, "ToolArg" + totkeys.ToString(), @"/c """"c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat"" & del $(ItemDir)$(ItemFileName).exe 2>nul & ""c:\Nim\bin\nim.exe"" c $(ItemPath)""", RegistryValueKind.String); totkeys++; Registry.SetValue(reg_keyname, "ToolNumKeys", totkeys, RegistryValueKind.DWord); } } } }