Beispiel #1
0
        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 IWpfTextViewMargin CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin marginContainer)
        {
            /* If a language service is registered for this content type, then the CodeWindowManager will
             * support the standard editor navigation margin.
             */
            IVsTextBuffer textBufferAdapter = EditorAdaptersFactoryService.GetBufferAdapter(wpfTextViewHost.TextView.TextBuffer);

            if (textBufferAdapter != null)
            {
                Guid?languageService = textBufferAdapter.GetLanguageServiceID();
                if (languageService.HasValue)
                {
                    return(null);
                }
            }

            //var viewAdapter = EditorAdaptersFactoryService.GetViewAdapter(wpfTextViewHost.TextView);
            //var codeWindow = viewAdapter.GetCodeWindow();
            //var dropdownBarManager = codeWindow as IVsDropdownBarManager;
            //if (dropdownBarManager != null && dropdownBarManager.GetDropdownBarClient() != null)
            //    return null;

            var providers = NavigationSourceProviders.Where(provider => provider.Metadata.ContentTypes.Any(contentType => wpfTextViewHost.TextView.TextBuffer.ContentType.IsOfType(contentType)));

            var sources =
                providers
                .Select(provider => provider.Value.TryCreateEditorNavigationSource(wpfTextViewHost.TextView.TextBuffer))
                .Where(source => source != null)
                .ToArray();

            return(new EditorNavigationMargin(wpfTextViewHost.TextView, sources, EditorNavigationTypeRegistryService));

            //var tagAggregator = BufferTagAggregatorFactoryService.CreateTagAggregator<ILanguageElementTag>(wpfTextViewHost.TextView.TextBuffer);
            ////var manager = LanguageElementManagerService.GetLanguageElementManager(wpfTextViewHost.TextView);
            ////if (manager == null)
            ////    return null;

            //return new EditorNavigationMargin(wpfTextViewHost.TextView, tagAggregator, GlyphService);
        }