Esempio n. 1
0
        //展开选中项的子项
        private void item_Expand(object sender, RoutedEventArgs e)
        {
            TreeViewItem treeItem = memberTreeView.SelectedItem as TreeViewItem;

            if (treeItem != null)
            {
                MenuItem   menu     = sender as MenuItem;
                int        expLevel = int.Parse(menu.Tag.ToString());
                MyTreeNode node     = treeItem.Tag as MyTreeNode;
                if (expLevel > 1000 && node.ChildrenCountAll > 10000)
                {
                    string           warnTxt = "你确定要一次性展开全部子节点吗?\n展开层级过大可能会由于数据量太大而造成程序卡死。";
                    MessageBoxResult result  = MessageBox.Show(warnTxt, "警告", MessageBoxButton.YesNo);
                    if (result == MessageBoxResult.No)
                    {
                        return;
                    }
                }

                levels = 0;
                TimingUtil.StartTiming();
                MyTrees.OpenDB();
                WindowView.notify.SetProcessBarVisible(true);
                ExpandNode(treeItem, expLevel);
                WindowView.notify.SetProcessBarVisible(false);
                MyTrees.CloseDB();
                WindowView.notify.SetStatusMessage(TimingUtil.EndTiming());
            }
        }
Esempio n. 2
0
        public void SetRootNode(MyTreeNode rootNode)
        {
            pager.Visibility = Visibility.Hidden;
            memberTreeView.Items.Clear();
            ringNodeIds.Clear();

            if (rootNode != null)
            {
                TreeViewItem rootItem = NewTreeViewItem(rootNode);

                memberTreeView.Items.Add(rootItem);

                //如果还有子节点,则添加一个节点,使该节点具有折叠的"+"
                if (rootNode.ChildrenCount > 0)
                {
                    rootItem.Items.Add(NewTreeViewItem(null));
                }

                MyTrees.OpenDB();
                //判断当前根节点是否存在父节点
                if (MyTrees.GetNodeBySysId(rootNode.TopId) != null)
                {
                    btnUpLevelNode.IsEnabled = true;
                    btnUpRootNode.IsEnabled  = true;
                }
                else
                {
                    btnUpLevelNode.IsEnabled = false;
                    btnUpRootNode.IsEnabled  = false;
                }
                MyTrees.CloseDB();
            }
        }
Esempio n. 3
0
        //导出图片
        private void btnExportImg_Click(object sender, RoutedEventArgs e)
        {
            MyTreeNode node = GetSelectedNode();

            ExportIMG.SaveNode2Image(this, node);
            WindowView.Refresh_Online_time();
        }
Esempio n. 4
0
        //节点太多,点击加载更多未显示的节点
        void moreNode_Load(object sender, RoutedEventArgs e)
        {
            TreeViewItem moreItem   = sender as TreeViewItem;
            MyTreeNode   node       = moreItem.Tag as MyTreeNode;
            TreeViewItem parentItem = moreItem.Parent as TreeViewItem;

            if (parentItem != null)
            {
                parentItem.Items.Remove(moreItem);

                MyTrees.OpenDB();
                List <MyTreeNode> childrenNodes = MyTrees.GetNodesByTopIdPage(node.TopId, node.ChildrenCount);
                MyTrees.CloseDB();
                foreach (MyTreeNode subNode in childrenNodes)
                {
                    TreeViewItem subItem = NewTreeViewItem(subNode);
                    parentItem.Items.Add(subItem);

                    //如果子节点还有孙子节点,则添加一个虚假的孙节点,使该子节点具有折叠的"+"
                    if (subNode.ChildrenCount > 0)
                    {
                        subItem.Items.Add(NewTreeViewItem(null));
                    }

                    WindowView.notify.SetStatusMessage("正在展开节点" + subItem.Header);
                }

                //表示分页加载更多的节点
                node.ChildrenCount = node.ChildrenCount + MyTrees.getNodePageSize;
                if (node.ChildrenCount < node.ChildrenCountAll)
                {
                    parentItem.Items.Add(NewTreeViewItem(node));
                }
            }
        }
Esempio n. 5
0
        //导出PDF
        private void btnExportPDF_Click(object sender, RoutedEventArgs e)
        {
            MyTreeNode node = GetSelectedNode();

            ExportPDF.Export2PDF(this, node);
            WindowView.Refresh_Online_time();
        }
