public BitmapSource GetThumbnailImage(string filePath, string fileName, RenderAspectEnum renderType, int thumbnailSize) { BitmapSource loadedFile = null; string cachePath = GetCachePath(thumbnailSize); string thumbnailFileName = ComposeFileName(fileName, filePath, renderType, thumbnailSize); string fullThumbnailFilePath = Path.Combine(cachePath, thumbnailFileName); try { if (Directory.Exists(cachePath) && File.Exists(fullThumbnailFilePath)) { using (var file = File.OpenRead(fullThumbnailFilePath)) { loadedFile = LoadImageFromStream(file); } } } catch (Exception ex) { logger.Trace(ex, "Exception loading cache file images for {fullpath} as {renderType}", Path.Combine(filePath, fileName), renderType.ToString()); return(null); } /* * if (loadedFile == null) logger.Info("Cache file not found at {FullThumbnailFilePath}", fullThumbnailFilePath); * else logger.Info("Loaded cache file at {FullThumbnailFilePath}", fullThumbnailFilePath); */ return(loadedFile); }
public bool UpdateThumnail(string filePath, string fileName, RenderAspectEnum renderType, int size, byte[] data) { bool updated = true; string cachePath = GetCachePath(size); string cachedFileName = ComposeFileName(fileName, renderType, size); string fullCachedFilePath = Path.Combine(cachePath, cachedFileName); try { if (!Directory.Exists(cachePath)) { Directory.CreateDirectory(cachePath); logger.Info("Created cache directory at {cachePath}", cachePath); } } catch (Exception ex) { logger.Trace(ex, "Exception creating the cache directory at {cachePath}", cachePath); throw ex; } try { using (var file = File.OpenWrite(fullCachedFilePath)) { file.Write(data, 0, data.Length); } logger.Info("Updated file thumbnail for {fileName} for size {size}", fileName, size); } catch (Exception ex) { logger.Trace(ex, "Exception updating a file thumbnail at {fullCachedFilePath} for size {size} ", fullCachedFilePath, size); throw ex; } return(updated); }
private static IEnumerable <Light> GetLights(RenderAspectEnum renderAspect) { List <Light> lights = new List <Light>(); if (renderAspect == RenderAspectEnum.VioletBlue) { lights.Add(new DirectionalLight(Colors.Violet, new Vector3D(-0.5, 1, -0.5))); lights.Add(new DirectionalLight(Colors.Blue, new Vector3D(-1, 0.5, -0.5))); } else if (renderAspect == RenderAspectEnum.RedOrangeYellow) { lights.Add(new DirectionalLight(Colors.Red, new Vector3D(-1, 0, 0))); lights.Add(new DirectionalLight(Colors.Yellow, new Vector3D(0, 1, 0))); lights.Add(new DirectionalLight(Colors.Orange, new Vector3D(0, 0, -1))); } else if (renderAspect == RenderAspectEnum.GreenLimeYellow) { lights.Add(new DirectionalLight(Colors.Green, new Vector3D(-1, -0, 0))); lights.Add(new DirectionalLight(Colors.Yellow, new Vector3D(0, 1, 0))); lights.Add(new DirectionalLight(Colors.LimeGreen, new Vector3D(0, 0, -1))); } else if (renderAspect == RenderAspectEnum.PinkFucsiaViolet) { lights.Add(new DirectionalLight(Colors.Pink, new Vector3D(-1, 0, 0))); lights.Add(new DirectionalLight(Color.FromArgb(1, 150, 40, 80), new Vector3D(0.3, 1, 0))); lights.Add(new DirectionalLight(Colors.Violet, new Vector3D(0, 0, -1))); } else if (renderAspect == RenderAspectEnum.CyanBlue) { lights.Add(new DirectionalLight(Colors.Blue, new Vector3D(-1, 0, 0))); lights.Add(new DirectionalLight(Colors.CornflowerBlue, new Vector3D(0, 1, 0))); lights.Add(new DirectionalLight(Colors.Cyan, new Vector3D(0, 0, -1))); } else if (renderAspect == RenderAspectEnum.RedRedish) { lights.Add(new DirectionalLight(Colors.Red, new Vector3D(-1, -0.3, 0))); lights.Add(new DirectionalLight(Colors.DarkRed, new Vector3D(0.3, 1, 0))); lights.Add(new DirectionalLight(Colors.PaleVioletRed, new Vector3D(0.3, -0.3, -1))); } else if (renderAspect == RenderAspectEnum.Yellow) { lights.Add(new DirectionalLight(Colors.Yellow, new Vector3D(-1, 0, 0))); lights.Add(new DirectionalLight(Colors.YellowGreen, new Vector3D(0, 1, 0))); lights.Add(new DirectionalLight(Color.FromArgb(1, 230, 230, 130), new Vector3D(0, 0, -1))); } else { if (renderAspect == RenderAspectEnum.PerNormal) { lights.Add(new DirectionalLight(Colors.DarkGreen, new Vector3D(-1, 0, 0))); lights.Add(new DirectionalLight(Colors.DarkRed, new Vector3D(0, 1, 0))); lights.Add(new DirectionalLight(Colors.DarkBlue, new Vector3D(0, 0, -1))); } lights.Add(new DirectionalLight(Colors.White, new Vector3D(-1, 1, -1))); } return(lights); }
public bool CheckThumbnailExists(string filePath, string fileName, RenderAspectEnum renderType, int thumbnailSize) { string cachePath = GetCachePath(); string thumbnailFileName = ComposeFileName(fileName, filePath, renderType, thumbnailSize); try { return(Directory.Exists(cachePath) && File.Exists(Path.Combine(cachePath, thumbnailFileName))); } catch { return(false); } }
public bool LoadDirectories(IEnumerable <string> paths) { IsLoading = false; MainDispatcher = Dispatcher.CurrentDispatcher; cancellationTokenSource = new CancellationTokenSource(); cancellationToken = cancellationTokenSource.Token; cache = DefaultFactory.GetDefaultThumbnailCache(); userSettings = DefaultFactory.GetDefaultUserSettings(); renderType = (RenderAspectEnum)userSettings.GetSettingInt(UserSettingEnum.Thumbnails3DAspect); logger.Info("Loading paths: Received: [{0}]", string.Join("] [", paths)); paths = paths.Where(p1 => !paths.Any(p2 => !p1.Equals(p2) && p1.Contains(p2))).ToArray(); // Remove selected subdirectories of other selected paths. logger.Info("Loading paths: After removed subdirs: [{0}]", string.Join("] [", paths)); try { IEnumerable <string> pathsFound = new List <string>(); for (int i = 0; i < SupportedExtensionsFilter.Length; i++) { foreach (string path in paths) { pathsFound = pathsFound.Concat(UtilMethods.EnumerateFiles(path, SupportedExtensionsFilter[i], SearchOption.AllDirectories, cancellationToken)); } } pathsFound = pathsFound.ToArray(); if (cancellationToken.IsCancellationRequested) { return(false); } if (pathsFound.Count() > 0) { CalculateThumnailSizes(pathsFound.Count()); InitializeFoundFilesObjects(pathsFound); return(true); } else { FilesFound = new ModelFileData[0]; } } catch (Exception ex) { logger.Trace(ex, "Unable to load: {ex}", ex.Message); } return(false); }
public bool UpdateThumnail(string filePath, string fileName, RenderAspectEnum renderType, int size, BitmapSource img) { bool updated = true; string cachePath = GetCachePath(size); string cachedFileName = ComposeFileName(fileName, filePath, renderType, size); string fullCachedFilePath = Path.Combine(cachePath, cachedFileName); try { if (!Directory.Exists(cachePath)) { Directory.CreateDirectory(cachePath); logger.Info("Created cache directory at {cachePath}", cachePath); } } catch (Exception ex) { logger.Trace(ex, "Exception creating the cache directory at {cachePath}", cachePath); return(false); } try { using (var file = File.OpenWrite(fullCachedFilePath)) { PngBitmapEncoder png = new PngBitmapEncoder(); png.Frames.Add(BitmapFrame.Create(img)); png.Save(file); } // logger.Debug("Updated file thumbnail for {fileName} for size {size}", fileName, size); } catch (Exception ex) { logger.Trace(ex, "Exception updating a file thumbnail at {fullCachedFilePath} for size {size} ", fullCachedFilePath, size); return(false); } return(updated); }
public void SetEnviorementOptions(RenderAspectEnum renderType) { this.renderType = renderType; viewport = new Viewport3D(); myModel3DGroup = new Model3DGroup(); myModelVisual3D = new ModelVisual3D(); myPCamera = new PerspectiveCamera(); RenderOptions.SetEdgeMode(viewport, EdgeMode.Unspecified); // Setup camera. myPCamera.UpDirection = new Vector3D(0, 0, 1); myPCamera.Position = new Point3D(2, -2, 2.75f); myPCamera.LookDirection = new Vector3D(-1, 1, -1); myPCamera.FieldOfView = 40; viewport.Camera = myPCamera; // Lights List <Light> lights = new List <Light>(); if (renderType == RenderAspectEnum.VioletBlue) { lights.Add(new DirectionalLight(Colors.Violet, new Vector3D(-0.5, 1, -0.5))); lights.Add(new DirectionalLight(Colors.Blue, new Vector3D(-1, 0.5, -0.5))); } else if (renderType == RenderAspectEnum.RedOrangeYellow) { lights.Add(new DirectionalLight(Colors.Red, new Vector3D(-1, -0.3, 0))); lights.Add(new DirectionalLight(Colors.Yellow, new Vector3D(0.3, 1, 0))); lights.Add(new DirectionalLight(Colors.Orange, new Vector3D(0.3, -0.3, -1))); } else if (renderType == RenderAspectEnum.GreenLimeYellow) { lights.Add(new DirectionalLight(Colors.Green, new Vector3D(-1, -0.3, 0))); lights.Add(new DirectionalLight(Colors.Yellow, new Vector3D(0.3, 1, 0))); lights.Add(new DirectionalLight(Colors.LimeGreen, new Vector3D(0.3, -0.3, -1))); } else if (renderType == RenderAspectEnum.PinkFucsiaViolet) { lights.Add(new DirectionalLight(Colors.Pink, new Vector3D(-1, -0.3, 0))); lights.Add(new DirectionalLight(Colors.Fuchsia, new Vector3D(0.3, 1, 0))); lights.Add(new DirectionalLight(Colors.Violet, new Vector3D(0.3, -0.3, -1))); } else if (renderType == RenderAspectEnum.CyanBlue) { lights.Add(new DirectionalLight(Colors.Blue, new Vector3D(-1, -0.3, 0))); lights.Add(new DirectionalLight(Colors.AliceBlue, new Vector3D(0.3, 1, 0))); lights.Add(new DirectionalLight(Colors.Cyan, new Vector3D(0.3, -0.3, -1))); } else if (renderType == RenderAspectEnum.RedRedish) { lights.Add(new DirectionalLight(Colors.Red, new Vector3D(-1, -0.3, 0))); lights.Add(new DirectionalLight(Colors.DarkRed, new Vector3D(0.3, 1, 0))); lights.Add(new DirectionalLight(Colors.PaleVioletRed, new Vector3D(0.3, -0.3, -1))); } else if (renderType == RenderAspectEnum.Yellow) { lights.Add(new DirectionalLight(Colors.Yellow, new Vector3D(-1, -0.3, 0))); lights.Add(new DirectionalLight(Colors.YellowGreen, new Vector3D(0.3, 1, 0))); lights.Add(new DirectionalLight(Colors.LightYellow, new Vector3D(0.3, -0.3, -1))); } else { if (renderType == RenderAspectEnum.PerNormal) { lights.Add(new DirectionalLight(Colors.DarkGreen, new Vector3D(-1, 0, 0))); lights.Add(new DirectionalLight(Colors.DarkRed, new Vector3D(0, 1, 0))); lights.Add(new DirectionalLight(Colors.DarkBlue, new Vector3D(0, 0, -1))); } lights.Add(new DirectionalLight(Colors.White, new Vector3D(-1, 1, -1))); } foreach (var light in lights) { myModel3DGroup.Children.Add(light); } // Add a grid myGridLines = new GridLinesVisual3D(); myGridLines.Fill = Brushes.LightGray; // Add the group of models to the ModelVisual3d. myModelVisual3D.Content = myModel3DGroup; viewport.Children.Add(myModelVisual3D); }
private string GetComposedFileNameForFilter(string fileName, string filePath, RenderAspectEnum renderType) { bool useNormalMap = DefaultFactory.GetDefaultUserSettings().GetSettingBool(UserSettingEnum.EnableThumnailColorsByShaders); return(string.Format($"{fileName}{(uint)filePath.GetHashCode()}.cached.{(useNormalMap ? "N" : ((int)renderType).ToString())}.*.png")); }
public IEnumerable <Tuple <int, string> > GetThumbnailsPaths(string filePath, string fileName, RenderAspectEnum renderType) { Tuple <int, string>[] foundFiles = null; string cachePath = GetCachePath(); string filesNameForFilter = GetComposedFileNameForFilter(fileName, filePath, renderType); try { if (Directory.Exists(cachePath)) { var files = UtilMethods.EnumerateFiles(cachePath, filesNameForFilter, SearchOption.AllDirectories); foundFiles = files.Select(f => new Tuple <int, string>(GetFileSizeFromFileName(f), f)).ToArray(); } } catch (Exception ex) { logger.Trace(ex, "Exception loading cache file paths for {fullpath} as {renderType}", Path.Combine(filePath, fileName), renderType.ToString()); return(null); } /* * if (foundFiles == null || foundFiles.Length == 0) logger.Info("No cache files found for {filePath} as {filesNameForFilter}", Path.Combine(filePath, fileName), filesNameForFilter); * else logger.Info("Found {fileCount} cache files for {filePath} as {filesNameForFilter}", foundFiles.Length, Path.Combine(filePath, fileName), filesNameForFilter); */ return(foundFiles); }
public IEnumerable <Tuple <int, BitmapSource> > GetThumbnailsImages(string filePath, string fileName, RenderAspectEnum renderType) { Tuple <int, BitmapSource>[] loadedFiles = new Tuple <int, BitmapSource> [0]; string cachePath = GetCachePath(); string filesNameForFilter = GetComposedFileNameForFilter(fileName, filePath, renderType); try { if (Directory.Exists(cachePath)) { var files = UtilMethods.EnumerateFiles(cachePath, filesNameForFilter, SearchOption.AllDirectories); loadedFiles = new Tuple <int, BitmapSource> [files.Count()]; int i = 0; foreach (var foundFile in files) { using (var file = File.OpenRead(foundFile)) { BitmapSource bmp = LoadImageFromStream(file); loadedFiles[i] = new Tuple <int, BitmapSource>(GetFileSizeFromFileName(foundFile), bmp); } i++; } } } catch (Exception ex) { logger.Trace(ex, "Exception loading cache file images for {fullpath} as {renderType}", Path.Combine(filePath, fileName), renderType.ToString()); } /* * if (loadedFiles.Length == 0) logger.Info("No cache files found for {filePath} as {filesNameForFilter}", Path.Combine(filePath, fileName), filesNameForFilter); * else logger.Info("Loaded {fileCount} cache files found for {filePath} as {filesNameForFilter}", loadedFiles.Length, Path.Combine(filePath, fileName), filesNameForFilter); */ return(loadedFiles); }
public void SetEnviorementOptions(RenderAspectEnum renderAspect) { GL.Disable(EnableCap.Light0); GL.Disable(EnableCap.Light1); GL.Disable(EnableCap.Light2); GL.Disable(EnableCap.Light3); // InitializeFloorGrid(); //// Lighting { float highLight = 1f; mat_diffuse1 = null; mat_diffuse2 = null; mat_diffuse3 = null; mat_diffuse4 = null; if (DefaultFactory.GetDefaultUserSettings().GetSettingBool(UserSettingEnum.EnableThumnailColorsByShaders)) { mat_diffuse1 = new float[] { 0f, 1f, 0f }; light_position1 = new float[] { 1f, 0f, 0f, 0f }; mat_diffuse2 = new float[] { 0f, 0f, 1f }; light_position2 = new float[] { 0f, 0f, 1f, 0f }; mat_diffuse3 = new float[] { 1f, 0f, 0f }; light_position3 = new float[] { 0f, -1f, 0f, 0f }; } else { if (renderAspect == RenderAspectEnum.VioletBlue) { mat_diffuse1 = new float[] { Colors.Violet.R / 256f, Colors.Violet.G / 256f, Colors.Violet.B / 256f }; light_position1 = new float[] { 0.5f, -1f, 0.5f, 0f }; mat_diffuse2 = new float[] { Colors.Blue.R / 256f, Colors.Blue.G / 256f, Colors.Blue.B / 256f }; light_position2 = new float[] { 1f, -0.5f, 0.5f, 0f }; } else if (renderAspect == RenderAspectEnum.RedOrangeYellow) { mat_diffuse1 = new float[] { 1f, 0f, 0f }; light_position1 = new float[] { 1f, 0f, 0f, 0f }; mat_diffuse2 = new float[] { 1, 1f, 0f }; light_position2 = new float[] { -0f, -1f, 0f, 0f }; mat_diffuse3 = new float[] { Colors.Orange.R / 256f, Colors.Orange.G / 256f, Colors.Orange.B / 256f }; light_position3 = new float[] { 0f, 0f, 1f, 0f }; } else if (renderAspect == RenderAspectEnum.GreenLimeYellow) { mat_diffuse1 = new float[] { 0f, 0.5f, 0f }; light_position1 = new float[] { 1f, 0f, 0f, 0f }; mat_diffuse2 = new float[] { 1, 1f, 0f }; light_position2 = new float[] { -0f, -1f, 0f, 0f }; mat_diffuse3 = new float[] { Colors.LimeGreen.R / 256f, Colors.LimeGreen.G / 256f, Colors.LimeGreen.B / 256f }; light_position3 = new float[] { 0f, 0f, 1f, 0f }; } else if (renderAspect == RenderAspectEnum.PinkFucsiaViolet) { mat_diffuse1 = new float[] { 1f, 0.75f, 0.795f }; light_position1 = new float[] { 1f, 0f, 0f, 0f }; mat_diffuse2 = new float[] { 0.58f, 0.155f, 0.31f }; light_position2 = new float[] { -0f, -1f, 0f, 0f }; mat_diffuse3 = new float[] { 0.93f, 0.51f, 0.93f }; light_position3 = new float[] { 0f, 0f, 1f, 0f }; } else if (renderAspect == RenderAspectEnum.CyanBlue) { mat_diffuse1 = new float[] { 0f, 0f, 1f }; light_position1 = new float[] { 1f, 0f, 0f, 0f }; mat_diffuse2 = new float[] { 0.39f, 0.58f, 0.92f }; light_position2 = new float[] { -0f, -1f, 0f, 0f }; mat_diffuse3 = new float[] { 0f, 1f, 1f }; light_position3 = new float[] { 0f, 0f, 1f, 0f }; } else if (renderAspect == RenderAspectEnum.RedRedish) { mat_diffuse1 = new float[] { 1f, 0f, 0f }; light_position1 = new float[] { 1f, 0f, 0f, 0f }; mat_diffuse2 = new float[] { 0.5f, 0f, 0f }; light_position2 = new float[] { -0f, -1f, 0f, 0f }; mat_diffuse3 = new float[] { 0.85f, 0.44f, 0.57f }; light_position3 = new float[] { 0f, 0f, 1f, 0f }; } else if (renderAspect == RenderAspectEnum.Yellow) { mat_diffuse1 = new float[] { 1f, 1f, 0f }; light_position1 = new float[] { 1f, 0f, 0f, 0f }; mat_diffuse2 = new float[] { 0.6f, 0.8f, 0.195f }; light_position2 = new float[] { -0f, -1f, 0f, 0f }; mat_diffuse3 = new float[] { 1f, 1f, 0.87f }; light_position3 = new float[] { 0f, 0f, 1f, 0f }; } else { if (renderAspect == RenderAspectEnum.PerNormal) { mat_diffuse1 = new float[] { 0f, 0.39f, 0f }; light_position1 = new float[] { 1f, 0f, 0f, 0f }; mat_diffuse2 = new float[] { 0f, 0f, 0.54f }; light_position2 = new float[] { 0f, 0f, 1f, 0f }; mat_diffuse3 = new float[] { 0.54f, 0f, 0f }; light_position3 = new float[] { 0f, -1f, 0f, 0f }; } mat_diffuse4 = new float[] { highLight, highLight, highLight }; light_position4 = new float[] { 1f, -1f, 1f, 0f }; } } } }
public static void SetListItemColoring(RenderAspectEnum renderAspect) { switch (renderAspect) { default: case RenderAspectEnum.PerNormal: { byte w = Convert.ToByte(255f * 0.50f); _ColoredImageEffect.ColorY = Color.FromRgb(w, 255, w); _ColoredImageEffect.ColorX = Color.FromRgb(255, w, w); _ColoredImageEffect.ColorZ = Color.FromRgb(w, w, 255); } break; case RenderAspectEnum.White: { byte w = Convert.ToByte(255f * 0.6f); _ColoredImageEffect.ColorY = Color.FromRgb(w, w, w); _ColoredImageEffect.ColorX = Color.FromRgb(w, w, w); _ColoredImageEffect.ColorZ = Color.FromRgb(w, w, w); } break; case RenderAspectEnum.VioletBlue: _ColoredImageEffect.ColorY = Colors.Blue; _ColoredImageEffect.ColorX = Colors.Violet; _ColoredImageEffect.ColorZ = Color.FromRgb(150, 80, 238); break; case RenderAspectEnum.RedOrangeYellow: _ColoredImageEffect.ColorY = Colors.Red; _ColoredImageEffect.ColorX = Colors.Yellow; _ColoredImageEffect.ColorZ = Colors.Orange; break; case RenderAspectEnum.GreenLimeYellow: _ColoredImageEffect.ColorY = Colors.Green; _ColoredImageEffect.ColorX = Colors.Yellow; _ColoredImageEffect.ColorZ = Colors.LimeGreen; break; case RenderAspectEnum.PinkFucsiaViolet: _ColoredImageEffect.ColorY = Colors.Pink; _ColoredImageEffect.ColorX = Color.FromArgb(1, 150, 40, 80); _ColoredImageEffect.ColorZ = Colors.Violet; break; case RenderAspectEnum.CyanBlue: _ColoredImageEffect.ColorY = Color.FromRgb(0, 0, 255); _ColoredImageEffect.ColorX = Color.FromRgb(100, 150, 234); _ColoredImageEffect.ColorZ = Color.FromRgb(0, 255, 255); break; case RenderAspectEnum.RedRedish: _ColoredImageEffect.ColorY = Colors.Red; _ColoredImageEffect.ColorX = Colors.DarkRed; _ColoredImageEffect.ColorZ = Colors.PaleVioletRed; break; case RenderAspectEnum.Yellow: _ColoredImageEffect.ColorY = Colors.Yellow; _ColoredImageEffect.ColorX = Colors.YellowGreen; _ColoredImageEffect.ColorZ = Color.FromArgb(1, 230, 230, 130); break; } if (renderAspect != RenderAspectEnum.PerNormal) { _ColoredImageEffectInverted.ColorX = Color.FromRgb((byte)(255 - _ColoredImageEffect.ColorX.R), (byte)(255 - _ColoredImageEffect.ColorX.G), (byte)(255 - _ColoredImageEffect.ColorX.B)); _ColoredImageEffectInverted.ColorY = Color.FromRgb((byte)(255 - _ColoredImageEffect.ColorY.R), (byte)(255 - _ColoredImageEffect.ColorY.G), (byte)(255 - _ColoredImageEffect.ColorY.B)); _ColoredImageEffectInverted.ColorZ = Color.FromRgb((byte)(255 - _ColoredImageEffect.ColorZ.R), (byte)(255 - _ColoredImageEffect.ColorZ.G), (byte)(255 - _ColoredImageEffect.ColorZ.B)); } else { byte c = Convert.ToByte(255f * 0.75f); _ColoredImageEffectInverted.ColorY = Color.FromRgb(c, 0, c); _ColoredImageEffectInverted.ColorX = Color.FromRgb(0, c, c); _ColoredImageEffectInverted.ColorZ = Color.FromRgb(c, c, 0); } }
private string GetComposedFileNameForFilter(string fileName, RenderAspectEnum renderType) { return(string.Format($"{fileName}.cached.{(int)renderType}.*.png")); }
private string ComposeFileName(string fileName, RenderAspectEnum renderType, int size) { return(string.Format($"{fileName}.cached.{(int)renderType}.{size}.png")); }
public IEnumerable <Tuple <int, byte[]> > GetThumbnails(string filePath, string fileName, RenderAspectEnum renderType) { Tuple <int, byte[]>[] loadedFiles = null; string cachePath = GetCachePath(); string filesNameForFilter = GetComposedFileNameForFilter(fileName, renderType); try { if (Directory.Exists(cachePath)) { var files = Directory.EnumerateFiles(cachePath, filesNameForFilter, SearchOption.AllDirectories); loadedFiles = new Tuple <int, byte[]> [files.Count()]; int i = 0; foreach (var foundFile in files) { using (var file = File.OpenRead(foundFile)) { loadedFiles[i] = new Tuple <int, byte[]>(GetFileSizeFromFileName(foundFile), new byte[file.Length]); file.Read(loadedFiles[i].Item2, 0, (int)file.Length); } i++; } } } catch (Exception ex) { logger.Trace(ex, "Exception loading a cache files for {fullpath} as {renderType}", Path.Combine(filePath, fileName), renderType.ToString()); throw ex; } if (loadedFiles == null) { logger.Info("No cache files found for {filePath} as {filesNameForFilter}", Path.Combine(filePath, fileName), filesNameForFilter); } else { logger.Info("Loaded {fileCount} cache files found for {filePath} as {filesNameForFilter}", loadedFiles.Length, Path.Combine(filePath, fileName), filesNameForFilter); } return(loadedFiles); }