예제 #1
0
        private void txtEditorFilter_TextChanged(object sender, EventArgs e)
        {
            if (_activeSaveFile == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(txtEditorFilter.Text))
            {
                EditorTree.Nodes.Clear();
                foreach (var node in _activeSaveFile.Nodes)
                {
                    var treeNode = new NodeEntryTreeNode(node);
                    BuildVisualSubTree(treeNode, null);
                    EditorTree.Nodes.Add(treeNode);
                }

                return;
            }
            // Filter nodes. We also show parents if children contain the text.

            var filterString = txtEditorFilter.Text.ToLowerInvariant();

            List <NodeEntry> filteredNodes = new List <NodeEntry>();

            foreach (var node in _activeSaveFile.FlatNodes)
            {
                if (node.ToString().Contains(filterString))
                {
                    filteredNodes.Add(node);
                }
            }

            List <NodeEntryTreeNode> filteredTreeNodes = new List <NodeEntryTreeNode>();

            EditorTree.Nodes.Clear();
            foreach (var node in _activeSaveFile.Nodes)
            {
                var treeNode = new NodeEntryTreeNode(node);

                BuildVisualSubTree(treeNode, filterString);
                if (treeNode.Text.ToLowerInvariant().Contains(filterString) || treeNode.Nodes.Count > 0)
                {
                    EditorTree.Nodes.Add(treeNode);
                }
            }

            EditorTree.ExpandAll();
        }