Esempio n. 6
0
        //显示到顶级根节点
        private void btnUpRootNode_Click(object sender, RoutedEventArgs e)
        {
            TreeViewItem oldRootItem = memberTreeView.Items[0] as TreeViewItem;
            MyTreeNode   oldRootNode = oldRootItem.Tag as MyTreeNode;
            MyTreeNode   newRootNode = MyTrees.GetNodeBySysId(oldRootNode.TopId);

            if (isRingClose(newRootNode.SysId))
            {
                return;
            }

            List <MyTreeNode> parentNodes = MyTrees.FindToRootNodeList(oldRootNode.TopId);

            if (parentNodes.Count > 0)
            {
                //先移除旧的根节点
                memberTreeView.Items.Remove(oldRootItem);

                for (int i = 0; i < parentNodes.Count; i++)
                {
                    MyTreeNode node = parentNodes[i];
                    //添加新的根节点
                    TreeViewItem newRootItem = NewTreeViewItem(parentNodes[i]);
                    newRootItem.IsExpanded = true;
                    newRootItem.Items.Add(oldRootItem);

                    oldRootItem = newRootItem;
                }
            }

            memberTreeView.Items.Add(oldRootItem);

            btnUpLevelNode.IsEnabled = false;
            btnUpRootNode.IsEnabled  = false;
        }
Esempio n. 7
0
        public static void Export2CSV(MyTreeNode node, string outputfile)
        {
            ringNodeIds.Clear();
            WindowView.notify.SetProcessBarVisible(true);
            WindowView.notify.SetStatusMessage("开始导出文件......");
            TimingUtil.StartTiming();

            StreamWriter mysw = new StreamWriter(outputfile, true, Encoding.Default);

            List <string> optCols = MyTrees.TableOptCols;
            string        header  = string.Join(",", optCols.ToArray());

            header = "会员ID,父级ID,会员姓名,所在层级,下级层数,直接下级会员数,下级会员总数," + header;
            mysw.WriteLine(header);

            StringBuilder allLines = new StringBuilder();

            row    = 2;
            allRow = node.ChildrenCount + 1;

            //导出所有父节点
            ExportAllParents2CSV(mysw, allLines, node);

            Export2CSVImp(mysw, allLines, node, true);

            mysw.Close();

            WindowView.notify.SetStatusMessage(TimingUtil.EndTiming());
            WindowView.notify.SetProcessBarVisible(false);
        }
Esempio n. 8
0
        void item_Expanded(object sender, RoutedEventArgs e)
        {
            TreeViewItem item = e.Source as TreeViewItem;

            if (item.HasItems && (item.Items[0] as TreeViewItem).Header.ToString() == "更多")
            {
                //先移除为使该节点具有折叠的"+"而添加的虚假的子节点
                item.Items.Clear();

                MyTreeNode        node          = item.Tag as MyTreeNode;
                List <MyTreeNode> childrenNodes = MyTrees.GetNodes_ByTopId(node.SysId);


                foreach (MyTreeNode subNode in childrenNodes)
                {
                    TreeViewItem subItem = NewTreeViewItem(subNode);
                    item.Items.Add(subItem);

                    //如果子节点还有孙子节点,则添加一个虚假的孙节点,使该子节点具有折叠的"+"
                    if (subNode.ChildrenCount > 0)
                    {
                        subItem.Items.Add(NewTreeViewItem(null));
                    }

                    WindowView.notify.SetStatusMessage("正在展开节点" + subItem.Header);
                }
            }
        }
Esempio n. 9
0
        //导出所有父节点
        private static void ExportAllParents2CSV(StreamWriter mysw, StringBuilder allLines, MyTreeNode node)
        {
            WindowView.notify.SetStatusMessage("正在导出该节点的所有父节点。。。");
            List <MyTreeNode> parentNodes = MyTrees.FindToRootNodeList(node.TopId);

            parentNodes.Reverse();
            allRow += parentNodes.Count;

            for (int i = 0; i < parentNodes.Count; i++)
            {
                MyTreeNode parentNode = parentNodes[i];
                allLines.Clear();
                allLines.Append(parentNode.SysId);
                allLines.Append(",");
                allLines.Append(parentNode.TopId);
                allLines.Append(",");
                allLines.Append(parentNode.Name);
                allLines.Append(",");
                allLines.Append(parentNode.Level);
                allLines.Append(",");
                allLines.Append(parentNode.ChildrenLevels);
                allLines.Append(",");
                allLines.Append(parentNode.ChildrenNodes.Count);
                allLines.Append(",");
                allLines.Append(parentNode.ChildrenCount);
                foreach (string otherProp in parentNode.OtherProps)
                {
                    allLines.Append(",");
                    allLines.Append(otherProp);
                }

                mysw.WriteLine(allLines.ToString());
            }
        }
