示例#1
0
        private int AddDropDownBar(bool refresh)
        {
            var cpc = (IConnectionPointContainer)_window;

            if (cpc != null)
            {
                IConnectionPoint cp;
                cpc.FindConnectionPoint(typeof(IVsCodeWindowEvents).GUID, out cp);
                if (cp != null)
                {
                    cp.Advise(this, out _cookieVsCodeWindowEvents);
                }
            }

            IWpfTextView wpfTextView = null;
            IVsTextView  vsTextView;

            if (ErrorHandler.Succeeded(_window.GetLastActiveView(out vsTextView)) && vsTextView != null)
            {
                wpfTextView = VsEditorAdaptersFactoryService.GetWpfTextView(vsTextView);
            }
            if (wpfTextView == null)
            {
                return(VSConstants.E_FAIL);
            }

            _client = new DropDownBarClient(_serviceProvider, wpfTextView);
            var result = _client.Register((IVsDropdownBarManager)_window);

            if (refresh)
            {
                var entryService = _serviceProvider.GetEntryService();
                if (entryService != null && entryService.TryGetAnalysisEntry(wpfTextView, out AnalysisEntry entry) && entry.IsAnalyzed)
                {
                    _client.RefreshNavigationsFromAnalysisEntry(entry)
                    .HandleAllExceptions(_serviceProvider, GetType())
                    .DoNotWait();
                }
            }

            return(result);
        }
示例#2
0
        private int AddDropDownBar()
        {
            var cpc = (IConnectionPointContainer)_window;

            if (cpc != null)
            {
                IConnectionPoint cp;
                cpc.FindConnectionPoint(typeof(IVsCodeWindowEvents).GUID, out cp);
                if (cp != null)
                {
                    cp.Advise(this, out _cookieVsCodeWindowEvents);
                }
            }

            IWpfTextView wpfTextView = null;
            IVsTextView  vsTextView;

            if (ErrorHandler.Succeeded(_window.GetLastActiveView(out vsTextView)) && vsTextView != null)
            {
                wpfTextView = VsEditorAdaptersFactoryService.GetWpfTextView(vsTextView);
            }
            if (wpfTextView == null)
            {
                return(VSConstants.E_FAIL);
            }

            AnalysisEntry entry;
            var           entryService = _serviceProvider.GetEntryService();

            if (entryService == null || !entryService.TryGetAnalysisEntry(wpfTextView, wpfTextView.TextBuffer, out entry))
            {
                return(VSConstants.E_FAIL);
            }

            _client = new DropDownBarClient(_serviceProvider, wpfTextView, entry);
            return(_client.Register((IVsDropdownBarManager)_window));
        }