Parameters
- color
- ArcGIS.Core.CIM.CIMColor
- width
- The width of stroke to construct.
//Create a polygon graphic using an envelope with simple line and fill styles. //Construct on the worker thread await QueuedTask.Run(() => { //Build 2D envelope Coordinate2D env_ll = new Coordinate2D(1.0, 4.75); Coordinate2D env_ur = new Coordinate2D(3.0, 5.75); //At 2.x - Envelope env = EnvelopeBuilder.CreateEnvelope(env_ll, env_ur); Envelope env = EnvelopeBuilderEx.CreateEnvelope(env_ll, env_ur); //Set symbolology, create and add element to layout CIMStroke outline = SymbolFactory.Instance.ConstructStroke( ColorFactory.Instance.BlueRGB, 2.0, SimpleLineStyle.DashDotDot); CIMPolygonSymbol polySym = SymbolFactory.Instance.ConstructPolygonSymbol( ColorFactory.Instance.RedRGB, SimpleFillStyle.ForwardDiagonal, outline); //At 2.x - GraphicElement polyElm = // LayoutElementFactory.Instance.CreatePolygonGraphicElement(layout, env, polySym); // polyElm.SetName("New Polygon"); GraphicElement polyElm = ElementFactory.Instance.CreateGraphicElement( layout, env, polySym, "New Polygon"); });
//Create a circle graphic element using a simple line and fill styles. //Construct on the worker thread await QueuedTask.Run(() => { //Build geometry Coordinate2D center = new Coordinate2D(2, 4); //At 2.x - EllipticArcBuilder eabCir = new EllipticArcBuilder(center, 0.5, esriArcOrientation.esriArcClockwise); var eabCir = new EllipticArcBuilderEx(center, 0.5, ArcOrientation.ArcClockwise); EllipticArcSegment cir = eabCir.ToSegment(); //Set symbolology, create and add element to layout CIMStroke outline = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlackRGB, 2.0, SimpleLineStyle.Dash); CIMPolygonSymbol circleSym = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB, SimpleFillStyle.Solid, outline); //At 2.x - GraphicElement cirElm = LayoutElementFactory.Instance.CreateCircleGraphicElement(layout, cir, circleSym); // cirElm.SetName("New Circle"); var polyLine = PolylineBuilderEx.CreatePolyline(cir); GraphicElement cirElm = ElementFactory.Instance.CreateGraphicElement(layout, polyLine, circleSym, "New Circle"); });
//Create an ellipse graphic with simple line and fill styles. //Construct on the worker thread await QueuedTask.Run(() => { //Build geometry Coordinate2D center = new Coordinate2D(2, 2.75); //At 2.x - EllipticArcBuilder eabElp = new EllipticArcBuilder(center, 0, 1, 0.45, esriArcOrientation.esriArcClockwise); var eabElp = new EllipticArcBuilderEx(center, 0, 1, 0.45, ArcOrientation.ArcClockwise); EllipticArcSegment ellipse = eabElp.ToSegment(); //Set symbolology, create and add element to layout CIMStroke outline = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.GreenRGB, 2.0, SimpleLineStyle.Dot); CIMPolygonSymbol ellipseSym = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.GreyRGB, SimpleFillStyle.Vertical, outline); //At 2.x - GraphicElement elpElm = LayoutElementFactory.Instance.CreateEllipseGraphicElement(layout, ellipse, ellipseSym); // elpElm.SetName("New Ellipse"); var polyLine = PolylineBuilderEx.CreatePolyline(ellipse); GraphicElement elpElm = ElementFactory.Instance.CreateGraphicElement(layout, polyLine, ellipseSym, "New Ellipse"); });
CIMStroke stroke = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlackRGB, 2.0); CIMLineSymbol lineSymbolFromStroke = SymbolFactory.Instance.ConstructLineSymbol(stroke);
//These methods must be called within the lambda passed to QueuedTask.Run var lineStrokeRed = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.RedRGB, 4.0); var markerCircle = SymbolFactory.Instance.ConstructMarker(ColorFactory.Instance.RedRGB, 12, SimpleMarkerStyle.Circle); markerCircle.MarkerPlacement = new CIMMarkerPlacementOnVertices() { AngleToLine = true, PlaceOnEndPoints = true, Offset = 0 }; var lineSymbolWithCircles = new CIMLineSymbol() { SymbolLayers = new CIMSymbolLayer[2] { markerCircle, lineStrokeRed } };
Target Platforms: Windows 11, Windows 10