Exemple #1
0
        private void BuildTree(DirectoryInfo directoryInfo, TreeNodeCollection addInMe)
        {
            TreeNode curNode = null;
            if (addInMe.ContainsKey(directoryInfo.FullName) == false)
                curNode = addInMe.Add(directoryInfo.FullName, directoryInfo.Name);
            else
                curNode = addInMe.Find(directoryInfo.FullName, false)[0];

            foreach (FileInfo file in directoryInfo.GetFiles())
            {
                if (curNode.Nodes.ContainsKey(file.FullName) == false)
                {
                    curNode.Nodes.Add(file.FullName, file.Name);
                }
            }
            foreach (DirectoryInfo subdir in directoryInfo.GetDirectories())
            {
                BuildTree(subdir, curNode.Nodes);
            }
        }
        private TreeNode macroPlaySelectNode(string method, TreeNodeCollection trc, TreeView view)
        {
            int c = method.IndexOf('\'');
            if (c > 0)
            {
                string m = method.Substring(c + 1);
                method = method.Substring(0, c);
                c = Int32.Parse(m);
            }
            else
            {
                c = 1;
            }

            TreeNode[] tns = trc.Find(method, true);
            if (tns.Length > 0)
            {
                view.SelectedNode = tns[c - 1];
                return view.SelectedNode;
            }
            return null;
        }
            private void InsertTreeNode(NavigatorPage page, TreeNodeCollection treeNodes, int depth, Dictionary<NavigatorPage, TreeNode> pageMap)
            {
                PathSegment segment = page.Path.Segments[depth];

                // see if node for this segment already exists
                TreeNode treeNode = CollectionUtils.FirstElement(treeNodes.Find(segment.LocalizedText, false));
                if (treeNode == null)
                {
                    // need to create the node, however, we can't just add it to the end of the child collection,
                    // we need to insert it at the appropriate place, which is just after the last "visited" node
                    // find first unvisited node, which indicates the insertion point
                    int i = 0;
                    for (; i < treeNodes.Count; i++)
                    {
                        if (!_visitedNodes.Contains(treeNodes[i]))
                            break;
                    }

                    // insert new node
                    treeNode = treeNodes.Insert(i, segment.LocalizedText, segment.LocalizedText);
                }

                if (depth < page.Path.Segments.Count - 1)
                {
                    // recur on next path segment
                    InsertTreeNode(page, treeNode.Nodes, depth + 1, pageMap);
                }
                else
                {
                    // this is the last path segment
                    treeNode.Tag = page;
                    pageMap.Add(page, treeNode);
                }

                // remember that this node has now been "visited"
                _visitedNodes.Add(treeNode);

            }
Exemple #4
0
        public static UserObject FindUserObjectTagFromTreeNodes(TreeNodeCollection nodeCollection, string findId) {
            TreeNode[] nodes = nodeCollection.Find(findId, true);

            foreach (TreeNode node in nodes) {
                UserObject userObj = (UserObject)node.Tag;
                if (userObj == null)
                    continue;
                if (userObj.Id == findId) {
                    return userObj;
                }
            }
            return null;
        }
        public static MemberObj FindMemberObjTagFromTreeNodes(TreeNodeCollection nodeCollection, string findId) {
            TreeNode[] nodes = nodeCollection.Find(findId, true);

            foreach (TreeNode node in nodes) {
                MemberObj userObj = (MemberObj)node.Tag;
                if (userObj == null)
                    continue;
                if (userObj.Id == findId) {
                    return userObj;
                }
            }
            return null;
        }
        // Ported from 'http://tinyurl.com/pgsadpk'
        private TreeNode AddPathToTree(TreeNodeCollection nodes, string path)
        {
            var fname = Path.GetFileName(path);

            if (path != fname)
                nodes = AddPathToTree(nodes, Path.GetDirectoryName(path)).Nodes;

            var node = nodes.Find(fname, false).FirstOrDefault();

            if (node == null)
                node = nodes.Add(fname, fname);

            return node;
        }
		static public TreeNode AddNode( TreeNodeCollection Tree, string Text )
		{
			TreeNode[] Childs = Tree.Find( Text, false );

			TreeNode Child = null;

			if ( Childs == null || Childs.Length == 0 )
			{
				Child = Tree.Add( Text );
				Child.Name = Text;
			}
			else
			{
				Child = Childs[0];
			}

			return Child;
		}
Exemple #8
0
        /// <summary>
        /// 获得选中的节点
        /// </summary>
        /// <param name="treeNodeCollection"></param>
        /// <param name="guid"></param>
        /// <returns></returns>
        public TreeNode GetParentSelectedNode(TreeNodeCollection treeNodeCollection, Guid guid)
        {
            Model.CustomerGroup model = GetModel(guid);

            return (treeNodeCollection.Find(model.parentGUID.ToString(), true))[0];
        }