private void updateImgFileList() { if (!string.IsNullOrEmpty(SelectedFilePath)) { IArchive archive = ArchiveFactory.Open(SelectedFilePath); var entries = archive.Entries.Where(e => e.IsDirectory == false && ( Path.GetExtension(e.Key).Equals(".jpg") || Path.GetExtension(e.Key).Equals(".jpeg") || Path.GetExtension(e.Key).Equals(".png") || Path.GetExtension(e.Key).Equals(".bmp"))); // Folder List FolderList.Clear(); var analysis = new Dictionary <int, int>(); foreach (var item in entries.ToList()) { var parts = item.Key.Split('\\').ToList <string>(); if (analysis.Keys.Contains <int>(parts.Count)) { analysis[parts.Count]++; } else { analysis.Add(parts.Count, 1); } } if (analysis.Count > 0) { //int folderIdx = analysis.OrderByDescending(val => val.Value).First().Key - 2; int folderIdx = analysis.Aggregate((x, y) => x.Value > y.Value ? x : y).Key - 2; // last idx for file name. And 0 start. if (folderIdx >= 0) { foreach (var item in entries.ToList()) { var parts = item.Key.Split('\\').ToList <string>(); if (parts.Count > folderIdx) { if (!FolderList.Contains(parts[folderIdx])) { FolderList.Add(parts[folderIdx]); } } } } } // Image File List ImgFileList.Clear(); foreach (var item in entries.ToList()) { ImgFileList.Add(item); } } }
public void Drop(IDropInfo dropInfo) { FileList.Clear(); var files = ((DataObject)dropInfo.Data).GetFileDropList().Cast <string>() .Where(fname => fname.EndsWith(".zip", ".rar")).ToList(); if (files.Count == 0) { return; } foreach (var file in files) { FileList.Add(file); } ImageData = null; ImgFileList.Clear(); }