private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { if (dataGridView1.SelectedCells.Count == 0) { return; } var img = dataGridView1.SelectedCells[0].OwningRow.Cells[0].Value; if (bMapOpen) { if (map != null) { webcam wc = list.FirstOrDefault(x => x.id.Equals(img)); if (wc != null) { map.panTo(wc); } } } else { ShowPic(img); //ThreadPool.QueueUserWorkItem(ShowPic, img); } }
public void panTo(webcam wc) { if (webBrowser1.Document != null) { webBrowser1.Document.InvokeScript("panTo", new object[] { wc.lat, wc.lng }); } }
private void downloadCams() { if (list.Count > 0) { foreach (webcam r in list) { r.lat = r.lat.Replace(",", "."); r.lng = r.lng.Replace(",", "."); ThreadPool.QueueUserWorkItem(downIfChanged, r); } } else { //string url = "http://webcam-api-eu.herokuapp.com/webcams/get_webcams_boundary?callback=jQuery164034308020158312846_1367187674405&limit=300&swpointy=58.71837604123238&swpointx=16.681749389062475&nepointy=59.64698212185716&nepointx=18.604356810937475&_=1367187675105"; string url = "http://webcam-api-eu.herokuapp.com/webcams/get_webcams_boundary?callback=jQuery164034308020158312846_1367187674405&limit=1000&swpointy=55&swpointx=11&nepointy=69&nepointx=25&_=1367187675105"; WebClient wc = new WebClient(); try { string json = wc.DownloadString(url).Replace("jQuery164034308020158312846_1367187674405(", "").Replace("\\ufeff", ""); json = json.Substring(0, json.Length - 1); dynamic obj = JObject.Parse(json); int icnt = 0; foreach (var ev in obj.webcams) { if (("" + ev.image_url).Contains("stp2.gofore.com")) { continue; } var r = new webcam { id = ev.id, url = ev.image_url, lat = ev.lat, lng = ev.lng, name = ev.name }; r.url = r.url.Replace("http://proxy.vackertvader.se/redirect?url=", ""); ThreadPool.QueueUserWorkItem(downIfChanged, r); list.Add(r); icnt++; if (icnt > 1000) { break; } } } catch { } } dataGridView1.DataSource = list.ToList(); labelCnt.Text = list.Count().ToString(); }
private webcam ConvertXYZToLatLngAlt(webcam wc) { webcam wcout = new webcam() { id = wc.id, lat = wc.lat, lng = wc.lng, LastModified = wc.LastModified, name = wc.name, url = wc.url }; string lat = ""; string lng = ""; double dlat = double.Parse(wc.lat.Replace(".", ",")); double dlng = double.Parse(wc.lng.Replace(".", ",")); GeoUTMConverter conv = new GeoUTMConverter(); conv.ToLatLon(dlat, dlng, 33, GeoUTMConverter.Hemisphere.Northern); wcout.lat = Math.Round(conv.Latitude, 6).ToString().Replace(",", "."); wcout.lng = Math.Round(conv.Longitude, 6).ToString().Replace(",", "."); return(wcout); }
private void downIfChanged(object state) { webcam r = state as webcam; using (WebClient wc = new WebClient()) { try { string strfolder = strDownloadPath + "\\webcams\\" + r.id + "\\" + DateTime.Today.ToString("yyyyMMdd") + "\\"; if (!Directory.Exists(strfolder)) { Directory.CreateDirectory(strfolder); } string strFileName = "tmp.jpg"; string strFilePath = strfolder + strFileName; if (File.Exists(strFilePath)) { File.Move(strFilePath, strFilePath.Replace(strFileName, (new FileInfo(strFilePath)).LastWriteTime.ToString("yyyyMMdd_HHmmss") + ".jpg")); } wc.DownloadFile(r.url, strFilePath); Thread.Sleep(1000); string lastmodified = wc.ResponseHeaders.AllKeys.Contains("Last-Modified") ? wc.ResponseHeaders["Last-Modified"] : DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); DateTime LastModified = DateTime.Parse(lastmodified); string destFileName = strFilePath.Replace(strFileName, LastModified.ToString("yyyyMMdd_HHmmss") + ".jpg"); if (File.Exists(strFilePath) && !File.Exists(destFileName)) { File.Move(strFilePath, destFileName); } if (File.Exists(strFilePath)) { File.Delete(strFilePath); } r.setFile(new FileInfo(destFileName)); r.cnt = Directory.EnumerateFiles(strfolder).Count(); r.LastModified = LastModified; } catch (Exception ex) { string s = ex.Message; } } }