public static EvBase ElementAt(EvFileFolder parent, string relativePath) { return(_ElementAt(parent, relativePath)); }
private void RefreshRecur(EvFileFolder parent) { var absPath = RootDirectoryPath + "\\" + parent.RelativePath; var dirInfo = new DirectoryInfo(absPath); var files = dirInfo.GetFileSystemInfos(); var check_exist = new bool[files.Length]; for (int i = 0; i < parent.Sub.Count; i++) { var item = parent.Sub[i]; if (!(item is IFile)) { continue; } var find = Array.FindIndex(files, file => file.Name == item.Name); if (find == -1) { parent.Sub.Remove(parent.Sub[i]); i--; } else { if (item is EvFileFolder) { RefreshRecur(parent.Sub[i] as EvFileFolder); } item.IsNodeSelected = false; check_exist[find] = true; } } /// 찾은 파일이 탐색기 목록에 없을 경우 추가 for (int i = 0; i < check_exist.Length; i++) { if (check_exist[i] == false) { var name = files[i].Name; var path = GetRelativePath(RootDirectoryPath, files[i].FullName); var toolTip = files[i].FullName; if (Directory.Exists(files[i].FullName)) { /// 폴더가 존재할 경우 폴더 추가 var addFolder = new EvFileFolder(name, path) { ToolTip = toolTip }; RefreshRecur(addFolder); parent.Sub.Add(addFolder); } else { /// 폴더가 아닌 파일일 경우 파일 추가 EvItem addItem; var ext = Path.GetExtension(files[i].Name).ToLower(); var fil = Filter.ContainsKey(ext); var isException = ExceptExtensions.FindIndex(item => item.ToLower() == ext); if (isException != -1) { continue; } if (fil == true) { addItem = Activator.CreateInstance(Filter[ext].Type, name, path) as EvFile; } else { addItem = new EvFile(name, path); } if (IconSetter.ContainsKey(ext) == true) { addItem.IconUri = IconSetter[ext]; } addItem.ToolTip = toolTip; parent.Sub.Add(addItem); } } } /// Filtering for (int i = 0; i < parent.Sub.Count; i++) { var item = parent.Sub[i]; var ext = Path.GetExtension(item.Name).ToLower(); if (item is EvFile && (filter == "\\" || (filter != "*" && filter != ext))) { parent.Sub.Remove(parent.Sub[i]); i--; } } /// Sort parent.Sub = new ObservableCollection <EvBase>(parent.Sub.OrderBy(item => { if (item is EvFileFolder) { return(Filter["//"].Order); } else if (item is EvFile) { var ext = System.IO.Path.GetExtension((item as EvFile).Name); var fil = Filter.ContainsKey(ext); if (fil == false) { return(Filter["*"].Order); } else { return(Filter[ext].Order); } } return(Filter["?"].Order); })); }