public void ProcessRequest(HttpContext context) { string file = context.Request.QueryString["File"]; if (!string.IsNullOrEmpty(file)) { context.Response.ContentType = "application/octet-stream"; context.Response.TransmitFile(file); return; } string scriptForRoute = context.Request.QueryString["ScriptForRoute"]; if (!string.IsNullOrEmpty(scriptForRoute)) { string gpxFile = PathFunctions.GetGpxPathFromRouteName(scriptForRoute); GpxParser parser = Helper.GetGpxParser(gpxFile); Helper.GenerateTrackCode(parser, context.Response, false); return; } string routeName = context.Request.QueryString["Route"]; string imageName = context.Request.QueryString["Image"]; UploadedImage img = UploadedImage.FromSession(routeName, imageName); string folder = PathFunctions.GetImagePathFromRouteName(routeName); if (img != null) { img.SaveTo(context.Response); } }
public void LoadPhothos() { if (photoLoaded) { return; } string original = PathFunctions.GetImagePathFromGpx(sourceFile); if (Directory.Exists(original)) { int prog = 0; foreach (string file in Directory.GetFiles(original, "*.jpg")) { if (AlreadyAvailable(file)) { continue; } try { DateTime photoTime; double latidudeRef, latitude, longitudeRef, longitude; Helper.GetImageInfos(file, out photoTime, out latidudeRef, out latitude, out longitudeRef, out longitude); TrackPoint tp = GetPoint(photoTime, 1); if (tp != null) { WayPoint wp = new WayPoint(tp); wp.link = file; wp.name = Helper.GetImageTitle(file); if (string.IsNullOrEmpty(wp.name)) { wp.name = Helper.GetImageCaption(prog++, wp.link); } wayPoints.Add(wp); } } catch { } } } photoLoaded = true; }
private ImageCache(string imagesPath) { files = Directory.Exists(imagesPath) ? Directory.GetFiles(imagesPath, "*.jpg") : new string[0]; thumbUrls = new string[files.Length]; reducedUrls = new string[files.Length]; captions = new string[files.Length]; fileUrls = new string[files.Length]; pages = (int)Math.Ceiling((float)files.Length / (float)maxPerPage); string thumbDir = PathFunctions.GetThumbsFolder(imagesPath); if (!Directory.Exists(thumbDir)) { Directory.CreateDirectory(thumbDir); } string reducedDir = PathFunctions.GetReducedFolder(imagesPath); if (!Directory.Exists(reducedDir)) { Directory.CreateDirectory(reducedDir); } for (int i = 0; i < files.Length; i++) { string file = files[i]; Helper.CreateThumbnail(file, 200 /*800*/); thumbUrls[i] = PathFunctions.GetUrlFromPath(PathFunctions.GetThumbFile(file), true); Helper.CreateReduced(file); reducedUrls[i] = PathFunctions.GetUrlFromPath(PathFunctions.GetReducedFile(file), true); string title = Helper.GetImageTitle(file); if (string.IsNullOrEmpty(title)) { title = Helper.GetImageCaption(i, file); } captions[i] = title; fileUrls[i] = PathFunctions.GetUrlFromPath(file, false); } }
public static UploadedImages FromSession(string routeName) { string key = GetKey(routeName); UploadedImages list = HttpContext.Current.Session[key] as UploadedImages; if (list == null) { list = new UploadedImages(); HttpContext.Current.Session[key] = list; //carico i file già presenti su file system ImageCache cache = Helper.GetImageCache(PathFunctions.GetImagePathFromRouteName(routeName)); for (int i = 0; i < cache.files.Length; i++) { UploadedImage img = new UploadedImage( cache.files[i], cache.captions[i] ); list.Add(img); } } return(list); }
private static string GetCacheFile(string imagesPath) { return(PathFunctions.GetWorkingPath(imagesPath) + ".xml"); }