Exemplo n.º 1
0
        public static TreeNode GetNodeFromPath(TreeView sourceTreeView, string path, DelegateTreeViewParse callback)
        {
            TreeNode oNode;

            if (sourceTreeView == null)
            {
                throw new NolmeArgumentNullException();
            }

            if (sourceTreeView.Nodes.Count == 0)
            {
                return(null);
            }

            string[] aszSplitedPath = DirectoryUtility.SplitRelativePath(path);
            if (aszSplitedPath.Length > 0)
            {
                for (int i = 0; i < sourceTreeView.Nodes.Count; i++)
                {
                    if (string.Compare(sourceTreeView.Nodes[i].Text, aszSplitedPath[0], true, CultureInfo.InvariantCulture) == 0)
                    {
                        // Callback
                        if (callback != null)
                        {
                            callback(sourceTreeView.Nodes[i], path, aszSplitedPath, 1);
                        }

                        if (aszSplitedPath.Length > 1)
                        {
                            // Check childs
                            oNode = Internal_IsPathExistInTreeview(sourceTreeView.Nodes[i], path, aszSplitedPath, 1, callback);
                        }
                        else
                        {
                            // Path to check is only a drive letter
                            // Comparaison here has succeeded
                            oNode = sourceTreeView.Nodes[i];
                        }
                        return(oNode);
                    }
                }
            }
            return(null);
        }
Exemplo n.º 2
0
        private static TreeNode Internal_IsPathExistInTreeview(TreeNode node, string pathToCheck, string[] pathArray, int level, DelegateTreeViewParse callback)
        {
            // Stop recurse
            if (level == pathArray.Length)
            {
                return(node);
            }

            // Scan all childs
            for (int i = 0; i < node.Nodes.Count; i++)
            {
                if (string.Compare(node.Nodes[i].Text, pathArray[level], true, CultureInfo.InvariantCulture) == 0)
                {
                    // Callback
                    if (callback != null)
                    {
                        callback(node.Nodes[i], pathToCheck, pathArray, level + 1);
                    }

                    // Check node childs
                    return(Internal_IsPathExistInTreeview(node.Nodes[i], pathToCheck, pathArray, level + 1, callback));
                }
            }
            return(null);
        }
Exemplo n.º 3
0
		private static TreeNode Internal_IsPathExistInTreeview (TreeNode node, string pathToCheck, string[] pathArray, int level, DelegateTreeViewParse callback)
		{
			// Stop recurse
			if (level == pathArray.Length)
			{
				return node;
			}

			// Scan all childs
			for (int i = 0; i < node.Nodes.Count; i++)
			{
				if (string.Compare (node.Nodes[i].Text, pathArray[level], true, CultureInfo.InvariantCulture) == 0)
				{
					// Callback
					if (callback != null)
					{
						callback (node.Nodes[i], pathToCheck, pathArray, level + 1);
					}

					// Check node childs
					return Internal_IsPathExistInTreeview (node.Nodes[i], pathToCheck, pathArray, level + 1, callback);
				}
			}
			return null;
		}
Exemplo n.º 4
0
		public static TreeNode GetNodeFromPath (TreeView sourceTreeView, string path, DelegateTreeViewParse callback)
		{
			TreeNode oNode;

			if (sourceTreeView == null)
			{
				throw new NolmeArgumentNullException ();
			}

			if (sourceTreeView.Nodes.Count == 0)
				return null;

			string[] aszSplitedPath = DirectoryUtility.SplitRelativePath (path);
			if (aszSplitedPath.Length > 0)
			{
				for (int i = 0; i < sourceTreeView.Nodes.Count; i++)
				{
					if (string.Compare (sourceTreeView.Nodes[i].Text, aszSplitedPath[0], true, CultureInfo.InvariantCulture) == 0)
					{
						// Callback
						if (callback != null)
						{
							callback (sourceTreeView.Nodes[i], path, aszSplitedPath, 1);
						}

						if (aszSplitedPath.Length > 1)
						{
							// Check childs
							oNode = Internal_IsPathExistInTreeview (sourceTreeView.Nodes[i], path, aszSplitedPath, 1, callback);
						}
						else
						{
							// Path to check is only a drive letter
							// Comparaison here has succeeded
							oNode = sourceTreeView.Nodes[i];
						}
						return oNode;
					}
				}
			}
			return null;
		}