public static void AddObject(string Name, CompressibleImage Obj) { if (_MapObjectCache.ContainsKey(Name)) { _MapObjectCache[Name] = Obj; } else { _MapObjectCache.Add(Name, Obj); } }
/// <summary> /// Loads All The System Resources Found In The Directory Specified /// </summary> /// <param name="BaseDirectory"></param> /// <returns></returns> public static LoadResults LoadSystemImages(string BaseDirectory) { LoadResults _TmpReturn = new LoadResults(); if (Directory.Exists(BaseDirectory)) { _SystemImageCache.Clear(); // Load All Objects Found foreach (string _ObjFile in Directory.GetFiles(BaseDirectory)) { if (_ObjFile.EndsWith(".png") == false) { continue; } System.IO.FileInfo _TmpFileInfo = new FileInfo(_ObjFile); _TmpReturn.TotalBytesLoaded += _TmpFileInfo.Length; _TmpFileInfo = null; try { CompressibleImage _TmpImage = new CompressibleImage(Image.FromFile(_ObjFile), System.Drawing.Imaging.ImageFormat.Png); _SystemImageCache.Add(_ObjFile.GetFileName(false), _TmpImage); _TmpReturn.TotalImagesLoaded++; } catch (Exception ex) { ErrorLogable.LogError(ex, "Error Loading Resource: " + BaseDirectory + _ObjFile, ACT.Core.Enums.ErrorLevel.Critical); _TmpReturn.TotalImagesFailed++; } } } else { _TmpReturn.TotalImagesLoaded = -1; ErrorLogable.LogError(null, "Error Loading Resources From Directory: " + BaseDirectory, ACT.Core.Enums.ErrorLevel.Critical); } return(_TmpReturn); }