Exemplo n.º 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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
 public override void AddUI(Grid grid)
 {
     if (Config != null && Config.ShownAtRunTime && Map != null)
     {
         #region
         ParameterSupport.FeatureLayerParameterConfig flConfig = Config as ParameterSupport.FeatureLayerParameterConfig;
         #region Get layer list
         List <GraphicsLayer> inputLayers = GetLayerList();
         #endregion
         Map.Layers.CollectionChanged -= Layers_CollectionChanged;
         Map.Layers.CollectionChanged += Layers_CollectionChanged;
         layerPanel = new StackPanel();
         layerPanel.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
         layerPanel.SetValue(Grid.ColumnProperty, 1);
         grid.Children.Add(layerPanel);
         populateLayerPanel(inputLayers);
         #endregion
     }
 }
Exemplo n.º 4
0
        string getGeometryType()
        {
            ParameterSupport.FeatureLayerParameterConfig flConfig = Config as ParameterSupport.FeatureLayerParameterConfig;
            switch (flConfig.GeometryType)
            {
            case ESRI.ArcGIS.Mapping.Core.GeometryType.Point:
                return("point ");

            case ESRI.ArcGIS.Mapping.Core.GeometryType.MultiPoint:
                return("multipoint ");

            case ESRI.ArcGIS.Mapping.Core.GeometryType.Polyline:
                return("line ");

            case ESRI.ArcGIS.Mapping.Core.GeometryType.Polygon:
                return("polygon ");
            }
            return(string.Empty);
        }
Exemplo n.º 5
0
        public override void AddUI(Grid grid)
        {
            if (Config != null && Config.ShownAtRunTime)
            {
                #region
                ParameterSupport.FeatureLayerParameterConfig flConfig = Config as ParameterSupport.FeatureLayerParameterConfig;
                if (flConfig != null)
                {
                    #region Button for drawing
                    Button btn = new Button()
                    {
                        Width = 22,
                        HorizontalAlignment = System.Windows.HorizontalAlignment.Left,
                        Style = System.Windows.Application.Current.Resources["SimpleButtonStyle"] as System.Windows.Style
                    };
                    btn.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
                    btn.SetValue(Grid.ColumnProperty, 1);
                    grid.Children.Add(btn);
                    string name = Config.Name;
                    btn.Click += (s, e) =>
                    {
                        if (Map == null)
                        {
                            return;
                        }
                        if (flConfig.GeometryType == ESRI.ArcGIS.Mapping.Core.GeometryType.Polyline)
                        {
                            Draw.DrawMode = DrawMode.Polyline;
                        }
                        else if (flConfig.GeometryType == ESRI.ArcGIS.Mapping.Core.GeometryType.Point ||
                                 flConfig.GeometryType == ESRI.ArcGIS.Mapping.Core.GeometryType.MultiPoint)
                        {
                            Draw.DrawMode = DrawMode.Point;
                        }
                        else if (flConfig.GeometryType == ESRI.ArcGIS.Mapping.Core.GeometryType.Polygon)
                        {
                            Draw.DrawMode = DrawMode.Polygon;
                        }
                        Draw.Map       = Map;
                        Draw.IsEnabled = true;
                    };
                    switch (flConfig.GeometryType)
                    {
                    case ESRI.ArcGIS.Mapping.Core.GeometryType.Polygon:
                        btn.Content = new Image()
                        {
                            Source              = new BitmapImage(new Uri("/ESRI.ArcGIS.Mapping.GP;component/Images/DrawPolygon16.png", UriKind.Relative)),
                            Stretch             = System.Windows.Media.Stretch.None,
                            VerticalAlignment   = System.Windows.VerticalAlignment.Center,
                            HorizontalAlignment = System.Windows.HorizontalAlignment.Center
                        };
                        break;

                    case ESRI.ArcGIS.Mapping.Core.GeometryType.Polyline:
                        btn.Content = new Image()
                        {
                            Source              = new BitmapImage(new Uri("/ESRI.ArcGIS.Mapping.GP;component/Images/DrawPolyline16.png", UriKind.Relative)),
                            Stretch             = System.Windows.Media.Stretch.None,
                            VerticalAlignment   = System.Windows.VerticalAlignment.Center,
                            HorizontalAlignment = System.Windows.HorizontalAlignment.Center
                        };
                        break;

                    case ESRI.ArcGIS.Mapping.Core.GeometryType.Point:
                    case ESRI.ArcGIS.Mapping.Core.GeometryType.MultiPoint:
                        btn.Content = new Image()
                        {
                            Source              = new BitmapImage(new Uri("/ESRI.ArcGIS.Mapping.GP;component/Images/DrawPoint16.png", UriKind.Relative)),
                            Stretch             = System.Windows.Media.Stretch.None,
                            VerticalAlignment   = System.Windows.VerticalAlignment.Center,
                            HorizontalAlignment = System.Windows.HorizontalAlignment.Center
                        };
                        break;

                    default:
                        btn.IsEnabled = false;
                        btn.Content   = Resources.Strings.NotAvailable;
                        break;
                    }
                    btn.SetValue(ToolTipService.ToolTipProperty, flConfig.ToolTip);
                    #endregion
                }
                #endregion
            }
        }