private void FileEventManager_ResourceCreated(object sender, ResourceEventArgs e) { bool alreadyAdded = this.NodeFromPath(e.Path) != null; // Don't add Resources that are already present. if (!alreadyAdded) { // Register newly detected ressource file if (File.Exists(e.Path) && Resource.IsResourceFile(e.Path)) { NodeBase newNode = this.ScanFile(e.Path); Node parentNode = this.NodeFromPath(Path.GetDirectoryName(e.Path)); if (parentNode == null) parentNode = this.folderModel.Root; this.InsertNodeSorted(newNode, parentNode); this.RegisterNodeTree(newNode); newNode.NotifyVisible(); } // Add new directory tree else if (e.IsDirectory) { // Actually, only add the directory itsself. Each file will trigger its own ResourceCreated event DirectoryNode newNode = new DirectoryNode(e.Path); //NodeBase newNode = this.ScanDirectory(e.Path); Node parentNode = this.NodeFromPath(Path.GetDirectoryName(e.Path)); if (parentNode == null) parentNode = this.folderModel.Root; this.InsertNodeSorted(newNode, parentNode); this.RegisterNodeTree(newNode); newNode.NotifyVisible(); } } // Perform previously scheduled selection this.PerformScheduleSelect(Path.GetFullPath(e.Path)); }