///////////////////////////////////////////////////////////////////////////// // 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 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); }
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; } } } } } }
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); } } }
/// <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); } }
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() { 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); } }
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 static IOleComponentManager Create() { IOleComponentManager cm = Substitute.For <IOleComponentManager>(); uint value; cm.FContinueIdle().ReturnsForAnyArgs(VSConstants.S_OK); cm.FOnComponentActivate(0u).ReturnsForAnyArgs(VSConstants.S_OK); cm.FOnComponentExitState(0u, 0, 0u, 0u, null).ReturnsForAnyArgs(VSConstants.S_OK); cm.FPushMessageLoop(0u, 0u, IntPtr.Zero).ReturnsForAnyArgs(VSConstants.S_OK); cm.FRegisterComponent(null, null, out value).ReturnsForAnyArgs(x => { x[2] = 1; return(VSConstants.S_OK); }); return(cm); }
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 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); } }
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 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); } }
///////////////////////////////////////////////////////////////////////////// // 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(); _languageService = new Babel.LanguageService(); _languageService.SetSite(this); IServiceContainer serviceContainter = (IServiceContainer)this; serviceContainter.AddService(typeof(Babel.LanguageService), _languageService, true); // Remeber the DTE for future use; _envDte = GetService(typeof(DTE)) as DTE; // Remember the dialog page object _languageService.FormattingPage = GetDialogPage(typeof(DaxFormattingPage)) as DaxFormattingPage; // Register for idle timer 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 | _OLECRF.olecrfNeedPeriodicIdleTime); crinfo[0].grfcadvf = (uint)(_OLECADVF.olecadvfModal | _OLECADVF.olecadvfRedrawOff | _OLECADVF.olecadvfWarningsOff); crinfo[0].uIdleTimeInterval = 1000; mgr.FRegisterComponent(this, crinfo, out _componentID); } AddMenuButtons(); #if DEBUG // Redirect console to Debug so log from Parser is visible Console.SetError(new ConsoleToDebugRedirector()); #endif SyncSnippets(); Instance = this; //commandBars.Add("My Command Bar", new Point(400,400), new CommandBarPopup(),) }
private void oleComponentInitialize() { Trace.WriteLine("Registering timer"); // 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() { base.Initialize(); IServiceContainer serviceContainer = (IServiceContainer)this; OneSLanguageService slanguageService = new OneSLanguageService(); slanguageService.SetSite((object)this); serviceContainer.AddService(typeof(OneSLanguageService), (object)slanguageService, true); IOleComponentManager service = this.GetService(typeof(SOleComponentManager)) as IOleComponentManager; if ((int)this.m_componentID != 0 || service == null) { return; } OLECRINFO[] pcrinfo = new OLECRINFO[1]; pcrinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO)); pcrinfo[0].grfcrf = 3U; pcrinfo[0].grfcadvf = 7U; pcrinfo[0].uIdleTimeInterval = 1000U; service.FRegisterComponent((IOleComponent)this, pcrinfo, out this.m_componentID); }
void RegisterAsOleComponent() { if (_componentId != 0) { return; } IOleComponentManager mgr = GetService <IOleComponentManager>(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; crInfo[0].uIdleTimeInterval = 1000; uint id; if (VSErr.Succeeded(mgr.FRegisterComponent(this, crInfo, out id))) { _componentId = id; } }
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); } }
/// <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; // fix a bug that component id not called. if (!HasComponent("sourceOutlinerWindow")) { uint componentID = 0; int hr = componentManager.FRegisterComponent(sourceOutlinerWindow, crinfo, out componentID); if (componentID != 0) { AddComponentToAutoReleasePool("sourceOutlinerWindow", componentID); } if (!ErrorHandler.Succeeded(hr)) { Trace.WriteLine("Initialize->IOleComponent registration failed"); } } sourceOutlinerWindow.InitializeDTE(dte); sourceOutlinerWindow.AddWindowEvents(); sourceOutlinerWindow.AddSolutionEvents(); }
public IronyPackage() { ServiceCreatorCallback callback = new ServiceCreatorCallback( delegate(IServiceContainer container, Type serviceType) { if (typeof(IronyLanguageService) == serviceType) { IronyLanguageService language = new IronyLanguageService(); 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(IronyLanguageService), callback, true); }
protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { instance = this; ModelScannerEvents.Start(); await base.InitializeAsync(cancellationToken, progress); _txtManager = await GetServiceAsync(typeof(SVsTextManager)) as IVsTextManager4; Assumes.Present(_txtManager); // register property changed event handler await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); XSharpXMLDocTools.Initialize(); var shell = await this.GetServiceAsync(typeof(SVsShell)) as IVsShell; if (shell != null) { shell.AdviseShellPropertyChanges(this, out shellCookie); } IServiceContainer serviceContainer = this as IServiceContainer; XSharpLegacyLanguageService languageService = new XSharpLegacyLanguageService(serviceContainer); languageService.SetSite(this); serviceContainer.AddService(typeof(XSharpLegacyLanguageService), languageService, true); //if (!XSettings.DisableClassViewObjectView) //{ // ServiceCreatorCallback callback = new ServiceCreatorCallback(CreateLibraryService); // serviceContainer.AddService(typeof(IXSharpLibraryManager), callback, true); //} RegisterDebuggerEvents(); addOurFileExtensionsForDiffAndPeek("Diff\\SupportedContentTypes"); addOurFileExtensionsForDiffAndPeek("Peek\\SupportedContentTypes"); // Register a timer to call several services // idle periods. _oleComponentManager = await GetServiceAsync(typeof(SOleComponentManager)) as IOleComponentManager; if (m_componentID == 0 && _oleComponentManager != 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 = _oleComponentManager.FRegisterComponent(this, crinfo, out m_componentID); } GetIntellisenseSettings(); await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); XSettings.LanguageService = this; }
/// <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 ComponentResourceManager resources = new ComponentResourceManager(typeof(ManifestEditorPane)); #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(new ViewModel(_store, _model, this, _textBuffer)); EnvDTE.DTE dte = GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE; _ManifestDesignerControl = new TizenManifestDesignerControl(new ViewModelTizen(_store, _model, this, _textBuffer), dte); Content = _ManifestDesignerControl; _ManifestDesignerControl.IsEnabledChanged += _ManifestDesignerControl_IsEnabledChanged; RegisterIndependentView(true); if (GetService(typeof(IMenuCommandService)) is IMenuCommandService 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)VSStd97CmdID.NewWindow, new EventHandler(OnNewWindow), new EventHandler(OnQueryNewWindow)); AddCommand(mcs, VSConstants.GUID_VSStandardCommandSet97, (int)VSStd97CmdID.ViewCode, new EventHandler(OnViewCode), new EventHandler(OnQueryViewCode)); } }
/// <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(); }
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); } } } }
// XSharpLanguageService _langService = null; #region Overridden Implementation /// <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 System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { // Suspend walking until Solution is opened. base.SolutionListeners.Add(new ModelScannerEvents(this)); await base.InitializeAsync(cancellationToken, progress); await JoinableTaskFactory.SwitchToMainThreadAsync(); _uiThread = new UIThread(); XSharpProjectPackage.instance = this; XSharpModel.XSolution.OutputWindow = this; this.RegisterProjectFactory(new XSharpProjectFactory(this)); this.settings = new XPackageSettings(this); validateVulcanEditors(); this.RegisterDebuggerEvents(); // Indicate how to open the different source files : SourceCode or Designer ?? this.RegisterEditorFactory(new XSharpEditorFactory(this)); this.RegisterProjectFactory(new XSharpWPFProjectFactory(this)); // editors for the binaries base.RegisterEditorFactory(new VOFormEditorFactory(this)); base.RegisterEditorFactory(new VOMenuEditorFactory(this)); base.RegisterEditorFactory(new VODBServerEditorFactory(this)); base.RegisterEditorFactory(new VOFieldSpecEditorFactory(this)); XSharp.Project.XSharpMenuItems.Initialize(this); // Register a timer to call our language service during // idle periods. IOleComponentManager mgr = await GetServiceAsync(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); } // Initialize Custom Menu Items // register property changed event handler var shell = await this.GetServiceAsync(typeof(SVsShell)) as IVsShell; Assumes.Present(shell); shell.AdviseShellPropertyChanges(this, out shellCookie); // // ObjectBrowser : Add the LibraryManager service as a Service provided by that container IServiceContainer container = this as IServiceContainer; ServiceCreatorCallback callback = new ServiceCreatorCallback(CreateLibraryService); // container.AddService(typeof(IXSharpLibraryManager), callback, true); this._documentWatcher = new XSharpDocumentWatcher(this); _txtManager = await GetServiceAsync(typeof(SVsTextManager)) as IVsTextManager4; // determine version of VS object vers; shell.GetProperty((int)__VSSPROPID5.VSSPROPID_ReleaseVersion, out vers); VsVersion = vers.ToString(); _errorList = await GetServiceAsync(typeof(SVsErrorList)) as IErrorList; _taskList = await GetServiceAsync(typeof(SVsTaskList)) as ITaskList; }
/// <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() { // Suspend walking until Solution is opened. base.SolutionListeners.Add(new ModelScannerEvents(this)); base.Initialize(); XSharpProjectPackage.instance = this; XSharpModel.XSolution.OutputWindow = this; this.RegisterProjectFactory(new XSharpProjectFactory(this)); this.settings = new XPackageSettings(this); validateVulcanEditors(); this.RegisterDebuggerEvents(); // Indicate how to open the different source files : SourceCode or Designer ?? this.RegisterEditorFactory(new XSharpEditorFactory(this)); this.RegisterProjectFactory(new XSharpWPFProjectFactory(this)); // editors for the binaries base.RegisterEditorFactory(new VOFormEditorFactory(this)); base.RegisterEditorFactory(new VOMenuEditorFactory(this)); base.RegisterEditorFactory(new VODBServerEditorFactory(this)); base.RegisterEditorFactory(new VOFieldSpecEditorFactory(this)); // Register the language service // Proffer the service. IServiceContainer serviceContainer = this as IServiceContainer; XSharpLanguageService langService = new XSharpLanguageService(); langService.SetSite(this); serviceContainer.AddService(typeof(XSharpLanguageService), 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); } // Initialize Custom Menu Items XSharp.Project.XSharpMenuItems.Initialize(this); // register property changed event handler var shell = this.GetService(typeof(SVsShell)) as IVsShell; shell.AdviseShellPropertyChanges(this, out shellCookie); // // LibraryManager : Offers Object Browser and ClassView // ObjectBrowser : Add the LibraryManager service as a Service provided by that container IServiceContainer container = this as IServiceContainer; ServiceCreatorCallback callback = new ServiceCreatorCallback(CreateService); // container.AddService(typeof(IXSharpLibraryManager), callback, true); this._documentWatcher = new XSharpDocumentWatcher(this); }
/// <summary> /// Registers this component and hooks this up for solution events. /// </summary> protected override void Initialize() { Logger.PublicEntry(() => { base.Initialize(); //Grab the options page this.vsOptionsPage = GetDialogPage(typeof(ContractOptionsPage)) as ContractOptionsPage; if (VSOptionsPage == null) { //If we can't get our options page, just use the default options this.vsOptionsPage = new ContractOptionsPage(); Logger.WriteAlways("Error: Options page 'Code Contracts Editor Extensions' could not be found!"); } Logger.EnableLogging = VSOptionsPage.Logging; #if LEADERBOARD //Tell leaderboard our startup options LeaderBoard.LeaderBoardAPI.SendLeaderBoardFeatureUse(VSOptionsPage.Options.GetId() | (int)LeaderBoardMasks.CodeContractsHelperId); #endif QueueWorkItem(() => { _outputPane = GetOutputPane(VSConstants.SID_SVsGeneralOutputWindowPane, "Code Contracts Editor Extensions"); }); //TODO: Is this the best place for this code? if (Logger.EnableLogging) { try { if (!String.IsNullOrEmpty(VSOptionsPage.OutputPath) && Directory.Exists(VSOptionsPage.OutputPath)) { _processIdUsedByStreamWriter = System.Diagnostics.Process.GetCurrentProcess().Id; _outputStream = File.CreateText(Path.Combine(VSOptionsPage.OutputPath, String.Format("ContractsHelperLog_{0}.txt", _processIdUsedByStreamWriter))); _outputStream.WriteLine("Log for Code Contracts Visual Studio Extension. Start time: " + _startTime); } else { //TODO: Failed to get output path! } } catch #if DEBUG (Exception exn) { //TODO: What to do on shipping? System.Windows.MessageBox.Show(@"An exception was thrown while trying to create a log file. Please send a picture of this stack trace to " + CrashMailRecepients + "\nException: " + exn, "Sorry!", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information, System.Windows.MessageBoxResult.OK, System.Windows.MessageBoxOptions.None); #else { #endif _outputStream = null; } } #region Register this component 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; ErrorHandler.ThrowOnFailure(componentManager.FRegisterComponent(this, crinfo, out _componentID)); } #endregion #region Hook up solution events // Attach to solution events var solution = GetService(typeof(SVsSolution)) as IVsSolution; if (solution != null) { uint solutionEventsCookie; solution.AdviseSolutionEvents(this, out solutionEventsCookie); } // Attach to build events var buildManager = GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager; if (buildManager != null) { uint buildManagerCookie; // TODO: add dispose and unregister buildManager.AdviseUpdateSolutionEvents(this, out buildManagerCookie); } _dte = GetService <DTE>(); #endregion }, "Initialize"); }