protected override bool TryCreateDropdownBarClient(out int comboBoxCount, out IVsDropdownBarClient client)
        {
            comboBoxCount = 2;
            client        = CreateDropdownBarClient();

            return(true);
        }
            private static IVsDropdownBarClient GetDropdownBarClient(IVsDropdownBar dropdownBar)
            {
                IVsDropdownBarClient dropdownBarClient = null;

                ErrorHandler.ThrowOnFailure(dropdownBar.GetClient(out dropdownBarClient));
                return(dropdownBarClient);
            }
        protected virtual int AddDropdownBar(int comboBoxCount, IVsDropdownBarClient client)
        {
            Contract.Requires <ArgumentNullException>(client != null, "client");
            Contract.Requires <ArgumentOutOfRangeException>(comboBoxCount > 0);

            IVsDropdownBarManager manager = CodeWindow as IVsDropdownBarManager;

            if (manager == null)
            {
                throw new NotSupportedException();
            }

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

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

            return(manager.AddDropdownBar(comboBoxCount, client));
        }
        protected virtual int RemoveDropdownBar()
        {
            IVsDropdownBarManager manager = CodeWindow as IVsDropdownBarManager;

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

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

            if (ErrorHandler.Succeeded(hr) && dropdownBar != null)
            {
                IVsDropdownBarClient client;
                hr = dropdownBar.GetClient(out client);
                if (ErrorHandler.Succeeded(hr) && client == _dropdownBarClient)
                {
                    _dropdownBarClient = null;
                    return(manager.RemoveDropdownBar());
                }
            }

            _dropdownBarClient = null;
            return(VSConstants.S_OK);
        }
        protected override bool TryCreateDropdownBarClient(out int comboBoxCount, out IVsDropdownBarClient client)
        {
            comboBoxCount = 2;
            client = CreateDropdownBarClient();

            return true;
        }
            private void AdddropdownBar(IVsDropdownBarManager dropdownManager)
            {
                IVsTextLines buffer;

                if (ErrorHandler.Failed(_codeWindow.GetBuffer(out buffer)))
                {
                    return;
                }

                var navigationBarClient      = new NavigationBarClient(dropdownManager, _codeWindow, _languageService.SystemServiceProvider, _languageService.Workspace);
                var textBuffer               = _languageService.EditorAdaptersFactoryService.GetDataBuffer(buffer);
                var controllerFactoryService = _languageService.Package.ComponentModel.GetService <INavigationBarControllerFactoryService>();
                var newController            = controllerFactoryService.CreateController(navigationBarClient, textBuffer);
                var hr = dropdownManager.AddDropdownBar(cCombos: 3, pClient: navigationBarClient);

                if (ErrorHandler.Failed(hr))
                {
                    newController.Disconnect();
                    ErrorHandler.ThrowOnFailure(hr);
                }

                _navigationBarController = newController;
                _dropdownBarClient       = navigationBarClient;
                return;
            }
