/// <summary> /// Auto Create Node From Path In Disk /// </summary> /// <param name="path"></param> /// <param name="size"> <1 is folder</param> /// <returns></returns> public static ExplorerNode GetNodeFromDiskPath(string path, long size = -1) { string[] path_split = path.Split('\\'); ExplorerNode parent = new ExplorerNode(); parent.NodeType.Type = CloudType.LocalDisk; parent.Info.Name = path_split[0]; for (int i = 1; i < path_split.Length; i++) { ExplorerNode node = new ExplorerNode(); node.Info.Name = path_split[i]; parent.AddChild(node); parent = node; } if (size >= 0) { parent.Info.Size = size; } else { System.IO.FileInfo info = new System.IO.FileInfo(path); if (info.Exists) { parent.Info.Size = info.Length; } } return(parent); }
public List <ExplorerNode> GetFullPath() { List <ExplorerNode> FullPathArrayNode = new List <ExplorerNode>(); FullPathArrayNode.Add(this); ExplorerNode parent = this.parent; while (parent != null) { FullPathArrayNode.Insert(0, parent); parent = parent.Parent; } return(FullPathArrayNode); }
public ExplorerNode MakeNodeTo(ExplorerNode RootFrom, ExplorerNode RootTo) { List <ExplorerNode> FullPathRootFrom = RootFrom.GetFullPath(); List <ExplorerNode> NodeFullPath = this.GetFullPath(); CloudType type_rootto = RootTo.GetRoot.NodeType.Type; for (int i = NodeFullPath.IndexOf(RootFrom) + 1; i < NodeFullPath.Count; i++) { ExplorerNode node = new ExplorerNode(); node.Info.Size = NodeFullPath[i].Info.Size; node.Info.Name = (type_rootto == CloudType.LocalDisk || type_rootto == CloudType.Dropbox) ? RemoveSpecialChar(NodeFullPath[i].Info.Name) : NodeFullPath[i].Info.Name; RootTo.AddChild(node); RootTo = node; } return(RootTo); }
public ExplorerNode Next(ExplorerNode next = null) { if (next != null && next.GetRoot == Root) { if (nodes.Count - 1 > index) { nodes.RemoveRange(index + 1, nodes.Count - 1 - index); } nodes.Add(next); } if (index < nodes.Count - 1) { index++; } else { return(null); } return(NodeWorking()); }
public ExplorerNode FindSameParent(ExplorerNode othernode) { List <ExplorerNode> list_other = othernode.GetFullPath(); List <ExplorerNode> list_this = GetFullPath(); ExplorerNode node = null; int max = list_other.Count <= list_this.Count ? list_other.Count : list_this.Count; for (int i = 0; i < max; i++) { if (list_other[i] == list_this[i]) { node = list_this[i]; } else { break; } } return(node); }
public DeleteItems(ExplorerNode item) { Items.Add(item); }
public ExplorerNode(NodeInfo info, ExplorerNode parent) { this.Info = info; parent.AddChild(this); }
public void AddChild(ExplorerNode child) { this.Child.Add(child); child.parent = this; }
public void RemoveChild(ExplorerNode child) { this.Child.Remove(child); child.Parent = null; }