} // private GraphicsLayer addRLL2Map(GraphicsLayer rl) /// <summary> /// If RL layer exists reload RL data and reattach RLL to map. /// Called from timer when map layers loaded. /// Set mapstate=Processing or Ready /// </summary> private void renewRL() { log(string.Format("VRedlineImpl.renewRL")); if (mapState != VMapState.Loaded) { return; } mapState = VMapState.Processing; var lyr = MapApplication.Current.SelectedLayer; //load RL content var gl = reloadRLData(MapApplication.Current.Map, VRedlineImpl.layerID, VRedlineImpl.layerName); if (gl == null) { mapState = VMapState.Ready; log(string.Format("VRedlineImpl.renewRL, RL layer doesn't exists")); return; } log(string.Format("VRedlineImpl.renewRL, symbols restored")); // attach RL layer to map in right way marks = new GraphicCollection(gl.Graphics); MapApplication.Current.Map.Layers.Remove(gl); addRLL2Map(gl); if (gl.ID == lyr.ID) { MapApplication.Current.SelectedLayer = gl; } log(string.Format("VRedlineImpl.renewRL done")); return; } // private void renewRL()
//Adding symbols from each entry read from the feed to the graphics object of the layer private void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) { if (e.Error != null) { if (LoadFailed != null) { LoadFailed(this, new RssLoadFailedEventArgs() { ex = new Exception("Error in Reading the RSS feed. Try Again later!", e.Error), UserState = e.UserState }); } return; } ESRI.ArcGIS.Client.GraphicCollection graphics = new ESRI.ArcGIS.Client.GraphicCollection(); using (Stream s = e.Result) { SyndicationFeed feed; List <SyndicationItem> feedItems = new List <SyndicationItem>(); using (XmlReader reader = XmlReader.Create(s)) { feed = SyndicationFeed.Load(reader); foreach (SyndicationItem feedItem in feed.Items) { SyndicationElementExtensionCollection ec = feedItem.ElementExtensions; string x = ""; string y = ""; foreach (SyndicationElementExtension ee in ec) { XmlReader xr = ee.GetReader(); switch (ee.OuterName) { case ("lat"): { y = xr.ReadElementContentAsString(); break; } case ("long"): { x = xr.ReadElementContentAsString(); break; } case ("point"): { string sp = xr.ReadElementContentAsString(); string[] sxsy = sp.Split(new char[] { ' ' }); x = sxsy[1]; y = sxsy[0]; break; } } } if (!string.IsNullOrEmpty(x)) { Graphic graphic = new Graphic() { Geometry = new MapPoint(Convert.ToDouble(x), Convert.ToDouble(y)) }; graphic.Attributes.Add("Title", feedItem.Title.Text); graphic.Attributes.Add("Summary", feedItem.Summary.Text); graphic.Attributes.Add("PublishDate", feedItem.PublishDate); graphic.Attributes.Add("Id", feedItem.Id); graphics.Add(graphic); } } } } //Invoking the initialize method of the base class to finish the initialization of the graphics layer: if (LoadCompleted != null) { LoadCompleted(this, new RssLoadedEventArgs() { Graphics = graphics, UserState = e.UserState } ); } }