private async Task GenerateRenderer(GenerateRendererParameters rendererParam)
        {
            GenerateRendererResult result = await generateRendererTask.GenerateRendererAsync(rendererParam);

            LayerDrawingOptions          layerDrawingOptions = null;
            LayerDrawingOptionCollection options             = null;

            // If this is the first execution of this sample create a new LayerDrawingOptionsCollection
            if (((ArcGISDynamicMapServiceLayer)map.Layers["USA"]).LayerDrawingOptions == null)
            {
                options = new LayerDrawingOptionCollection();

                // Add a new LayerDrawingOptions for layer ID 2 using the generated renderer
                options.Add(new LayerDrawingOptions()
                {
                    LayerID = 2, Renderer = result.Renderer
                });
            }
            else
            {
                // Otherwise the layer will have an existing LayerDrawingOptionsCollection from a previous button click
                options = ((ArcGISDynamicMapServiceLayer)map.Layers["USA"]).LayerDrawingOptions;

                // Iterate over the LayerDrawingOptionsCollection.
                // For layer ID 2 get the existing LayerDrawingOptions object and apply the newly generated renderer
                foreach (LayerDrawingOptions drawOption in options)
                {
                    if (drawOption.LayerID == 2)
                    {
                        layerDrawingOptions = drawOption;
                        drawOption.Renderer = result.Renderer;
                    }
                }
            }

            // Retrieve the GenerateRendererParameters Where clause and create a new LayerDefinition for layer ID 2
            if (!string.IsNullOrEmpty(rendererParam.Where))
            {
                LayerDefinition layerDefinition = new LayerDefinition()
                {
                    LayerID    = 2,
                    Definition = rendererParam.Where
                };

                ((ArcGISDynamicMapServiceLayer)map.Layers["USA"]).LayerDefinitions =
                    new ObservableCollection <LayerDefinition>()
                {
                    layerDefinition
                };
            }

            // Apply the updated LayerDrawingOptionsCollection to the LayerDrawingOptions property on the layer
            ((ArcGISDynamicMapServiceLayer)map.Layers["USA"]).LayerDrawingOptions = options;
        }
        private async Task GenerateRenderer(GenerateRendererParameters rendererParam)
        {
            GenerateRendererResult result = await generateRendererTask.GenerateRendererAsync(rendererParam);

            LayerDrawingOptions layerDrawingOptions = null;
            LayerDrawingOptionCollection options = null;

            // If this is the first execution of this sample create a new LayerDrawingOptionsCollection
            if (((ArcGISDynamicMapServiceLayer)map.Layers["USA"]).LayerDrawingOptions == null)
            {
                options = new LayerDrawingOptionCollection();

                // Add a new LayerDrawingOptions for layer ID 2 using the generated renderer
                options.Add(new LayerDrawingOptions() { LayerID = 2, Renderer = result.Renderer });
            }
            else
            {
                // Otherwise the layer will have an existing LayerDrawingOptionsCollection from a previous button click
                options = ((ArcGISDynamicMapServiceLayer)map.Layers["USA"]).LayerDrawingOptions;

                // Iterate over the LayerDrawingOptionsCollection. 
                // For layer ID 2 get the existing LayerDrawingOptions object and apply the newly generated renderer
                foreach (LayerDrawingOptions drawOption in options)
                {
                    if (drawOption.LayerID == 2)
                    {
                        layerDrawingOptions = drawOption;
                        drawOption.Renderer = result.Renderer;
                    }
                }
            }

            // Retrieve the GenerateRendererParameters Where clause and create a new LayerDefinition for layer ID 2
            if (!string.IsNullOrEmpty(rendererParam.Where))
            {
                LayerDefinition layerDefinition = new LayerDefinition()
                {
                    LayerID = 2,
                    Definition = rendererParam.Where
                };

                ((ArcGISDynamicMapServiceLayer)map.Layers["USA"]).LayerDefinitions =
                    new ObservableCollection<LayerDefinition>() { layerDefinition };
            }

            // Apply the updated LayerDrawingOptionsCollection to the LayerDrawingOptions property on the layer
            ((ArcGISDynamicMapServiceLayer)map.Layers["USA"]).LayerDrawingOptions = options;
        }
        private void ApplyRangeValueClick(object sender, RoutedEventArgs e)
        {
            ClassBreaksRenderer newClassBreaksRenderer = new ClassBreaksRenderer();
            newClassBreaksRenderer.Field = "POP00_SQMI";
            var Infos = new ClassBreakInfoCollection();
            Infos.Add(new ClassBreakInfo()
            {

                Minimum = 0,
                Maximum = 12,
                Symbol = new SimpleFillSymbol()
                {
                    Color = Color.FromArgb(255, 0, 255, 0)
                }
            });

            Infos.Add(new ClassBreakInfo()
            {
                Maximum = 31.3,
                Symbol = new SimpleFillSymbol()
                {
                    Color = Color.FromArgb(255, 100, 255, 100)
                }
            });

            Infos.Add(new ClassBreakInfo()
            {
                Maximum = 59.7,
                Symbol = new SimpleFillSymbol()
                {
                    Color = Color.FromArgb(255, 0, 255, 200)
                }
            });

            Infos.Add(new ClassBreakInfo()
            {
                Maximum = 146.2,
                Symbol = new SimpleFillSymbol()
                {
                    Color = Color.FromArgb(255, 0, 255, 255)
                }
            });

            Infos.Add(new ClassBreakInfo()
            {
                Maximum = 57173,
                Symbol = new SimpleFillSymbol()
                {
                    Color = Color.FromArgb(255, 0, 0, 255)
                }
            });
            newClassBreaksRenderer.Infos = Infos;
            var layer = mapView1.Map.Layers["USA"] as ArcGISDynamicMapServiceLayer;
            LayerDrawingOptionCollection layerDrawingOptionCollection = new LayerDrawingOptionCollection()
            {
                new LayerDrawingOptions()
            {
                LayerID = 3,
                Renderer = newClassBreaksRenderer
            }
            };

            layer.LayerDrawingOptions = layerDrawingOptionCollection;

            layer.VisibleLayers = new ObservableCollection<int> { 3 };
        }
        private void ApplyUniqueValueClick(object sender, RoutedEventArgs e)
        {

            UniqueValueRenderer uvr = new UniqueValueRenderer();
            uvr.Fields = new ObservableCollection<string>(new string[] { "SUB_REGION" });
            uvr.DefaultSymbol = new SimpleFillSymbol() { Color = Colors.Gray };

            uvr.Infos.Add(new UniqueValueInfo { Values = new ObservableCollection<object>(new object[] { "Pacific"}), Symbol = new SimpleFillSymbol() { Color = Colors.Purple, Outline = new SimpleLineSymbol() { Color = Colors.Transparent } } });
            uvr.Infos.Add(new UniqueValueInfo { Values = new ObservableCollection<object>(new object[] { "W N Cen"}), Symbol = new SimpleFillSymbol() { Color = Colors.Green, Outline = new SimpleLineSymbol() { Color = Colors.Transparent } } });
            uvr.Infos.Add(new UniqueValueInfo { Values = new ObservableCollection<object>(new object[] { "W S Cen"}), Symbol = new SimpleFillSymbol() { Color = Colors.Cyan, Outline = new SimpleLineSymbol() { Color = Colors.Transparent } } });
            uvr.Infos.Add(new UniqueValueInfo { Values = new ObservableCollection<object>(new object[] { "E N Cen"}), Symbol = new SimpleFillSymbol() { Color = Colors.Yellow, Outline = new SimpleLineSymbol() { Color = Colors.Transparent } } });
            uvr.Infos.Add(new UniqueValueInfo { Values = new ObservableCollection<object>(new object[] { "Mtn"}), Symbol = new SimpleFillSymbol() { Color = Colors.Blue, Outline = new SimpleLineSymbol() { Color = Colors.Transparent } } });
            uvr.Infos.Add(new UniqueValueInfo { Values = new ObservableCollection<object>(new object[] { "N Eng"}), Symbol = new SimpleFillSymbol() { Color = Colors.Red, Outline = new SimpleLineSymbol() { Color = Colors.Transparent } } });
            uvr.Infos.Add(new UniqueValueInfo { Values = new ObservableCollection<object>(new object[] { "E S Cen"}), Symbol = new SimpleFillSymbol() { Color = Colors.Brown, Outline = new SimpleLineSymbol() { Color = Colors.Transparent } } });
            uvr.Infos.Add(new UniqueValueInfo { Values = new ObservableCollection<object>(new object[] { "Mid Atl"}), Symbol = new SimpleFillSymbol() { Color = Colors.Magenta, Outline = new SimpleLineSymbol() { Color = Colors.Transparent } } });
            uvr.Infos.Add(new UniqueValueInfo { Values = new ObservableCollection<object>(new object[] { "S Atl" }), Symbol = new SimpleFillSymbol() { Color = Colors.Orange, Outline = new SimpleLineSymbol() { Color = Colors.Transparent } } });

          

            var layer = mapView1.Map.Layers["USA"] as ArcGISDynamicMapServiceLayer;
            LayerDrawingOptionCollection layerDrawingOptionCollection = new LayerDrawingOptionCollection()
            {
                new LayerDrawingOptions()
            {
                LayerID = 2,
                Renderer = uvr
            }
            };

            layer.LayerDrawingOptions = layerDrawingOptionCollection;

            layer.VisibleLayers = new ObservableCollection<int> { 2 };
        }
        private async Task<ArcGISDynamicMapServiceLayer> AddFileDatasetToDynamicMapServiceLayer(WorkspaceFactoryType workspaceType, string directoryPath, List<string> fileNames)
        {
            try
            {
                // Create a new WorkspaceInfo object with a unique ID.
                string uniqueId = Guid.NewGuid().ToString();
                WorkspaceInfo workspaceInfo = new WorkspaceInfo(uniqueId, workspaceType, "DATABASE=" + directoryPath);

                // Create and initialize a new LocalMapService instance.
                LocalMapService localMapService = new LocalMapService(_emptyMapPackage) { EnableDynamicLayers = true };
                localMapService.DynamicWorkspaces.Add(workspaceInfo);
                await localMapService.StartAsync();

                // Create and initialize new ArcGISLocalDynamicMapServiceLayer over the local service.
                var dynLayer = new ArcGISDynamicMapServiceLayer()
                {
                    ID = "Workspace: " + (new DirectoryInfo(directoryPath)).Name,
                    ServiceUri = localMapService.UrlMapService
                };
                await dynLayer.InitializeAsync();

                // Create a DynamicLayerInfoCollection to hold the new datasets as "dynamic layers".
                DynamicLayerInfoCollection dynamicLayerInfoCollection = new DynamicLayerInfoCollection();
                dynLayer.DynamicLayerInfos = dynamicLayerInfoCollection;

                // Create a LayerDrawingOptionsCollection to specify the symbology for each layer.
                LayerDrawingOptionCollection layerDrawingOptionsCollection = new LayerDrawingOptionCollection();
                dynLayer.LayerDrawingOptions = layerDrawingOptionsCollection;

                // Iterate over each of the selected files in the workspace.
                int counter = 0;
                foreach (string fileName in fileNames)
                {
                    // Create a new DynamicLayerInfo (to make changes to existing map service layers use the CreateDynamicLayerInfosFromLayerInfos() method.
                    DynamicLayerInfo dynamicLayerInfo = new DynamicLayerInfo { ID = counter, Name = "Dataset: " + fileName };

                    // Create a DataSource object to represent the physical datasource implementation (table or raster) which will become the DataSource 
                    // property of a new LayerDataSource in the map service. Other supported datasource types are JoinDataSource and QueryDataSource.
                    DataSource dataSource = null;

                    // If the workspace type is Raster create a new RasterDataSource.
                    if (workspaceInfo.FactoryType == WorkspaceFactoryType.Raster)
                    {
                        // Create a new RasterDataSource object
                        dataSource = new RasterDataSource
                        {
                            // Match the DataSourceName to the physical filename on disk (including extension).
                            DataSourceName = fileName,

                            // Provide the WorkspaceID (the unique workspace identifier created earlier). A LocalMapService may have multiple dynamic workspaces.
                            WorkspaceID = workspaceInfo.Id
                        };
                    }
                    else
                    {
                        // Else if the workspace is not Raster create a new TableDataSource
                        dataSource = new TableDataSource
                        {
                            // Match the DataSourceName to the physical filename on disk (excluding extension).
                            DataSourceName = fileName,

                            // Provide the WorkspaceID (the unique workspace identifier created earlier). A LocalMapService may have multiple dynamic workspaces.
                            WorkspaceID = workspaceInfo.Id
                        };
                    }

                    // Set the Source property of the DynamicLayerInfo object.
                    dynamicLayerInfo.Source = new LayerDataSource { DataSource = dataSource };

                    // Add the new DynamicLayerInfo object to the collection.
                    dynamicLayerInfoCollection.Add(dynamicLayerInfo);

                    // Create a new LayerDrawingOptions object to hold the renderer information.
                    var layerDrawOpt = new LayerDrawingOptions()
                    {
                        // Match up the LayerID to the ID of the layer within the service.
                        LayerID = counter,
                    };

                    // Use the GetDetails method which now supports dynamic data sources to determine the geometry type of the new datasource.
                    var featureLayerInfo = await dynLayer.GetDetailsAsync(dynamicLayerInfo.ID);

                    switch (featureLayerInfo.GeometryType)
                    {
                        case GeometryType.Envelope:
                            layerDrawOpt.Renderer = new SimpleRenderer() { Symbol = new SimpleFillSymbol() { Color = GetRandomColor(), Outline = new SimpleLineSymbol() { Color = GetRandomColor() } } };
                            break;
                        case GeometryType.MultiPoint:
                            layerDrawOpt.Renderer = new SimpleRenderer() { Symbol = new SimpleMarkerSymbol() { Color = GetRandomColor(), Size = 8 } };
                            break;
                        case GeometryType.Point:
                            layerDrawOpt.Renderer = new SimpleRenderer() { Symbol = new SimpleMarkerSymbol() { Color = GetRandomColor(), Size = 8 } };
                            break;
                        case GeometryType.Polygon:
                            layerDrawOpt.Renderer = new SimpleRenderer() { Symbol = new SimpleFillSymbol() { Color = GetRandomColor(), Outline = new SimpleLineSymbol() { Color = GetRandomColor() } } };
                            break;
                        case GeometryType.Polyline:
                            layerDrawOpt.Renderer = new SimpleRenderer() { Symbol = new SimpleLineSymbol() { Color = GetRandomColor() } };
                            break;
                        default:
                            break;
                    }

                    // Set the LayerDrawingOptions property on the local dynamic map service layer (the LayerID property ties this to the DynamicLayerInfo object).
                    layerDrawingOptionsCollection.Add(layerDrawOpt);

                    counter++;
                }

                return dynLayer;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return null;
            }
        }
        private async Task <ArcGISDynamicMapServiceLayer> AddFileDatasetToDynamicMapServiceLayer(WorkspaceFactoryType workspaceType, string directoryPath, List <string> fileNames)
        {
            try
            {
                // Create a new WorkspaceInfo object with a unique ID.
                string        uniqueId      = Guid.NewGuid().ToString();
                WorkspaceInfo workspaceInfo = new WorkspaceInfo(uniqueId, workspaceType, "DATABASE=" + directoryPath);

                // Create and initialize a new LocalMapService instance.
                LocalMapService localMapService = new LocalMapService(_emptyMapPackage)
                {
                    EnableDynamicLayers = true
                };
                localMapService.DynamicWorkspaces.Add(workspaceInfo);
                await localMapService.StartAsync();

                // Create and initialize new ArcGISLocalDynamicMapServiceLayer over the local service.
                var dynLayer = new ArcGISDynamicMapServiceLayer()
                {
                    ID         = "Workspace: " + (new DirectoryInfo(directoryPath)).Name,
                    ServiceUri = localMapService.UrlMapService
                };
                await dynLayer.InitializeAsync();

                // Create a DynamicLayerInfoCollection to hold the new datasets as "dynamic layers".
                DynamicLayerInfoCollection dynamicLayerInfoCollection = new DynamicLayerInfoCollection();
                dynLayer.DynamicLayerInfos = dynamicLayerInfoCollection;

                // Create a LayerDrawingOptionsCollection to specify the symbology for each layer.
                LayerDrawingOptionCollection layerDrawingOptionsCollection = new LayerDrawingOptionCollection();
                dynLayer.LayerDrawingOptions = layerDrawingOptionsCollection;

                // Iterate over each of the selected files in the workspace.
                int counter = 0;
                foreach (string fileName in fileNames)
                {
                    // Create a new DynamicLayerInfo (to make changes to existing map service layers use the CreateDynamicLayerInfosFromLayerInfos() method.
                    DynamicLayerInfo dynamicLayerInfo = new DynamicLayerInfo {
                        ID = counter, Name = "Dataset: " + fileName
                    };

                    // Create a DataSource object to represent the physical datasource implementation (table or raster) which will become the DataSource
                    // property of a new LayerDataSource in the map service. Other supported datasource types are JoinDataSource and QueryDataSource.
                    DataSource dataSource = null;

                    // If the workspace type is Raster create a new RasterDataSource.
                    if (workspaceInfo.FactoryType == WorkspaceFactoryType.Raster)
                    {
                        // Create a new RasterDataSource object
                        dataSource = new RasterDataSource
                        {
                            // Match the DataSourceName to the physical filename on disk (including extension).
                            DataSourceName = fileName,

                            // Provide the WorkspaceID (the unique workspace identifier created earlier). A LocalMapService may have multiple dynamic workspaces.
                            WorkspaceID = workspaceInfo.Id
                        };
                    }
                    else
                    {
                        // Else if the workspace is not Raster create a new TableDataSource
                        dataSource = new TableDataSource
                        {
                            // Match the DataSourceName to the physical filename on disk (excluding extension).
                            DataSourceName = fileName,

                            // Provide the WorkspaceID (the unique workspace identifier created earlier). A LocalMapService may have multiple dynamic workspaces.
                            WorkspaceID = workspaceInfo.Id
                        };
                    }

                    // Set the Source property of the DynamicLayerInfo object.
                    dynamicLayerInfo.Source = new LayerDataSource {
                        DataSource = dataSource
                    };

                    // Add the new DynamicLayerInfo object to the collection.
                    dynamicLayerInfoCollection.Add(dynamicLayerInfo);

                    // Create a new LayerDrawingOptions object to hold the renderer information.
                    var layerDrawOpt = new LayerDrawingOptions()
                    {
                        // Match up the LayerID to the ID of the layer within the service.
                        LayerID = counter,
                    };

                    // Use the GetDetails method which now supports dynamic data sources to determine the geometry type of the new datasource.
                    var featureLayerInfo = await dynLayer.GetDetailsAsync(dynamicLayerInfo.ID);

                    switch (featureLayerInfo.GeometryType)
                    {
                    case GeometryType.Envelope:
                        layerDrawOpt.Renderer = new SimpleRenderer()
                        {
                            Symbol = new SimpleFillSymbol()
                            {
                                Color = GetRandomColor(), Outline = new SimpleLineSymbol()
                                {
                                    Color = GetRandomColor()
                                }
                            }
                        };
                        break;

                    case GeometryType.Multipoint:
                        layerDrawOpt.Renderer = new SimpleRenderer()
                        {
                            Symbol = new SimpleMarkerSymbol()
                            {
                                Color = GetRandomColor(), Size = 8
                            }
                        };
                        break;

                    case GeometryType.Point:
                        layerDrawOpt.Renderer = new SimpleRenderer()
                        {
                            Symbol = new SimpleMarkerSymbol()
                            {
                                Color = GetRandomColor(), Size = 8
                            }
                        };
                        break;

                    case GeometryType.Polygon:
                        layerDrawOpt.Renderer = new SimpleRenderer()
                        {
                            Symbol = new SimpleFillSymbol()
                            {
                                Color = GetRandomColor(), Outline = new SimpleLineSymbol()
                                {
                                    Color = GetRandomColor()
                                }
                            }
                        };
                        break;

                    case GeometryType.Polyline:
                        layerDrawOpt.Renderer = new SimpleRenderer()
                        {
                            Symbol = new SimpleLineSymbol()
                            {
                                Color = GetRandomColor()
                            }
                        };
                        break;

                    default:
                        break;
                    }

                    // Set the LayerDrawingOptions property on the local dynamic map service layer (the LayerID property ties this to the DynamicLayerInfo object).
                    layerDrawingOptionsCollection.Add(layerDrawOpt);

                    counter++;
                }

                return(dynLayer);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return(null);
            }
        }
        private void ApplyUniqueValueClick(object sender, RoutedEventArgs e)
        {
            UniqueValueRenderer uvr = new UniqueValueRenderer();

            uvr.Fields        = new ObservableCollection <string>(new string[] { "SUB_REGION" });
            uvr.DefaultSymbol = new SimpleFillSymbol()
            {
                Color = Colors.Gray
            };

            uvr.Infos.Add(new UniqueValueInfo {
                Values = new ObservableCollection <object>(new object[] { "Pacific" }), Symbol = new SimpleFillSymbol()
                {
                    Color = Colors.Purple, Outline = new SimpleLineSymbol()
                    {
                        Color = Colors.Transparent
                    }
                }
            });
            uvr.Infos.Add(new UniqueValueInfo {
                Values = new ObservableCollection <object>(new object[] { "W N Cen" }), Symbol = new SimpleFillSymbol()
                {
                    Color = Colors.Green, Outline = new SimpleLineSymbol()
                    {
                        Color = Colors.Transparent
                    }
                }
            });
            uvr.Infos.Add(new UniqueValueInfo {
                Values = new ObservableCollection <object>(new object[] { "W S Cen" }), Symbol = new SimpleFillSymbol()
                {
                    Color = Colors.Cyan, Outline = new SimpleLineSymbol()
                    {
                        Color = Colors.Transparent
                    }
                }
            });
            uvr.Infos.Add(new UniqueValueInfo {
                Values = new ObservableCollection <object>(new object[] { "E N Cen" }), Symbol = new SimpleFillSymbol()
                {
                    Color = Colors.Yellow, Outline = new SimpleLineSymbol()
                    {
                        Color = Colors.Transparent
                    }
                }
            });
            uvr.Infos.Add(new UniqueValueInfo {
                Values = new ObservableCollection <object>(new object[] { "Mtn" }), Symbol = new SimpleFillSymbol()
                {
                    Color = Colors.Blue, Outline = new SimpleLineSymbol()
                    {
                        Color = Colors.Transparent
                    }
                }
            });
            uvr.Infos.Add(new UniqueValueInfo {
                Values = new ObservableCollection <object>(new object[] { "N Eng" }), Symbol = new SimpleFillSymbol()
                {
                    Color = Colors.Red, Outline = new SimpleLineSymbol()
                    {
                        Color = Colors.Transparent
                    }
                }
            });
            uvr.Infos.Add(new UniqueValueInfo {
                Values = new ObservableCollection <object>(new object[] { "E S Cen" }), Symbol = new SimpleFillSymbol()
                {
                    Color = Colors.Brown, Outline = new SimpleLineSymbol()
                    {
                        Color = Colors.Transparent
                    }
                }
            });
            uvr.Infos.Add(new UniqueValueInfo {
                Values = new ObservableCollection <object>(new object[] { "Mid Atl" }), Symbol = new SimpleFillSymbol()
                {
                    Color = Colors.Magenta, Outline = new SimpleLineSymbol()
                    {
                        Color = Colors.Transparent
                    }
                }
            });
            uvr.Infos.Add(new UniqueValueInfo {
                Values = new ObservableCollection <object>(new object[] { "S Atl" }), Symbol = new SimpleFillSymbol()
                {
                    Color = Colors.Orange, Outline = new SimpleLineSymbol()
                    {
                        Color = Colors.Transparent
                    }
                }
            });



            var layer = mapView1.Map.Layers["USA"] as ArcGISDynamicMapServiceLayer;
            LayerDrawingOptionCollection layerDrawingOptionCollection = new LayerDrawingOptionCollection()
            {
                new LayerDrawingOptions()
                {
                    LayerID  = 2,
                    Renderer = uvr
                }
            };

            layer.LayerDrawingOptions = layerDrawingOptionCollection;

            layer.VisibleLayers = new ObservableCollection <int> {
                2
            };
        }
        private void ApplyRangeValueClick(object sender, RoutedEventArgs e)
        {
            ClassBreaksRenderer newClassBreaksRenderer = new ClassBreaksRenderer();

            newClassBreaksRenderer.Field = "POP00_SQMI";
            var Infos = new ClassBreakInfoCollection();

            Infos.Add(new ClassBreakInfo()
            {
                Minimum = 0,
                Maximum = 12,
                Symbol  = new SimpleFillSymbol()
                {
                    Color = Color.FromArgb(255, 0, 255, 0)
                }
            });

            Infos.Add(new ClassBreakInfo()
            {
                Maximum = 31.3,
                Symbol  = new SimpleFillSymbol()
                {
                    Color = Color.FromArgb(255, 100, 255, 100)
                }
            });

            Infos.Add(new ClassBreakInfo()
            {
                Maximum = 59.7,
                Symbol  = new SimpleFillSymbol()
                {
                    Color = Color.FromArgb(255, 0, 255, 200)
                }
            });

            Infos.Add(new ClassBreakInfo()
            {
                Maximum = 146.2,
                Symbol  = new SimpleFillSymbol()
                {
                    Color = Color.FromArgb(255, 0, 255, 255)
                }
            });

            Infos.Add(new ClassBreakInfo()
            {
                Maximum = 57173,
                Symbol  = new SimpleFillSymbol()
                {
                    Color = Color.FromArgb(255, 0, 0, 255)
                }
            });
            newClassBreaksRenderer.Infos = Infos;
            var layer = mapView1.Map.Layers["USA"] as ArcGISDynamicMapServiceLayer;
            LayerDrawingOptionCollection layerDrawingOptionCollection = new LayerDrawingOptionCollection()
            {
                new LayerDrawingOptions()
                {
                    LayerID  = 3,
                    Renderer = newClassBreaksRenderer
                }
            };

            layer.LayerDrawingOptions = layerDrawingOptionCollection;

            layer.VisibleLayers = new ObservableCollection <int> {
                3
            };
        }
