Exemple #1
0
        // Shows counties by population density when the Class Breaks button is clicked
        private void ClassBreaksButton_Click(object sender, RoutedEventArgs e)
        {
            ClassBreaksRenderer cbr = new ClassBreaksRenderer();

            // Symbolize based on the population density field
            cbr.Field = "POP00_SQMI";
            var Infos = new ClassBreakInfoCollection();
            SimpleLineSymbol outline = new SimpleLineSymbol()
            {
                Color = Colors.LightGray
            };

            #region Define Class Breaks

            // Create five class breaks, with symbols ranging from green for the lowest density to
            // blue for the highest
            cbr.Infos.Add(new ClassBreakInfo()
            {
                Minimum = 0,
                Maximum = 12,
                Symbol  = new SimpleFillSymbol()
                {
                    Color   = Color.FromArgb(255, 0, 255, 0),
                    Outline = outline
                }
            });

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

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

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

            cbr.Infos.Add(new ClassBreakInfo()
            {
                Maximum = 57173,
                Symbol  = new SimpleFillSymbol()
                {
                    Color   = Color.FromArgb(255, 0, 0, 255),
                    Outline = outline
                }
            });

            #endregion

            // Get the USA layer from the map and apply the class breaks renderer to the counties layer
            var layer = map1.Layers["USA"] as ArcGISDynamicMapServiceLayer;
            if (layer.LayerDrawingOptions == null)
            {
                layer.LayerDrawingOptions = new LayerDrawingOptionCollection();
            }
            layer.LayerDrawingOptions.Add(new LayerDrawingOptions()
            {
                LayerID  = 3, // counties layer has an ID of 3
                Renderer = cbr
            });

            // Make it so only the counties layer is visible
            layer.VisibleLayers = new ObservableCollection <int>(new int[] { 3 });
        }
        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 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 };
        }
        // Shows counties by population density when the Class Breaks button is clicked
        private void ClassBreaksButton_Click(object sender, RoutedEventArgs e)
        {
            ClassBreaksRenderer cbr = new ClassBreaksRenderer();

            // Symbolize based on the population density field
            cbr.Field = "POP00_SQMI";
            var Infos = new ClassBreakInfoCollection();
            SimpleLineSymbol outline = new SimpleLineSymbol() { Color = Colors.LightGray };

            #region Define Class Breaks

            // Create five class breaks, with symbols ranging from green for the lowest density to
            // blue for the highest
            cbr.Infos.Add(new ClassBreakInfo()
            {

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

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

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

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

            cbr.Infos.Add(new ClassBreakInfo()
            {
                Maximum = 57173,
                Symbol = new SimpleFillSymbol()
                {
                    Color = Color.FromArgb(255, 0, 0, 255),
                    Outline = outline
                }
            });

            #endregion

            // Get the USA layer from the map and apply the class breaks renderer to the counties layer
            var layer = map1.Layers["USA"] as ArcGISDynamicMapServiceLayer;
            if (layer.LayerDrawingOptions == null)
                layer.LayerDrawingOptions = new LayerDrawingOptionCollection();
            layer.LayerDrawingOptions.Add(new LayerDrawingOptions()
            {
                LayerID = 3, // counties layer has an ID of 3
                Renderer = cbr
            });

            // Make it so only the counties layer is visible
            layer.VisibleLayers = new ObservableCollection<int>(new int[] { 3 });
        }