2012-08-31 05:29:32 +00:00
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
namespace NBTExplorer.Model
|
|
|
|
|
{
|
|
|
|
|
public class DirectoryDataNode : DataNode
|
|
|
|
|
{
|
|
|
|
|
private string _path;
|
|
|
|
|
|
|
|
|
|
public DirectoryDataNode (string path)
|
|
|
|
|
{
|
|
|
|
|
_path = path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override NodeCapabilities Capabilities
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return NodeCapabilities.Search;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string NodeDisplay
|
|
|
|
|
{
|
|
|
|
|
get { return Path.GetFileName(_path); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool HasUnexpandedChildren
|
|
|
|
|
{
|
|
|
|
|
get { return !IsExpanded; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void ExpandCore ()
|
|
|
|
|
{
|
|
|
|
|
foreach (string dirpath in Directory.GetDirectories(_path)) {
|
|
|
|
|
Nodes.Add(new DirectoryDataNode(dirpath));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (string filepath in Directory.GetFiles(_path)) {
|
|
|
|
|
DataNode node = null;
|
2012-09-03 03:25:23 +00:00
|
|
|
|
foreach (var item in FileTypeRegistry.RegisteredTypes) {
|
|
|
|
|
if (item.Value.NamePatternTest(filepath))
|
|
|
|
|
node = item.Value.NodeCreate(filepath);
|
2012-08-31 05:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (node != null)
|
|
|
|
|
Nodes.Add(node);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void ReleaseCore ()
|
|
|
|
|
{
|
|
|
|
|
Nodes.Clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|