Exemplo n.º 1
0
        private int AddDropDownBar()
        {
            DropDownBarClient dropDown = _client = new DropDownBarClient(_textView);

            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);
        }
Exemplo n.º 2
0
 private int RemoveDropDownBar()
 {
     if (_client != null)
     {
         IVsDropdownBarManager manager = (IVsDropdownBarManager)_window;
         _client.Dispose();
         _client = null;
         _textView.TextBuffer.Properties.RemoveProperty(typeof(DropDownBarClient));
         return(manager.RemoveDropdownBar());
     }
     return(VSConstants.S_OK);
 }
Exemplo n.º 3
0
        private int AddDropDownBar()
        {
            var text = _textView.TextBuffer.CurrentSnapshot.GetText();

            _textView.TextBuffer.PostChanged += (x, y) =>
            {
                var          currentText = _textView.TextBuffer.CurrentSnapshot.GetText();
                Token[]      currentTokens;
                ParseError[] currentErrors;

                var currentAst = Parser.ParseInput(currentText, out currentTokens, out currentErrors);

                if (_client != null)
                {
                    _client.UpdateAst(currentAst);
                }
            };

            Token[]      tokens;
            ParseError[] errors;

            var ast = Parser.ParseInput(text, out tokens, out errors);

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

            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);
        }
Exemplo n.º 4
0
        private int AddDropDownBar()
        {
            var text = _textView.TextBuffer.CurrentSnapshot.GetText();

            _textView.TextBuffer.PostChanged += (x, y) =>
            {
                var currentText = _textView.TextBuffer.CurrentSnapshot.GetText();
                Token[] currentTokens;
                ParseError[] currentErrors;

                var currentAst = Parser.ParseInput(currentText, out currentTokens, out currentErrors);

                if (_client != null)
                    _client.UpdateAst(currentAst);
            };

            Token[] tokens;
            ParseError[] errors;

            var ast = Parser.ParseInput(text, out tokens, out errors);

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

            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;
        }
Exemplo n.º 5
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;
 }