public class FileNode : PropertyChangedBase
{
public FileNode()
{
this.Files = new ObservableCollection<FileNode>();
this.IsFile = false;
}
private string _name = string.Empty;
public string Name
{
get { return _name; }
set
{
_name = value;
NotifyOfPropertyChange(nameof(Name));
}
}
private string _fullPath;
public string FullPath
{
get => _fullPath;
set
{
_fullPath = value;
NotifyOfPropertyChange(nameof(FullPath));
}
}
public FileNode Parent { get; set; }
public ObservableCollection<FileNode> Files { get; set; }
public bool IsFile { get; set; }
public string PrefixPath { get; set; }
private bool _isSelected;
public bool IsSelected
{
get => _isSelected;
set
{
_isSelected = value;
NotifyOfPropertyChange(nameof(IsSelected));
}
}
private bool _isExpanded;
public bool IsExpanded
{
get => _isExpanded;
set
{
_isExpanded = value;
NotifyOfPropertyChange(nameof(IsExpanded));
}
}
private Visibility _Visibility = Visibility.Visible;
public Visibility Visibility
{ get { return _Visibility; } set { _Visibility = value; NotifyOfPropertyChange(nameof(Visibility)); } }
}
private FileNode FindFileNodeWithFullPath(IList<FileNode> nodes, string fullPath)
{
foreach (var file in nodes)
{
if (file.FullPath == fullPath)
{
return file;
}
if (file.Files != null)
{
var subFile = FindFileNodeWithFullPath(file.Files, fullPath);
if (subFile != null)
{
return subFile;
}
}
}
return null;
}