public IEditorNavigationDropdownBarClient CreateEditorNavigationDropdownBar(IVsCodeWindow codeWindow, IVsEditorAdaptersFactoryService editorAdaptersFactory) { // a code window can only be associated with a single buffer, so the primary view will get us the correct information IVsTextView primaryViewAdapter = codeWindow.GetPrimaryView(); IWpfTextView textView = editorAdaptersFactory.GetWpfTextView(primaryViewAdapter); IBufferGraph bufferGraph = BufferGraphFactoryService.CreateBufferGraph(textView.TextBuffer); Collection <ITextBuffer> buffers = bufferGraph.GetTextBuffers(i => true); List <IEditorNavigationSource> sources = new List <IEditorNavigationSource>(); foreach (ITextBuffer buffer in buffers) { var bufferProviders = NavigationSourceProviders.Where(provider => provider.Metadata.ContentTypes.Any(contentType => buffer.ContentType.IsOfType(contentType))); var bufferSources = bufferProviders .Select(provider => provider.Value.TryCreateEditorNavigationSource(buffer)) .Where(source => source != null); sources.AddRange(bufferSources); } return(new EditorNavigationDropdownBar(codeWindow, editorAdaptersFactory, sources, BufferGraphFactoryService, EditorNavigationTypeRegistryService)); }
public static Collection <ITextBuffer> GetRazorBuffers(this IBufferGraph bufferGraph) { if (bufferGraph == null) { throw new ArgumentNullException(nameof(bufferGraph)); } return(bufferGraph.GetTextBuffers(TextBufferExtensions.IsRazorBuffer)); }
public void RefreshBuffers(IBufferGraph graph) { this.bufferGraph.Clear(); var buffers = graph.GetTextBuffers(b => true); int index = 0; foreach (var buffer in buffers) { this.bufferGraph.Add(new BufferInfoViewModel { ContentType = buffer.ContentType.DisplayName, BufferType = buffer.GetType(), ActualContentType = new ContentTypeViewModel(buffer.ContentType), Index = index++ }); } NotifyChanged("BufferGraph"); this.SelectedBuffer = this.bufferGraph.FirstOrDefault( b => TextEditor.IsNonProjectionOrElisionBufferType(b.BufferType)); }
public void RefreshBuffers(IBufferGraph graph) { this.bufferGraph.Clear(); var buffers = graph.GetTextBuffers(b => true); int index = 0; foreach ( var buffer in buffers ) { this.bufferGraph.Add(new BufferInfoViewModel { ContentType = buffer.ContentType.DisplayName, BufferType = buffer.GetType(), ActualContentType = new ContentTypeViewModel(buffer.ContentType), Index = index++ }); } NotifyChanged("BufferGraph"); this.SelectedBuffer = this.bufferGraph.FirstOrDefault( b => TextEditor.IsNonProjectionOrElisionBufferType(b.BufferType)); }