Example #1
0
            async void HandleClick(object sender, RoutedEventArgs e)
            {
                SyncHelper.CancelAndDispose(ref _Bar._cancellationSource, true);
                if (_Menu != null && _Bar._SymbolList == _Menu)
                {
                    _Bar.HideMenu();
                    return;
                }
                if (Node.Kind().IsTypeDeclaration() == false)
                {
                    var span = Node.FullSpan;
                    if (span.Contains(_Bar._SemanticContext.Position) && Node.SyntaxTree.FilePath == _Bar._SemanticContext.Document.FilePath ||
                        Node.IsKind(SyntaxKind.RegionDirectiveTrivia))
                    {
                        _Bar._View.SelectNode(Node, Keyboard.Modifiers != ModifierKeys.Control);
                    }
                    else
                    {
                        Node.GetIdentifierToken().GetLocation().GoToSource();
                    }
                    return;
                }

                var ct = _Bar._cancellationSource.GetToken();

                await CreateMenuForTypeSymbolNodeAsync(ct);

                _FilterBox.UpdateNumbers((await _Bar._SemanticContext.GetSymbolAsync(Node, ct) as ITypeSymbol)?.GetMembers());
                var footer = (TextBlock)_Menu.Footer;

                if (_PartialCount > 1)
                {
                    footer.Append(ThemeHelper.GetImage(KnownImageIds.OpenDocumentFromCollection))
                    .Append(_PartialCount);
                }
                footer.Append(ThemeHelper.GetImage(KnownImageIds.Code))
                .Append(Node.GetLineSpan().Length + 1);
                _Bar.ShowMenu(this, _Menu);
                _FilterBox?.FocusTextBox();
            }
Example #2
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();
            }