private void SetIconPrimitiveNames(CIMPointSymbol symbol, bool useWhite) { List <CIMColor> colors = new List <CIMColor>(); ColorUtil.CollectColors(symbol, colors); if (colors.Count == 1) { var color = colors[0]; bool colorIt = !useWhite || ColorUtil.IsBlackColor(color); if (colorIt) { UnlockAndSetPrimitiveName(symbol, (layer) => !useWhite || ColorUtil.IsBlackLayer(layer), "icon_element"); } else { SymbolUtil.LockAllLayers(symbol); // all locked - no color primitive name } } else if (colors.Count == 2) { var color1 = colors[0]; var color2 = colors[1]; bool colorIt = useWhite ? ((ColorUtil.IsBlackColor(color1) && ColorUtil.IsWhiteColor(color2)) || (ColorUtil.IsBlackColor(color2) && ColorUtil.IsWhiteColor(color1))) : ((ColorUtil.IsBlackColor(color1) && !ColorUtil.IsBlackColor(color2)) || (ColorUtil.IsBlackColor(color2) && !ColorUtil.IsBlackColor(color1))); if (colorIt) { UnlockAndSetPrimitiveName(symbol, (layer) => !ColorUtil.IsBlackLayer(layer), "icon_element"); } else { SymbolUtil.LockAllLayers(symbol); } } else { // all locked SymbolUtil.LockAllLayers(symbol); } ++_updatedSymbols; }
private void SetFramePrimitiveNames(CIMPointSymbol symbol, string key) { if (symbol == null) { return; } // verify that the point symbol has only one vector marker layer if (symbol.SymbolLayers == null) { return; } if (symbol.SymbolLayers.Length != 1) { return; } CIMVectorMarker marker = symbol.SymbolLayers[0] as CIMVectorMarker; if (marker == null) { return; } if (marker.MarkerGraphics == null) { return; } // find the fill marker CIMMarkerGraphic fill = null; CIMMarkerGraphic outline = null; double maxArea = 0; double maxLength = 0; foreach (var graphic in marker.MarkerGraphics) { if (graphic == null) { continue; } var hasFill = SymbolUtil.HasFill(graphic.Symbol as CIMMultiLayerSymbol); var hasStroke = SymbolUtil.IsStroke(graphic.Symbol as CIMMultiLayerSymbol); if (graphic.Geometry is ArcGIS.Core.Geometry.Multipart geom) { if (hasFill) { double area = Math.Abs(geom.Area); if (area > maxArea) { maxArea = area; fill = graphic; } } if (hasStroke) { double length = Math.Abs(geom.Length); if (length > maxLength) { maxLength = length; outline = graphic; } } } } // add the primitive names foreach (var graphic in marker.MarkerGraphics) { if (graphic == fill) { SymbolUtil.SetPrimitiveNames(graphic.Symbol as CIMMultiLayerSymbol, "frame_fill", "frame_outline", false, false); } else if (graphic == outline) { SymbolUtil.SetPrimitiveNames(graphic.Symbol as CIMMultiLayerSymbol, "frame_outline", "frame_outline", false, false); } else { SymbolUtil.SetPrimitiveNames(graphic.Symbol as CIMMultiLayerSymbol, "frame_outline", "frame_outline", false, false); } } ++_updatedSymbols; }