Пример #1
0
        public void OnBeforeExpand(CommandRunner runner, bool populateChildren)
        {
            TreeView tv = this.TreeView;

            if (!IsRoot)
            {
                if (tv != null && tv.InvokeRequired)
                {
                    tv.Invoke((Action)(() => {
                        this.Nodes.Clear();
                        SetExpandedImageIndex(this);
                    }));
                }
                else
                {
                    this.Nodes.Clear();
                    SetExpandedImageIndex(this);
                }
            }


            string path = this.FullPath.Replace("//", "/");

            if (!path.EndsWith("/"))
            {
                path += "/";
            }

            if (populateChildren && this.Nodes.Count == 0)
            {
                List <DroidExplorer.Core.IO.FileSystemInfo> fileSystemInfoList = runner.ListDirectories(path);

                if (tv != null && tv.InvokeRequired)
                {
                    tv.Invoke((Action)(() => {
                        this.AddChildTreeNodes(this.Nodes, fileSystemInfoList);
                    }));
                }
                else // no need to invoke
                {
                    AddChildTreeNodes(this.Nodes, fileSystemInfoList);
                }
            }
        }