Example #1
0
 public RootItem(CSharpBar bar)
 {
     _Bar = bar;
     Icon = ThemeHelper.GetImage(KnownImageIds.Namespace);
     this.ReferenceCrispImageBackground(EnvironmentColors.MainWindowActiveCaptionColorKey);
     SetResourceReference(ForegroundProperty, VsBrushes.CommandBarTextActiveKey);
     Header = new ThemedToolBarText();
     _Menu  = new SymbolList(bar._SemanticContext)
     {
         Container     = _Bar._SymbolListContainer,
         ContainerType = SymbolListType.NodeList,
         Header        = new StackPanel {
             Margin   = WpfHelper.MenuItemMargin,
             Children =
             {
                 new Separator  {
                     Tag = new ThemedMenuText("Search Declaration")
                 },
                 new StackPanel {
                     Orientation = Orientation.Horizontal,
                     Children    =
                     {
                         ThemeHelper.GetImage(KnownImageIds.SearchContract).WrapMargin(WpfHelper.GlyphMargin),
                         (_FinderBox = new MemberFinderBox()
                         {
                             MinWidth = 150
                         }),
                         (_ScopeBox = new SearchScopeBox{
                             Contents =
                             {
                                 new ThemedButton(KnownImageIds.StopFilter, "Clear filter", ClearFilter).ClearBorder()
                             }
                         }),
                     }
                 },
             }
         },
         Footer = _Note = new TextBlock {
             Margin = WpfHelper.MenuItemMargin
         }
         .ReferenceProperty(TextBlock.ForegroundProperty, EnvironmentColors.SystemGrayTextBrushKey)
     };
     _Bar.SetupSymbolListMenu(_Menu);
     _FinderBox.TextChanged  += SearchCriteriaChanged;
     _ScopeBox.FilterChanged += SearchCriteriaChanged;
     _ScopeBox.FilterChanged += (s, args) => _FinderBox.Focus();
 }
Example #2
0
            async Task CreateMenuForTypeSymbolNodeAsync(CancellationToken cancellationToken)
            {
                if (_Menu != null)
                {
                    ((TextBlock)_Menu.Footer).Clear();
                    await RefreshItemsAsync(Node, cancellationToken);

                    return;
                }
                _Menu = new SymbolList(_Bar._SemanticContext)
                {
                    Container     = _Bar._SymbolListContainer,
                    ContainerType = SymbolListType.NodeList
                };
                _Menu.Header = new WrapPanel {
                    Orientation = Orientation.Horizontal,
                    Children    =
                    {
                        new ThemedButton(new ThemedMenuText(Node.GetDeclarationSignature(),  true)
                                         .SetGlyph(ThemeHelper.GetImage(Node.GetImageId())), null,
                                         () => _Bar._SemanticContext.RelocateDeclarationNode(Node).GetLocation().GoToSource())
                        {
                            BorderThickness = WpfHelper.TinyMargin,
                            Margin          = WpfHelper.SmallHorizontalMargin,
                            Padding         = WpfHelper.SmallHorizontalMargin,
                        },
                        (_FilterBox = new SymbolFilterBox(_Menu)),
                    }
                };
                _Menu.Footer = new TextBlock {
                    Margin = WpfHelper.MenuItemMargin
                }
                .ReferenceProperty(TextBlock.ForegroundProperty, EnvironmentColors.SystemGrayTextBrushKey);
                _Bar.SetupSymbolListMenu(_Menu);
                await AddItemsAsync(Node, cancellationToken);

                if (_Menu.Symbols.Count > 100)
                {
                    ScrollViewer.SetCanContentScroll(_Menu, true);
                }
            }
Example #3
0
            async void HandleClick(object sender, RoutedEventArgs e)
            {
                CancellationHelper.CancelAndDispose(ref _Bar._cancellationSource, true);
                if (_Menu != null && _Bar._SymbolList == _Menu)
                {
                    _Bar.HideMenu();
                    return;
                }
                if (Node.IsTypeDeclaration() == false)
                {
                    var span = Node.FullSpan;
                    if (span.Contains(_Bar._SemanticContext.Position) && Node.SyntaxTree.FilePath == _Bar._SemanticContext.Document.FilePath)
                    {
                        _Bar._View.SelectNode(Node, Keyboard.Modifiers != ModifierKeys.Control);
                    }
                    else
                    {
                        Node.GetIdentifierToken().GetLocation().GoToSource();
                    }
                    return;
                }
                if (_Menu == null)
                {
                    _Menu = new SymbolList {
                        Container = _Bar._SymbolListContainer
                    };
                    _Menu.Header = new WrapPanel {
                        Orientation = Orientation.Horizontal,
                        Children    =
                        {
                            new ThemedButton(new ThemedMenuText(Node.GetDeclarationSignature(),  true)
                                             .SetGlyph(ThemeHelper.GetImage(Node.GetImageId())), null,
                                             () => _Bar._SemanticContext.RelocateDeclarationNode(Node).GetLocation().GoToSource())
                            {
                                BorderThickness = WpfHelper.TinyMargin,
                                Margin          = WpfHelper.SmallHorizontalMargin,
                                Padding         = WpfHelper.SmallHorizontalMargin,
                            },
                            (_FilterBox = new MemberFilterBox(_Menu)),
                        }
                    };
                    _Menu.Footer = new TextBlock {
                        Margin = WpfHelper.MenuItemMargin
                    }
                    .ReferenceProperty(TextBlock.ForegroundProperty, EnvironmentColors.SystemGrayTextBrushKey);
                    _Bar.SetupSymbolListMenu(_Menu);
                    await AddItemsAsync(Node, _Bar._cancellationSource.GetToken());

                    if (_Menu.Symbols.Count > 100)
                    {
                        ScrollViewer.SetCanContentScroll(_Menu, true);
                    }
                }
                else
                {
                    ((TextBlock)_Menu.Footer).Clear();
                    await RefreshItemsAsync(Node, _Bar._cancellationSource.GetToken());
                }
                var footer = (TextBlock)_Menu.Footer;

                if (Config.Instance.NaviBarOptions.MatchFlags(NaviBarOptions.CodeStatistics))
                {
                    if (_PartialCount > 1)
                    {
                        footer.Append(ThemeHelper.GetImage(KnownImageIds.OpenDocumentFromCollection))
                        .Append(_PartialCount);
                    }
                    footer.Append(ThemeHelper.GetImage(KnownImageIds.Code))
                    .Append(_Bar._View.TextSnapshot.GetLineSpan(Node.Span).Length);
                    footer.Visibility = Visibility.Visible;
                }
                else
                {
                    footer.Visibility = Visibility.Collapsed;
                }
                _Menu.ItemsControlMaxHeight = _Bar._View.ViewportHeight / 2;
                _Bar.ShowMenu(this, _Menu);
                _FilterBox?.FocusTextBox();
            }