コード例 #1
0
 public EditorNavigationSource TryCreateEditorNavigationSource(ITextBuffer textBuffer)
 {
     return textBuffer.Properties.GetOrCreateSingletonProperty(
         () =>
         {
             var result = new EditorNavigationSource(textBuffer, textBuffer.GetBackgroundParser(), GlyphService);
             result.Initialize();
             return result;
         });
 }
コード例 #2
0
        public EditorNavigationDropdownBarClient(IVsCodeWindow codeWindow, IVsEditorAdaptersFactoryService editorAdaptersFactory, EditorNavigationSource source, IBufferGraphFactoryService bufferGraphFactoryService)
        {
            _codeWindow = codeWindow;
            _editorAdaptersFactory = editorAdaptersFactory;
            _source = source;
            _bufferGraphFactoryService = bufferGraphFactoryService;
            _currentTextView = editorAdaptersFactory.GetWpfTextView(codeWindow.GetLastActiveView());
            _dispatcher = _currentTextView.VisualElement.Dispatcher;
            _imageList = new ImageList
            {
                ColorDepth = ColorDepth.Depth32Bit
            };

            var connectionPointContainer = codeWindow as IConnectionPointContainer;
            if (connectionPointContainer != null)
            {
                var textViewEventsGuid = typeof(IVsCodeWindowEvents).GUID;
                IConnectionPoint connectionPoint;
                connectionPointContainer.FindConnectionPoint(ref textViewEventsGuid, out connectionPoint);
                connectionPoint?.Advise(this, out _codeWindowEventsCookie);
            }

            var primaryView = codeWindow.GetPrimaryView();
            if (primaryView != null)
                ((IVsCodeWindowEvents)this).OnNewView(primaryView);

            var secondaryView = codeWindow.GetSecondaryView();
            if (secondaryView != null)
                ((IVsCodeWindowEvents)this).OnNewView(secondaryView);

            _navigationItems = new List<EditorTypeNavigationTarget>();

            source.NavigationTargetsChanged += OnNavigationTargetsChanged;
            UpdateNavigationTargets();

            _currentTextView.Caret.PositionChanged += OnCaretPositionChanged;
        }