Example #1
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);
        }
        private void Test_ContextMenu_DefaultLocation(object sender, RoutedEventArgs e)
        {
            var contextMenu = CreateContextMenu();

            _contextMenuManager.ShowContextMenu(contextMenu);
        }