imgProps(img img, string fn) { myImg = img; width = 0; height = 0; string appPath = img.absoluteUrl; if (!File.Exists(fn)) { if (CourseMan.Config.IgnoreWmaBmpFileExist) return; throw new Exception(string.Format("File {0}, referenced in {1}, does not exist.", fn, img.ErrorId)); } System.Drawing.Bitmap bmp = new Bitmap(fn); width = bmp.Width; height = bmp.Height; }
static public imgProps getImgProps(img img) { //string fn = HttpContext.Current.Server.MapPath(img.absoluteUrl); string fn = LMComLib.EaUrlInfoLib.MapPath(img.absoluteUrl); lock (typeof(imgProps)) { imgProps res = (imgProps)CourseMan.fromCache(fn); if (res != null) { //aby fungovalo resize v design time res.myImg.width = img.width; res.myImg.height = img.height; //if (dbInfo.myImg.width != img.width || dbInfo.myImg.height != img.height) //throw new Exception(string.Format("File {0}, referenced in {1} and {2}, has multiple width or height.", fn, img.ErrorId, dbInfo.myImg.ErrorId)); return res; } res = new imgProps(img, fn); if (res.width > 0) CourseMan.toCache(res, fn); return res; } }
public void append(img img) { images.Add(img); string id = resxId(img.varName, null); pathsBuf.Add(id, imgProps.getImgProps(img)); foreach (KeyValuePair<string, StringBuilder> kp in buffs) kp.Value.Append(string.Concat("[#", id, "#]")); }