示例#1
0
        public void Invoke(Document activeDocument)
        {
            var bindingMethod = GetSelectedBindingMethod(activeDocument);

            var projectScopes = GetProjectScopes(activeDocument).ToArray();

            if (projectScopes.Any(ps => !ps.StepSuggestionProvider.Populated))
            {
                MessageBox.Show("Step bindings are still being analyzed. Please wait.", "Go to steps");
                return;
            }
            var candidatingPositions = projectScopes.SelectMany(ps => GetMatchingSteps(bindingMethod, ps)).ToArray();

            if (candidatingPositions.Length == 0)
            {
                MessageBox.Show("No matching step found.", "Go to steps");
                return;
            }

            if (candidatingPositions.Length == 1)
            {
                JumpToStep(candidatingPositions[0]);
                return;
            }

            var menuBuilder = new ContextMenuBuilder();

            menuBuilder.Title = "Go to steps: Multiple matching steps found.";
            menuBuilder.AddRange(candidatingPositions.Select((si, index) =>
                                                             new ContextMenuBuilder.ContextCommandItem(
                                                                 GetStepInstanceGotoTitle(si),
                                                                 () => JumpToStep(si))));

            VsContextMenuManager.ShowContextMenu(menuBuilder.ToContextMenu(), dte);
        }