/// <summary>
        /// Create a polygon symbol with a cross hatch fill. <br/>
        /// ![PolygonSymbolCrossHatch](http://Esri.github.io/arcgis-pro-sdk/images/Symbology/polygon-crosshatch.png)
        /// </summary>
        /// <returns></returns>
        public static Task <CIMPolygonSymbol> CreateCrossHatchPolygonAsync()
        {
            return(QueuedTask.Run <CIMPolygonSymbol>(() =>
            {
                var trans = 50.0;//semi transparent
                CIMStroke outline = SymbolFactory.Instance.ConstructStroke(CIMColor.CreateRGBColor(0, 0, 0, trans), 2.0, SimpleLineStyle.Solid);

                //Stroke for the hatch fill
                var dash = SymbolFactory.Instance.ConstructStroke(CIMColor.CreateRGBColor(255, 170, 0, trans), 1.0, SimpleLineStyle.Dash);

                //Mimic cross hatch
                CIMFill[] crossHatch =
                {
                    new CIMHatchFill()
                    {
                        Enable = true,
                        Rotation = 0.0,
                        Separation = 5.0,
                        LineSymbol = new CIMLineSymbol()
                        {
                            SymbolLayers = new CIMSymbolLayer[1]{
                                dash
                            }
                        }
                    },
                    new CIMHatchFill()
                    {
                        Enable = true,
                        Rotation = 90.0,
                        Separation = 5.0,
                        LineSymbol = new CIMLineSymbol()
                        {
                            SymbolLayers = new CIMSymbolLayer[1]{
                                dash
                            }
                        }
                    }
                };
                List <CIMSymbolLayer> symbolLayers = new List <CIMSymbolLayer>();
                symbolLayers.Add(outline);
                foreach (var fill in crossHatch)
                {
                    symbolLayers.Add(fill);
                }
                return new CIMPolygonSymbol()
                {
                    SymbolLayers = symbolLayers.ToArray()
                };
            }));
        }
示例#2
0
        private CIMRenderer CreateniqueValueRendererForUSStatesUsingDefinition(FeatureLayer featureLayer)
        {
            //All of these methods have to be called on the MCT
            if (Module1.OnUIThread)
            {
                throw new CalledOnWrongThreadException();
            }

            // color ramp
            CIMICCColorSpace colorSpace = new CIMICCColorSpace()
            {
                URL = "Default RGB"
            };

            CIMContinuousColorRamp continuousColorRamp = new CIMLinearContinuousColorRamp();

            continuousColorRamp.FromColor  = CIMColor.CreateRGBColor(255, 255, 100); // yellow
            continuousColorRamp.ToColor    = CIMColor.CreateRGBColor(255, 0, 0);     // red
            continuousColorRamp.ColorSpace = colorSpace;

            CIMRandomHSVColorRamp randomHSVColorRamp = new CIMRandomHSVColorRamp()
            {
                ColorSpace = colorSpace,
                MinAlpha   = 100,
                MaxAlpha   = 100,
                MinH       = 0,
                MaxH       = 360,
                MinS       = 15,
                MaxS       = 30,
                MinV       = 99,
                MaxV       = 100,
                Seed       = 0
            };

            UniqueValueRendererDefinition uvRendererDef = new UniqueValueRendererDefinition()
            {
                ColorRamp        = continuousColorRamp, // randomHSVColorRamp,
                UseDefaultSymbol = true,
                ValueFields      = new List <string> {
                    "TOTPOP2010"
                }
            };

            //Configure the Renderer using the layer and the contents of the STATENAM
            //field
            return(featureLayer.CreateRenderer(uvRendererDef));
        }
示例#3
0
 private void BulkGraphicsCreation()
 {
     #region Bulk Graphics creation
     //Point Feature layer to convert into graphics
     var lyr = MapView.Active?.Map?.GetLayersAsFlattenedList().OfType <FeatureLayer>().FirstOrDefault();
     //Graphics layer to store the graphics to
     var gl = MapView.Active.Map.GetLayersAsFlattenedList().OfType <ArcGIS.Desktop.Mapping.GraphicsLayer>().FirstOrDefault();
     if (lyr == null)
     {
         return;
     }
     QueuedTask.Run(() =>
     {
         //Point symbol for graphics
         var pointSymbol = SymbolFactory.Instance.ConstructPointSymbol(CIMColor.CreateRGBColor(100, 255, 40), 10, SimpleMarkerStyle.Circle);
         //Collection to hold the point graphics
         var listGraphicElements = new List <CIMGraphic>();
         //Iterate through each point feature in the feature layer
         using (RowCursor rows = lyr.Search()) //execute
         {
             int i = 0;
             while (rows.MoveNext())
             {
                 using (var feature = rows.Current as Feature)
                 {
                     //Create a point graphic for the feature
                     var crimePt = feature.GetShape() as MapPoint;
                     if (crimePt != null)
                     {
                         var cimGraphicElement = new CIMPointGraphic
                         {
                             Location = crimePt, //MapPoint
                             Symbol   = pointSymbol.MakeSymbolReference()
                         };
                         //Add the point feature to the collection
                         listGraphicElements.Add(cimGraphicElement);
                         i++;
                     }
                 }
             }
         }
         //Magic happens...Add all the features to the Graphics layer
         gl.AddElements(listGraphicElements);
     });
     #endregion
 }
        /// <summary>
        /// Create a polygon symbol with a dash dot fill. <br/>
        /// ![PolygonSymbolDashDot](http://Esri.github.io/arcgis-pro-sdk/images/Symbology/polygon-dash-dot.png)
        /// </summary>
        /// <returns></returns>
        public static async Task <CIMPolygonSymbol> CreateDashDotFill()
        {
            var polyDashDotFill = await QueuedTask.Run(() =>
            {
                var trans         = 50.0;//semi transparent
                CIMStroke outline = SymbolFactory.Instance.ConstructStroke(CIMColor.CreateRGBColor(0, 0, 0, trans), 2.0, SimpleLineStyle.Solid);

                //Stroke for the fill
                var dashDot = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.RedRGB, 1.0, SimpleLineStyle.DashDotDot);
                //Mimic cross hatch
                CIMFill[] solidColorHatch =
                {
                    new CIMHatchFill()
                    {
                        Enable     = true,
                        Rotation   = 0.0,
                        Separation = 2.5,
                        LineSymbol = new CIMLineSymbol()
                        {
                            SymbolLayers = new CIMSymbolLayer[1]{
                                dashDot
                            }
                        }
                    },
                    new CIMSolidFill()
                    {
                        Enable = true,
                        Color  = ColorFactory.Instance.CreateRGBColor(255, 255, 0)
                    },
                };
                List <CIMSymbolLayer> symbolLayers = new List <CIMSymbolLayer>();
                symbolLayers.Add(outline);
                foreach (var fill in solidColorHatch)
                {
                    symbolLayers.Add(fill);
                }
                return(new CIMPolygonSymbol()
                {
                    SymbolLayers = symbolLayers.ToArray()
                });
            });

            return(polyDashDotFill);
        }
