I have a Silverlight app that uses a "Print Preview" window.
My client has 4 layers that need to be included in the Print Preview window. These 4 layers are used for Red Line editing. [Redline Points, Polygons, Lines and Text] and are managed by the editor tools.
The print preview spins up its own map control and copies all the layers from the main map and places them on the Preview Map. This has been working great for all layers except the 4 above.
The code that copied the layers from the main map to the preview map looked something like:
....
case "ESRI.ArcGIS.Client.FeatureLayer":
featLayer = new FeatureLayer();
featLayer.Url = ((FeatureLayer)l).Url;
featLayer.ID = ((FeatureLayer)l).ID;
featLayer.MaximumResolution = ((FeatureLayer)l).MaximumResolution;
featLayer.MinimumResolution = ((FeatureLayer)l).MinimumResolution;
featLayer.Opacity = ((FeatureLayer)l).Opacity;
featLayer.Visible = ((FeatureLayer)l).Visible;
_newLayer = featLayer;
break;
....
if (_newLayer != null)
{
ahMapControl.Layers.Add(_newLayer);
ahMapControl.Extent = _env;
logger.Info("PRINTING: Adding layer to AdHoc map. Layer ID: " + _newLayer.ID);
}
This worked fine for most layers, with the exception of the Red Line features.
Looking at some other code, it uses deep cloning to setup the preview map. We created a helper class to facilitate that and re-tooled to the following:
foreach (Layer l in MainMapCollection)
{
_newLayer = CloneUtility.CloneLayer(l);
if (_newLayer != null)
{
ahMapControl.Layers.Add(_newLayer);
ahMapControl.UpdateLayout();
ahMapControl.Extent = _env;
logger.Info("PRINTING: Adding layer to AdHoc map. Layer ID: " + _newLayer.ID);
}
}
public static class CloneUtility {
public static Graphic CloneGraphic(Graphic source)
public static GraphicsLayer CloneGraphicsLayer(GraphicsLayer source)
public static Layer CloneLayer(Layer source)
public static LayerCollection Clone(LayerCollection source)
}
This worked better in that Red Line Text now shows up. But no luck on the Points, Lines and Polygons. All other layers, like WIP, are showing up fine. The only difference I can see is that our client does not "Save/Publish" the red line data. They use Import and Export if they want to persist the data.
Stepping through it I see that Redline Points has 10 graphics, and the copy also has 10 once the clone is complete. They are identical as far as I can tell. The layer is getting added to the preview map, visibility and opacity are set correctly.
Anyone out there with any Ideas?