Exemple #7
0
        protected virtual int AddDropdownBar(int comboBoxCount, [NotNull] IVsDropdownBarClient client)
        {
            Requires.NotNull(client, nameof(client));
            Requires.Range(comboBoxCount > 0, nameof(comboBoxCount));

            IVsDropdownBarManager manager = CodeWindow as IVsDropdownBarManager;

            if (manager == null)
            {
                throw new NotSupportedException();
            }

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

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

            return(manager.AddDropdownBar(comboBoxCount, client));
        }
        private int AddDropDownBar()
        {
            int comboBoxCount;
            IVsDropdownBarClient client;
            if (TryCreateDropdownBarClient(out comboBoxCount, out client))
            {
                ErrorHandler.ThrowOnFailure(AddDropdownBar(comboBoxCount, client));
                _dropdownBarClient = client;
            }

            return VSConstants.S_OK;
        }
        private int AddDropDownBar()
        {
            int comboBoxCount;
            IVsDropdownBarClient client;

            if (TryCreateDropdownBarClient(out comboBoxCount, out client))
            {
                ErrorHandler.ThrowOnFailure(AddDropdownBar(comboBoxCount, client));
                _dropdownBarClient = client;
            }

            return(VSConstants.S_OK);
        }
            private void RemoveDropdownBar(IVsDropdownBarManager dropdownManager)
            {
                if (ErrorHandler.Succeeded(dropdownManager.RemoveDropdownBar()))
                {
                    if (_navigationBarController != null)
                    {
                        _navigationBarController.Disconnect();
                        _navigationBarController = null;
                    }

                    _dropdownBarClient = null;
                }
            }
        private bool TryCreateDropdownBarClient(out int comboBoxCount, out IVsDropdownBarClient client)
        {
            var componentModel            = ServiceProvider.GetComponentModel();
            var editorAdaptersFactory     = componentModel.DefaultExportProvider.GetExportedValueOrDefault <IVsEditorAdaptersFactoryService>();
            var bufferGraphFactoryService = componentModel.DefaultExportProvider.GetExportedValue <IBufferGraphFactoryService>();

            var textView = editorAdaptersFactory.GetWpfTextView(CodeWindow.GetPrimaryView());

            var editorNavigationSourceProvider = componentModel.DefaultExportProvider.GetExportedValueOrDefault <EditorNavigationSourceProvider>();
            var editorNavigationSource         = editorNavigationSourceProvider.TryCreateEditorNavigationSource(textView.TextBuffer);

            comboBoxCount = 2;
            client        = new EditorNavigationDropdownBarClient(CodeWindow, editorAdaptersFactory, editorNavigationSource, bufferGraphFactoryService);

            return(true);
        }
