Пример #1
0
        private bool HideMenus(ToolStripItemCollection collection, NodeFilterInfoBase filterInfo)
        {
            bool hasVisibleNodes = false;

            foreach (CustomToolStripMenuItem menuItem in collection)
            {
                var hide = false;
                if (menuItem.DropDownItems.Count > 0)
                {
                    var childrenIsVisible = HideMenus(menuItem.DropDownItems, filterInfo);
                    if (!childrenIsVisible)
                    {
                        hide = true;
                    }
                    hasVisibleNodes |= childrenIsVisible;
                }
                else
                {
                    if (!IsFilteredMenu(menuItem, filterInfo))
                    {
                        hide = true;
                    }
                    else
                    {
                        hasVisibleNodes = true;
                    }
                }
                menuItem.Visible = !hide;
            }

            return(hasVisibleNodes);
        }
Пример #2
0
        private void Filter(string filter, NodeFilterInfoBase filterInfo)
        {
            RestoreNodes();
            var filters = filter.ToLower().Split('.');

            HideNodes(treeView1.Nodes, filterInfo);
            HideNodes(treeView1.Nodes, filters, 0, !String.IsNullOrEmpty(filter));
        }
Пример #3
0
        private bool IsFilteredNode(CustomTreeNode node, NodeFilterInfoBase filter)
        {
            if (node.Dumper == null)
            {
                return(true);
            }

            return(!filter.IsHide(node.Dumper));
        }
Пример #4
0
        private bool IsFilteredMenu(CustomToolStripMenuItem node, NodeFilterInfoBase filter)
        {
            if (node.Dumper == null)
            {
                return(true);
            }

            return(!filter.IsHide(node.Dumper));
        }
Пример #5
0
        private bool HideNodes(TreeNodeCollection nodes, NodeFilterInfoBase filterInfo)
        {
            bool hasVisibleNodes = false;
            var  nodesToRemove   = new List <TreeNode>();

            foreach (CustomTreeNode node in nodes)
            {
                if (node.Nodes.Count > 0)
                {
                    var childrenIsVisible = HideNodes(node.Nodes, filterInfo);
                    if (!childrenIsVisible)
                    {
                        nodesToRemove.Add(node);
                    }
                    hasVisibleNodes |= childrenIsVisible;
                }
                else
                {
                    if (!IsFilteredNode(node, filterInfo))
                    {
                        nodesToRemove.Add(node);
                    }
                    else
                    {
                        hasVisibleNodes = true;
                    }
                }
            }

            foreach (TreeNode node in nodesToRemove)
            {
                removedNodes.Add(new RemovedTreeNode {
                    RemovedNode = node, ParentNode = node.Parent, RemovedNodeIndex = node.Index
                });
                node.Remove();
            }
            return(hasVisibleNodes);
        }
Пример #6
0
 public static void AddFilter(NodeFilterInfoBase filter)
 {
     filters.Add(filter);
 }