private void GetImage() { FileInfo fi = null; if (LocalCachingSettings.UseLocalCaching) { string fn = LocalCachingSettings.LocalCachingFolder + @"\" + _dataset.DatasetName + @"\" + _level + @"\" + _row + @"\" + _col + ".jpg"; fi = new FileInfo(fn); try { if (fi.Exists) { _bm = (System.Drawing.Bitmap)System.Drawing.Image.FromFile(fn); return; } } catch { } } try { string url = _dataset.TileUrl, quadkey = String.Empty; if (url.Contains("\n")) { url = url.Replace("\r", String.Empty); string[] urls = url.Split('\n'); url = urls[RasterTile.index % urls.Length]; RasterTile.index++; if (RasterTile.index > 1000) { RasterTile.index = 0; } } if (url.Contains("{3}")) { quadkey = _grid.Quadkey(_dataset.Extent, _level, _row, _col, _resolution); } url = String.Format(url, _col, _row, _level, quadkey); using (MemoryStream ms = WebFunctions.DownloadStream(url)) { _bm = (System.Drawing.Bitmap)System.Drawing.Image.FromStream(ms); if (fi != null) { fi.Refresh(); if (!fi.Exists) { if (!fi.Directory.Exists) { fi.Directory.Create(); } ms.Position = 0; StreamWriter sw = new StreamWriter(fi.FullName); ms.WriteTo(sw.BaseStream); sw.Flush(); sw.Close(); } } } } catch { } }