示例#1
0
        private static void UnHighlight(List <CodeItem> codeItems, Color foregroundColor,
                                        Dictionary <string, int> bookmarks)
        {
            foreach (var item in codeItems)
            {
                if (item == null)
                {
                    continue;
                }

                item.FontWeight          = FontWeights.Regular;
                item.NameBackgroundColor = Brushes.Transparent.Color;
                item.IsHighlighted       = false;

                if (!BookmarkHelper.IsBookmark(bookmarks, item))
                {
                    item.ForegroundColor = foregroundColor;
                }
                else
                {
                    item.ForegroundColor = item.BookmarkStyles[bookmarks[item.Id]].ForegroundColor;
                }

                if (item is IMembers)
                {
                    var hasMembersItem = (IMembers)item;

                    if (hasMembersItem.Members.Any())
                    {
                        UnHighlight(hasMembersItem.Members, foregroundColor, bookmarks);
                    }
                }

                if (item is CodeClassItem)
                {
                    var classItem = (CodeClassItem)item;
                    classItem.BorderColor = Colors.DarkGray;
                }
            }
        }
示例#2
0
        /// <summary>
        /// Determine if an item should be visible
        /// </summary>
        /// <param name="item">CodeItem that is checked</param>
        /// <param name="name">Text filter</param>
        /// <param name="filterOnBookmarks">Are we only showing bookmarks?</param>
        /// <param name="bookmarks">List of current bookmarks</param>
        /// <returns></returns>
        private static bool ShouldBeVisible(CodeItem item, string name = "",
                                            bool filterOnBookmarks     = false, Dictionary <string, int> bookmarks = null)
        {
            var visible = true;

            var filterRule = GetFilterRule(item);

            if (filterRule != null && filterRule.Visible == false)
            {
                return(false);
            }

            if (filterOnBookmarks)
            {
                visible = BookmarkHelper.IsBookmark(bookmarks, item);
            }

            if (!string.IsNullOrEmpty(name))
            {
                visible = visible && item.Name.Contains(name, StringComparison.OrdinalIgnoreCase);
            }

            // If an item has any visible members, it should be visible.
            // If an item does not have any visible members, hide it depending on an option
            if (item is IMembers hasMembersItem &&
                hasMembersItem?.Members != null)
            {
                if (hasMembersItem.Members.Any(m => m.IsVisible == Visibility.Visible))
                {
                    visible = true;
                }
                else if (!hasMembersItem.Members.Any(m => m.IsVisible == Visibility.Visible) && filterRule != null)
                {
                    visible = !filterRule.HideIfEmpty;
                }
            }

            return(visible);
        }
示例#3
0
        private static bool ShouldBeVisible(CodeItem item, string name = "",
                                            bool filterOnBookmarks     = false, Dictionary <string, int> bookmarks = null)
        {
            var visible = true;

            if (Settings.Default.FilterRules != null)
            {
                var filterRule = Settings.Default.FilterRules.LastOrDefault(f =>
                                                                            (f.Access == item.Access || f.Access == CodeItemAccessEnum.All) &&
                                                                            (f.Kind == item.Kind || f.Kind == CodeItemKindEnum.All));

                if (filterRule != null)
                {
                    visible = filterRule.Visible;
                }
            }

            if (filterOnBookmarks)
            {
                visible = BookmarkHelper.IsBookmark(bookmarks, item);
            }

            return(visible && item.Name.Contains(name, StringComparison.OrdinalIgnoreCase));
        }