Beispiel #1
0
        public System.Collections.IEnumerable GetChildren(TreePath treePath)
        {
            if (treePath.IsEmpty())
                foreach (string str in Environment.GetLogicalDrives())
                {
                    RootItem item = new RootItem(str);
                    yield return item;
                }
            else
            {
                List<BaseItem> items = new List<BaseItem>();
                BaseItem parent = treePath.LastNode as BaseItem;
                if (parent != null)
                {
                    foreach (string str in Directory.GetDirectories(parent.ItemPath))
                        items.Add(new FolderItem(str, parent));
                    foreach (string str in Directory.GetFiles(parent.ItemPath))
                        items.Add(new FileItem(str, parent));

                    _itemsToRead.AddRange(items);
                    if (!_worker.IsBusy)
                        _worker.RunWorkerAsync();

                    foreach (BaseItem item in items)
                        yield return item;
                }
                else
                    yield break;
            }
        }
        public System.Collections.IEnumerable GetChildren(TreePath treePath)
        {
            if (treePath.IsEmpty())
            {
                foreach (string str in Environment.GetLogicalDrives())
                {
                    RootItem item = new RootItem(str);
                    yield return(item);
                }
            }
            else
            {
                List <BaseItem> items  = new List <BaseItem>();
                BaseItem        parent = treePath.LastNode as BaseItem;
                if (parent != null)
                {
                    foreach (string str in Directory.GetDirectories(parent.ItemPath))
                    {
                        items.Add(new FolderItem(str, parent));
                    }
                    foreach (string str in Directory.GetFiles(parent.ItemPath))
                    {
                        items.Add(new FileItem(str, parent));
                    }

                    _itemsToRead.AddRange(items);
                    if (!_worker.IsBusy)
                    {
                        _worker.RunWorkerAsync();
                    }

                    foreach (BaseItem item in items)
                    {
                        yield return(item);
                    }
                }
                else
                {
                    yield break;
                }
            }
        }