Esempio n. 10
0
        //导出选中的树节点到csv表格
        private void ButtonExportSelectedNode_Click(object sender, RoutedEventArgs e)
        {
            MyTreeNode node = GetSelectedNode();

            ExportCSV.ExportNodes(node);
            WindowView.Refresh_Online_time();
        }
Esempio n. 11
0
        private TreeViewItem NewTreeViewItem(MyTreeNode node)
        {
            TreeViewItem item = new TreeViewItem();

            if (node == null)
            {
                item.Header  = "none";
                item.ToolTip = "none type node";
            }
            else if (node.SysId == "moreNode")
            {
                item.Header  = "双击加载更多节点";
                item.ToolTip = string.Format("双击加载更多{0}({1})的子节点,已加载节点数:{2},未加载节点数{3}",
                                             node.Name, node.TopId, node.ChildrenCount, node.ChildrenCountAll - node.ChildrenCount);
                item.Tag = node;
                item.MouseDoubleClick += moreNode_Load;
                item.Foreground        = new SolidColorBrush(Colors.Red);
            }
            else
            {
                item.Header  = node.Name;
                item.ToolTip = node.ToString();
                item.Tag     = node;
                if (node.ChildrenCount > 0)
                {
                    item.Expanded += item_Expanded;
                }
            }
            return(item);
        }
Esempio n. 12
0
        //显示上一级节点
        private void btnUpLevelNode_Click(object sender, RoutedEventArgs e)
        {
            TreeViewItem oldRootItem = memberTreeView.Items[0] as TreeViewItem;
            MyTreeNode   oldRootNode = oldRootItem.Tag as MyTreeNode;
            MyTreeNode   newRootNode = MyTrees.GetNodeBySysId(oldRootNode.TopId);

            if (isRingClose(newRootNode.SysId))
            {
                return;
            }

            //先移除旧的根节点
            memberTreeView.Items.Remove(oldRootItem);

            //添加新的根节点
            TreeViewItem newRootItem = NewTreeViewItem(newRootNode);

            memberTreeView.Items.Add(newRootItem);
            newRootItem.IsExpanded = true;

            //新的根节点添加子节点
            List <MyTreeNode> childrenNodes = MyTrees.GetNodes_ByTopId(newRootNode.SysId);
            bool hasNotAdded = true;

            foreach (MyTreeNode subNode in childrenNodes)
            {
                if (hasNotAdded)
                {
                    if (oldRootNode.SysId == subNode.SysId)
                    {
                        newRootItem.Items.Add(oldRootItem);
                        hasNotAdded = false;
                        continue;
                    }
                }
                TreeViewItem subItem = NewTreeViewItem(subNode);
                newRootItem.Items.Add(subItem);

                //如果子节点还有孙子节点,则添加一个虚假的孙节点,使该子节点具有折叠的"+"
                if (subNode.ChildrenCount > 0)
                {
                    subItem.Items.Add(NewTreeViewItem(null));
                }
            }

            //判断当前根节点是否存在父节点
            if (MyTrees.GetNodeBySysId(newRootNode.TopId) != null)
            {
                btnUpLevelNode.IsEnabled = true;
                btnUpRootNode.IsEnabled  = true;
            }
            else
            {
                btnUpLevelNode.IsEnabled = false;
                btnUpRootNode.IsEnabled  = false;
            }
        }
Esempio n. 13
0
 private static void ExportAllImgs(MyTreeView mytreeview, MyTreeNode node)
 {
     mytreeview.BeginExportImg();
     exportNodes.Clear();
     exportNodes.Add(node);
     while (exportNodes.Count > 0)
     {
         ExportImg(mytreeview, exportNodes[0]);
     }
     mytreeview.EndExportImg();
 }
