Exemple #1
0
        void item_Expanded(TreeNode tn)
        {
            MyTreeNode node = tn.Tag as MyTreeNode;

            if (node != null)
            {
                List <MyTreeNode> childrenNodes = MyTrees.GetNodesByTopId(node.SysId);;
                foreach (MyTreeNode subNode in childrenNodes)
                {
                    Button   grandson = NewTreeViewItem(subNode);
                    TreeNode newNode  = memberTreeView.AddNode(grandson, tn);
                    newNode.Tag       = subNode;
                    newNode.Collapsed = true;
                }
            }
        }
Exemple #2
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);
                }
            }
        }
        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);
                    }
                }
            }
        }
        private void InitMyTree()
        {
            //加载正确的节点
            List <MyTreeNode> roots = new List <MyTreeNode>();

//            if (MyTreeNode.AllNodes.ContainsKey(1))
//            {
//                roots.AddRange(MyTreeNode.AllNodes[1].Values);
//            }
            foreach (MyTreeNode node in roots)
            {
                TreeViewItem rootItem = NewTreeViewItem(node);
                rootItem.Expanded  += item_Expanded;
                rootItem.Collapsed += item_Collapsed;

                memberTreeView.Items.Add(rootItem);
                List <MyTreeNode> childrenNodes = MyTrees.GetNodesByTopId(node.SysId);
                foreach (MyTreeNode subNode in childrenNodes)
                {
                    TreeViewItem subItem = NewTreeViewItem(subNode);
                    rootItem.Items.Add(subItem);
                }
            }

            //将错误节点也加上
//            foreach (string item in MyTreeNode.ErrNodes.Keys)
//            {
//                TreeViewItem errRootItem = new TreeViewItem();
//                errRootItem.Header = item;
//                errRootItem.ToolTip = "下线人数:" + MyTreeNode.ErrNodes[item].Count;
//                memberTreeView.Items.Add(errRootItem);
//                foreach (MyTreeNode errNode in MyTreeNode.ErrNodes[item])
//                {
//                    TreeViewItem errItem = new TreeViewItem();
//                    errItem.Header = errNode.RealName;
//                    errItem.ToolTip = "Id:" + errNode.SysId + ",级别:" + errNode.Layer + ",出错行数:" + errNode.DescendantCount;
//                    errRootItem.Items.Add(errItem);
//                }
//            }
        }