StonehearthEditor.Module.FilterAliasTree C# (CSharp) Method

FilterAliasTree() public method

public FilterAliasTree ( string searchTerm ) : TreeNode
searchTerm string
return System.Windows.Forms.TreeNode
        public TreeNode FilterAliasTree(string searchTerm)
        {
            TreeNode root = new TreeNode(Name);
            root.ImageIndex = 100;
            root.SelectedImageIndex = 100;
            root.ExpandAll();
            bool hasItems = false;

            foreach (KeyValuePair<string, Dictionary<string, ModuleFile>> pair in mModuleFiles)
            {
                TreeNode subRoot = new TreeNode(pair.Key);
                if (pair.Key == "aliases")
                {
                    subRoot.ExpandAll();
                }

                subRoot.SelectedImageIndex = 100;
                subRoot.ImageIndex = 100;
                foreach (ModuleFile alias in pair.Value.Values)
                {
                    TreeNode newNode = alias.GetTreeNode(searchTerm);
                    if (newNode != null)
                    {
                        subRoot.Nodes.Add(newNode);
                    }
                }

                if (subRoot.Nodes.Count > 0)
                {
                    hasItems = true;
                    root.Nodes.Add(subRoot);
                }
            }

            return (searchTerm == "" || searchTerm == null || hasItems) ? root : null;
        }