Exemple #12
0
        protected virtual void HandleLanguagePreferencesChanged(object sender, [NotNull] EventArgs e)
        {
            Requires.NotNull(e, nameof(e));

            int comboBoxCount;
            IVsDropdownBarClient client;

            if (_dropdownBarClient == null && LanguagePreferences.ShowDropdownBar && TryCreateDropdownBarClient(out comboBoxCount, out client))
            {
                ErrorHandler.ThrowOnFailure(AddDropdownBar(comboBoxCount, client));
                _dropdownBarClient = client;
            }
            else if (_dropdownBarClient != null && !LanguagePreferences.ShowDropdownBar)
            {
                ErrorHandler.ThrowOnFailure(RemoveDropdownBar());
            }
        }
        protected virtual void HandleLanguagePreferencesChanged(object sender, EventArgs e)
        {
            Contract.Requires <ArgumentNullException>(e != null, "e");

            int comboBoxCount;
            IVsDropdownBarClient client;

            if (_dropdownBarClient == null && LanguagePreferences.ShowDropdownBar && TryCreateDropdownBarClient(out comboBoxCount, out client))
            {
                ErrorHandler.ThrowOnFailure(AddDropdownBar(comboBoxCount, client));
                _dropdownBarClient = client;
            }
            else if (_dropdownBarClient != null && !LanguagePreferences.ShowDropdownBar)
            {
                ErrorHandler.ThrowOnFailure(RemoveDropdownBar());
            }
        }
        public virtual int AddAdornments()
        {
            IVsTextView textView;
            if (ErrorHandler.Succeeded(CodeWindow.GetPrimaryView(out textView)) && textView != null)
                ErrorHandler.ThrowOnFailure(OnNewView(textView));
            if (ErrorHandler.Succeeded(CodeWindow.GetSecondaryView(out textView)) && textView != null)
                ErrorHandler.ThrowOnFailure(OnNewView(textView));

            int comboBoxCount;
            IVsDropdownBarClient client;
            if (LanguagePreferences.ShowDropdownBar && TryCreateDropdownBarClient(out comboBoxCount, out client))
            {
                ErrorHandler.ThrowOnFailure(AddDropdownBar(comboBoxCount, client));
                _dropdownBarClient = client;
            }

            return VSConstants.S_OK;
        }
        protected virtual bool TryCreateDropdownBarClient(out int comboBoxCount, out IVsDropdownBarClient client)
        {
            var componentModel        = _serviceProvider.GetComponentModel();
            var dropdownBarFactory    = componentModel.DefaultExportProvider.GetExportedValueOrDefault <IEditorNavigationDropdownBarFactoryService>();
            var editorAdaptersFactory = componentModel.DefaultExportProvider.GetExportedValueOrDefault <IVsEditorAdaptersFactoryService>();

            editorAdaptersFactory.GetWpfTextView(_codeWindow.GetPrimaryView());
            var dropdownBarClient = dropdownBarFactory.CreateEditorNavigationDropdownBar(CodeWindow, editorAdaptersFactory);

            if (dropdownBarClient == null || dropdownBarClient.DropdownCount == 0)
            {
                comboBoxCount = 0;
                client        = null;
                return(false);
            }

            comboBoxCount = dropdownBarClient.DropdownCount;
            client        = dropdownBarClient;
            return(true);
        }
        private int RemoveDropDownBar()
        {
            var manager = CodeWindow as IVsDropdownBarManager;
            if (manager == null)
                return VSConstants.E_FAIL;

            IVsDropdownBar dropdownBar;
            int hr = manager.GetDropdownBar(out dropdownBar);
            if (ErrorHandler.Succeeded(hr) && dropdownBar != null)
            {
                IVsDropdownBarClient client;
                hr = dropdownBar.GetClient(out client);
                if (ErrorHandler.Succeeded(hr) && client == _dropdownBarClient)
                {
                    _dropdownBarClient = null;
                    return manager.RemoveDropdownBar();
                }
            }

            _dropdownBarClient = null;
            return VSConstants.S_OK;
        }
        private int AddDropdownBar(int comboBoxCount, IVsDropdownBarClient client)
        {
            var manager = CodeWindow as IVsDropdownBarManager;

            if (manager == null)
            {
                throw new NotSupportedException();
            }

            IVsDropdownBar dropdownBar;
            var            hr = manager.GetDropdownBar(out dropdownBar);

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

            return(manager.AddDropdownBar(comboBoxCount, client));
        }
        public virtual int AddAdornments()
        {
            IVsTextView textView;

            if (ErrorHandler.Succeeded(CodeWindow.GetPrimaryView(out textView)) && textView != null)
            {
                ErrorHandler.ThrowOnFailure(OnNewView(textView));
            }
            if (ErrorHandler.Succeeded(CodeWindow.GetSecondaryView(out textView)) && textView != null)
            {
                ErrorHandler.ThrowOnFailure(OnNewView(textView));
            }

            int comboBoxCount;
            IVsDropdownBarClient client;

            if (LanguagePreferences.ShowDropdownBar && TryCreateDropdownBarClient(out comboBoxCount, out client))
            {
                ErrorHandler.ThrowOnFailure(AddDropdownBar(comboBoxCount, client));
                _dropdownBarClient = client;
            }

            return(VSConstants.S_OK);
        }
        protected virtual int AddDropdownBar(int comboBoxCount, IVsDropdownBarClient client)
        {
            Contract.Requires<ArgumentNullException>(client != null, "client");
            Contract.Requires<ArgumentOutOfRangeException>(comboBoxCount > 0);

            IVsDropdownBarManager manager = CodeWindow as IVsDropdownBarManager;
            if (manager == null)
                throw new NotSupportedException();

            IVsDropdownBar dropdownBar;
            int hr = manager.GetDropdownBar(out dropdownBar);
            if (ErrorHandler.Succeeded(hr) && dropdownBar != null)
            {
                hr = manager.RemoveDropdownBar();
                if (ErrorHandler.Failed(hr))
                    return hr;
            }

            return manager.AddDropdownBar(comboBoxCount, client);
        }
