public void ShowAirportPopup(string icao, Form form, Point location) { FSCloudPortAirport airport = null; if (this.airportLookup.TryGetValue(icao, out airport)) { this.fsCloudPortPopup.Airport = airport; this.containerForFSCloudPortPopup.Show(form, location); } }
private void ParseAirportListHtml(string html, Dictionary <string, FSCloudPortAirport> airports) { CQ dom = CQ.Create(html); var dataTableRows = dom["body > table tr"].Elements; int ix = 0; foreach (IDomElement dataTableRow in dataTableRows) { // Skip the header if (ix > 0) { var airport = new FSCloudPortAirport(); var trCQ = CQ.Create(dataTableRow); // There's only one link so get the url directly airport.Url = trCQ["a"].Attr("href"); airport.ICAO = trCQ["a"].Text().Trim().ToUpper(); // Everything else in InnerText in tds var tds = trCQ["td"].Elements; if (!airports.ContainsKey(airport.ICAO)) { int jx = 0; foreach (var td in tds) { if (jx > 0) { switch (jx) { // Lat / lon case 1: string[] latLonArray = td.InnerText.Split(','); if (latLonArray.Length == 2) { airport.Latitude = double.Parse(latLonArray[0], NumberStyles.Any, CultureInfo.InvariantCulture); airport.Longitude = double.Parse(latLonArray[1], NumberStyles.Any, CultureInfo.InvariantCulture); } break; // Runways, buildings, static aircraft case 2: string[] valArray = td.InnerText.Split(','); if (valArray.Length == 3) { airport.Runways = int.Parse(valArray[0].Trim()); airport.Buildings = int.Parse(valArray[1].Trim()); airport.StaticAircraft = int.Parse(valArray[2].Trim()); } break; // Name case 3: airport.Name = WebUtility.HtmlDecode(td.InnerText.Trim()); break; // Last modified case 4: DateTime lastModified = DateTime.UtcNow; if (DateTime.TryParseExact(td.InnerText, "dd-MMM yyyy HH:mm", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out lastModified)) { airport.LastModifiedDateTime = lastModified; } break; } } jx++; } airports.Add(airport.ICAO, airport); } } ix++; } }