Esempio n. 1
0
        private void TreeControl_NodeExpandedChanged(object sender, TreeControl.NodeEventArgs e)
        {            
            var treeView = TreeView.As<FilteredTreeView>();
            // early exit
            if (m_updating || !m_searching || e.Node.Tag == null
                 || treeView == null) return;

            if(m_toExpand != null)
            {
                var node = m_toExpand;
                m_toExpand = null;
                try
                {
                    m_updating = true;
                    TreeControlAdapter.Expand(node.Tag);
                    treeView.RestoreExpansion(e.Node, TreeControlAdapter);
                }
                finally
                {
                    m_updating = false;
                }
            }
            else if(e.Node.Expanded && RestoreSubExpansion)
            {
                treeView.RestoreExpansion(e.Node, TreeControlAdapter);
            }
        }
Esempio n. 2
0
        private void TreeControl_NodeExpandedChanging(object sender, TreeControl.CancelNodeEventArgs e)
        {            
            var treeView = TreeView.As<FilteredTreeView>();
            // early exit
            if (m_updating || !m_searching || e.Node.Tag == null
                 || treeView == null) return;

            // is the node or any of its decendants passed filter
            if (treeView.IsMatched(e.Node.Tag))
            {
                if (e.Node.Expanded)
                {
                    if (!treeView.IsFullyExpaned(e.Node.Tag))
                    {
                        // add all the children that did not pass
                        // the filtering to the exempted set.
                        treeView.AddToExemptSet(e.Node.Tag);

                        // save e.Node and expand it in NodeExpandedChanged event handler.
                        m_toExpand = e.Node;
                    }

                    if (RestoreSubExpansion)
                        treeView.SaveExpansion(e.Node);
                } // end of if (e.Node.Expanded )
                else
                { // e.Node about to expand. Remove all its children from exempted set.
                  // so normal filtering will be applied.
                    treeView.RemoveFromExemptSet(e.Node.Tag);
                }
            }//  end of if(treeView.IsMatched(e.Node.Tag))
            else
            {
                if(e.Node.Expanded)
                {
                    if (RestoreSubExpansion)
                        treeView.SaveExpansion(e.Node);
                }
                else
                {
                    treeView.AddToExemptSet(e.Node.Tag);
                }
            }
        }