Exemple #20
0
 protected abstract bool TryCreateDropdownBarClient(out int comboBoxCount, out IVsDropdownBarClient client);
Exemple #21
0
 public int AddDropdownBar(int cCombos, IVsDropdownBarClient pClient)
 {
     return(VSConstants.E_FAIL);
 }
 public int AddDropdownBar(int cCombos, IVsDropdownBarClient pClient)
 {
     return DropdownBarManager.AddDropdownBar(cCombos, pClient);
 }
        protected virtual void HandleLanguagePreferencesChanged(object sender, EventArgs e)
        {
            int num = 0;
            IVsDropdownBarClient client = null;

            //System.Diagnostics.Contracts.Contract.Requires<ArgumentNullException>(e != null, "e");
            if (((this._dropdownBarClient == null) && this.LanguagePreferences.ShowDropdownBar) && this.TryCreateDropdownBarClient(out num, out client))
            {
                ErrorHandler.ThrowOnFailure(this.AddDropdownBar(num, client));
                this._dropdownBarClient = client;
            }
            else if ((this._dropdownBarClient != null) && !this.LanguagePreferences.ShowDropdownBar)
            {
                ErrorHandler.ThrowOnFailure(this.RemoveDropdownBar());
            }
        }
 protected abstract bool TryCreateDropdownBarClient(out int comboBoxCount, out IVsDropdownBarClient client);
        protected virtual void HandleLanguagePreferencesChanged(object sender, EventArgs e)
        {
            Contract.Requires<ArgumentNullException>(e != null, "e");

            int comboBoxCount;
            IVsDropdownBarClient client;
            if (_dropdownBarClient == null && LanguagePreferences.ShowDropdownBar && TryCreateDropdownBarClient(out comboBoxCount, out client))
            {
                ErrorHandler.ThrowOnFailure(AddDropdownBar(comboBoxCount, client));
                _dropdownBarClient = client;
            }
            else if (_dropdownBarClient != null && !LanguagePreferences.ShowDropdownBar)
            {
                ErrorHandler.ThrowOnFailure(RemoveDropdownBar());
            }
        }
        public virtual int AddAdornments()
        {
            IVsTextView view;
            int num = 0;
            IVsDropdownBarClient client = null;

            if (ErrorHandler.Succeeded(this.CodeWindow.GetPrimaryView(out view)) && (view != null))
            {
                ErrorHandler.ThrowOnFailure(this.OnNewView(view));
            }
            if (ErrorHandler.Succeeded(this.CodeWindow.GetSecondaryView(out view)) && (view != null))
            {
                ErrorHandler.ThrowOnFailure(this.OnNewView(view));
            }
            if (this.LanguagePreferences.ShowDropdownBar && this.TryCreateDropdownBarClient(out num, out client))
            {
                ErrorHandler.ThrowOnFailure(this.AddDropdownBar(num, client));
                this._dropdownBarClient = client;
            }
            return 0;
        }
 public int AddDropdownBar(int cCombos, IVsDropdownBarClient pClient)
 {
     return(DropdownBarManager.AddDropdownBar(cCombos, pClient));
 }
        private int AddDropdownBar(int comboBoxCount, IVsDropdownBarClient client)
        {
            var manager = CodeWindow as IVsDropdownBarManager;
            if (manager == null)
                throw new NotSupportedException();

            IVsDropdownBar dropdownBar;
            var hr = manager.GetDropdownBar(out dropdownBar);
            if (ErrorHandler.Succeeded(hr) && dropdownBar != null)
            {
                hr = manager.RemoveDropdownBar();
                if (ErrorHandler.Failed(hr))
                    return hr;
            }

            return manager.AddDropdownBar(comboBoxCount, client);
        }