示例#5
0
        /// <summary>
        /// Create a polygon symbol with a gradient color fill. <br/>
        /// ![PolygonSymbolGradientColor](http://Esri.github.io/arcgis-pro-sdk/images/Symbology/polygon-gradient-color.png)
        /// </summary>
        /// <remarks>
        /// 1. Create a solid colored stroke with 50% transparency
        /// 1. Create a fill using gradient colors red through green
        /// 1. Apply both the stroke and fill as a symbol layer array to the new PolygonSymbol
        /// </remarks>
        /// <returns></returns>
        public static Task <CIMPolygonSymbol> CreateGradientFillAsync()
        {
            return(QueuedTask.Run <CIMPolygonSymbol>(() =>
            {
                var trans = 50.0;//semi transparent
                CIMStroke outline = SymbolFactory.Instance.ConstructStroke(CIMColor.CreateRGBColor(0, 0, 0, trans), 2.0, SimpleLineStyle.Solid);
                //Mimic cross hatch
                CIMFill solidColorHatch =
                    new CIMGradientFill()
                {
                    ColorRamp = ColorFactory.Instance.ConstructColorRamp(ColorRampAlgorithm.LinearContinuous,
                                                                         ColorFactory.Instance.RedRGB, ColorFactory.Instance.GreenRGB)
                };
                List <CIMSymbolLayer> symbolLayers = new List <CIMSymbolLayer>();
                symbolLayers.Add(outline);
                symbolLayers.Add(solidColorHatch);

                return new CIMPolygonSymbol()
                {
                    SymbolLayers = symbolLayers.ToArray()
                };
            }));
        }
示例#6
0
        public void UpdateColor(string colorValue)
        {
            // Update Status Color for Selected Point and Polygon Graphics
            QueuedTask.Run(() =>
            {
                // Take the currently selected text and update it as needed
                // get the first graphics layer in the map's collection of graphics layers
                var graphicsLayer = MapView.Active.Map.GetLayersAsFlattenedList()
                                    .OfType <ArcGIS.Desktop.Mapping.GraphicsLayer>().FirstOrDefault();
                if (graphicsLayer == null)
                {
                    return;
                }

                var selectedGraphicLayers = MapView.Active.GetSelectedLayers().OfType <GraphicsLayer>();
                if (selectedGraphicLayers.Count() == 0)
                { //nothing selected. So clear the selected graphic layer.
                    SelectedGraphicsLayerTOC = null;
                    MessageBox.Show("No graphic layer selected.", "Select layer");
                    return;
                }

                SelectedGraphicsLayerTOC = selectedGraphicLayers.FirstOrDefault();
                var selectedElements     = graphicsLayer.GetSelectedElements().
                                           OfType <GraphicElement>().Where(elem => elem.GetGraphic() is CIMPolygonGraphic || elem.GetGraphic() is CIMPointGraphic);

                if (selectedElements.Count() == 0)
                { //nothing selected. So clear the selected graphic layer.
                    MessageBox.Show("No point or polygon workflow graphics selected.", "Select graphics");
                    return;
                }

                CIMColor myColor = null;
                switch (colorValue)
                {
                case "red":
                    myColor = CIMColor.CreateRGBColor(255, 0, 0, 40);
                    break;

                case "yellow":
                    myColor = CIMColor.CreateRGBColor(255, 255, 0, 40);
                    break;

                case "green":
                    myColor = CIMColor.CreateRGBColor(0, 255, 0, 40);
                    break;
                }

                foreach (var elem in selectedElements)
                {
                    // Get the CIM Graphic and update it
                    if (elem.GetGraphic() is CIMPolygonGraphic)
                    {
                        var newCIMGraphic           = elem.GetGraphic() as CIMPolygonGraphic;
                        CIMPolygonSymbol polySymbol = SymbolFactory.Instance.ConstructPolygonSymbol(myColor);    //  (CIMColor.CreateRGBColor(CreateRGBColor(0, 255, 0, 50));
                        newCIMGraphic.Symbol        = polySymbol.MakeSymbolReference();
                        elem.SetGraphic(newCIMGraphic);
                    }

                    if (elem.GetGraphic() is CIMPointGraphic)
                    {
                        var newCIMGraphic          = elem.GetGraphic() as CIMPointGraphic;
                        CIMPointSymbol pointSymbol = SymbolFactory.Instance.ConstructPointSymbol(myColor);    //  (CIMColor.CreateRGBColor(CreateRGBColor(0, 255, 0, 50));
                        newCIMGraphic.Symbol       = pointSymbol.MakeSymbolReference();
                        elem.SetGraphic(newCIMGraphic);
                    }
                }
            });
        }
        /// <summary>
        /// Warning! You must call this method on the MCT!
        /// </summary>
        /// <returns></returns>
        private CIMRenderer CreateUniqueValueRendererForUSStates()
        {
            //All of these methods have to be called on the MCT
            if (Module1.OnUIThread)
            {
                throw new CalledOnWrongThreadException();
            }

            //Create the Unique Value Renderer
            CIMUniqueValueRenderer uniqueValueRenderer = new CIMUniqueValueRenderer()
            {
                // set the value field
                Fields = new string[] { "STATE_NAME" }
            };

            //Construct the list of UniqueValueClasses
            List <CIMUniqueValueClass> classes = new List <CIMUniqueValueClass>();

            // Alabama
            List <CIMUniqueValue> alabamaValues = new List <CIMUniqueValue>();
            CIMUniqueValue        alabamaValue  = new CIMUniqueValue()
            {
                FieldValues = new string[] { "Alabama" }
            };

            alabamaValues.Add(alabamaValue);

            var alabamaColor = CIMColor.CreateRGBColor(255, 170, 0);

            var alabama = new CIMUniqueValueClass()
            {
                Values   = alabamaValues.ToArray(),
                Label    = "Alabama",
                Visible  = true,
                Editable = true,
                Symbol   = new CIMSymbolReference()
                {
                    Symbol = SymbolFactory.Instance.ConstructPolygonSymbol(alabamaColor)
                }
            };

            classes.Add(alabama);

            // Alaska
            List <CIMUniqueValue> alaskaValues = new List <CIMUniqueValue>();
            CIMUniqueValue        alaskaValue  = new CIMUniqueValue()
            {
                FieldValues = new string[] { "Alaska" }
            };

            alaskaValues.Add(alaskaValue);

            var alaskaColor = CIMColor.CreateRGBColor(255, 0, 0);

            var alaska = new CIMUniqueValueClass()
            {
                Values   = alaskaValues.ToArray(),
                Label    = "Alaska",
                Visible  = true,
                Editable = true,
                Symbol   = new CIMSymbolReference()
                {
                    Symbol = SymbolFactory.Instance.ConstructPolygonSymbol(alaskaColor)
                }
            };

            classes.Add(alaska);

            // California
            List <CIMUniqueValue> californiaValues = new List <CIMUniqueValue>();
            CIMUniqueValue        californiaValue  = new CIMUniqueValue()
            {
                FieldValues = new string[] { "California" }
            };

            californiaValues.Add(californiaValue);

            var californiaColor = CIMColor.CreateRGBColor(85, 255, 0);

            var california = new CIMUniqueValueClass()
            {
                Values   = californiaValues.ToArray(),
                Label    = "California",
                Visible  = true,
                Editable = true,
                Symbol   = new CIMSymbolReference()
                {
                    Symbol = SymbolFactory.Instance.ConstructPolygonSymbol(californiaColor)
                }
            };

            classes.Add(california);

            // Colorado
            List <CIMUniqueValue> coloradoValues = new List <CIMUniqueValue>();
            CIMUniqueValue        coloradoValue  = new CIMUniqueValue()
            {
                FieldValues = new string[] { "Colorado" }
            };

            coloradoValues.Add(coloradoValue);

            var coloradoColor = CIMColor.CreateRGBColor(0, 92, 230);

            var colorado = new CIMUniqueValueClass()
            {
                Values   = coloradoValues.ToArray(),
                Label    = "Colorado",
                Visible  = true,
                Editable = true,
                Symbol   = new CIMSymbolReference()
                {
                    Symbol = SymbolFactory.Instance.ConstructPolygonSymbol(coloradoColor)
                }
            };

            classes.Add(colorado);

            // so on and so forth for all the 51.
            //....

            //Add the classes to a group (by default there is only one group or "symbol level")
            // Unique value groups
            CIMUniqueValueGroup groupOne = new CIMUniqueValueGroup()
            {
                Heading = "State Names",
                Classes = classes.ToArray()
            };

            uniqueValueRenderer.Groups = new CIMUniqueValueGroup[] { groupOne };

            //Draw the rest with the default symbol
            uniqueValueRenderer.UseDefaultSymbol = true;
            uniqueValueRenderer.DefaultLabel     = "All other values";

            var defaultColor = CIMColor.CreateRGBColor(215, 215, 215);

            uniqueValueRenderer.DefaultSymbol = new CIMSymbolReference()
            {
                Symbol = SymbolFactory.Instance.ConstructPolygonSymbol(defaultColor)
            };

            return(uniqueValueRenderer as CIMRenderer);
        }
