public void GenerateMarkers() { Response.Write("<script type=\"text/javascript\">\r\n"); Response.Write("function addMarkers(){\r\n"); foreach (Route r in Routes) { string url = r.GetRouteUrl(editMode); string gpxFile = PathFunctions.GetGpxPathFromRouteName(r.Name); GpxParser parser = Helper.GetGpxParser(gpxFile); if (parser == null) { continue; } //TrackPoint p = parser.Tracks[0].Segments[0].Points[0]; GenericPoint p = parser.MediumPoint; string color = r.Draft ? "red" : "blue"; string title = r.Title.Replace("'", "\\'") + (r.Draft ? " (bozza)" : ""); string name = r.Name; string description = string.Format("<iframe scrolling=\"no\" frameborder=\"no\" src=\"/RouteData.aspx?name={0}\"/>", r.Name); string icon = r.Draft ? "/Images/draft_marker.png" : ""; string imageFolder = PathFunctions.GetImagePathFromGpx(gpxFile); string imageFile = Path.Combine(imageFolder, string.IsNullOrEmpty(r.Image) ? "" : r.Image); if (!File.Exists(imageFile)) { string[] files = Directory.GetFiles(imageFolder, "*.jpg"); if (files.Length > 0) { imageFile = files[0]; } else { imageFile = ""; } } string thumbFile = imageFile.Length == 0 ? "" : PathFunctions.GetThumbFile(imageFile); string photo = thumbFile.Length == 0 ? "" : PathFunctions.GetUrlFromPath(thumbFile, false).Replace("'", "\\'"); Response.Write(string.Format( "GV_Draw_Marker({{ lat: {0}, lon: {1}, name: '{2}', desc: '{3}', color: '{4}', icon: '{5}', photo: '{6}', url: '{7}', route_name:'{8}', draw_track: true }});\r\n", p.lat.ToString(System.Globalization.CultureInfo.InvariantCulture), p.lon.ToString(System.Globalization.CultureInfo.InvariantCulture), title, description, color, icon, photo, url, name)); } Response.Write("}\r\n"); Response.Write("</script>\r\n"); }
public static string CreateThumbnail(string file, int size) { string thumbFile = PathFunctions.GetThumbFile(file); if (File.Exists(thumbFile)) { return(thumbFile); } using (System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(file)) { using (Bitmap img = CreateThumbnail(bmp, size)) { img.Save(thumbFile); } } return(thumbFile); }