public void OnTargetConcatFileNamesChanged() { // get file names ChosenFileNames.Clear(); Message = ""; if (!string.IsNullOrWhiteSpace(TargetConcatFileNames)) { ChosenFileNames.AddRange(TargetConcatFileNames.Split(pathSeparator) .Select(s => s.Trim()) .Where(s => !string.IsNullOrWhiteSpace(s))); } CanResizeByPixel = ChosenFileCount == 1; // check enable/disable, and detect file dimesion if single img if (ChosenFileCount == 1) { var size = GetImageDimension(Path.Combine(TargetConcatFolders, TargetConcatFileNames)); WidthPixel = size == null ? 0 : ((Size)size).Width; HeightPixel = size == null ? 0 : ((Size)size).Height; OriginalWidthPixel = WidthPixel; OriginalHeightPixel = HeightPixel; } else if (ChosenFileCount == 0) { ResizeByRatio = true; // implicitly ResizeByPixel = false; OriginalWidthPixel = WidthPixel = OriginalHeightPixel = HeightPixel = 0; } CanResize = ChosenFolderCount != 0; Message = ChosenFolderCount != 0 ? "" : "Please select at least one file or one folder."; }
private List <FileInfo> GetFileInfos() { if (ChosenFolderCount == 0) { return(null); } else if (ChosenFolderCount == 1 && ChosenFileCount == 1) { return(new List <FileInfo> { new FileInfo(Path.Combine(TargetConcatFolders, TargetConcatFileNames)) }); } else if (ChosenFolderCount == 1 && ChosenFileCount > 1) { return(new List <FileInfo>(ChosenFileNames.Select(fn => new FileInfo(Path.Combine(ChosenFolders[0], fn))).Where(fi => fi.Exists))); } else if (ChosenFolderCount >= 1 && ChosenFileCount == 0) { var filePaths = new List <string>(); foreach (var folder in ChosenFolders) { if (SubFoldersIncluded) { filePaths.AddRange(Directory.GetFiles(folder, "*.*", SearchOption.AllDirectories) .Where(p => p.EndsWithAny(imageExtensions))); } else { filePaths.AddRange(Directory.GetFiles(folder).Where(p => p.EndsWithAny(imageExtensions))); } } return(filePaths .Select(p => new FileInfo(p)).ToList()); } throw new InvalidOperationException("Invalid info is provided for folder and file names."); }