/// <summary> /// Internally used by the file system watcher entities /// </summary> /// <param name="sParentTreePath"></param> /// <param name="sFullPathToEntry"></param> /// <param name="bIsDirectory"></param> void AddToItem(string sParentTreePath, string sFullPathToEntry, bool bIsDirectory) { var parentItem = GetTreeItemByPath(sParentTreePath, true); // If the item is null, then the entry doesn't exist meaning it is not shown and does not need to be updated if (parentItem != null && parentItem.IsExpanded == true) { var itemToAdd = TreeItemFactory.CreateCustomTreeItemInstance(); // We can safely assume that this is a valid path since only the file system watcher call this method var splitPath = sFullPathToEntry.Split('\\'); itemToAdd.IdentificationName = splitPath[splitPath.Length - 1]; itemToAdd.FullPathToReference = sFullPathToEntry; itemToAdd.IsDirectory = bIsDirectory; if (bIsDirectory) { itemToAdd.Items.Add(CustomTreeItem.CreateNewDummyItem()); } itemToAdd.MakeHeader(); parentItem.Items.Add(itemToAdd); parentItem.RefreshLiveSorting(); parentItem.Items.Refresh(); } }
void SearchDirectory() { Items.Clear(); var topLevel = TreeItemFactory.CreateCustomTreeItemInstance(); topLevel.IsDirectory = true; var dirInf = new DirectoryInfo(WatchDir); topLevel.FullPathToReference = WatchDir; topLevel.IdentificationName = dirInf.Name; topLevel.MakeHeader(); topLevel.Items.Add(CustomTreeItem.CreateNewDummyItem()); topLevel.RefreshContextMenu(GlobalContextMenu); Items.Add(topLevel); topLevel.IsExpanded = true; }