public SymbolMenu(CSharpSmartBar bar) { Menu = new SymbolList { IsVsProject = bar._IsVsProject, Container = bar._SymbolListContainer }; Menu.Header = new StackPanel { Margin = WpfHelper.MenuItemMargin, Children = { (Title = new ThemedMenuText { TextAlignment = TextAlignment.Center, Padding = WpfHelper.SmallMargin }), (FilterBox = new MemberFilterBox(Menu)), new Separator() } }; _Bar = bar; }
bool IMemberTypeFilter.Filter(MemberFilterTypes filterTypes) { return(MemberFilterBox.FilterByImageId(filterTypes, _ImageId)); }
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(); }
bool IMemberFilterable.Filter(MemberFilterTypes filterTypes) { return(MemberFilterBox.FilterByImageId(filterTypes, CommandItem.ImageId)); }