示例#1
0
        //collapse current node
        public void GetParentNodeTOCListByNodeID(int tocNodeID)
        {
            if (TOCNodeList == null)
            {
                return;
            }

            if (tocNodeID >= TOCNodeList.Count)
            {
                Console.WriteLine("GetParentNodeTOCListByNodeID node{0} error", tocNodeID);
                return;
            }

            TOCNode parentNode = TOCNodeList [tocNodeID].ParentNode;

            if (parentNode == null || parentNode.NodeLevel == 0)
            {
                if (TOCNodeList.Count > 0)
                {
                    TOCNodeList.Clear();
                }
                TOCNodeList.AddRange(RootNodeList);
            }
            else
            {
                List <TOCNode> nodeList = new List <TOCNode> (0);
                nodeList.AddRange(parentNode.ChildNodes);

                if (nodeList != null)
                {
                    if (TOCNodeList.Count > 0)
                    {
                        TOCNodeList.RemoveAll(item => item != null);
                    }
                    TOCNodeList = nodeList;
                }
            }

            if (TOCNodeList.Any())
            {
                CurrentLevel = TOCNodeList [0].NodeLevel;
            }

            UpdateTOCNodeListAndRefreshTableView();
        }
        //expand current node
        public void GetSubNodeTOCListByNodeID(int tocNodeID)
        {
            if (tocNodeID >= TOCNodeList.Count)
            {
                Console.WriteLine("GetSubNodeTOCListByNodeID node{0} error", tocNodeID);
                return;
            }

            List <TOCNode> subNodeList = new List <TOCNode> (0);

            subNodeList.AddRange(TOCNodeList [tocNodeID].ChildNodes);
            if (subNodeList != null)
            {
                if (TOCNodeList.Count > 0)
                {
                    TOCNodeList.RemoveAll(item => item != null);
                }

                TOCNodeList  = subNodeList;
                CurrentLevel = TOCNodeList [0].NodeLevel;

                UpdateTOCNodeListAndRefreshTableView();
            }
        }