Example #1
0
        bool matchesGeomType(GraphicsLayer gLayer)
        {
            ParameterSupport.FeatureLayerParameterConfig flConfig = Config as ParameterSupport.FeatureLayerParameterConfig;

            ESRI.ArcGIS.Mapping.Core.GeometryType geomType = Core.LayerExtensions.GetGeometryType(gLayer);

            if (flConfig.GeometryType == geomType)
            {
                return(true);
            }
            return(false);
        }
 private void AddResultLayer(GraphicsLayer resultsLayer, bool isSelected, string displayName,
                             ESRI.ArcGIS.Mapping.Core.GeometryType geometryType, int?index)
 {
     resultsLayer.SetValue(ESRI.ArcGIS.Client.Extensibility.MapApplication.LayerNameProperty, displayName);
     resultsLayer.ID = displayName;
     resultsLayer.SetValue(ESRI.ArcGIS.Client.Extensibility.LayerExtensions.InitialUpdateCompletedProperty, true);
     if (index == null || index.Value < 0 || index.Value >= Map.Layers.Count)
     {
         Map.Layers.Add(resultsLayer);
     }
     else
     {
         Map.Layers.Insert(index.Value, resultsLayer);
     }
 }
Example #3
0
        private List <GraphicsLayer> GetLayerList()
        {
            ParameterSupport.FeatureLayerParameterConfig flConfig = Config as FeatureLayerParameterConfig;
            List <GraphicsLayer> inputLayers = new List <GraphicsLayer>();

            if (flConfig != null)
            {
                for (int i = Map.Layers.Count - 1; i >= 0; i--)
                {
                    Layer item = Map.Layers[i];
                    if (!(item is GraphicsLayer))
                    {
                        continue;
                    }
                    ESRI.ArcGIS.Mapping.Core.GeometryType geomType = Core.LayerExtensions.GetGeometryType(item as GraphicsLayer);
                    switch (geomType)
                    {
                    case ESRI.ArcGIS.Mapping.Core.GeometryType.Point:
                    case ESRI.ArcGIS.Mapping.Core.GeometryType.MultiPoint:
                    case ESRI.ArcGIS.Mapping.Core.GeometryType.Polygon:
                    case ESRI.ArcGIS.Mapping.Core.GeometryType.Polyline:
                        if (matchesGeomType(item as GraphicsLayer))
                        {
                            inputLayers.Add(item as GraphicsLayer);
                        }
                        break;

                    case ESRI.ArcGIS.Mapping.Core.GeometryType.Unknown:
                        GraphicsLayer gLayer = item as GraphicsLayer;
                        if (gLayer.Graphics.Count > 0)
                        {
                            ESRI.ArcGIS.Mapping.Core.GeometryType gType = GetGeometryTypeFromGraphic(gLayer.Graphics.ElementAtOrDefault(0));
                            Core.LayerExtensions.SetGeometryType(gLayer, gType);
                            if (matchesGeomType(item as GraphicsLayer))
                            {
                                inputLayers.Add(item as GraphicsLayer);
                            }
                        }
                        else
                        {
                            gLayer.Graphics.CollectionChanged += Graphics_CollectionChanged;
                        }
                        break;
                    }
                }
            }
            return(inputLayers);
        }
        private void addToMap(GPFeatureRecordSetLayer result, ParameterConfig config)
        {
            if (result == null)
            {
                return;
            }

            SpatialReference sr = Map.SpatialReference.Clone();

            ESRI.ArcGIS.Mapping.Core.GeometryType geomType = Core.GeometryType.Unknown;
            FeatureLayerParameterConfig           flConfig = config as FeatureLayerParameterConfig;

            foreach (Graphic item in result.FeatureSet.Features)
            {
                if (item.Geometry != null)
                {
                    item.Geometry.SpatialReference = sr;
                    if (geomType == Core.GeometryType.Unknown)
                    {
                        if (item.Geometry is MapPoint)
                        {
                            geomType = Core.GeometryType.Point;
                        }
                        else if (item.Geometry is MultiPoint)
                        {
                            geomType = Core.GeometryType.MultiPoint;
                        }
                        else if (item.Geometry is ESRI.ArcGIS.Client.Geometry.Polygon)
                        {
                            geomType = Core.GeometryType.Polygon;
                        }
                        else if (item.Geometry is ESRI.ArcGIS.Client.Geometry.Polyline)
                        {
                            geomType = Core.GeometryType.Polyline;
                        }
                    }
                    if (flConfig != null && flConfig.DoubleFields != null && flConfig.DoubleFields.Length > 0)
                    {
                        foreach (string name in flConfig.DoubleFields)
                        {
                            if (item.Attributes.ContainsKey(name) && item.Attributes[name] != null &&
                                (!(item.Attributes[name] is double)))
                            {
                                double d;
                                if (double.TryParse(item.Attributes[name].ToString(), System.Globalization.NumberStyles.Any, CultureHelper.GetCurrentCulture(), out d))
                                {
                                    item.Attributes[name] = d;
                                }
                            }
                        }
                    }
                    if (flConfig != null && flConfig.SingleFields != null && flConfig.SingleFields.Length > 0)
                    {
                        foreach (string name in flConfig.SingleFields)
                        {
                            if (item.Attributes.ContainsKey(name) && item.Attributes[name] != null &&
                                (!(item.Attributes[name] is Single)))
                            {
                                Single s;
                                if (Single.TryParse(item.Attributes[name].ToString(), out s))
                                {
                                    item.Attributes[name] = s;
                                }
                            }
                        }
                    }
                }
            }
            GraphicsLayer layer = GraphicsLayer.FromGraphics(result.FeatureSet.Features, new SimpleRenderer());

            if (flConfig != null)
            {
                if (flConfig.GeometryType == geomType)
                {
                    layer.Renderer = flConfig.Layer.Renderer;
                }
                else
                {
                    layer.Renderer = FeatureLayerParameterConfig.GetSimpleRenderer(geomType);
                }

                setLayerProps(config, layer);
                if (flConfig.Layer != null)
                {
                    Core.LayerExtensions.SetFields(layer, Core.LayerExtensions.GetFields(flConfig.Layer));
                    Core.LayerExtensions.SetDisplayField(layer, Core.LayerExtensions.GetDisplayField(flConfig.Layer));
                    Core.LayerExtensions.SetGeometryType(layer, Core.LayerExtensions.GetGeometryType(flConfig.Layer));

                    // Set whether pop-ups are enabled and whether to show them on click or on hover
                    LayerProperties.SetIsPopupEnabled(layer, LayerProperties.GetIsPopupEnabled(flConfig.Layer));
                    Core.LayerExtensions.SetPopUpsOnClick(layer, Core.LayerExtensions.GetPopUpsOnClick(flConfig.Layer));
                }
            }

            GraphicsLayerTypeFixer.CorrectDataTypes(layer.Graphics, layer);

            Map.Layers.Add(layer);
            layerParamNameIDLookup.Add(config.Name, layer.ID);
        }