Beispiel #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);
        }
Beispiel #2
0
        /// <summary>
        /// Raises the ProcessNode event.
        /// </summary>
        /// <param name="e">The event argument.</param>
        protected virtual void OnProcessNode(ProcessNodeEventArgs e)
        {
            ProcessNodeEventHandler handler = this.ProcessNode;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Beispiel #3
0
        /// <summary>
        /// This method ensures that the ProcessNodeEventArgs class is a singleton.  Making this class
        /// a singleton prevents multiple instances from being created, which could help to prevent
        /// heap fragmentation when the tree being navigated has hundreds or thousands of nodes.
        /// </summary>
        /// <param name="node">The node to be exposed by the event argument.</param>
        internal static ProcessNodeEventArgs CreateInstance(TreeNode node)
        {
            if (ProcessNodeEventArgs.instance == null)
            {
                ProcessNodeEventArgs.instance = new ProcessNodeEventArgs();
            }

            ProcessNodeEventArgs.instance.node = node;
            ProcessNodeEventArgs.instance.processDescendants = true;
            ProcessNodeEventArgs.instance.processSiblings    = true;
            ProcessNodeEventArgs.instance.stopProcessing     = false;

            return(ProcessNodeEventArgs.instance);
        }
 /// <summary>
 /// Raises the ProcessNode event.
 /// </summary>
 /// <param name="e">The event argument.</param>
 protected virtual void OnProcessNode(ProcessNodeEventArgs e)
 {
     ProcessNodeEventHandler handler = this.ProcessNode;
     if (handler != null)
         handler(this, e);
 }
        private void treeViewWalker_ProcessNode_HighlightMatchingNodes(object sender, ProcessNodeEventArgs e)
        {
            if (e.Node.Text.ToLower(CultureInfo.CurrentCulture).IndexOf(textBox1.Text.ToLower(CultureInfo.CurrentCulture), StringComparison.CurrentCultureIgnoreCase) > -1)
            {
                e.Node.BackColor = Color.Yellow;
                e.Node.ForeColor = Color.Red;
                e.Node.Expand();
            }

            //treeViewWalker.ProcessNode -= new ProcessNodeEventHandler(treeViewWalker_ProcessNode_HighlightMatchingNodes);
        }
        /// <summary>
        /// This method ensures that the ProcessNodeEventArgs class is a singleton.  Making this class
        /// a singleton prevents multiple instances from being created, which could help to prevent
        /// heap fragmentation when the tree being navigated has hundreds or thousands of nodes.
        /// </summary>
        /// <param name="node">The node to be exposed by the event argument.</param>
        internal static ProcessNodeEventArgs CreateInstance(TreeNode node)
        {
            if (ProcessNodeEventArgs.instance == null)
                ProcessNodeEventArgs.instance = new ProcessNodeEventArgs();

            ProcessNodeEventArgs.instance.node = node;
            ProcessNodeEventArgs.instance.processDescendants = true;
            ProcessNodeEventArgs.instance.processSiblings = true;
            ProcessNodeEventArgs.instance.stopProcessing = false;

            return ProcessNodeEventArgs.instance;
        }