示例#8
0
        private void CreateLayer()
        {
            Map map = MapView.Active.Map;

            #region Create layer with create-params
            var flyrCreatnParam = new FeatureLayerCreationParams(new Uri(@"c:\data\world.gdb\cities"))
            {
                Name             = "World Cities",
                IsVisible        = false,
                MinimumScale     = 1000000,
                MaximumScale     = 5000,
                DefinitionFilter = new CIMDefinitionFilter()
                {
                    DefinitionExpression = "Population > 100000",
                    Name = "More than 100k"
                },
                RendererDefinition = new SimpleRendererDefinition()
                {
                    SymbolTemplate = SymbolFactory.Instance.ConstructPointSymbol(CIMColor.CreateRGBColor(255, 0, 0), 8, SimpleMarkerStyle.Hexagon).MakeSymbolReference()
                }
            };

            var featureLayer = LayerFactory.Instance.CreateLayer <FeatureLayer>(flyrCreatnParam, map, LayerPosition.AutoArrange);
            #endregion

            #region Create a subtype group layer
            var subtypeGroupLayerCreateParam = new SubtypeGroupLayerCreationParams
                                               (
                new Uri(@"c:\data\SubtypeAndDomain.gdb\Fittings")
                                               );

            #region Define Subtype layers
            subtypeGroupLayerCreateParam.SubtypeLayers = new List <SubtypeFeatureLayerCreationParams>()
            {
                //define first subtype layer with unique value renderer
                new SubtypeFeatureLayerCreationParams()
                {
                    SubtypeId          = 1,
                    RendererDefinition = new UniqueValueRendererDefinition(new string[] { "type" })
                },

                //define second subtype layer with simple symbol renderer
                new SubtypeFeatureLayerCreationParams()
                {
                    SubtypeId          = 2,
                    RendererDefinition = new SimpleRendererDefinition()
                    {
                        SymbolTemplate = SymbolFactory.Instance.ConstructPointSymbol(CIMColor.CreateRGBColor(255, 0, 0), 8, SimpleMarkerStyle.Hexagon).MakeSymbolReference()
                    }
                }
            };
            #endregion

            #region Define additional parameters
            subtypeGroupLayerCreateParam.DefinitionFilter = new CIMDefinitionFilter()
            {
                Name = "IsActive",
                DefinitionExpression = "Enabled = 1"
            };
            subtypeGroupLayerCreateParam.IsVisible    = true;
            subtypeGroupLayerCreateParam.MinimumScale = 50000;
            #endregion

            SubtypeGroupLayer subtypeGroupLayer =
                LayerFactory.Instance.CreateLayer <SubtypeGroupLayer>(subtypeGroupLayerCreateParam, map);
            #endregion
        }
示例#9
0
        internal async void UpdateCluster(bool isTolerance)
        {
            if (MapView.Active == null)
            {
                return;
            }
            // Get Layer Name
            string inputFC = SelectedLayer.Name;

            int  minPoints = 2;
            bool parsed    = Int32.TryParse(MinPoints, out minPoints);

            /// Set PYT path -This could be inserted as a resource file //
            string tool_path = "C:\\Dev_summit\\2018\\InteractiveAnalytics\\pyt\\UpdateCluster.pyt\\UpdateClusterTool";

            IReadOnlyList <string> args = null;

            if (isTolerance)
            {
                /// Arguments for executing process using Tolerance
                args = Geoprocessing.MakeValueArray(inputFC, minPoints, ValueSlider, -1);
            }
            else
            {
                /// Arguments for executing process using Threshold
                args = Geoprocessing.MakeValueArray(inputFC, minPoints, -1, ValueThreshold);
            }

            Task <IGPResult> task;

            /// Execute the Tool in the python toolbox
            task = Geoprocessing.ExecuteToolAsync(tool_path, args, flags: GPExecuteToolFlags.AddToHistory);


            StyleProjectItem style;
            CIMPointSymbol   pointSymbol = null;

            /// Get Pro Styles
            style = await QueuedTask.Run <StyleProjectItem>(() => Project.Current.GetItems <StyleProjectItem>().First(s => s.Name == "ArcGIS 2D"));


            await QueuedTask.Run(() =>
            {
                /// Search for a specific Symbol
                /// Other styles Arcgis/Resouces/Styles/Styles.stylx SQLite DB
                SymbolStyleItem symbolStyleItem = (SymbolStyleItem)style.LookupItem(StyleItemType.PointSymbol, "Circle 1_Shapes_3");
                pointSymbol = (CIMPointSymbol)symbolStyleItem.Symbol;

                /// Cluster Ids based in Color Schema
                int[] ids = new int[] { -1, 1, 2, 3, 4, 5, 6, 7, 8 };

                /// Set Colors
                string[] colors = new string[] { "156,156,156", "166,206,227", "31,120,180", "178,223,138",
                                                 "51,160,44", "251,154,153", "227,26,28", "253,191,111",
                                                 "255,127,0" };
                /// Color Field
                String[] fields = new string[] { "COLOR_ID" };

                /// Make a reference of the point symbol
                CIMSymbolReference symbolPointTemplate = pointSymbol.MakeSymbolReference();

                /// Get definition of type symbology unique values
                UniqueValueRendererDefinition uniqueValueRendererDef = new UniqueValueRendererDefinition(fields, symbolPointTemplate, null, symbolPointTemplate, false);

                /// Get Current renderer of the Selected Layer
                CIMUniqueValueRenderer renderer  = (CIMUniqueValueRenderer)SelectedLayer.CreateRenderer(uniqueValueRendererDef);
                CIMUniqueValueClass[] newClasses = new CIMUniqueValueClass[colors.Count()];

                /// Get Point Symbol as string for creating other point colors
                string point = pointSymbol.ToXml();

                /// Create Each Color
                for (int i = 0; i < ids.Length; i++)
                {
                    CIMPointSymbol npoint = CIMPointSymbol.FromXml(point);
                    if (ids[i] == -1)
                    {
                        npoint.SetSize(4);
                    }
                    else
                    {
                        npoint.SetSize(6);
                    }
                    CIMSymbolReference symbolPointTemplatei = npoint.MakeSymbolReference();
                    newClasses[i]                          = new CIMUniqueValueClass();
                    newClasses[i].Values                   = new CIMUniqueValue[1];
                    newClasses[i].Values[0]                = new CIMUniqueValue();
                    newClasses[i].Values[0].FieldValues    = new string[1];
                    newClasses[i].Values[0].FieldValues[0] = ids[i].ToString();
                    newClasses[i].Label                    = ids[i].ToString();
                    newClasses[i].Symbol                   = symbolPointTemplatei;
                    var color = colors[i].Split(',');
                    double r  = Convert.ToDouble(color[0]);
                    double g  = Convert.ToDouble(color[1]);
                    double b  = Convert.ToDouble(color[2]);
                    newClasses[i].Symbol.Symbol.SetColor(CIMColor.CreateRGBColor(r, g, b));
                }
                /// Add Colors into the renderer
                renderer.Groups[0].Classes = newClasses;

                /// Apply new renderer in the layer
                SelectedLayer.SetRenderer(renderer);

                //SelectedLayer.RecalculateRenderer();
            });
        }
        /// <summary>
        /// On activating this MapTool, the sketch segment symbology is modified along with the symbologies of the
        /// unselected current and unselected regular vertices of the sketch.
        /// The SketchSymbol property of the MapTool is also modified, which is different from the sketch segment and vertices.
        /// This property is used to customize the fixed part of the sketch, i.e. the part of the sketch that shows you what the
        /// output will look like if you finish the sketch right then without doing any more edits.
        /// </summary>
        /// <param name="active"></param>
        /// <returns></returns>
        protected override Task OnToolActivateAsync(bool active)
        {
            var darkBlue = new CIMRGBColor()
            {
                R = 0, G = 76, B = 153
            };
            var lightBlue = new CIMRGBColor()
            {
                R = 102, G = 178, B = 255
            };
            var darkGreen = new CIMRGBColor()
            {
                R = 0, G = 153, B = 0
            };
            var lightGreen = new CIMRGBColor()
            {
                R = 102, G = 255, B = 102
            };
            var red = new CIMRGBColor()
            {
                R = 153, G = 0, B = 0
            };
            var white = new CIMRGBColor()
            {
                R = 255, G = 255, B = 255
            };

            //return base.OnToolActivateAsync(active);
            return(QueuedTask.Run(() =>
            {
                //Getting the current symbology options of the segment
                var segmentOptions = GetSketchSegmentSymbolOptions();
                //Modifying the primary color, secondary color, and the width of the segment symbology options
                segmentOptions.PrimaryColor = darkBlue;
                segmentOptions.Width = 1.5;
                segmentOptions.SecondaryColor = lightBlue;

                //Creating a new vertex symbol options instances with the values you want
                //Vertex symbol options instance 1
                var vertexOptions = new VertexSymbolOptions(VertexSymbolType.RegularUnselected);
                vertexOptions.Color = darkGreen;
                vertexOptions.MarkerType = VertexMarkerType.Circle;
                vertexOptions.OutlineColor = lightGreen;
                vertexOptions.OutlineWidth = 4;
                vertexOptions.Size = 8;

                //Vertex symbol options instance 2
                var vertexOptions2 = new VertexSymbolOptions(VertexSymbolType.CurrentUnselected);
                vertexOptions2.Color = white;
                vertexOptions2.OutlineColor = red;
                vertexOptions2.MarkerType = VertexMarkerType.PushPin;
                vertexOptions2.OutlineWidth = 5;
                vertexOptions2.Size = 10;

                try
                {
                    //Setting the value of the segment symbol options
                    SetSketchSegmentSymbolOptions(segmentOptions);

                    //Setting the value of the vertex symbol options of the regular unselected vertices using the vertexOptions instance 1 created above.
                    SetSketchVertexSymbolOptions(VertexSymbolType.RegularUnselected, vertexOptions);
                    //Setting symbol options of current unselected vertex
                    SetSketchVertexSymbolOptions(VertexSymbolType.CurrentUnselected, vertexOptions2);

                    //Similarly you can set symbol options for current selected vertex and regular selected vertex
                    //SetSketchVertexSymbolOptions(VertexSymbolType.CurrentSelected, vertexOptions3);
                    //SetSketchVertexSymbolOptions(VertexSymbolType.RegularSelected, vertexOptions4);

                    //Modifying the SketchSymbol property of the MapTool
                    var yellow = CIMColor.CreateRGBColor(255, 215, 0);
                    var cimLineSymbol = SymbolFactory.Instance.ConstructLineSymbol(yellow, 4, SimpleLineStyle.DashDotDot);
                    base.SketchSymbol = cimLineSymbol.MakeSymbolReference();
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine($@"Unexpected Exception: {ex}");
                }
            }));
        }
