Beispiel #1
0
 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;
 }
Beispiel #2
0
        static int AddSymbolMembers(CSharpSmartBar bar, SymbolList list, ISymbol source, string typeCategory)
        {
            var nsOrType = source as INamespaceOrTypeSymbol;
            var members  = nsOrType.GetMembers().RemoveAll(m => m.CanBeReferencedByName == false);

            if (bar._IsVsProject)
            {
                switch (nsOrType.Name)
                {
                case nameof(KnownImageIds):
                    list.ContainerType = SymbolItemType.VsKnownImage;
                    list.IconProvider  = s => {
                        var f = s.Symbol as IFieldSymbol;
                        if (f == null || f.HasConstantValue == false || f.Type.SpecialType != SpecialType.System_Int32)
                        {
                            return(null);
                        }
                        return(ThemeHelper.GetImage((int)f.ConstantValue));
                    };
                    break;
                }
            }
            if (source.Kind == SymbolKind.NamedType && (source as INamedTypeSymbol).TypeKind == TypeKind.Enum)
            {
                // sort enum members by value
                members = members.Sort(CodeAnalysisHelper.CompareByFieldIntegerConst);
            }
            else
            {
                members = members.Sort(CodeAnalysisHelper.CompareByAccessibilityKindName);
            }
            foreach (var item in members)
            {
                var i = list.Add(item, bar._Context, false);
                if (typeCategory != null)
                {
                    i.Hint = typeCategory;
                }
            }
            return(members.Length);
        }