Exemple #1
0
        public static CIMStroke CreateSolidStroke(CIMColor color, double width = -1)
        {
            var solidStroke = new CIMSolidStroke();

            solidStroke.Color       = color ?? DefaultStrokeColor;
            solidStroke.ColorLocked = false;
            solidStroke.CapStyle    = LineCapStyle.Round;
            solidStroke.JoinStyle   = LineJoinStyle.Round;
            solidStroke.MiterLimit  = 10.0;
            solidStroke.Width       = width >= 0 ? width : DefaultStrokeWidth;
            solidStroke.Enable      = true;
            return(solidStroke);
        }
Exemple #2
0
        public static CIMLineSymbol CreateLineSymbol(float red, float green, float blue,
                                                     double lineWidth)
        {
            CIMColor color = ColorUtils.CreateRGB(red, green, blue);

            var solidStroke = new CIMSolidStroke
            {
                Color = color,
                Width = lineWidth
            };

            CIMLineSymbol lineSymbol = CreateLineSymbol(solidStroke);

            return(lineSymbol);
        }
Exemple #3
0
        /// <summary>
        /// Renders a polygon feature layer with Dot Density symbols to represent quantities.
        /// ![Dot Density renderer](http://Esri.github.io/arcgis-pro-sdk/images/Renderers/dotDensity-renderer.png)
        /// </summary>
        /// <remarks></remarks>
        /// <returns></returns>
        internal static Task DotDensityRendererAsync()
        {
            //Check feature layer name
            //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data
            var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType <FeatureLayer>().FirstOrDefault(f => f.Name == "USDemographics");

            if (featureLayer == null)
            {
                MessageBox.Show("This renderer works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data", "Data missing");
                return(Task.FromResult(0));
            }
            return(QueuedTask.Run(() =>
            {
                //Define size of the dot to use for the renderer
                int dotSize = 3;
                //Check if the TOTPOP10 field exists
                int idxField = -1;
                using (var table = featureLayer.GetTable())
                {
                    var def = table.GetDefinition();
                    idxField = def.FindField("TOTPOP10");
                }
                // "TOTPOP10" field was not found
                if (idxField == -1)
                {
                    return;
                }

                //array of fields to be represented in the renderer
                string[] valueFields = new string[] { "TOTPOP10" };
                //Create the DotDensityRendererDefinition object
                var dotDensityDef = new DotDensityRendererDefinition(valueFields, SDKHelpers.GetColorRamp(),
                                                                     dotSize, 30000, "Dot", "people");
                //Create the renderer using the DotDensityRendererDefinition
                CIMDotDensityRenderer dotDensityRndr = (CIMDotDensityRenderer)featureLayer.CreateRenderer(dotDensityDef);

                //if you want to customize the dot symbol for the renderer, create a "DotDensitySymbol" which is an
                //Amalgamation of 3 symbol layers: CIMVectorMarker, CIMSolidFill and CIMSolidStroke
                //Define CIMVectorMarker layer
                var cimMarker = SymbolFactory.Instance.ConstructMarker(ColorFactory.Instance.RedRGB, dotSize);
                var dotDensityMarker = cimMarker as CIMVectorMarker;
                //Definte the placement
                CIMMarkerPlacementInsidePolygon markerPlacement = new CIMMarkerPlacementInsidePolygon {
                    Randomness = 100, GridType = PlacementGridType.RandomFixedQuantity, Clipping = PlacementClip.RemoveIfCenterOutsideBoundary
                };
                dotDensityMarker.MarkerPlacement = markerPlacement;

                //Define CIMSolidFill layer
                CIMSolidFill solidFill = new CIMSolidFill {
                    Color = new CIMRGBColor {
                        R = 249, G = 232, B = 189, Alpha = 50
                    }
                };

                //Define CIMSolidStroke
                CIMSolidStroke solidStroke = new CIMSolidStroke {
                    Color = ColorFactory.Instance.GreyRGB, Width = .5
                };

                //Create the amalgamated CIMPolygonSymbol that includes the 3 layers
                var dotDensitySymbol = new CIMPolygonSymbol
                {
                    SymbolLayers = new CIMSymbolLayer[] { dotDensityMarker, solidFill, solidStroke }
                };

                //Apply the dotDensitySymbol to the CIMDotDenstityRenderer's DotDensitySymbol property.
                dotDensityRndr.DotDensitySymbol = dotDensitySymbol.MakeSymbolReference();

                //Apply the renderer to the polygon Feature Layer.
                featureLayer.SetRenderer(dotDensityRndr);
            }));
        }