예제 #1
0
 // ------------------
 public void SetDirtyFlag()
 {
     for (TreeViewElem elem = this; elem != null; elem = elem.parent)
     {
         elem.dirtyFlag = true;
     }
 }
예제 #2
0
        // -------------------
        public void AddChild(TreeViewElem elem)
        {
            if ((elem.parent != null) && (elem.parent != this))
            {
                elem.parent.RemoveChild(elem);
            }

            this.children.Add(elem);
            elem.parent = this;
        }
예제 #3
0
        // -------------------
        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);
        }
예제 #4
0
 // ---------------------
 public void Select(TreeViewElem elem)
 {
     this.selectedElem = elem;
 }
예제 #5
0
 // -----------------
 public void RemoveChild(TreeViewElem elem)
 {
     this.children.Remove(elem);
 }