StonehearthEditor.FileData.UpdateTreeNode C# (CSharp) Method

UpdateTreeNode() public method

public UpdateTreeNode ( TreeNode node, string filter ) : bool
node System.Windows.Forms.TreeNode
filter string
return bool
        public virtual bool UpdateTreeNode(TreeNode node, string filter)
        {
            if (HasErrors)
            {
                node.SelectedImageIndex = 0;
                node.ImageIndex = 0;
                node.ToolTipText = Errors;
            }

            return true;
        }

Usage Example

Exemplo n.º 1
0
        // 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);
        }
All Usage Examples Of StonehearthEditor.FileData::UpdateTreeNode