Exemple #29
0
 int IVsDropdownBarManager.AddDropdownBar(int cCombos, IVsDropdownBarClient pClient) => ((IVsDropdownBarManager)_editorWindow).AddDropdownBar(cCombos, pClient);
 protected virtual int AddDropdownBar(int comboBoxCount, IVsDropdownBarClient client)
 {
     IVsDropdownBar bar;
     System.Diagnostics.Contracts.Contract.Requires<ArgumentNullException>(client != null, "client");
     IVsDropdownBarManager codeWindow = this.CodeWindow as IVsDropdownBarManager;
     if (codeWindow == null)
     {
         throw new NotSupportedException();
     }
     if (ErrorHandler.Succeeded(codeWindow.GetDropdownBar(out bar)) && (bar != null))
     {
         int hr = codeWindow.RemoveDropdownBar();
         if (ErrorHandler.Failed(hr))
         {
             return hr;
         }
     }
     return codeWindow.AddDropdownBar(comboBoxCount, client);
 }
        protected virtual bool TryCreateDropdownBarClient(out int comboBoxCount, out IVsDropdownBarClient client)
        {
            var componentModel = _serviceProvider.GetComponentModel();
            var dropdownBarFactory = componentModel.DefaultExportProvider.GetExportedValueOrDefault<IJavaEditorNavigationDropdownBarFactoryService>();
            var editorAdaptersFactory = componentModel.DefaultExportProvider.GetExportedValueOrDefault<IVsEditorAdaptersFactoryService>();

            editorAdaptersFactory.GetWpfTextView(_codeWindow.GetPrimaryView());
            var dropdownBarClient = dropdownBarFactory.CreateEditorNavigationDropdownBar(CodeWindow, editorAdaptersFactory);

            if (dropdownBarClient == null || dropdownBarClient.DropdownCount == 0)
            {
                comboBoxCount = 0;
                client = null;
                return false;
            }

            comboBoxCount = dropdownBarClient.DropdownCount;
            client = dropdownBarClient;
            return true;
        }
        private bool TryCreateDropdownBarClient(out int comboBoxCount, out IVsDropdownBarClient client)
        {
            var componentModel = ServiceProvider.GetComponentModel();
            var editorAdaptersFactory = componentModel.DefaultExportProvider.GetExportedValueOrDefault<IVsEditorAdaptersFactoryService>();
            var bufferGraphFactoryService = componentModel.DefaultExportProvider.GetExportedValue<IBufferGraphFactoryService>();

            var textView = editorAdaptersFactory.GetWpfTextView(CodeWindow.GetPrimaryView());

            var editorNavigationSourceProvider = componentModel.DefaultExportProvider.GetExportedValueOrDefault<EditorNavigationSourceProvider>();
            var editorNavigationSource = editorNavigationSourceProvider.TryCreateEditorNavigationSource(textView.TextBuffer);

            comboBoxCount = 2;
            client = new EditorNavigationDropdownBarClient(CodeWindow, editorAdaptersFactory, editorNavigationSource, bufferGraphFactoryService);

            return true;
        }
 protected virtual int RemoveDropdownBar()
 {
     IVsDropdownBar bar;
     IVsDropdownBarClient client;
     IVsDropdownBarManager codeWindow = this.CodeWindow as IVsDropdownBarManager;
     if (codeWindow == null)
     {
         return -2147467259;
     }
     if ((ErrorHandler.Succeeded(codeWindow.GetDropdownBar(out bar)) && (bar != null)) && (ErrorHandler.Succeeded(bar.GetClient(out client)) && (client == this._dropdownBarClient)))
     {
         this._dropdownBarClient = null;
         return codeWindow.RemoveDropdownBar();
     }
     this._dropdownBarClient = null;
     return 0;
 }
Exemple #34
0
 protected override bool TryCreateDropdownBarClient(out int comboBoxCount, out IVsDropdownBarClient client)
 {
     comboBoxCount = 0;
     client = null;
     return false;
 }
Exemple #35
0
 protected override bool TryCreateDropdownBarClient(out int comboBoxCount, out IVsDropdownBarClient client)
 {
     comboBoxCount = 0;
     client        = null;
     return(false);
 }