async void gpAircraftComms_JobCompleted(object sender, JobInfoEventArgs e) { try { if (_graphicsLayerPoly != null) { _graphicsLayerPoly.Graphics.Clear(); } Geoprocessor gpAircraftComCov = sender as Geoprocessor; client.ArcGISDynamicMapServiceLayer gpLayer = gpAircraftComCov.GetResultMapServiceLayer(e.JobInfo.JobId); gpLayer.ID = "AircraftCommunicationCoverageMap"; gpLayer.Opacity = .65; _mapWidget.Map.Layers.Add(gpLayer); _mapWidget.Map.Layers.Add(_graphicsLayer); //get legend HttpClient client = new HttpClient(); string response = await client.GetStringAsync(_baseURL + "MapServer/legend?f=pjson"); XmlDocument doc = (XmlDocument)JsonConvert.DeserializeXmlNode(response); XmlNodeList xmlnode = doc.GetElementsByTagName("legend"); List <legend> pLegends = new List <legend>(); _dtLegends.Clear(); foreach (XmlNode node in xmlnode) { legend pLegend = new legend(); foreach (XmlNode child in node.ChildNodes) { if (child.Name == "label") { pLegend.label = child.InnerText; } if (child.Name == "url") { pLegend.url = _baseURL + "MapServer/1/images/" + child.InnerText; } } _dtLegends.Add(pLegend); } if (pWin == null) { pWin = new LegendDialog(); } pWin.ListView.DataContext = _dtLegends; pWin.Closed += pWin_Closed; pWin.Show(); pWin.Topmost = true; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } }
async void gpAircraftComms_JobCompleted(object sender, JobInfoEventArgs e) { try { if (_graphicsLayerPoly != null) _graphicsLayerPoly.Graphics.Clear(); Geoprocessor gpAircraftComCov = sender as Geoprocessor; client.ArcGISDynamicMapServiceLayer gpLayer = gpAircraftComCov.GetResultMapServiceLayer(e.JobInfo.JobId); gpLayer.ID = "AircraftCommunicationCoverageMap"; gpLayer.Opacity = .65; _mapWidget.Map.Layers.Add(gpLayer); _mapWidget.Map.Layers.Add(_graphicsLayer); //get legend HttpClient client = new HttpClient(); string response = await client.GetStringAsync(_baseURL + "MapServer/legend?f=pjson"); XmlDocument doc = (XmlDocument)JsonConvert.DeserializeXmlNode(response); XmlNodeList xmlnode = doc.GetElementsByTagName("legend"); List<legend> pLegends = new List<legend>(); _dtLegends.Clear(); foreach (XmlNode node in xmlnode) { legend pLegend = new legend(); foreach (XmlNode child in node.ChildNodes) { if (child.Name == "label") pLegend.label = child.InnerText; if (child.Name == "url") pLegend.url = _baseURL + "MapServer/1/images/" + child.InnerText; } _dtLegends.Add(pLegend); } if (pWin == null) pWin = new LegendDialog(); pWin.ListView.DataContext = _dtLegends; pWin.Closed += pWin_Closed; pWin.Show(); pWin.Topmost = true; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } }