Пример #1
0
        private int RemoveDropDownBar()
        {
            var cpc = (IConnectionPointContainer)_window;

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

            if (_client != null)
            {
                IVsDropdownBarManager manager = (IVsDropdownBarManager)_window;
                _client.Unregister();
                // A buffer may have multiple DropDownBarClients, given one may open multiple CodeWindows
                // over a single buffer using Window/New Window
                List <DropDownBarClient> listDropDownBarClient;
                if (_textBuffer.Properties.TryGetProperty(typeof(DropDownBarClient), out listDropDownBarClient) && listDropDownBarClient != null)
                {
                    listDropDownBarClient.Remove(_client);
                    if (listDropDownBarClient.Count == 0)
                    {
                        _textBuffer.Properties.RemoveProperty(typeof(DropDownBarClient));
                    }
                }
                _client = null;
                return(manager.RemoveDropdownBar());
            }
            return(VSConstants.S_OK);
        }
Пример #2
0
        private int AddDropDownBar()
        {
            var pythonProjectEntry = _textView.TextBuffer.GetAnalysis() as IPythonProjectEntry;

            if (pythonProjectEntry == null)
            {
                return(VSConstants.E_FAIL);
            }

            DropDownBarClient dropDown = _client = new DropDownBarClient(_textView, pythonProjectEntry);

            IVsDropdownBarManager manager = (IVsDropdownBarManager)_window;

            IVsDropdownBar dropDownBar;
            int            hr = manager.GetDropdownBar(out dropDownBar);

            if (ErrorHandler.Succeeded(hr) && dropDownBar != null)
            {
                hr = manager.RemoveDropdownBar();
                if (!ErrorHandler.Succeeded(hr))
                {
                    return(hr);
                }
            }

            int res = manager.AddDropdownBar(2, dropDown);

            if (ErrorHandler.Succeeded(res))
            {
                _textView.TextBuffer.Properties[typeof(DropDownBarClient)] = dropDown;
            }
            return(res);
        }
Пример #3
0
 private int RemoveDropDownBar()
 {
     if (_client != null)
     {
         IVsDropdownBarManager manager = (IVsDropdownBarManager)_window;
         _client.Unregister();
         _client = null;
         _textView.TextBuffer.Properties.RemoveProperty(typeof(DropDownBarClient));
         return(manager.RemoveDropdownBar());
     }
     return(VSConstants.S_OK);
 }
Пример #4
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 entry = wpfTextView.TryGetAnalysisEntry(_serviceProvider);
                if (entry != null && entry.IsAnalyzed)
                {
                    _client.RefreshNavigationsFromAnalysisEntry(entry)
                    .HandleAllExceptions(_serviceProvider, GetType())
                    .DoNotWait();
                }
            }

            return(result);
        }
Пример #5
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));
        }
Пример #6
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;
            }

            IPythonProjectEntry pythonProjectEntry;
            if (!wpfTextView.TextBuffer.TryGetPythonProjectEntry(out pythonProjectEntry)) {
                return VSConstants.E_FAIL;
            }

            _client = new DropDownBarClient(_serviceProvider, wpfTextView, pythonProjectEntry);
            return _client.Register((IVsDropdownBarManager)_window);
        }
Пример #7
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);
                }
            }

            IPythonProjectEntry pythonProjectEntry;

            if (!_textBuffer.TryGetPythonProjectEntry(out pythonProjectEntry))
            {
                return(VSConstants.E_FAIL);
            }

            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, pythonProjectEntry);

            IVsDropdownBarManager manager = (IVsDropdownBarManager)_window;

            IVsDropdownBar dropDownBar;
            int            hr = manager.GetDropdownBar(out dropDownBar);

            if (ErrorHandler.Succeeded(hr) && dropDownBar != null)
            {
                hr = manager.RemoveDropdownBar();
                if (!ErrorHandler.Succeeded(hr))
                {
                    return(hr);
                }
            }

            int res = manager.AddDropdownBar(2, _client);

            if (ErrorHandler.Succeeded(res))
            {
                // A buffer may have multiple DropDownBarClients, given one may open multiple CodeWindows
                // over a single buffer using Window/New Window
                List <DropDownBarClient> listDropDownBarClient;
                if (!_textBuffer.Properties.TryGetProperty(typeof(DropDownBarClient), out listDropDownBarClient) || listDropDownBarClient == null)
                {
                    listDropDownBarClient = new List <DropDownBarClient>();
                    _textBuffer.Properties[typeof(DropDownBarClient)] = listDropDownBarClient;
                }
                listDropDownBarClient.Add(_client);
            }
            return(res);
        }