示例#11
0
 protected override Task OnToolActivateAsync(bool active)
 {
     _lineSymbol = SymbolFactory.Instance.ConstructLineSymbol(CIMColor.CreateRGBColor(0, 0, 0), 4.0, SimpleLineStyle.Solid);
     return(base.OnToolActivateAsync(active));
 }
示例#12
0
 protected override Task OnToolActivateAsync(bool active)
 {
     _polygonSymbol = SymbolFactory.Instance.ConstructPolygonSymbol(CIMColor.CreateRGBColor(255, 255, 0));
     return(base.OnToolActivateAsync(active));
 }
示例#13
0
        public async void Example6()
        {
            Map map = MapView.Active.Map;
            await QueuedTask.Run(() =>
            {
                StreamLayer streamLayer = null;
                //https://geoeventsample1.esri.com:6443/arcgis/rest/services/AirportTraffics/StreamServer

                #region Defining a unique value renderer definition

                var uvrDef = new UniqueValueRendererDefinition()
                {
                    ValueFields    = new string[] { "ACTYPE" },
                    SymbolTemplate = SymbolFactory.Instance.ConstructPointSymbol(
                        ColorFactory.Instance.RedRGB, 10, SimpleMarkerStyle.Hexagon)
                                     .MakeSymbolReference(),
                    ValuesLimit = 5
                };
                //Note: CreateRenderer can only create value classes based on
                //the current events it has received
                streamLayer.SetRenderer(streamLayer.CreateRenderer(uvrDef));

                #endregion

                #region Setting a unique value renderer for latest observations

                //Define the classes by hand to avoid using CreateRenderer(...)
                CIMUniqueValueClass uvcB727 = new CIMUniqueValueClass()
                {
                    Values = new CIMUniqueValue[] { new CIMUniqueValue()
                                                    {
                                                        FieldValues = new string[] { "B727" }
                                                    } },
                    Visible = true,
                    Label   = "Boeing 727",
                    Symbol  = SymbolFactory.Instance.ConstructPointSymbol(CIMColor.CreateRGBColor(255, 0, 0), 8, SimpleMarkerStyle.Hexagon).MakeSymbolReference()
                };

                CIMUniqueValueClass uvcD9 = new CIMUniqueValueClass()
                {
                    Values = new CIMUniqueValue[] { new CIMUniqueValue()
                                                    {
                                                        FieldValues = new string[] { "DC9" }
                                                    } },
                    Visible = true,
                    Label   = "DC 9",
                    Symbol  = SymbolFactory.Instance.ConstructPointSymbol(CIMColor.CreateRGBColor(0, 255, 0), 8, SimpleMarkerStyle.Hexagon).MakeSymbolReference()
                };
                //Assign the classes to a group
                CIMUniqueValueGroup uvGrp = new CIMUniqueValueGroup()
                {
                    Classes = new CIMUniqueValueClass[] { uvcB727, uvcD9 }
                };
                //assign the group to the renderer
                var UVrndr = new CIMUniqueValueRenderer()
                {
                    Fields           = new string[] { "ACTYPE" },
                    Groups           = new CIMUniqueValueGroup[] { uvGrp },
                    UseDefaultSymbol = true,
                    DefaultLabel     = "Others",
                    DefaultSymbol    = SymbolFactory.Instance.ConstructPointSymbol(
                        CIMColor.CreateRGBColor(185, 185, 185), 8, SimpleMarkerStyle.Hexagon).MakeSymbolReference()
                };
                //set the renderer. Depending on the current events recieved, the
                //layer may or may not have events for each of the specified
                //unique value classes
                streamLayer.SetRenderer(UVrndr);

                #endregion

                #region Setting a unique value renderer for previous observations
                //The layer must be track aware and spatial
                if (streamLayer.TrackType != TrackType.Spatial)
                {
                    return;
                }
                //Must be on QueuedTask!
                //Define unique value classes same as we do for current observations
                //or use "CreateRenderer(...)" to assign them automatically
                CIMUniqueValueClass uvcB727Prev = new CIMUniqueValueClass()
                {
                    Values = new CIMUniqueValue[] { new CIMUniqueValue()
                                                    {
                                                        FieldValues = new string[] { "B727" }
                                                    } },
                    Visible = true,
                    Label   = "Boeing 727",
                    Symbol  = SymbolFactory.Instance.ConstructPointSymbol(
                        CIMColor.CreateRGBColor(255, 0, 0), 4, SimpleMarkerStyle.Hexagon)
                              .MakeSymbolReference()
                };

                CIMUniqueValueClass uvcD9Prev = new CIMUniqueValueClass()
                {
                    Values = new CIMUniqueValue[] { new CIMUniqueValue()
                                                    {
                                                        FieldValues = new string[] { "DC9" }
                                                    } },
                    Visible = true,
                    Label   = "DC 9",
                    Symbol  = SymbolFactory.Instance.ConstructPointSymbol(
                        CIMColor.CreateRGBColor(0, 255, 0), 4, SimpleMarkerStyle.Hexagon)
                              .MakeSymbolReference()
                };

                CIMUniqueValueGroup uvGrpPrev = new CIMUniqueValueGroup()
                {
                    Classes = new CIMUniqueValueClass[] { uvcB727Prev, uvcD9Prev }
                };

                var UVrndrPrev = new CIMUniqueValueRenderer()
                {
                    Fields           = new string[] { "ACTYPE" },
                    Groups           = new CIMUniqueValueGroup[] { uvGrpPrev },
                    UseDefaultSymbol = true,
                    DefaultLabel     = "Others",
                    DefaultSymbol    = SymbolFactory.Instance.ConstructPointSymbol(
                        CIMColor.CreateRGBColor(185, 185, 185), 4, SimpleMarkerStyle.Hexagon)
                                       .MakeSymbolReference()
                };

                #endregion

                #region Setting a simple renderer to draw track lines
                //The layer must be track aware and spatial
                if (streamLayer.TrackType != TrackType.Spatial)
                {
                    return;
                }
                //Must be on QueuedTask!
                //Note: only a simple renderer with solid line symbol is supported for track
                //line renderer
                var trackRenderer = new SimpleRendererDefinition()
                {
                    SymbolTemplate = SymbolFactory.Instance.ConstructLineSymbol(
                        ColorFactory.Instance.BlueRGB, 2, SimpleLineStyle.Solid)
                                     .MakeSymbolReference()
                };
                streamLayer.SetRenderer(
                    streamLayer.CreateRenderer(trackRenderer),
                    FeatureRendererTarget.TrackLines);

                #endregion

                #region Check Previous Observation and Track Line Visibility

                //The layer must be track aware and spatial for these settings
                //to have an effect
                if (streamLayer.TrackType != TrackType.Spatial)
                {
                    return;
                }
                //Must be on QueuedTask
                if (!streamLayer.AreTrackLinesVisible)
                {
                    streamLayer.SetTrackLinesVisibility(true);
                }
                if (!streamLayer.ArePreviousObservationsVisible)
                {
                    streamLayer.SetPreviousObservationsVisibility(true);
                }

                #endregion

                #region Make Track Lines and Previous Observations Visible
                //The layer must be track aware and spatial for these settings
                //to have an effect
                if (streamLayer.TrackType != TrackType.Spatial)
                {
                    return;
                }
                //Must be on QueuedTask
                //Note: Setting PreviousObservationsCount larger than the
                //"SetExpirationMaxCount()" has no effect
                streamLayer.SetPreviousObservationsCount(6);
                if (!streamLayer.AreTrackLinesVisible)
                {
                    streamLayer.SetTrackLinesVisibility(true);
                }
                if (!streamLayer.ArePreviousObservationsVisible)
                {
                    streamLayer.SetPreviousObservationsVisibility(true);
                }
                #endregion


                #region Retrieve the current observation renderer

                //Must be on QueuedTask!
                var renderer = streamLayer.GetRenderer();

                #endregion

                #region Retrieve the previous observation renderer
                //The layer must be track aware and spatial
                if (streamLayer.TrackType != TrackType.Spatial)
                {
                    return;
                }
                //Must be on QueuedTask!
                var prev_renderer = streamLayer.GetRenderer(
                    FeatureRendererTarget.PreviousObservations);

                #endregion

                #region Retrieve the track lines renderer
                //The layer must be track aware and spatial
                if (streamLayer.TrackType != TrackType.Spatial)
                {
                    return;
                }
                //Must be on QueuedTask!
                var track_renderer = streamLayer.GetRenderer(
                    FeatureRendererTarget.TrackLines);

                #endregion
            });
        }
