I want to change the fill of polygons, when the user press a button. I am using this to get the render of the layer:
CIMSimpleRenderer currentRenderer = layer.GetRenderer() as CIMSimpleRenderer;
I am saving this render in a dict, to be able to change back later.
I am creating this, I want to alter to change the color of the polygons:
CIMSimpleRenderer newRenderer = layer.GetRenderer() as CIMSimpleRenderer;
I am using this to make a new fill:
var fill = SymbolFactory.Instance.ConstructSolidFill(ColorFactory.Instance.CreateRGBColor(0, 0, 0));
How can I add the fill to the newRender?
For every polygon feature layer in TOC, I want to change the fill color, but retain the outline color.
Solved! Go to Solution.
Since you have access to the SymbolLayers, you can manipulate any of these layers.
//Get the layers in the symbol
var symbolLayer = polygonSymbol.SymbolLayers.ToList();
//Can modify the layers in the symbol anyway you want.
Symbols are made of layers. You can extract the symbol layers from your renderer's symbol and add the fill symbol to these layers. Here is a code snippet
var renderer = lyr.GetRenderer() as CIMSimpleRenderer;
//Get the renderer's symbol and cast it to the type of symbol
var polygonSymbol = renderer.Symbol.Symbol as CIMPolygonSymbol;
//Get the layers in the symbol
var symbolLayer = polygonSymbol.SymbolLayers.ToList();
//Create a solid fill symbol layer
var fill = SymbolFactory.Instance.ConstructSolidFill(ColorFactory.Instance.RedRGB);
//Add the fill to the symbol layers
symbolLayer.Add(fill);
//Set the symbol layers back to the symbol
polygonSymbol.SymbolLayers = symbolLayer.ToArray();
//Set the symbol back to the renderer
renderer.Symbol.Symbol = polygonSymbol;
//Set the renderer back to the layer
lyr.SetRenderer(renderer);
You can see the renderer's symbol layers in the UI Like this:
Hi Uma, thanks for your answer.
I added the new fill, and can see it like this:
But is there a way, to turn off the visibility of the middle symbol layer?
Since you have access to the SymbolLayers, you can manipulate any of these layers.
//Get the layers in the symbol
var symbolLayer = polygonSymbol.SymbolLayers.ToList();
//Can modify the layers in the symbol anyway you want.