Esempio n. 14
0
        private Button NewTreeViewItem(MyTreeNode subNode)
        {
            Button btn = new Button();

            btn.Content     = subNode.Name;
            btn.ToolTip     = "级别:" + subNode.Level + ",下线人数:" + subNode.ChildrenCount;
            btn.Click      += new RoutedEventHandler(btn_Click);
            btn.MouseEnter += item_MouseEnter;
            btn.MouseMove  += item_MouseMove;
            return(btn);
        }
Esempio n. 15
0
        private TreeViewItem NewTreeViewItem(MyTreeNode subNode)
        {
            TreeViewItem item = new TreeViewItem();

            item.Header      = subNode.Name + ",级别:" + subNode.Level + ",下线人数:" + subNode.ChildrenCount;
            item.Tag         = subNode;
            item.MouseEnter += item_MouseEnter;
            item.MouseLeave += item_MouseLeave;
            item.MouseMove  += item_MouseMove;
            return(item);
        }
Esempio n. 16
0
        void item_SelectedChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            TreeViewItem selectedItem = e.NewValue as TreeViewItem;

            if (selectedItem != null)
            {
                MyTreeNode node = selectedItem.Tag as MyTreeNode;
                if (node != null)
                {
                    myNodeInfo.SetNode(node);
                }
            }
        }
Esempio n. 17
0
        public static List <MyTreeNode> FindToRootNodeList(string parentId)
        {
            List <MyTreeNode> nodes      = new List <MyTreeNode>();
            MyTreeNode        parentNode = GetNodeBySysId(parentId);

            while (parentNode != null)
            {
                nodes.Add(parentNode);
                parentNode = GetNodeBySysId(parentNode.TopId);
            }

            return(nodes);
        }
Esempio n. 18
0
        internal static List <MyTreeNode> FindBySql(List <string> searchParams)
        {
            List <MyTreeNode> result = new List <MyTreeNode>();
            string            sysId  = searchParams[0];
            string            opt    = searchParams[1];

            if (sysId != "")
            {
                if (opt == "等于")
                {
                    MyTreeNode node = GetNodeBySysId(sysId);
                    if (node != null)
                    {
                        result.Add(node);
                    }
                }
                else if (opt == "开头")
                {
                    foreach (string id in allNodes.Keys)
                    {
                        if (id.StartsWith(sysId))
                        {
                            result.Add(allNodes[id]);
                        }
                    }
                }
                else if (opt == "结尾")
                {
                    foreach (string id in allNodes.Keys)
                    {
                        if (id.EndsWith(sysId))
                        {
                            result.Add(allNodes[id]);
                        }
                    }
                }
                else if (opt == "包含")
                {
                    foreach (string id in allNodes.Keys)
                    {
                        if (id.Contains(sysId))
                        {
                            result.Add(allNodes[id]);
                        }
                    }
                }
            }

            return(result);
        }
Esempio n. 19
0
        void item_Expanded(object sender, RoutedEventArgs e)
        {
            TreeViewItem item = e.Source as TreeViewItem;

            if (item.HasItems && (item.Items[0] as TreeViewItem).Header.ToString() == "none")
            {
                //先移除为使该节点具有折叠的"+"而添加的虚假的子节点
                item.Items.Clear();

                if ((e.Source as TreeViewItem).IsSelected)
                {
                    MyTrees.OpenDB();
                }

                MyTreeNode        node          = item.Tag as MyTreeNode;
                List <MyTreeNode> childrenNodes = MyTrees.GetNodesByTopIdPage(node.SysId, 0);

                foreach (MyTreeNode subNode in childrenNodes)
                {
                    TreeViewItem subItem = NewTreeViewItem(subNode);
                    item.Items.Add(subItem);

                    //如果子节点还有孙子节点,则添加一个虚假的孙节点,使该子节点具有折叠的"+"
                    if (subNode.ChildrenCount > 0)
                    {
                        subItem.Items.Add(NewTreeViewItem(null));
                    }

                    WindowView.notify.SetStatusMessage("正在展开节点" + subItem.Header);
                }

                //表示分页加载更多的节点
                if (node.ChildrenCount > MyTrees.getNodePageSize)
                {
                    MyTreeNode moreNode = new MyTreeNode();
                    moreNode.SysId            = "moreNode";
                    moreNode.Name             = node.Name;
                    moreNode.TopId            = node.SysId;
                    moreNode.ChildrenCount    = MyTrees.getNodePageSize;
                    moreNode.ChildrenCountAll = node.ChildrenCount;
                    item.Items.Add(NewTreeViewItem(moreNode));
                }

                if ((e.Source as TreeViewItem).IsSelected)
                {
                    MyTrees.CloseDB();
                }
            }
        }
