private IntPtr CreateCodeView(string documentMoniker, IVsTextLines textLines, IVsHierarchy hierarchy, uint itemid, bool createdDocData, ref string editorCaption, ref Guid cmdUI) { Type codeWindowType = typeof(IVsCodeWindow); Guid riid = codeWindowType.GUID; Guid clsid = typeof(VsCodeWindowClass).GUID; var compModel = (IComponentModel)_package.GetService(typeof(SComponentModel)); var adapterService = compModel.GetService<IVsEditorAdaptersFactoryService>(); var window = adapterService.CreateVsCodeWindowAdapter((IOleServiceProvider)_serviceProvider.GetService(typeof(IOleServiceProvider))); ErrorHandler.ThrowOnFailure(window.SetBuffer(textLines)); ErrorHandler.ThrowOnFailure(window.SetBaseEditorCaption(null)); ErrorHandler.ThrowOnFailure(window.GetEditorCaption(READONLYSTATUS.ROSTATUS_Unknown, out editorCaption)); IVsUserData userData = textLines as IVsUserData; if (userData != null) { if (_promptEncodingOnLoad) { var guid = VSConstants.VsTextBufferUserDataGuid.VsBufferEncodingPromptOnLoad_guid; userData.SetData(ref guid, (uint)1); } } var textMgr = (IVsTextManager)_package.GetService(typeof(SVsTextManager)); var bufferEventListener = new TextBufferEventListener(textLines); if (!createdDocData) { // we have a pre-created buffer, go ahead and initialize now as the buffer already // exists and is initialized. bufferEventListener.OnLoadCompleted(0); } InitializeLanguageService(textLines); cmdUI = VSConstants.GUID_TextEditorFactory; return Marshal.GetIUnknownForObject(window); }
private IVsCodeWindow CreateCodeView(string documentMoniker, IVsTextLines textLines, bool createdDocData, ref string editorCaption, ref Guid cmdUI) { Type codeWindowType = typeof(IVsCodeWindow); var compModel = _package.AsVsServiceProvider().GetComponentModel(); var adapterService = compModel.GetService <IVsEditorAdaptersFactoryService>(); var window = adapterService.CreateVsCodeWindowAdapter(_oleServiceProvider); ErrorHandler.ThrowOnFailure(window.SetBuffer(textLines)); ErrorHandler.ThrowOnFailure(window.SetBaseEditorCaption(null)); ErrorHandler.ThrowOnFailure(window.GetEditorCaption(READONLYSTATUS.ROSTATUS_Unknown, out editorCaption)); cmdUI = VSConstants.GUID_TextEditorFactory; var textMgr = _package.AsVsServiceProvider().GetTextManager(); var bufferEventListener = new TextBufferEventListener(compModel, textLines, textMgr, window); if (!createdDocData) { // we have a pre-created buffer, go ahead and initialize now as the buffer already // exists and is initialized. bufferEventListener.OnLoadCompleted(0); } return(window); }
protected override IVsCodeWindow CreateCodeView(string documentMoniker, IVsTextLines textLines, bool createdDocData, ref string editorCaption, ref Guid cmdUI) { IVsCodeWindow window = base.CreateCodeView(documentMoniker, textLines, createdDocData, ref editorCaption, ref cmdUI); var compModel = Package.AsVsServiceProvider().GetComponentModel(); var textMgr = Package.AsVsServiceProvider().GetTextManager(); var bufferEventListener = new TextBufferEventListener(compModel, textLines, textMgr, window); if (!createdDocData) { // we have a pre-created buffer, go ahead and initialize now as the buffer already // exists and is initialized. bufferEventListener.OnLoadCompleted(0); } return window; }
protected override IVsCodeWindow CreateCodeView(string documentMoniker, IVsTextLines textLines, bool createdDocData, ref string editorCaption, ref Guid cmdUI) { IVsCodeWindow window = base.CreateCodeView(documentMoniker, textLines, createdDocData, ref editorCaption, ref cmdUI); var compModel = Package.AsVsServiceProvider().GetComponentModel(); var textMgr = Package.AsVsServiceProvider().GetTextManager(); var bufferEventListener = new TextBufferEventListener(compModel, textLines, textMgr, window); if (!createdDocData) { // we have a pre-created buffer, go ahead and initialize now as the buffer already // exists and is initialized. bufferEventListener.OnLoadCompleted(0); } return(window); }
protected virtual IVsCodeWindow CreateCodeView(string documentMoniker, IVsTextLines textLines, bool createdDocData, ref string editorCaption, ref Guid cmdUI) { ThreadHelper.ThrowIfNotOnUIThread(); var codeWindowType = typeof(IVsCodeWindow); var riid = codeWindowType.GUID; var clsid = typeof(VsCodeWindowClass).GUID; //var compModel = (IComponentModel)new VsServiceProviderWrapper(Package).GetService(typeof(SComponentModel)); zdes bylo tak var compModel = (IComponentModel)ServiceProvider.GetService(typeof(SComponentModel)); Assumes.Present(compModel); var adapterService = compModel.GetService <IVsEditorAdaptersFactoryService>(); var window = adapterService.CreateVsCodeWindowAdapter((IOleServiceProvider)ServiceProvider.GetService(typeof(IOleServiceProvider))); ErrorHandler.ThrowOnFailure(window.SetBuffer(textLines)); ErrorHandler.ThrowOnFailure(window.SetBaseEditorCaption(null)); ErrorHandler.ThrowOnFailure(window.GetEditorCaption(READONLYSTATUS.ROSTATUS_Unknown, out editorCaption)); var userData = textLines as IVsUserData; if (userData != null) { if (PromptEncodingOnLoad) { var guid = VSConstants.VsTextBufferUserDataGuid.VsBufferEncodingPromptOnLoad_guid; userData.SetData(ref guid, (uint)1); } } cmdUI = VSConstants.GUID_TextEditorFactory; //var compModel = (IComponentModel)new VsServiceProviderWrapper(Package).GetService(typeof(SComponentModel)); zdes bylo tak var componentModel = (IComponentModel)ServiceProvider.GetService(typeof(SComponentModel)); var bufferEventListener = new TextBufferEventListener(componentModel, textLines, _languageServiceId); if (!createdDocData) { // we have a pre-created buffer, go ahead and initialize now as the buffer already // exists and is initialized bufferEventListener.OnLoadCompleted(0); } return(window); }
private IVsCodeWindow CreateCodeView(string documentMoniker, IVsTextLines textLines, bool createdDocData, ref string editorCaption, ref Guid cmdUI) { Type codeWindowType = typeof(IVsCodeWindow); var compModel = _package.AsVsServiceProvider().GetComponentModel(); var adapterService = compModel.GetService<IVsEditorAdaptersFactoryService>(); var window = adapterService.CreateVsCodeWindowAdapter(_oleServiceProvider); ErrorHandler.ThrowOnFailure(window.SetBuffer(textLines)); ErrorHandler.ThrowOnFailure(window.SetBaseEditorCaption(null)); ErrorHandler.ThrowOnFailure(window.GetEditorCaption(READONLYSTATUS.ROSTATUS_Unknown, out editorCaption)); cmdUI = VSConstants.GUID_TextEditorFactory; var textMgr = _package.AsVsServiceProvider().GetTextManager(); var bufferEventListener = new TextBufferEventListener(compModel, textLines, textMgr, window); if (!createdDocData) { // we have a pre-created buffer, go ahead and initialize now as the buffer already // exists and is initialized. bufferEventListener.OnLoadCompleted(0); } return window; }
public int CreateEditorInstance(uint grfCreateDoc, string pszMkDocument, string pszPhysicalView, IVsHierarchy pvHier, uint itemid, IntPtr punkDocDataExisting, out IntPtr ppunkDocView, out IntPtr ppunkDocData, out string pbstrEditorCaption, out Guid pguidCmdUI, out int pgrfCDW) { ppunkDocView = IntPtr.Zero; ppunkDocData = IntPtr.Zero; pbstrEditorCaption = string.Empty; pguidCmdUI = Guid.Empty; pgrfCDW = 0; var isGaugeProject = pvHier.ToProject().IsGaugeProject(); if (!isGaugeProject) { return(VSConstants.VS_E_UNSUPPORTEDFORMAT); } if ((grfCreateDoc & (VSConstants.CEF_OPENFILE | VSConstants.CEF_SILENT)) == 0) { throw new ArgumentException("Only Open or Silent is valid"); } var pTextBuffer = GetTextBuffer(punkDocDataExisting); if (pTextBuffer == null) { return(VSConstants.E_FAIL); } var textBufferSite = pTextBuffer as IObjectWithSite; if (textBufferSite != null) { textBufferSite.SetSite(_serviceProvider); } var clsidCodeWindow = typeof(VsCodeWindowClass).GUID; var iidCodeWindow = typeof(IVsCodeWindow).GUID; var pCodeWindow = (IVsCodeWindow)_package.CreateInstance(ref clsidCodeWindow, ref iidCodeWindow, typeof(IVsCodeWindow)); if (pCodeWindow == null) { return(VSConstants.E_FAIL); } var bufferEventListener = new TextBufferEventListener(pTextBuffer); pCodeWindow.SetBuffer(pTextBuffer); if (!(punkDocDataExisting == IntPtr.Zero)) { bufferEventListener.OnLoadCompleted(0); } ppunkDocView = Marshal.GetIUnknownForObject(pCodeWindow); ppunkDocData = Marshal.GetIUnknownForObject(pTextBuffer); pguidCmdUI = VSConstants.GUID_TextEditorFactory; pbstrEditorCaption = string.Empty; return(VSConstants.S_OK); }