Exemplo n.º 9
0
        private void ApplyUniqueValueClick(object sender, RoutedEventArgs e)
        {
            UniqueValueRenderer uvr = new UniqueValueRenderer();

            uvr.Fields        = new ObservableCollection <string>(new string[] { "NOMBRE_DPT" });
            uvr.DefaultSymbol = new SimpleFillSymbol()
            {
                Color = Colors.Gray
            };

            uvr.Infos.Add(new UniqueValueInfo {
                Values = new ObservableCollection <object>(new object[] { "Región Atlántico" }), Symbol = new SimpleFillSymbol()
                {
                    Color = Colors.Purple, Outline = new SimpleLineSymbol()
                    {
                        Color = Colors.Transparent
                    }
                }
            });
            uvr.Infos.Add(new UniqueValueInfo {
                Values = new ObservableCollection <object>(new object[] { "Región Andina" }), Symbol = new SimpleFillSymbol()
                {
                    Color = Colors.Green, Outline = new SimpleLineSymbol()
                    {
                        Color = Colors.Transparent
                    }
                }
            });
            uvr.Infos.Add(new UniqueValueInfo {
                Values = new ObservableCollection <object>(new object[] { "Región Amazonía" }), Symbol = new SimpleFillSymbol()
                {
                    Color = Colors.Cyan, Outline = new SimpleLineSymbol()
                    {
                        Color = Colors.Transparent
                    }
                }
            });
            uvr.Infos.Add(new UniqueValueInfo {
                Values = new ObservableCollection <object>(new object[] { "Región Pacífica" }), Symbol = new SimpleFillSymbol()
                {
                    Color = Colors.Yellow, Outline = new SimpleLineSymbol()
                    {
                        Color = Colors.Transparent
                    }
                }
            });
            uvr.Infos.Add(new UniqueValueInfo {
                Values = new ObservableCollection <object>(new object[] { "Región Orinoquía" }), Symbol = new SimpleFillSymbol()
                {
                    Color = Colors.Blue, Outline = new SimpleLineSymbol()
                    {
                        Color = Colors.Transparent
                    }
                }
            });
            uvr.Infos.Add(new UniqueValueInfo {
                Values = new ObservableCollection <object>(new object[] { "Archipiélago San Andrés Providencia y Santa Catalina" }), Symbol = new SimpleFillSymbol()
                {
                    Color = Colors.Red, Outline = new SimpleLineSymbol()
                    {
                        Color = Colors.Transparent
                    }
                }
            });

            var layer = mapView1.Map.Layers["Col"] as ArcGISDynamicMapServiceLayer;
            LayerDrawingOptionCollection layerDrawingOptionCollection = new LayerDrawingOptionCollection()
            {
                new LayerDrawingOptions()
                {
                    LayerID  = 2,
                    Renderer = uvr
                }
            };

            layer.LayerDrawingOptions = layerDrawingOptionCollection;

            layer.VisibleLayers = new ObservableCollection <int> {
                2
            };
        }