示例#14
0
        public async void Example4()
        {
            Map map = MapView.Active.Map;
            await QueuedTask.Run(() =>
            {
                //StreamLayer streamLayer = null;
                //

                #region Setting a unique value renderer for latest observations

                var url = @"https://geoeventsample1.esri.com:6443/arcgis/rest/services/AirportTraffics/StreamServer";
                var uri = new Uri(url, UriKind.Absolute);
                //Must be on QueuedTask!
                var createParams = new FeatureLayerCreationParams(uri)
                {
                    IsVisible = false
                };
                var streamLayer = LayerFactory.Instance.CreateLayer <StreamLayer>(
                    createParams, map);
                //Define the unique values by hand
                var uvr = new CIMUniqueValueRenderer()
                {
                    Fields           = new string[] { "ACTYPE" },
                    UseDefaultSymbol = true,
                    DefaultLabel     = "Others",
                    DefaultSymbol    = SymbolFactory.Instance.ConstructPointSymbol(
                        CIMColor.CreateRGBColor(185, 185, 185), 8, SimpleMarkerStyle.Hexagon).MakeSymbolReference()
                };

                var classes = new List <CIMUniqueValueClass>();
                //add in classes - one for ACTYPE of 727, one for DC 9
                classes.Add(
                    new CIMUniqueValueClass()
                {
                    Values = new CIMUniqueValue[] {
                        new CIMUniqueValue()
                        {
                            FieldValues = new string[] { "B727" }
                        }
                    },
                    Visible = true,
                    Label   = "Boeing 727",
                    Symbol  = SymbolFactory.Instance.ConstructPointSymbol(
                        ColorFactory.Instance.RedRGB, 10, SimpleMarkerStyle.Hexagon).MakeSymbolReference()
                });
                classes.Add(
                    new CIMUniqueValueClass()
                {
                    Values = new CIMUniqueValue[] {
                        new CIMUniqueValue()
                        {
                            FieldValues = new string[] { "DC9" }
                        }
                    },
                    Visible = true,
                    Label   = "DC 9",
                    Symbol  = SymbolFactory.Instance.ConstructPointSymbol(
                        ColorFactory.Instance.GreenRGB, 10, SimpleMarkerStyle.Hexagon).MakeSymbolReference()
                });
                //add the classes to a group
                var groups = new List <CIMUniqueValueGroup>()
                {
                    new CIMUniqueValueGroup()
                    {
                        Classes = classes.ToArray()
                    }
                };
                //add the groups to the renderer
                uvr.Groups = groups.ToArray();
                //Apply the renderer (for current observations)
                streamLayer.SetRenderer(uvr);
                streamLayer.SetVisibility(true);//turn on the layer

                #endregion
            });
        }
