public StackNodeControl FindNode(string key, bool searchAllChild = true)
        {
            StackNodeControl n = null;

            foreach (StackNodeControl node in this.Nodes)
            {
                if (node.Key == key)
                {
                    n = node;
                }
                else
                {
                    n = node.FindNode(key);
                }
                if (n == null)
                {
                    continue;
                }
                else
                {
                    break;
                }
            }
            return(n);
        }
 private void OnNodeClicked(StackNodeControl node)
 {
     if (this.StackNodeClick != null)
     {
         this.StackNodeClick(this.StackedTree, new StackNodeEventArgs(node));
     }
 }
        public void OnSelectionChanged(StackNodeEventArgs e)
        {
            this.SuspendDrawing();
            if (_selectedNode != null)
            {
                _selectedNode.BackColor = Color.White;
                _selectedNode.ForeColor = Color.Black;
            }
            _selectedNode           = e.Node;
            _selectedNode.BackColor = this.SelectionColor;
            _selectedNode.ForeColor = this.SelectionForeColor;

            if (e.Node.Nodes.Count == 0)
            {
                var p = SelectedNode.ParentNode;
                while (p != null)
                {
                    p.Expand();
                    p = p.ParentNode;
                }
                pnlMain.ScrollControlIntoView(SelectedNode.Parent);
            }
            this.ResumeDrawing();
            if (SelectionChanged != null)
            {
                SelectionChanged(this, e);
            }
        }
 private void ClearFilters(StackNodeControl node)
 {
     node.Filtered = true;
     foreach (StackNodeControl child in node.Nodes)
     {
         child.Filtered = true;
         ClearFilters(child);
     }
 }
        private void FilterNode(StackNodeControl node)
        {
            foreach (StackNodeControl child in node.Nodes)
            {
                FilterNode(child);
            }

            bool isVisible      = !node.IsSearchable || node.SearchString.ToLower().Contains(_filterString.ToLower());
            bool isChildVisible = node.Nodes.Any(child => child.Filtered == true);

            node.Filtered = isVisible || isChildVisible;
        }
        private int GetHeight(StackNodeControl node)
        {
            if (!node.IsVisible || !node.Filtered)
            {
                return(0);
            }
            int totalHeight = 40;

            if (node.Nodes.Count == 0 || !node.IsExpanded)
            {
                return(totalHeight);
            }
            else  //Get ChildPanel Height
            {
                //Immediate Nodes
                foreach (StackNodeControl child in node.Nodes)
                {
                    totalHeight += GetHeight(child);
                }
                return(totalHeight);
            }
        }
        private void CreateNodes(SampleItem sample, StackNodeControl parent = null)
        {
            StackNodeControl node;

            if (parent == null)
            {
                node = treeView.Nodes.Add(sample.Guid.ToString(), sample.Name);
            }
            else
            {
                node = parent.Nodes.Add(sample.Guid.ToString(), sample.Name);
                node.IsSearchable = true;

                /*
                 * A node can be searched based on the following parameters
                 * 1. Text of the parent node
                 * 2. Name and Title of the node itself
                 * 3. Keywords defined for the parent node
                 * 4. Keywords defined for the node itself
                 */
                node.SearchString = string.Format("{0} {1} {2} {3} {4}", parent.Text, sample.Name, sample.Title, sample.KeyWords, sample.Parent.KeyWords);
            }
            node.Tag    = sample;
            node.Status = sample.Status;
            if (!sample.Items.IsNullOrEmpty())
            {
                node.ExpandedImage  = node.Level == 0 ? StackTreeControl.ImageList["Minus"] : StackTreeControl.ImageList["ExpandedArrow"];
                node.CollapsedImage = node.Level == 0 ? StackTreeControl.ImageList["Plus"] : StackTreeControl.ImageList["CollapsedArrow"];
                foreach (var item in sample.Items)
                {
                    CreateNodes(item, node);
                }
            }
            else
            {
                node.ExpandedImage = node.CollapsedImage = StackTreeControl.ImageList["Leaf"];
            }
        }
 public StackNodeEventArgs(StackNodeControl node)
 {
     this.Node = node;
 }