// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved.
using System.IO;
namespace FlaxEditor.Content
{
///
/// Content tree node used for main directories.
///
///
public class MainContentTreeNode : ContentTreeNode
{
private FileSystemWatcher _watcher;
///
public override bool CanDelete => false;
///
public override bool CanDuplicate => false;
///
/// Initializes a new instance of the class.
///
/// The parent project.
/// The folder type.
/// The folder path.
public MainContentTreeNode(ProjectTreeNode parent, ContentFolderType type, string path)
: base(parent, type, path)
{
_watcher = new FileSystemWatcher(path)
{
IncludeSubdirectories = true,
EnableRaisingEvents = true
};
//_watcher.Changed += OnEvent;
_watcher.Created += OnEvent;
_watcher.Deleted += OnEvent;
_watcher.Renamed += OnEvent;
}
private void OnEvent(object sender, FileSystemEventArgs e)
{
Editor.Instance.ContentDatabase.OnDirectoryEvent(this, e);
}
///
protected override void DoDragDrop()
{
// No drag for root nodes
}
///
public override void OnDestroy()
{
_watcher.EnableRaisingEvents = false;
_watcher.Dispose();
_watcher = null;
base.OnDestroy();
}
}
}