// ------------------ public void SetDirtyFlag() { for (TreeViewElem elem = this; elem != null; elem = elem.parent) { elem.dirtyFlag = true; } }
// ------------------- public void AddChild(TreeViewElem elem) { if ((elem.parent != null) && (elem.parent != this)) { elem.parent.RemoveChild(elem); } this.children.Add(elem); elem.parent = this; }
// ------------------- static public TreeViewElem CreateDirectoryStructure(TreeViewElem root, string fullPath, ElemConstructor folderConstructor) { if (fullPath.IndexOf('\\') >= 0) { fullPath = fullPath.Replace('\\', '/'); } int startPos = 0; int sepPos = 0; TreeViewElem parent = root; for (; (startPos < fullPath.Length); startPos = (sepPos + 1)) { sepPos = fullPath.IndexOf("/", startPos); if (sepPos == startPos) { continue; } if (sepPos < 0) { sepPos = fullPath.Length; } string folderName = fullPath.Substring(startPos, (sepPos - startPos)); //Debug.Log("\tCreate sub folder [" + folderName + "] of [" + path + "]"); TreeViewElem folderElem = parent.Find(folderName); // as FolderElem; if (folderElem == null) { //Debug.Log("\tNOT found..."); folderElem = folderConstructor(root, fullPath.Substring(0, sepPos), folderName); folderElem.name = folderName; folderElem.parent = parent; parent.AddChild(folderElem); } else { //Debug.Log("\tFOUND!"); } parent = folderElem; } return(parent); }
// --------------------- public void Select(TreeViewElem elem) { this.selectedElem = elem; }
// ----------------- public void RemoveChild(TreeViewElem elem) { this.children.Remove(elem); }