private ContextMenu CreateContextMenu()
        {
            var command     = new Action <ContextMenuItem>(item => MessageBox.Show($"hello {item.Label}", "test"));
            var contextMenu = _contextMenuManager.CreateContextMenu("Test context menu",
                                                                    new ContextMenuItem("Defined step [regex]", command, "StepDefinitionsDefined"),
                                                                    new ContextMenuItem("Invalid defined step [regex]", command, "StepDefinitionsDefinedInvalid"),
                                                                    new ContextMenuItem("Ambiguous step [regex]", command, "StepDefinitionsAmbiguous"),
                                                                    new ContextMenuItem("Undefined step", command, "StepDefinitionsUndefined"));

            return(contextMenu);
        }
Пример #2
0
        public IAsyncContextMenu ShowContextMenu(string header, bool async, params ContextMenuItem[] contextMenuItems)
        {
            var         contextMenuManager = new ContextMenuManager(UiResourceProvider.Instance);
            ContextMenu contextMenu        = contextMenuManager.CreateContextMenu(header, contextMenuItems);
            var         caretPosition      = VsUtils.GetCaretPosition(IdeScope.ServiceProvider);

            if (caretPosition != null)
            {
                Logger.LogVerbose($"Caret screen position: {caretPosition.Value.X}:{caretPosition.Value.Y}");
                contextMenuManager.ShowContextMenu(contextMenu, caretPosition.Value);
            }
            else
            {
                contextMenuManager.ShowContextMenu(contextMenu);
            }
            if (async)
            {
                return(new AsyncContextMenu(contextMenu, IdeScope, contextMenuManager));
            }
            return(null);
        }