// Returns true if should show parent node public override bool UpdateTreeNode(TreeNode node, string filter) { base.UpdateTreeNode(node, filter); mTreeNode = node; node.Tag = this; if (!HasErrors) { node.SelectedImageIndex = (int)JsonType; node.ImageIndex = (int)JsonType; } bool filterMatchesSelf = true; ModuleFile owner = GetModuleFile(); if (!string.IsNullOrEmpty(filter) && owner != null && !owner.Alias.Contains(filter)) { filterMatchesSelf = false; } bool hasChildMatchingFilter = false; if (JsonType == JSONTYPE.JOB) { if (OpenedFiles.Count > 1) { FileData recipeJsonData = OpenedFiles[1]; TreeNode recipes = new TreeNode(recipeJsonData.FileName); recipeJsonData.UpdateTreeNode(recipes, filter); IOrderedEnumerable <KeyValuePair <string, FileData> > sortedRecipes = recipeJsonData.LinkedFileData.OrderBy(recipe => recipe.Key); foreach (KeyValuePair <string, FileData> recipe in sortedRecipes) { string recipePath = recipe.Key; string recipeName = System.IO.Path.GetFileNameWithoutExtension(recipePath); if (string.IsNullOrEmpty(filter) || recipeName.Contains(filter) || filterMatchesSelf) { TreeNode recipeNode = new TreeNode(recipeName); recipe.Value.UpdateTreeNode(recipeNode, filter); recipes.Nodes.Add(recipeNode); hasChildMatchingFilter = true; } } node.Nodes.Add(recipes); } } if (!hasChildMatchingFilter && !filterMatchesSelf) { if (!filter.Contains("error") || !HasErrors) { return(false); } } return(true); }
public TreeNode GetTreeNode(string filter) { TreeNode treeNode = new TreeNode(Alias); if (mFileData != null) { bool matchesFilter = mFileData.UpdateTreeNode(treeNode, filter); if (matchesFilter) { return(treeNode); } } return(null); }