private void CreateGalleryPage(ImageTreeDirectory currentImageTree, DirectoryInfo currentSlideDirectory, CancellationToken token) { GenerationStarted?.Invoke(new DirectoryGenerateInfo { Directory = currentSlideDirectory }); if (token.IsCancellationRequested) { return; } try { var currentImages = currentImageTree.DescendantImages.Where(p => p.Depth == 0).OrderBy(p => p.Item.FileInfo.Name); var deepImages = currentImageTree.DescendantImages; int countOwnImages = currentImages.Count(); //Don't count current images as deep images, even though they will be included in the recursive JSON. int countDeepImages = deepImages.Count(p => p.Depth > 0); var subTreesWithImages = currentImageTree.ChildDirectories.Where(p => p.DescendantImages.Count > 0); WriteJson(currentSlideDirectory, currentImages, deepImages, countOwnImages, countDeepImages); if (token.IsCancellationRequested) { return; } WriteIndexPage(currentImageTree, subTreesWithImages, currentSlideDirectory, countOwnImages, countDeepImages); WriteSlideshowPage(currentSlideDirectory); foreach (var subImageTree in subTreesWithImages) { if (token.IsCancellationRequested) { return; } var subSlideDirectory = currentSlideDirectory.CreateSubdirectory(subImageTree.DirectoryInfo.Name); CreateGalleryPage(subImageTree, subSlideDirectory, token); } } catch (Exception ex) { GenerationFailed?.Invoke(new DirectoryGenerateInfo { Directory = currentSlideDirectory, Exception = ex }); } }
protected virtual void OnGenerationStart(object sender, System.EventArgs e) { GenerationStarted?.Invoke(sender, e); }
protected void OnGenerationStarted(EventArgs e) { GenerationStarted?.Invoke(this, e); }