Esempio n. 20
0
 void item_MouseMove(object sender, MouseEventArgs e)
 {
     if (isAutoExpand.IsChecked == true)
     {
         Button     item = sender as Button;
         TreeNode   tn   = (TreeNode)(item.Parent);
         MyTreeNode node = tn.Tag as MyTreeNode;
         if (node != null)
         {
             statusText.Text = "Id:" + node.SysId + ",TopId:" + node.TopId;
         }
         isCurrentLeave = true;
         e.Handled      = true;
     }
 }
Esempio n. 21
0
 void item_MouseMove(object sender, MouseEventArgs e)
 {
     if (isAutoExpand.IsChecked == true)
     {
         TreeViewItem item = sender as TreeViewItem;
         //Console.WriteLine("$$$$$$$$$$鼠标移动了"+item.Header);
         MyTreeNode node = item.Tag as MyTreeNode;
         if (node != null)
         {
             statusText.Text = "Id:" + node.SysId + ",TopId:" + node.TopId;
         }
         isCurrentLeave = true;
         e.Handled      = true;
     }
 }
Esempio n. 22
0
        //获取选中的节点
        public MyTreeNode GetSelectedNode()
        {
            TreeViewItem selectedItem = memberTreeView.SelectedItem as TreeViewItem;

            if (selectedItem != null)
            {
                MyTreeNode node = (memberTreeView.SelectedItem as TreeViewItem).Tag as MyTreeNode;
                if (node != null)
                {
                    return(node);
                }
            }

            return(null);
        }
Esempio n. 23
0
        internal void SetNode(MyTreeNode node)
        {
            grpNodeInfo.Header = "单个节点详细信息 - " + node.Name + "(" + node.SysId + ")";

            nodeInfoCols[0].Text = node.SysId;
            nodeInfoCols[1].Text = node.TopId;
            nodeInfoCols[2].Text = node.Name;
            nodeInfoCols[3].Text = node.Level.ToString();
            nodeInfoCols[4].Text = node.ChildrenLevels.ToString();
            nodeInfoCols[5].Text = node.ChildrenNodes.Count.ToString();
            nodeInfoCols[6].Text = node.ChildrenCount.ToString();
            for (int i = 0; i < node.OtherProps.Count; i++)
            {
                nodeInfoCols[i + 7].Text = node.OtherProps[i];
            }
        }
Esempio n. 24
0
        void item_Expanded(TreeNode tn)
        {
            MyTreeNode node = tn.Tag as MyTreeNode;

            if (node != null)
            {
                List <MyTreeNode> childrenNodes = MyTrees.GetNodes_ByTopId(node.SysId);;
                foreach (MyTreeNode subNode in childrenNodes)
                {
                    Button   grandson = NewTreeViewItem(subNode);
                    TreeNode newNode  = memberTreeView.AddNode(grandson, tn);
                    newNode.Tag       = subNode;
                    newNode.Collapsed = true;
                }
            }
        }
Esempio n. 25
0
        //构建树(将节点加进树结构中合适的位置)
        private static void ConstructTree(MyTreeNode myNode)
        {
            //是否包含父节点
            MyTreeNode parentNode = GetNodeBySysId(myNode.TopId);

            if (parentNode != null)
            {
                ChildrenCountInc(myNode);//所有父节点的子孙节点加1
                parentNode.ChildrenNodes.Add(myNode);
//                myNode.ParentNode = parentNode;
            }
            else
            {
                //父节点不存在
                NoParentNodes.Add(myNode);
            }
        }
Esempio n. 26
0
        //构建树(将节点加进树结构中合适的位置)
        private static void ConstructTree(MyTreeNode myNode)
        {
            //是否包含父节点
            MyTreeNode parentNode = FindParentNode(myNode.TopId);

            if (parentNode != null)
            {
                ChildrenCountInc(myNode);//所有父节点的子孙节点加1
//                parentNode.ChildrenNodes.Add(myNode);
                parentNode.SubCount++;
            }
            else
            {
                //父节点不存在
                NoParentNodes.Add(myNode);
            }
        }
