Ejemplo n.º 1
0
        private static void Refresh()
        {
            TreeWalker.RefreshExpanded(structure);
            string selected = "";

            if (tv.SelectedNode != null)
            {
                selected = tv.SelectedNode.FullPath;
            }
            List <string> ExpandedNodes = new List <string>();

            if (tv != null && tv.Nodes != null && tv.Nodes.Count > 0 && tv.Nodes[0].Nodes != null && tv.Nodes[0].Nodes.Count > 0)
            {
                System.Windows.Forms.TreeNode Nodes1 = tv.Nodes[0];
                structure.Expanded = true;
                TreeWalker.collectExpandedNodes(Nodes1.Nodes[0], structure);
            }

            tv.Nodes.Clear();
            if (tv.Nodes == null || tv.Nodes.Count == 0 || !tv.Nodes.Contains(new System.Windows.Forms.TreeNode("ROOT")))
            {
                root = tv.Nodes.Add("ROOT");
            }
            tv.BeginUpdate();
            TreeWalker.RefreshAdded(structure);
            TreeWalker.Walk(structure, root);

            tv.EndUpdate();
            tv.Update();
            tv.Refresh();


            System.Windows.Forms.TreeNode Nodes2 = tv.Nodes[0];
            tv.Nodes[0].Expand();
            TreeWalker.ExpandNodes(Nodes2.Nodes[0], structure);
            if (selected != "")
            {
                tv.SelectedNode = TreeWalker.GetTreeViewNodeFromPath(tv.Nodes, selected, tv);
            }
            /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        }
Ejemplo n.º 2
0
        public static void Walk(TreeNode tn, System.Windows.Forms.TreeNode tnc)
        {
            int dummy = 0;

            if (tnc != null)
            {
                System.Windows.Forms.TreeNode temp = null;
                //if (tnc.Nodes != null && !tnc.Nodes.Contains(new System.Windows.Forms.TreeNode(tn.Name))) temp = tnc.Nodes.Add(tn.Name);

                if (tn.AddedToTree == false)
                {
                    tn.AddedToTree = true; temp = tnc.Nodes.Add(tn.Name);                           // tnc.TreeView.BeginUpdate();
                }
                else
                {
                    foreach (System.Windows.Forms.TreeNode iterating in tnc.Nodes)
                    {
                        if (iterating.Name == tn.Name)
                        {
                            temp = iterating;
                        }
                    }
                }

                if (tn.Changed > 10)
                {
                    temp.ForeColor = System.Drawing.Color.Blue;
                }
                if (tn.Changed > 50)
                {
                    temp.ForeColor = System.Drawing.Color.Green;
                }
                if (tn.Changed > 100)
                {
                    temp.ForeColor = System.Drawing.Color.DarkGreen;
                }
                if (tn.Changed > 200)
                {
                    temp.ForeColor = System.Drawing.Color.DarkOrange;
                }
                if (tn.Changed > 1000)
                {
                    temp.ForeColor = System.Drawing.Color.OrangeRed;
                }
                if (tn.Changed > 2000)
                {
                    temp.ForeColor = System.Drawing.Color.Red;
                }
                if (tn.Changed > 10000)
                {
                    temp.ForeColor = System.Drawing.Color.HotPink;
                }
                if (tn.Children != null && tn.Children.Count != 0)
                {
                    foreach (TreeNode node in tn.Children)
                    {
                        TreeWalker.Walk(node, temp);
                        if (TreeWalker.iteration > 100)
                        {
                            dummy++;
                        }
                    }
                }
            }
        }