Exemple #1
0
        private bool WalkNodes(TreeNode node)
        {
            // Fire the ProcessNode event.
            ProcessNodeEventArgs args = ProcessNodeEventArgs.CreateInstance(node);

            this.OnProcessNode(args);

            // Cache the value of ProcessSiblings since ProcessNodeEventArgs is a singleton.
            bool processSiblings = args.ProcessSiblings;

            if (args.StopProcessing)
            {
                this.stopProcessing = true;
            }
            else if (args.ProcessDescendants)
            {
                for (int i = 0; i < node.Nodes.Count; ++i)
                {
                    if (!this.WalkNodes(node.Nodes[i]) || this.stopProcessing)
                    {
                        break;
                    }
                }
            }

            return(processSiblings);
        }