Esempio n. 27
0
        //所有父节点的子孙节点数自增,(如果需要的话,所有父节点的子孙节点最深层级数自增)
        private static void ChildrenCountInc(MyTreeNode node)
        {
            //帮助判断是否存在闭环
            Dictionary <string, MyTreeNode> parentList = new Dictionary <string, MyTreeNode>();
            //parentList.Add(node.SysId, node);

            ushort     deepLevel = 0; //深度(父节点到子节点之间的层级数之差)
            MyTreeNode parent    = FindParentNode(node.TopId);

            while (parent != null)
            {
                //判断是否构成闭环
                if (parentList.ContainsKey(parent.SysId))
                {
                    if (!RingNodes.ContainsKey(node.SysId))
                    {
                        RingNodes.Add(node.SysId, node);
                    }

                    foreach (string item in parentList.Keys)
                    {
                        if (!RingNodes.ContainsKey(item))
                        {
                            RingNodes.Add(item, parentList[item]);
                        }
                    }
                    break;
                }
                parentList.Add(parent.SysId, parent);

                parent.ChildrenCount++;
                deepLevel++;
                if (parent.ChildrenLevels < deepLevel)
                {
                    parent.ChildrenLevels = deepLevel;
                }

                //继续循环遍历查找父节点的父节点,直到根节点
                parent = FindParentNode(parent.TopId);
            }

            if (node.Level == 0)
            {
                node.Level = (ushort)(deepLevel + 1);
            }
        }
Esempio n. 28
0
        private static void Export2CSVImp(StreamWriter mysw, StringBuilder allLines, MyTreeNode node, bool recu)
        {
            if (isRingClose(node.SysId))
            {
                return;
            }

            allLines.Clear();
            allLines.Append(node.SysId);
            allLines.Append(",");
            allLines.Append(node.TopId);
            allLines.Append(",");
            allLines.Append(node.Name);
            allLines.Append(",");
            allLines.Append(node.Level);
            allLines.Append(",");
            allLines.Append(node.ChildrenLevels);
            allLines.Append(",");
            allLines.Append(node.ChildrenCount);
            allLines.Append(",");
            allLines.Append(node.ChildrenCountAll);
            allLines.Append(",");
            foreach (string otherProp in node.OtherProps)
            {
                allLines.Append(",");
                allLines.Append(otherProp);
            }

            mysw.WriteLine(allLines.ToString());
            row++;
            if (row % 100 == 0)
            {
                WindowView.notify.SetProcessBarValue((int)(100.0 * row / allRow));
                WindowView.notify.SetStatusMessage("正在导出第" + row + "个节点(总共" + allRow + "个节点)");
            }

            if (recu)
            {
                List <MyTreeNode> childrenNodes = MyTrees.GetNodesByTopId(node.SysId);
                foreach (MyTreeNode subNode in childrenNodes)
                {
                    Export2CSVImp(mysw, allLines, subNode, recu);
                }
            }
        }
Esempio n. 29
0
        public void InsertNodes(MyTreeNode node, string[] optCols)
        {
            cmd.Parameters.AddRange(new[]   {
                            new MySqlParameter("@0_" + n,  node.SysId),
                            new MySqlParameter("@1_" + n,  node.TopId),
                            new MySqlParameter("@2_" + n,  optCols[2]),
                            new MySqlParameter("@3_" + n,  node.Level),
                            new MySqlParameter("@4_" + n,  node.ChildrenLevels),
                            new MySqlParameter("@5_" + n,  node.SubCount),
                new MySqlParameter("@6_" + n,  node.ChildrenCount)
            });

            for (int i = 3; i < optCols.Length; i++)
            {
                cmd.Parameters.Add(new MySqlParameter("@" + (i + 4) + "_" + n, optCols[i]));
            }
            n++;
        }
Esempio n. 30
0
        void item_Expanded(object sender, RoutedEventArgs e)
        {
            TreeViewItem item = e.Source as TreeViewItem;

            foreach (TreeViewItem subItem in item.Items)
            {
                MyTreeNode node = subItem.Tag as MyTreeNode;
                if (node != null)
                {
                    List <MyTreeNode> childrenNodes = MyTrees.GetNodesByTopId(node.SysId);
                    foreach (MyTreeNode subNode in childrenNodes)
                    {
                        TreeViewItem grandson = NewTreeViewItem(subNode);
                        subItem.Items.Add(grandson);
                    }
                }
            }
        }