Exemplo n.º 1
0
        internal void ShowContextMenu(RoutedEventArgs e)
        {
            var m = ContextMenu as CSharpSymbolContextMenu;

            if (m == null)
            {
                ContextMenu = m = new CSharpSymbolContextMenu(SemanticContext)
                {
                    Resources  = SharedDictionaryManager.ContextMenu,
                    Foreground = ThemeHelper.ToolWindowTextBrush,
                    IsEnabled  = true,
                };
            }
            var item = SelectedSymbolItem;

            if (item == null ||
                (item.Symbol == null && item.SyntaxNode == null) ||
                (e.OriginalSource as DependencyObject).GetParentOrSelf <ListBoxItem>() == null)
            {
                e.Handled = true;
                return;
            }
            m.Symbol     = item.Symbol;
            m.SyntaxNode = item.SyntaxNode;
            m.Items.Clear();
            SetupContextMenu(m, item);
            m.AddTitleItem(item.SyntaxNode?.GetDeclarationSignature() ?? item.Symbol.GetOriginalName());
            m.IsOpen = true;
        }
Exemplo n.º 2
0
 void SetupContextMenu(CSharpSymbolContextMenu menu, SymbolItem item)
 {
     if (item.SyntaxNode != null)
     {
         SetupMenuCommand(item, IconIds.SelectCode, R.CMD_SelectCode, s => {
             if (s.IsExternal)
             {
                 s.SyntaxNode.SelectNode(true);
             }
             else
             {
                 s.Container.SemanticContext.View.SelectNode(s.SyntaxNode, true);
             }
         });
         //SetupMenuCommand(item, KnownImageIds.Copy, "Copy Code", s => Clipboard.SetText(s.SyntaxNode.ToFullString()));
         item.SetSymbolToSyntaxNode();
     }
     if (item.Symbol != null)
     {
         if (item.SyntaxNode == null && item.Symbol.HasSource())
         {
             menu.AddSymbolNodeCommands();
         }
         else
         {
             menu.AddSymbolCommands();
         }
         menu.Items.Add(new Separator());
         menu.SyntaxNode = item.SyntaxNode;
         menu.Symbol     = item.Symbol;
         menu.AddAnalysisCommands();
     }
 }
Exemplo n.º 3
0
 void SetupContextMenu(CSharpSymbolContextMenu menu, SymbolItem item)
 {
     if (item.SyntaxNode != null)
     {
         SetupMenuCommand(item, KnownImageIds.BlockSelection, "Select Code", s => s.Container.SemanticContext.View.SelectNode(s.SyntaxNode, true));
         //SetupMenuCommand(item, KnownImageIds.Copy, "Copy Code", s => Clipboard.SetText(s.SyntaxNode.ToFullString()));
         item.SetSymbolToSyntaxNode();
     }
     if (item.Symbol != null)
     {
         if (item.SyntaxNode == null && item.Symbol.HasSource())
         {
             SetupMenuCommand(item, KnownImageIds.GoToDefinition, "Go to Definition", s => s.Symbol.GoToSource());
             SetupMenuCommand(item, KnownImageIds.BlockSelection, "Select Code", s => s.Symbol.GetSyntaxNode().SelectNode(true));
         }
         menu.AddSymbolCommands();
         menu.Items.Add(new Separator());
         menu.SyntaxNode = item.SyntaxNode;
         menu.Symbol     = item.Symbol;
         menu.AddAnalysisCommands();
     }
 }