示例#15
0
        public static async Task DisplayMaps(string strAoiPath)
        {
            BA_Objects.Aoi oAoi = Module1.Current.Aoi;
            if (String.IsNullOrEmpty(oAoi.Name))
            {
                if (System.IO.Directory.Exists(strAoiPath))
                {
                    // Initialize AOI object
                    oAoi = new BA_Objects.Aoi("animas_AOI_prms", strAoiPath);
                    // Store current AOI in Module1
                    Module1.Current.Aoi = oAoi;
                }
                else
                {
                    ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("!!Please set an AOI before testing the maps", "BAGIS Pro");
                }
            }

            Map oMap = await MapTools.SetDefaultMapNameAsync(Constants.MAPS_DEFAULT_MAP_NAME);

            if (oMap != null)
            {
                if (oMap.Layers.Count() > 0)
                {
                    string strMessage = "Adding the maps to the display will overwrite the current arrangement of data layers. " +
                                        "This action cannot be undone." + System.Environment.NewLine + "Do you wish to continue ?";
                    MessageBoxResult oRes = ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(strMessage, "BAGIS", MessageBoxButton.YesNo);
                    if (oRes != MessageBoxResult.Yes)
                    {
                        return;
                    }
                }

                Layout layout = await MapTools.GetDefaultLayoutAsync(Constants.MAPS_DEFAULT_LAYOUT_NAME);

                if (layout != null)
                {
                    bool bFoundIt = false;
                    //A layout view may exist but it may not be active
                    //Iterate through each pane in the application and check to see if the layout is already open and if so, activate it
                    foreach (var pane in ProApp.Panes)
                    {
                        if (!(pane is ILayoutPane layoutPane))  //if not a layout view, continue to the next pane
                        {
                            continue;
                        }
                        if (layoutPane.LayoutView.Layout == layout) //if there is a match, activate the view
                        {
                            (layoutPane as Pane).Activate();
                            bFoundIt = true;
                        }
                    }
                    if (!bFoundIt)
                    {
                        ILayoutPane iNewLayoutPane = await ProApp.Panes.CreateLayoutPaneAsync(layout); //GUI thread
                    }
                    await MapTools.SetDefaultMapFrameDimensionAsync(Constants.MAPS_DEFAULT_MAP_FRAME_NAME, layout, oMap,
                                                                    1.0, 2.0, 7.5, 9.0);

                    //remove existing layers from map frame
                    await MapTools.RemoveLayersfromMapFrame();

                    //add aoi boundary to map and zoom to layer
                    string strPath = GeodatabaseTools.GetGeodatabasePath(oAoi.FilePath, GeodatabaseNames.Aoi, true) +
                                     Constants.FILE_AOI_VECTOR;
                    Uri aoiUri = new Uri(strPath);
                    await MapTools.AddAoiBoundaryToMapAsync(aoiUri, Constants.MAPS_AOI_BOUNDARY);

                    //add Snotel Represented Area Layer
                    strPath = GeodatabaseTools.GetGeodatabasePath(oAoi.FilePath, GeodatabaseNames.Analysis, true) +
                              Constants.FILE_SNOTEL_REPRESENTED;
                    Uri           uri       = new Uri(strPath);
                    CIMColor      fillColor = CIMColor.CreateRGBColor(255, 0, 0, 50); //Red with 30% transparency
                    BA_ReturnCode success   = await MapTools.AddPolygonLayerAsync(uri, fillColor, false, Constants.MAPS_SNOTEL_REPRESENTED);

                    if (success.Equals(BA_ReturnCode.Success))
                    {
                        Module1.ToggleState("MapButtonPalette_BtnSnotel_State");
                    }

                    // add aoi streams layer
                    strPath = GeodatabaseTools.GetGeodatabasePath(oAoi.FilePath, GeodatabaseNames.Layers, true) +
                              Constants.FILE_STREAMS;
                    uri = new Uri(strPath);
                    await MapTools.AddLineLayerAsync(uri, Constants.MAPS_STREAMS, ColorFactory.Instance.BlueRGB);

                    // add Snotel Layer
                    strPath = GeodatabaseTools.GetGeodatabasePath(oAoi.FilePath, GeodatabaseNames.Layers, true) +
                              Constants.FILE_SNOTEL;
                    uri     = new Uri(strPath);
                    success = await MapTools.AddPointMarkersAsync(uri, Constants.MAPS_SNOTEL, ColorFactory.Instance.BlueRGB,
                                                                  SimpleMarkerStyle.X, 16);

                    if (success == BA_ReturnCode.Success)
                    {
                        Module1.Current.AoiHasSnotel = true;
                    }

                    // add Snow Course Layer
                    strPath = GeodatabaseTools.GetGeodatabasePath(oAoi.FilePath, GeodatabaseNames.Layers, true) +
                              Constants.FILE_SNOW_COURSE;
                    uri     = new Uri(strPath);
                    success = await MapTools.AddPointMarkersAsync(uri, Constants.MAPS_SNOW_COURSE, CIMColor.CreateRGBColor(0, 255, 255),
                                                                  SimpleMarkerStyle.Star, 16);

                    if (success == BA_ReturnCode.Success)
                    {
                        Module1.Current.AoiHasSnowCourse = true;
                    }

                    // add hillshade layer
                    strPath = GeodatabaseTools.GetGeodatabasePath(oAoi.FilePath, GeodatabaseNames.Surfaces, true) +
                              Constants.FILE_HILLSHADE;
                    uri = new Uri(strPath);
                    await MapTools.DisplayRasterAsync(uri, Constants.MAPS_HILLSHADE, 0);

                    // add elev zones layer
                    strPath = GeodatabaseTools.GetGeodatabasePath(oAoi.FilePath, GeodatabaseNames.Analysis, true) +
                              Constants.FILE_ELEV_ZONE;
                    uri = new Uri(strPath);
                    await MapTools.DisplayRasterWithSymbolAsync(uri, Constants.MAPS_ELEV_ZONE, "ArcGIS Colors",
                                                                "Elevation #2", "NAME", 30, true);

                    Module1.ToggleState("MapButtonPalette_BtnElevation_State");

                    // add slope zones layer
                    strPath = GeodatabaseTools.GetGeodatabasePath(oAoi.FilePath, GeodatabaseNames.Analysis, true) +
                              Constants.FILE_SLOPE_ZONE;
                    uri = new Uri(strPath);
                    await MapTools.DisplayRasterWithSymbolAsync(uri, Constants.MAPS_SLOPE_ZONE, "ArcGIS Colors",
                                                                "Slope", "NAME", 30, false);

                    Module1.ToggleState("MapButtonPalette_BtnSlope_State");

                    // add aspect zones layer
                    strPath = GeodatabaseTools.GetGeodatabasePath(oAoi.FilePath, GeodatabaseNames.Analysis, true) +
                              Constants.FILE_ASPECT_ZONE;
                    uri = new Uri(strPath);
                    await MapTools.DisplayRasterWithSymbolAsync(uri, Constants.MAPS_ASPECT_ZONE, "ArcGIS Colors",
                                                                "Aspect", "NAME", 30, false);

                    Module1.ToggleState("MapButtonPalette_BtnAspect_State");


                    // create map elements
                    await MapTools.AddMapElements(Constants.MAPS_DEFAULT_LAYOUT_NAME, "ArcGIS Colors", "1.5 Point");

                    await MapTools.DisplayNorthArrowAsync(layout, Constants.MAPS_DEFAULT_MAP_FRAME_NAME);

                    await MapTools.DisplayScaleBarAsync(layout, Constants.MAPS_DEFAULT_MAP_FRAME_NAME);

                    // update map elements for default map (elevation)
                    BA_Objects.MapDefinition defaultMap = MapTools.LoadMapDefinition(BagisMapType.ELEVATION);
                    await MapTools.UpdateMapElementsAsync(layout, Module1.Current.Aoi.Name.ToUpper(), defaultMap);

                    await MapTools.UpdateLegendAsync(layout, defaultMap);


                    //zoom to aoi boundary layer
                    double bufferFactor = 1.1;
                    bool   bZoomed      = await MapTools.ZoomToExtentAsync(aoiUri, bufferFactor);
                }
            }
        }
        public void btnChangeRoomSymbology(object sender, EventArgs e)
        {
            var polygonSymbology = ((RadioButton)sender).Tag;

            QueuedTask.Run(() =>
            {
                //Get the active map's definition - CIMMap.

                if (polygonSymbology.ToString() == "None")
                {
                    var cimMap = MapView.Active.Map.GetDefinition();
                    Debug.WriteLine(cimMap.ToString());
                    Debug.WriteLine(cimMap.ToXml());

                    //FeatureLayer a = MapView.Active.Map.Layers[1] as FeatureLayer;
                    var lyr = MapView.Active.Map.GetLayersAsFlattenedList().OfType <FeatureLayer>().FirstOrDefault(s => s.ShapeType == esriGeometryType.esriGeometryPolygon);
                    CIMSimpleRenderer renderer = lyr.GetRenderer() as CIMSimpleRenderer;
                    CIMStroke outline          = SymbolFactory.Instance.ConstructStroke(
                        ColorFactory.Instance.GreyRGB, 0.5, SimpleLineStyle.Solid);
                    CIMPolygonSymbol fillWithOutline = SymbolFactory.Instance.ConstructPolygonSymbol(
                        ColorFactory.Instance.CreateRGBColor(255, 255, 255), SimpleFillStyle.Solid, outline);
                    //Update the symbol of the current simple renderer
                    renderer.Symbol = fillWithOutline.MakeSymbolReference();
                    //Update the feature layer renderer
                    lyr.SetRenderer(renderer);
                }
                if (polygonSymbology.ToString() == "Multicolor1")
                {
                    Debug.WriteLine("Multicolor1");
                    var cimMap = MapView.Active.Map.GetDefinition();
                    //FeatureLayer a = MapView.Active.Map.Layers[1] as FeatureLayer;
                    var lyr = MapView.Active.Map.GetLayersAsFlattenedList().OfType <FeatureLayer>().FirstOrDefault(s => s.ShapeType == esriGeometryType.esriGeometryPolygon);
                    CIMUniqueValueRenderer renderer = lyr.GetRenderer() as CIMUniqueValueRenderer;

                    // color ramp
                    CIMICCColorSpace colorSpace = new CIMICCColorSpace()
                    {
                        URL = "Default RGB"
                    };

                    CIMRandomHSVColorRamp randomHSVColorRamp = new CIMRandomHSVColorRamp()
                    {
                        ColorSpace = colorSpace,
                        MinAlpha   = 100,
                        MaxAlpha   = 100,
                        MinH       = 0,
                        MaxH       = 360,
                        MinS       = 15,
                        MaxS       = 30,
                        MinV       = 99,
                        MaxV       = 100,
                        Seed       = 0
                    };


                    UniqueValueRendererDefinition uvr = new UniqueValueRendererDefinition()
                    {
                        ValueFields = new string[] { "GROUP_DESCRIPTION" }, //multiple fields in the array if needed.
                        ColorRamp   = randomHSVColorRamp                    //Specify color ramp
                    };



                    var r = lyr.CreateRenderer(uvr);
                    //var sc = r.GetSchema();
                    lyr.SetRenderer(r);

                    CIMUniqueValueRenderer r2 = lyr.GetRenderer() as CIMUniqueValueRenderer;
                    foreach (var item in r2.Groups)
                    {
                        var g = item as CIMUniqueValueGroup;

                        foreach (var c in g.Classes)
                        {
                            if (c.Label == "Multiple") //change this to 'Multiple'
                            {
                                //example for simple color
                                //var alaskaColor = CIMColor.CreateRGBColor(255, 0, 0);
                                //var s = new CIMSymbolReference() { Symbol = SymbolFactory.Instance.ConstructPolygonSymbol(alaskaColor) };

                                List <CIMSymbolLayer> symbolLayers = new List <CIMSymbolLayer>();
                                CIMStroke outline = SymbolFactory.Instance.ConstructStroke(CIMColor.CreateRGBColor(0, 0, 0, 50.0), 2.0, SimpleLineStyle.Solid);
                                symbolLayers.Add(outline);
                                var solid      = SymbolFactory.Instance.ConstructStroke(CIMColor.CreateRGBColor(255, 0, 0, 50.0), 1.0, SimpleLineStyle.Solid);
                                CIMHatchFill h = new CIMHatchFill()
                                {
                                    Enable     = true,
                                    Rotation   = -45.0,
                                    Separation = 5.0,
                                    LineSymbol = new CIMLineSymbol()
                                    {
                                        SymbolLayers = new CIMSymbolLayer[1] {
                                            solid
                                        }
                                    }
                                };
                                symbolLayers.Add(h);
                                CIMPolygonSymbol p = new CIMPolygonSymbol()
                                {
                                    SymbolLayers = symbolLayers.ToArray()
                                };
                                var s = new CIMSymbolReference()
                                {
                                    Symbol = p
                                };
                                c.Symbol = s;
                            }
                        }
                    }
                    lyr.SetRenderer(r2);
                }
                if (polygonSymbology.ToString() == "Multicolor2")
                {
                    Debug.WriteLine("Multicolor2");
                    var cimMap = MapView.Active.Map.GetDefinition();
                    //FeatureLayer a = MapView.Active.Map.Layers[1] as FeatureLayer;
                    var lyr = MapView.Active.Map.GetLayersAsFlattenedList().OfType <FeatureLayer>().FirstOrDefault(s => s.ShapeType == esriGeometryType.esriGeometryPolygon);
                    CIMUniqueValueRenderer renderer = lyr.GetRenderer() as CIMUniqueValueRenderer;

                    // color ramp
                    CIMICCColorSpace colorSpace = new CIMICCColorSpace()
                    {
                        URL = "Default RGB"
                    };

                    CIMRandomHSVColorRamp randomHSVColorRamp = new CIMRandomHSVColorRamp()
                    {
                        ColorSpace = colorSpace,
                        MinAlpha   = 100,
                        MaxAlpha   = 100,
                        MinH       = 0,
                        MaxH       = 360,
                        MinS       = 15,
                        MaxS       = 30,
                        MinV       = 99,
                        MaxV       = 100,
                        Seed       = 0
                    };


                    UniqueValueRendererDefinition uvr = new UniqueValueRendererDefinition()
                    {
                        ValueFields = new string[] { "FUNCTION_DESCRIPTION" }, //multiple fields in the array if needed.
                        ColorRamp   = randomHSVColorRamp                       //Specify color ramp
                    };



                    var r = lyr.CreateRenderer(uvr);
                    //var sc = r.GetSchema();
                    lyr.SetRenderer(r);

                    CIMUniqueValueRenderer r2 = lyr.GetRenderer() as CIMUniqueValueRenderer;
                    foreach (var item in r2.Groups)
                    {
                        var g = item as CIMUniqueValueGroup;

                        foreach (var c in g.Classes)
                        {
                            if (c.Label == "Multiple") //change this to 'Multiple'
                            {
                                //example for simple color
                                //var alaskaColor = CIMColor.CreateRGBColor(255, 0, 0);
                                //var s = new CIMSymbolReference() { Symbol = SymbolFactory.Instance.ConstructPolygonSymbol(alaskaColor) };

                                List <CIMSymbolLayer> symbolLayers = new List <CIMSymbolLayer>();
                                CIMStroke outline = SymbolFactory.Instance.ConstructStroke(CIMColor.CreateRGBColor(0, 0, 0, 50.0), 2.0, SimpleLineStyle.Solid);
                                symbolLayers.Add(outline);
                                var solid      = SymbolFactory.Instance.ConstructStroke(CIMColor.CreateRGBColor(255, 0, 0, 50.0), 1.0, SimpleLineStyle.Solid);
                                CIMHatchFill h = new CIMHatchFill()
                                {
                                    Enable     = true,
                                    Rotation   = -45.0,
                                    Separation = 5.0,
                                    LineSymbol = new CIMLineSymbol()
                                    {
                                        SymbolLayers = new CIMSymbolLayer[1] {
                                            solid
                                        }
                                    }
                                };
                                symbolLayers.Add(h);
                                CIMPolygonSymbol p = new CIMPolygonSymbol()
                                {
                                    SymbolLayers = symbolLayers.ToArray()
                                };
                                var s = new CIMSymbolReference()
                                {
                                    Symbol = p
                                };
                                c.Symbol = s;
                            }
                        }
                    }
                    lyr.SetRenderer(r2);
                }
                if (polygonSymbology.ToString() == "Multicolor3")
                {
                    Debug.WriteLine("Multicolor2");
                    var cimMap = MapView.Active.Map.GetDefinition();
                    //FeatureLayer a = MapView.Active.Map.Layers[1] as FeatureLayer;
                    var lyr = MapView.Active.Map.GetLayersAsFlattenedList().OfType <FeatureLayer>().FirstOrDefault(s => s.ShapeType == esriGeometryType.esriGeometryPolygon);
                    CIMUniqueValueRenderer renderer = lyr.GetRenderer() as CIMUniqueValueRenderer;

                    // color ramp
                    CIMICCColorSpace colorSpace = new CIMICCColorSpace()
                    {
                        URL = "Default RGB"
                    };

                    CIMRandomHSVColorRamp randomHSVColorRamp = new CIMRandomHSVColorRamp()
                    {
                        ColorSpace = colorSpace,
                        MinAlpha   = 100,
                        MaxAlpha   = 100,
                        MinH       = 0,
                        MaxH       = 360,
                        MinS       = 15,
                        MaxS       = 30,
                        MinV       = 99,
                        MaxV       = 100,
                        Seed       = 0
                    };


                    UniqueValueRendererDefinition uvr = new UniqueValueRendererDefinition()
                    {
                        ValueFields = new string[] { "USE_CODE_DESCRIPTION" }, //multiple fields in the array if needed.
                        ColorRamp   = randomHSVColorRamp                       //Specify color ramp
                    };



                    var r = lyr.CreateRenderer(uvr);

                    //var sc = r.GetSchema();
                    lyr.SetRenderer(r);

                    CIMUniqueValueRenderer r2 = lyr.GetRenderer() as CIMUniqueValueRenderer;


                    foreach (var item in r2.Groups)
                    {
                        var g = item as CIMUniqueValueGroup;

                        foreach (var c in g.Classes)
                        {
                            if (c.Label == "Multiple") //change this to 'Multiple'
                            {
                                //example for simple color
                                //var alaskaColor = CIMColor.CreateRGBColor(255, 0, 0);
                                //var s = new CIMSymbolReference() { Symbol = SymbolFactory.Instance.ConstructPolygonSymbol(alaskaColor) };

                                List <CIMSymbolLayer> symbolLayers = new List <CIMSymbolLayer>();
                                CIMStroke outline = SymbolFactory.Instance.ConstructStroke(CIMColor.CreateRGBColor(0, 0, 0, 50.0), 2.0, SimpleLineStyle.Solid);
                                symbolLayers.Add(outline);
                                var solid      = SymbolFactory.Instance.ConstructStroke(CIMColor.CreateRGBColor(255, 0, 0, 50.0), 1.0, SimpleLineStyle.Solid);
                                CIMHatchFill h = new CIMHatchFill()
                                {
                                    Enable     = true,
                                    Rotation   = -45.0,
                                    Separation = 5.0,
                                    LineSymbol = new CIMLineSymbol()
                                    {
                                        SymbolLayers = new CIMSymbolLayer[1] {
                                            solid
                                        }
                                    }
                                };
                                symbolLayers.Add(h);
                                CIMPolygonSymbol p = new CIMPolygonSymbol()
                                {
                                    SymbolLayers = symbolLayers.ToArray()
                                };
                                var s = new CIMSymbolReference()
                                {
                                    Symbol = p
                                };
                                c.Symbol = s;
                            }
                        }
                    }
                    lyr.SetRenderer(r2);
                }
                if (polygonSymbology.ToString() == "Beige")
                {
                    var cimMap = MapView.Active.Map.GetDefinition();
                    //FeatureLayer a = MapView.Active.Map.Layers[1] as FeatureLayer;
                    var lyr = MapView.Active.Map.GetLayersAsFlattenedList().OfType <FeatureLayer>().FirstOrDefault(s => s.ShapeType == esriGeometryType.esriGeometryPolygon);
                    //CIMSimpleRenderer renderer = lyr.GetRenderer() as CIMSimpleRenderer;
                    CIMSimpleRenderer renderer = new CIMSimpleRenderer()
                    {
                    };
                    CIMStroke outline = SymbolFactory.Instance.ConstructStroke(
                        ColorFactory.Instance.GreyRGB, 0.5, SimpleLineStyle.Solid);
                    CIMPolygonSymbol fillWithOutline = SymbolFactory.Instance.ConstructPolygonSymbol(
                        ColorFactory.Instance.CreateRGBColor(255, 222, 173), SimpleFillStyle.Solid, outline);

                    //Update the symbol of the current simple renderer
                    renderer.Symbol = fillWithOutline.MakeSymbolReference();
                    //Update the feature layer renderer
                    lyr.SetRenderer(renderer);

                    /*
                     *
                     * unique value rendere
                     * internal static Task UniqueValueRenderer(FeatureLayer featureLayer)
                     * {
                     * return QueuedTask.Run(() =>
                     * {
                     * //construct unique value renderer definition
                     * UniqueValueRendererDefinition uvr = new
                     * UniqueValueRendererDefinition()
                     * {
                     * ValueFields = new string[] { SDKHelpers.GetDisplayField(featureLayer) }, //multiple fields in the array if needed.
                     * ColorRamp = SDKHelpers.GetColorRamp(), //Specify color ramp
                     * };
                     *
                     * //Creates a "Renderer"
                     * var cimRenderer = featureLayer.CreateRenderer(uvr);
                     *
                     * //Sets the renderer to the feature layer
                     * featureLayer.SetRenderer(cimRenderer);
                     * });
                     *
                     * }
                     *
                     *
                     * diagonal cross hatch example
                     * public static Task<CIMPolygonSymbol> CreateDiagonalCrossPolygonAsync()
                     * {
                     * return QueuedTask.Run<CIMPolygonSymbol>(() =>
                     * {
                     * var trans = 50.0;//semi transparent
                     * CIMStroke outline = SymbolFactory.Instance.ConstructStroke(CIMColor.CreateRGBColor(0, 0, 0, trans), 2.0, SimpleLineStyle.Solid);
                     *
                     * //Stroke for the fill
                     * var solid = SymbolFactory.Instance.ConstructStroke(CIMColor.CreateRGBColor(255, 0, 0, trans), 1.0, SimpleLineStyle.Solid);
                     *
                     * //Mimic cross hatch
                     * CIMFill[] diagonalCross =
                     * {
                     * new CIMHatchFill() {
                     * Enable = true,
                     * Rotation = 45.0,
                     * Separation = 5.0,
                     * LineSymbol = new CIMLineSymbol() { SymbolLayers = new CIMSymbolLayer[1] { solid } }
                     * },
                     * new CIMHatchFill() {
                     * Enable = true,
                     * Rotation = -45.0,
                     * Separation = 5.0,
                     * LineSymbol = new CIMLineSymbol() { SymbolLayers = new CIMSymbolLayer[1] { solid } }
                     * }
                     * };
                     * List<CIMSymbolLayer> symbolLayers = new List<CIMSymbolLayer>();
                     * symbolLayers.Add(outline);
                     * foreach (var fill in diagonalCross)
                     * symbolLayers.Add(fill);
                     * return new CIMPolygonSymbol() { SymbolLayers = symbolLayers.ToArray() };
                     * });
                     * }
                     */
                }
            });

            Debug.WriteLine(MapView.Active.Map.Layers[0].Name); // .SetLabelVisibility(true);
            Debug.WriteLine(MapView.Active.Map.Layers[1].Name); // .SetLabelVisibility(true);
            //Debug.WriteLine(MapView.Active.Map.SetLabelEngine
        }