public AncestryBrowserWindowViewModel(TypeInfo typeInfo)
        {
            _typeInfo = typeInfo;

            ExpandCollapseAllCommand = new DelegateCommand(ExpandCollapseAllCommandHandler);

            _options = new MemberOptions
            {
                ShowProperties        = true,
                ShowEvents            = true,
                ShowMethods           = true,
                ShowProtected         = true,
                ShowProtectedInternal = true,
                ShowPublic            = true
            };

            Type = new TypeViewModel(_typeInfo);

            _ancestry = Type.Ancestry.ToList();
            _ancestry.Last().IsLast = true;
            Assemblies = _ancestry
                         .GroupBy(t => t.TypeInfo.Module.Assembly)
                         .Select(g => new AssemblyViewModel(g.Key, g))
                         .ToList();

            var currentIndex = 0;

            foreach (var assembly in Assemblies)
            {
                var brush = BrushProvider.BrushPairs[currentIndex].Background as SolidColorBrush;
                brush = new SolidColorBrush(
                    new Color {
                    A = 72, R = brush.Color.R, G = brush.Color.G, B = brush.Color.B
                });

                assembly.BackgroundBrush = brush;
                assembly.CaptionBrush    = BrushProvider.BrushPairs[currentIndex].Caption;
                currentIndex++;
                if (currentIndex == BrushProvider.BrushPairs.Count)
                {
                    currentIndex = 0;
                }
            }

            KindGroup = new CommandsGroupViewModel(
                Resources.Members,
                new List <GroupedUserCommand>
            {
                new GroupedUserCommand(Resources.All, ShowAllMemberKinds, true),
                new GroupedUserCommand(Resources.Virtual, ShowVirtualMembers)
            });

            UpdateMembers();
            FillToolTips();
        }
Exemplo n.º 2
0
        public void UpdateMembers(MemberOptions options)
        {
            ResetMembers(_events);
            ResetMembers(_fields);
            ResetMembers(_methods);
            ResetMembers(_properties);

            IEnumerable <MemberViewModel> members = new MemberViewModel[0];

            if (options.ShowFields)
            {
                members = members.Concat(_fields);
            }
            if (options.ShowProperties)
            {
                members = members.Concat(_properties);
            }
            if (options.ShowEvents)
            {
                members = members.Concat(_events);
            }
            if (options.ShowMethods)
            {
                members = members.Concat(_methods);
            }

            if (!options.ShowPrivate)
            {
                members = members.Where(m => !m.IsPrivate);
            }
            if (!options.ShowInternal)
            {
                members = members.Where(m => !m.IsInternal);
            }
            if (!options.ShowProtected)
            {
                members = members.Where(m => !m.IsProtected);
            }
            if (!options.ShowProtectedInternal)
            {
                members = members.Where(m => !m.IsProtectedInternal);
            }
            if (!options.ShowPublic)
            {
                members = members.Where(m => !m.IsPublic);
            }
            if (!string.IsNullOrWhiteSpace(options.SearchTerm))
            {
                members =
                    members.Where(
                        m => m.MemberInfo.Name.IndexOf(options.SearchTerm.Trim(), StringComparison.InvariantCultureIgnoreCase) >= 0);
            }
            if (options.MemberKind == MemberKind.Virtual)
            {
                members = members.OfType <ICanBeVirtual>().Where(m => m.IsVirtual).OfType <MemberViewModel>();
                foreach (var member in members)
                {
                    var maybeVirtualMember = member as ICanBeVirtual;

                    if (maybeVirtualMember.IsOverride)
                    {
                        member.IsMarked = true;
                    }
                }
            }

            Members = members.ToArray();
        }