/// <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; } } } } } }
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); } }
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)); }
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 Dispose(bool disposing) { if (disposing) { _languageService.Dispose(); _languageService = null; } try { if (_componentID != 0) { IOleComponentManager mgr = GetService(typeof(SOleComponentManager)) as IOleComponentManager; if (mgr != null) { mgr.FRevokeComponent(_componentID); } _componentID = 0; } } finally { base.Dispose(disposing); } }
protected override void OnClose() { // unhook from Undo related services if (_undoManager != null) { IVsLinkCapableUndoManager linkCapableUndoMgr = (IVsLinkCapableUndoManager)_undoManager; if (linkCapableUndoMgr != null) { linkCapableUndoMgr.UnadviseLinkedUndoClient(); } // Throw away the undo stack etc. // It is important to “zombify†the undo manager when the owning object is shutting down. // This is done by calling IVsLifetimeControlledObject.SeverReferencesToOwner on the undoManager. // This call will clear the undo and redo stacks. This is particularly important to do if // your undo units hold references back to your object. It is also important if you use // "mdtStrict" linked undo transactions as this sample does (see IVsLinkedUndoTransactionManager). // When one object involved in linked undo transactions clears its undo/redo stacks, then // the stacks of the other documents involved in the linked transaction will also be cleared. IVsLifetimeControlledObject lco = (IVsLifetimeControlledObject)_undoManager; lco.SeverReferencesToOwner(); _undoManager = null; } IOleComponentManager mgr = GetService(typeof(SOleComponentManager)) as IOleComponentManager; mgr?.FRevokeComponent(_componentId); Dispose(true); base.OnClose(); }
public int FDoIdle(uint grfidlef) { bool bPeriodic = (grfidlef & (uint)_OLEIDLEF.oleidlefPeriodic) != 0; IOleComponentManager cmpMgr = (IOleComponentManager)Package.GetGlobalService(typeof(SOleComponentManager)); if (bPeriodic && cmpMgr != null) { //var changes = FileUtilities.Instance.getCurrentTextSnapShot().Version.Changes; ////var changes = FileUtilities.Instance.GetIWpfTextView((string)document).TextSnapshot.Version.Changes; //if (changes != null) //{ // StaDynParser parser = new StaDynParser(); // parser.parseAll(); // SourceHelper.refreshHighlighting(); //} Trace.WriteLine("Entering timer"); StaDynParser parser = new StaDynParser(); parser.parseAll(); SourceHelper.refreshHighlighting(); cmpMgr.FRevokeComponent(m_componentID); } return(0); }
///////////////////////////////////////////////////////////////////////////// // 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); } }
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 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); }
protected override void Dispose(bool disposing) { try { this.UnRegisterDebuggerEvents(); if (null != _libraryManager) { _libraryManager.Dispose(); _libraryManager = null; } if (_oleComponentManager != null) { ThreadHelper.JoinableTaskFactory.Run(async delegate { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); _oleComponentManager.FRevokeComponent(m_componentID); }); _oleComponentManager = null; } } finally { base.Dispose(disposing); } }
public int DoIdle(IOleComponentManager mgr) { UIThread.MustBeCalledFromUIThread(); Debug.Assert(!this.isDisposed, "tried to do idle work on a disposed TaskReporter"); lock (queueLock) { // process up to MAX items at a time int MAX = 50; // How to pick a value? I tried a couple values with a project with many errors, and this value seems to work well. This value is also happy for unit tests. while (work.Count != 0 && mgr.FContinueIdle() != 0) { int i = 0; while (work.Count != 0 && i < MAX) { Action workItem = work.Dequeue(); workItem(); ++i; } } if (work.Count != 0) { return(1); } else { return(0); } } }
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() { 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 override void Dispose(bool disposing) { try { _mySolutionListener.Dispose(); if (_componentID != 0) { IOleComponentManager mgr = GetIOleComponentManager(); mgr.FRevokeComponent(_componentID); _componentID = 0; } if (_libraryManager != null) { _libraryManager.Dispose(); _libraryManager = null; } } finally { base.Dispose(disposing); } }
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); } }
private void UpdateSmartTags(IOleComponentManager compMgr = null) { //SmartTagController controller; //if (_textView.Properties.TryGetProperty<SmartTagController>(typeof(SmartTagController), out controller)) //{ // controller.ShowSmartTag(compMgr); //} }
public VsIdleTaskHost(System.IServiceProvider serviceProvider, Func<bool> task, TimeSpan updateDelay) { Guard.NotNull(() => serviceProvider, serviceProvider); Guard.NotNull(() => task, task); this.componentManager = (IOleComponentManager)serviceProvider.GetService(typeof(SOleComponentManager)); this.host = new HostComponent(task, updateDelay); }
public VsIdleTaskHost(System.IServiceProvider serviceProvider, Func <bool> task, TimeSpan updateDelay) { Guard.NotNull(() => serviceProvider, serviceProvider); Guard.NotNull(() => task, task); this.componentManager = (IOleComponentManager)serviceProvider.GetService(typeof(SOleComponentManager)); this.host = new HostComponent(task, updateDelay); }
public KeystrokeThief(IOleComponentManager manager) { if (manager == null) { throw new ArgumentNullException("manager"); } _manager = manager; }
/// <summary> /// Gets a boolean indicating whether a component can continue idle processing. Returns false when idle processing should stop /// </summary> /// <returns></returns> public bool ContinueIdle() { if (_mgr == null) { _mgr = _context.GetService <IOleComponentManager>(typeof(SOleComponentManager)); } return(_mgr == null || 0 != _mgr.FContinueIdle()); }
public static void OnIdle(IOleComponentManager compMgr) { foreach (var window in _windows) { if (compMgr.FContinueIdle() == 0) { break; } window.Value._filter.DoIdle(compMgr); } }
/// <summary> /// Gets a boolean indicating whether a component can continue idle processing. Returns false when idle processing should stop /// </summary> /// <returns></returns> public bool ContinueIdle() { ThreadHelper.ThrowIfNotOnUIThread(); if (_mgr == null) { _mgr = _context.GetService <IOleComponentManager>(typeof(SOleComponentManager)); } return(_mgr == null || 0 != _mgr.FContinueIdle()); }
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 KeystrokeThief() { var manager = ServiceProvider.GlobalProvider.GetService(typeof(SOleComponentManager)) as IOleComponentManager; if (manager == null) { throw new ArgumentNullException("manager"); } _manager = manager; }
public void OnIdle(IOleComponentManager compMgr) { foreach (TextLineEventListener listener in _documents.Values) { if (compMgr.FContinueIdle() == 0) { break; } listener.OnIdle(); } }
protected override void Dispose(bool disposing) { if ((int)this.m_componentID != 0) { IOleComponentManager service = this.GetService(typeof(SOleComponentManager)) as IOleComponentManager; if (service != null) { service.FRevokeComponent(this.m_componentID); } this.m_componentID = 0U; } base.Dispose(disposing); }
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(); }
protected override void Dispose(bool disposing) { if (m_ComponentID != 0) { IOleComponentManager mgr = GetService(typeof(SOleComponentManager)) as IOleComponentManager; if (mgr != null) { int hr = mgr.FRevokeComponent(m_ComponentID); } m_ComponentID = 0; } base.Dispose(disposing); }
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)); }
} // proc Initialize protected override void Dispose(bool disposing) { if (languageTimerComponent != 0) { IOleComponentManager mgr = this.GetService(typeof(SOleComponentManager)) as IOleComponentManager; if (mgr != null) { mgr.FRevokeComponent(languageTimerComponent); } languageTimerComponent = 0; } base.Dispose(disposing); } // proc Dispose
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() { 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; } } } } } }
public int FGetParentComponentManager(out IOleComponentManager ppicm) { throw new NotImplementedException(); }
///////////////////////////////////////////////////////////////////////////// // Overridden 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 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.ToString())); base.Initialize(); // retrieve the installation directory using (RegistryKey rootKey = this.UserRegistryRoot) { using (RegistryKey packageKey = rootKey.OpenSubKey("ExtensionManager\\EnabledExtensions")) { PackageRootPath = packageKey.GetValue(GuidList.guidNPLLanguageServicePkgString + ",1.0") as String; } } ////Create Editor Factory. Note that the base Package class will call Dispose on it. // base.RegisterEditorFactory(new EditorFactory(this)); // Add our command handlers for menu (commands must exist in the .vsct file) OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null != mcs) { // Create the command for the tool window CommandID toolwndCommandID = new CommandID(GuidList.guidNPLLanguageServiceCmdSet, (int)PkgCmdIDList.cmdidMyNPLOutlineTool); MenuCommand menuToolWin = new MenuCommand(ShowToolWindow, toolwndCommandID); mcs.AddCommand(menuToolWin); } componentManager = (IOleComponentManager)GetService(typeof(SOleComponentManager)); // Register callback for Language Service interface that returns the language service itself IServiceContainer serviceContainer = this; serviceContainer.AddService(typeof(ILuaLanguageService), OnCreateLuaLanguageService, true); serviceContainer.AddService(typeof(IRefactoringService), OnCreateRefactoringService, true); // Initialize the DTE and the code outline file manager, and hook up events. InitializeSourceOutlinerToolWindow(); serviceContainer.AddService(typeof(SourceOutlineToolWindow), sourceOutlinerWindow, true); CreateCustomServices(serviceContainer); }
/// <summary> /// Gets a boolean indicating whether a component can continue idle processing. Returns false when idle processing should stop /// </summary> /// <returns></returns> public bool ContinueIdle() { if(_mgr == null) _mgr = _context.GetService<IOleComponentManager>(typeof(SOleComponentManager)); return 0 != _mgr.FContinueIdle(); }
private void Register(IOleComponentManager componentManager) { var pcrinfo = new OLECRINFO { cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO)), grfcrf = (uint)(_OLECRF.olecrfNeedIdleTime | _OLECRF.olecrfNeedPeriodicIdleTime), grfcadvf = (uint)(_OLECADVF.olecadvfModal | _OLECADVF.olecadvfRedrawOff | _OLECADVF.olecadvfWarningsOff), uIdleTimeInterval = 100, }; componentManager.FRegisterComponent(this, new[] { pcrinfo }, out componentId); }
public ComponentManagerEventArgs(IOleComponentManager compMgr) { _compMgr = compMgr; }
internal virtual int OnIdle(bool periodic, IOleComponentManager mgr) { if (!this.IsActive) return 0; // here's our chance to synchronize combo's and so on, // first we see if the caret has moved. IVsTextView view = this.lastActiveView; if (view == null) return 0; ISource s = this.GetSource(view); if (s == null) return 0; int line = -1, col = -1; var hr = view.GetCaretPos(out line, out col); if (NativeMethods.Failed(hr)) return 0; if (line != this.lastLine || col != this.lastCol || this.lastFileName == null) { this.lastLine = line; this.lastCol = col; this.lastFileName = s.GetFilePath(); CodeWindowManager cwm = this.GetCodeWindowManagerForView(view); if (cwm != null) { this.OnCaretMoved(cwm, view, line, col); } } s.OnIdle(periodic); // do idle processing for currently-focused file bool moreToDo = false; #if CHECK_ALL_DIRTY_FILES_ON_PERIODIC_IDLE if (periodic && mgr.FContinueIdle() != 0) { // while there is spare idle time, pick a dirty file (if there is one) and do idle processing for it for (int i = 0; i < this.sources.Count; ++i) { Source so = this.sources[i] as Source; if (so != null && so.IsDirty) { so.OnIdle(periodic); if (mgr.FContinueIdle() == 0) { moreToDo = true; break; } } } } #endif return moreToDo ? 1 : 0; }
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; }
internal void DoIdle(IOleComponentManager compMgr) { }
public virtual void Close() { if (this.site != null) { if (this.editorFactory != null) { Guid editorGuid = this.editorFactory.GetType().GUID; IVsRegisterEditors vre = (IVsRegisterEditors)site.QueryService( VsConstants.SID_SVsRegisterEditors, typeof(IVsRegisterEditors)); vre.UnregisterEditor(this.editorFactoryCookie); this.editorFactory.Close(); this.editorFactory = null; } if (this.projectFactory != null) { IVsRegisterProjectTypes rpt = (IVsRegisterProjectTypes)this.site.QueryService(VsConstants.SID_IVsRegisterProjectTypes, typeof(IVsRegisterProjectTypes)); if (rpt != null) { rpt.UnregisterProjectType(this.projectFactoryCookie); } this.projectFactoryCookie = 0; this.projectFactory.Close(); this.projectFactory = null; } } foreach (LanguageService svc in this.languageServices.Values) { svc.Done(); } this.languageServices.Clear(); if (this.componentID != 0) { this.componentManager.FRevokeComponent(this.componentID); this.componentID = 0; } this.componentManager = null; if (site != null) site.Dispose(); this.site = null; GC.Collect(); }
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); } }
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() { 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(); }
public void OnComponentEnterState(uint dwComponentID, uint uStateID, uint uContext, uint cpicmExclude, IOleComponentManager[] rgpicmExclude, uint dwReserved) { throw new NotImplementedException(); }
internal void ShowSmartTag(IOleComponentManager compMgr = null) { if (!_sessionIsInvalid) { // caret / text hasn't changed since we last computed the smart tag, don't bother computing again. return; } ITextSnapshot snapshot = _textView.TextViewModel.DataBuffer.CurrentSnapshot; SnapshotPoint? caretPoint = _textView.Caret.Position.Point.GetPoint(snapshot, PositionAffinity.Successor); if (caretPoint != null && _curSession != null && !_curSession.IsDismissed && _curSession.ApplicableToSpan != null && _curSession.ApplicableToSpan.GetSpan(_textView.TextBuffer.CurrentSnapshot).Contains(caretPoint.Value.Position)) { return; } _sessionIsInvalid = false; // Figure out the point in the buffer where we are triggering. // We need to use the view's data buffer as the source location if (_curSession != null && !_curSession.IsDismissed) { _curSession.Dismiss(); } if (!caretPoint.HasValue) { return; } ITrackingPoint triggerPoint = snapshot.CreateTrackingPoint(caretPoint.Value, PointTrackingMode.Positive); ISmartTagSession newSession = _curSession = _broker.CreateSmartTagSession(_textView, SmartTagType.Factoid, triggerPoint, SmartTagState.Collapsed); newSession.Properties.AddProperty(typeof(SmartTagController), compMgr); newSession.Properties.AddProperty(typeof(SmartTagSource.AbortedAugmentInfo), this); newSession.Start(); }
public int FOnComponentExitState(uint dwComponentID, uint uStateID, uint uContext, uint cpicmExclude, IOleComponentManager[] rgpicmExclude) { throw new NotImplementedException(); }
/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put any initialization code that relies on services provided by Visual Studio. /// </summary> protected override void Initialize() { DisplayMessage(Resources.StatusPrefix, string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString())); base.Initialize(); // Add command handlers for the menu (commands must exist in the .ctc file) OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null != mcs) { // Create the command for the tool window in the Other Windows menu. CommandID toolwndCommandID = new CommandID(GuidList.guidSourceOutlinerCmdSet, (int)PkgCmdIDList.cmdidSourceOutliner1); MenuCommand menuToolWin = new MenuCommand(new EventHandler(ShowToolWindow), toolwndCommandID); mcs.AddCommand(menuToolWin); } _dte = GetService(typeof(EnvDTE._DTE)) as EnvDTE.DTE; if (_dte == null) { throw new NullReferenceException("DTE is null"); } _window = (SourceOutlineToolWindow)this.FindToolWindow(typeof(SourceOutlineToolWindow), 0, true); _window.Package = this; _componentManager = (IOleComponentManager)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 = 100; int hr = _componentManager.FRegisterComponent(_window, crinfo, out this._componentID); if (!ErrorHandler.Succeeded(hr)) { DisplayMessage(Resources.ErrorPrefix, "Initialize->IOleComponent registration failed"); } } // Initialize the DTE and the code outline file manager, and hook up events. InitializeToolWindow(); }