Пример #1
0
        private void ShowImplementationsToolwindow(IEnumerable <Declaration> implementations, string name)
        {
            // throws a COMException if toolwindow was already closed
            var window    = new SimpleListControl(string.Format(RubberduckUI.AllImplementations_Caption, name));
            var presenter = new ImplementationsListDockablePresenter(IDE, AddIn, window, implementations);

            presenter.Show();
        }
Пример #2
0
        private void FindAllImplementations(Declaration target, VBProjectParseResult parseResult)
        {
            string name;
            var    implementations = (target.DeclarationType == DeclarationType.Class
                ? FindAllImplementationsOfClass(target, parseResult, out name)
                : FindAllImplementationsOfMember(target, parseResult, out name)) ??
                                     new List <Declaration>();

            var declarations         = implementations as IList <Declaration> ?? implementations.ToList();
            var implementationsCount = declarations.Count();

            if (implementationsCount == 1)
            {
                // if there's only 1 implementation, just jump to it:
                ImplementationsListDockablePresenter.OnNavigateImplementation(IDE, declarations.First());
            }
            else if (implementationsCount > 1)
            {
                // if there's more than one implementation, show the dockable navigation window:
                try
                {
                    ShowImplementationsToolwindow(declarations, name);
                }
                catch (COMException)
                {
                    // the exception is related to the docked control host instance,
                    // trying again will work (I know, that's bad bad bad code)
                    ShowImplementationsToolwindow(declarations, name);
                }
            }
            else
            {
                var message = string.Format(RubberduckUI.AllImplementations_NoneFound, name);
                var caption = string.Format(RubberduckUI.AllImplementations_Caption, name);
                MessageBox.Show(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }