ConstructPolygonSymbol(CIMColor,SimpleFillStyle,CIMStroke) Method
Constructs a polygon symbol of specific color, style and outline.
Create rectangle graphic with simple symbology
//Create a simple 2D rectangle graphic and apply simple fill and
//outline symbols.
//Construct on the worker thread
await QueuedTask.Run(() =>
{
//Build 2D envelope geometry
Coordinate2D rec_ll = new Coordinate2D(1.0, 4.75);
Coordinate2D rec_ur = new Coordinate2D(3.0, 5.75);
//At 2.x - Envelope rec_env = EnvelopeBuilder.CreateEnvelope(rec_ll, rec_ur);
Envelope rec_env = EnvelopeBuilderEx.CreateEnvelope(rec_ll, rec_ur);
//Set symbolology, create and add element to layout
CIMStroke outline = SymbolFactory.Instance.ConstructStroke(
ColorFactory.Instance.BlackRGB, 5.0, SimpleLineStyle.Solid);
CIMPolygonSymbol polySym = SymbolFactory.Instance.ConstructPolygonSymbol(
ColorFactory.Instance.GreenRGB, SimpleFillStyle.DiagonalCross, outline);
//At 2.x - GraphicElement recElm =
// LayoutElementFactory.Instance.CreateRectangleGraphicElement(
// layout, rec_env, polySym);
// recElm.SetName("New Rectangle");
//
GraphicElement recElm = ElementFactory.Instance.CreateGraphicElement(
container, rec_env, polySym, "New Rectangle");
//Or use Predefined shape
GraphicElement recElm2 = ElementFactory.Instance.CreatePredefinedShapeGraphicElement(
container, PredefinedShape.Rectangle, rec_env, polySym,
"New Rectangle2");
});
How to construct a polygon symbol of specific color, fill style and outline
CIMStroke outline = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlueRGB, 2.0, SimpleLineStyle.Solid);
CIMPolygonSymbol fillWithOutline = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB, SimpleFillStyle.Solid, outline);
How to construct a polygon symbol without an outline
CIMPolygonSymbol fillWithoutOutline = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB, SimpleFillStyle.Solid, null);
Target Platforms: Windows 11, Windows 10, Windows 8.1
ArcGIS Pro version: 2.0 or higher.