Parameters
- color
- ArcGIS.Core.CIM.CIMColor
- width
- The width of stroke to construct.
- lineStyle
- SimpleLineStyle
/// <summary> /// Create a polygon symbol with a diagonal cross hatch fill. <br/> ///  /// </summary> { 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 = [ outline, .. diagonalCross ]; //This is the polygon symbol with a diagonal cross hatch fill CIMPolygonSymbol diagonalCrossHatchFillSymbol = new() { SymbolLayers = [.. symbolLayers] }; //To apply the symbol to a polygon feature layer //var renderer = theLayer.GetRenderer() as CIMSimpleRenderer; //renderer.Symbol = diagonalCrossHatchFillSymbol.MakeSymbolReference(); //theLayer.SetRenderer(renderer); }
/// <summary> /// Create a polygon symbol using the ConstructHatchFill method . <br/> ///  /// </summary> { CIMStroke lineStroke = SymbolFactory.Instance.ConstructStroke(CIMColor.CreateRGBColor(51, 51, 51, 60), 4, SimpleLineStyle.Solid); //gradient var hatchFill = SymbolFactory.Instance.ConstructHatchFill(lineStroke, 45, 6, 0); List<CIMSymbolLayer> symbolLayers = new() { hatchFill }; //This is the polygon symbol with a diagonal cross hatch fill CIMPolygonSymbol crossHatchPolygonSymbol = new CIMPolygonSymbol() { SymbolLayers = symbolLayers.ToArray() }; //To apply the symbol to a polygon feature layer //var renderer = theLayer.GetRenderer() as CIMSimpleRenderer; //renderer.Symbol = crossHatchPolygonSymbol.MakeSymbolReference(); //theLayer.SetRenderer(renderer); }
/// <summary> /// Create a polygon symbol with a dash dot fill. <br/> ///  /// </summary> { //Note: Run withing QueuedTask 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 = [outline, .. solidColorHatch]; //This is the polygon symbol with a dash dot fill CIMPolygonSymbol dashDotFillPolygon = new CIMPolygonSymbol() { SymbolLayers = symbolLayers.ToArray() }; //To apply the symbol to a polygon feature layer //var renderer = theLayer.GetRenderer() as CIMSimpleRenderer; //renderer.Symbol = dashDotFillPolygon.MakeSymbolReference(); //theLayer.SetRenderer(renderer); }
/// <summary> /// Create a polygon symbol with a gradient color fill. <br/> ///  /// 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 /// </summary> { //Note: Run withing QueuedTask 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> { outline, solidColorHatch }; CIMPolygonSymbol gradientColorFillPolygon = new CIMPolygonSymbol() { SymbolLayers = symbolLayers.ToArray() }; //To apply the symbol to a polygon feature layer //var renderer = theLayer.GetRenderer() as CIMSimpleRenderer; //renderer.Symbol = gradientColorFillPolygon.MakeSymbolReference(); //theLayer.SetRenderer(renderer); }
/// <summary> /// Create a polygon symbol using the ConstructGradientFill method. Constructs a gradient fill using the specified color ramp. <br/> ///  /// </summary> { //Note: Run withing QueuedTask //outine CIMStroke outline = SymbolFactory.Instance.ConstructStroke(CIMColor.CreateRGBColor(49, 49, 49), 2.0, SimpleLineStyle.Solid); //gradient fill using a color ramp var gradientFill = SymbolFactory.Instance.ConstructGradientFill(GetColorRamp(), GradientFillMethod.Linear); List<CIMSymbolLayer> symbolLayers = new List<CIMSymbolLayer> { outline, gradientFill }; CIMPolygonSymbol gradientColorRampSymbol = new CIMPolygonSymbol() { SymbolLayers = symbolLayers.ToArray() }; //To apply the symbol to a polygon feature layer //var renderer = theLayer.GetRenderer() as CIMSimpleRenderer; //renderer.Symbol = gradientColorRampSymbol.MakeSymbolReference(); //theLayer.SetRenderer(renderer); //Helper method to get a color ramp from the "ArcGIS Colors" style. static CIMColorRamp GetColorRamp() { //Get a ColorRamp StyleProjectItem style = Project.Current.GetItems<StyleProjectItem>().FirstOrDefault(s => s.Name == "ArcGIS Colors"); var colorRampList = style.SearchColorRamps("Heat Map 4 - Semitransparent"); CIMColorRamp colorRamp = colorRampList[0].ColorRamp; return colorRamp; } }
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)