private void UnlockAndSetPrimitiveName(CIMMultiLayerSymbol symbol, Func <CIMSymbolLayer, bool> UnlockIt, string name)
        {
            if (symbol == null)
            {
                return;
            }
            if (symbol.SymbolLayers == null)
            {
                return;
            }
            foreach (var layer in symbol.SymbolLayers)
            {
                layer.ColorLocked = false;

                if (layer is CIMVectorMarker)
                {
                    var markerGraphics = (layer as CIMVectorMarker).MarkerGraphics;
                    if (markerGraphics != null)
                    {
                        foreach (var markerGraphic in markerGraphics)
                        {
                            if (markerGraphic.Symbol is CIMMultiLayerSymbol)
                            {
                                UnlockAndSetPrimitiveName(markerGraphic.Symbol as CIMMultiLayerSymbol, UnlockIt, name);
                            }
                            if (markerGraphic.Symbol is CIMTextSymbol)
                            {
                                // we don't set the primitive name on the internal polygon symbol, but rather on the text marker graphic
                                // still, we want the color locking to be set
                                UnlockAndSetPrimitiveName((markerGraphic.Symbol as CIMTextSymbol).Symbol as CIMMultiLayerSymbol, UnlockIt, "");
                                markerGraphic.PrimitiveName = name;
                            }
                        }
                    }
                }

                // mark the layer as fill or outline
                if (layer is CIMFill || layer is CIMStroke)
                {
                    if (UnlockIt(layer))
                    {
                        layer.PrimitiveName = name;
                    }
                    else
                    {
                        layer.ColorLocked = true;
                    }
                    if (layer is CIMHatchFill hatchFill)
                    {
                        UnlockAndSetPrimitiveName(hatchFill.LineSymbol, UnlockIt, name);
                    }
                }
            }
        }
Пример #2
0
        static public void SetPrimitiveNames(CIMMultiLayerSymbol symbol, string frame_fill, string frame_outline, bool just_black, bool markers)
        {
            if (symbol == null)
            {
                return;
            }

            // check if we can remove some layers
            // TODO

            if (symbol.SymbolLayers == null)
            {
                return;
            }
            foreach (var layer in symbol.SymbolLayers)
            {
                if (markers && layer is CIMVectorMarker)
                {
                    var markerGraphics = (layer as CIMVectorMarker).MarkerGraphics;
                    if (markerGraphics != null)
                    {
                        foreach (var markerGraphic in markerGraphics)
                        {
                            if (markerGraphic.Symbol is CIMMultiLayerSymbol)
                            {
                                SetPrimitiveNames(markerGraphic.Symbol as CIMMultiLayerSymbol, frame_fill, frame_outline, just_black, markers);
                            }
                        }
                    }
                }

                // mark the layer as fill or outline
                if (layer is CIMFill && frame_fill != null)
                {
                    if (!just_black || ColorUtil.IsNeutralColor(layer))
                    {
                        layer.PrimitiveName = frame_fill;
                    }
                    if (layer is CIMHatchFill hatchFill)
                    {
                        SetPrimitiveNames(hatchFill.LineSymbol, frame_fill, frame_outline, just_black, markers);
                    }
                }
                if (layer is CIMStroke && frame_outline != null)
                {
                    if (!just_black || ColorUtil.IsNeutralColor(layer))
                    {
                        layer.PrimitiveName = frame_outline;
                    }
                }
            }
        }
Пример #3
0
        static public void CollectColors(CIMMultiLayerSymbol symbol, List <CIMColor> colors)
        {
            if (symbol == null)
            {
                return;
            }
            if (symbol.SymbolLayers == null)
            {
                return;
            }
            foreach (var layer in symbol.SymbolLayers)
            {
                if (layer is CIMVectorMarker)
                {
                    var markerGraphics = (layer as CIMVectorMarker).MarkerGraphics;
                    if (markerGraphics != null)
                    {
                        foreach (var markerGraphic in markerGraphics)
                        {
                            if (markerGraphic.Symbol is CIMMultiLayerSymbol)
                            {
                                CollectColors(markerGraphic.Symbol as CIMMultiLayerSymbol, colors);
                            }
                            if (markerGraphic.Symbol is CIMTextSymbol)
                            {
                                CollectColors((markerGraphic.Symbol as CIMTextSymbol).Symbol as CIMMultiLayerSymbol, colors);
                            }
                        }
                    }
                }

                // mark the layer as fill or outline
                if (layer is CIMSolidFill)
                {
                    if (!ContainsColor(colors, (layer as CIMSolidFill).Color))
                    {
                        colors.Add((layer as CIMSolidFill).Color);
                    }
                }
                if (layer is CIMSolidStroke)
                {
                    if (!ContainsColor(colors, (layer as CIMSolidStroke).Color))
                    {
                        colors.Add((layer as CIMSolidStroke).Color);
                    }
                }
                if (layer is CIMHatchFill)
                {
                    CollectColors((layer as CIMHatchFill).LineSymbol, colors);
                }
            }
        }
Пример #4
0
 static public void LockAllLayers(CIMMultiLayerSymbol symbol)
 {
     if (symbol == null)
     {
         return;
     }
     if (symbol.SymbolLayers == null)
     {
         return;
     }
     foreach (var layer in symbol.SymbolLayers)
     {
         if (layer == null)
         {
             continue;
         }
         layer.ColorLocked = true;
     }
 }
Пример #5
0
 static public bool HasFill(CIMMultiLayerSymbol symbol)
 {
     if (symbol == null)
     {
         return(false);
     }
     if (symbol.SymbolLayers == null)
     {
         return(false);
     }
     foreach (var layer in symbol.SymbolLayers)
     {
         if (layer is CIMFill)
         {
             return(true);
         }
     }
     return(false);
 }
Пример #6
0
 static public bool IsStroke(CIMMultiLayerSymbol symbol)
 {
     if (symbol == null)
     {
         return(false);
     }
     if (symbol.SymbolLayers == null)
     {
         return(false);
     }
     foreach (var layer in symbol.SymbolLayers)
     {
         if (layer is CIMStroke)
         {
             return(true);
         }
         return(false); // stroke only
     }
     return(false);
 }
Пример #7
0
        /// <summary>
        /// Call this method to apply symbol groups to the featureLayer - one group per value in the renderer.
        /// The first group to be added will be the first group to be drawn
        /// </summary>
        /// <param name="featureLayer"></param>
        private void SetUpSymbolLevelsForUSHighways(FeatureLayer featureLayer)
        {
            //All of these methods have to be called on the MCT
            if (Module1.OnUIThread)
            {
                throw new CalledOnWrongThreadException();
            }

            CIMBaseLayer baseLayer = featureLayer.GetDefinition();
            //We need CIMGeoFeatureLayerBase because this class controls whether or not we
            //use 'groups' (ie Pro Symbol Levels) with the renderer
            CIMGeoFeatureLayerBase geoFeatureLayer = baseLayer as CIMGeoFeatureLayerBase;

            // assume the unique value renderer was created using the CreateCIMRenderer()
            CIMUniqueValueRenderer uniqueValueRenderer = geoFeatureLayer.Renderer as CIMUniqueValueRenderer;

            CIMSymbolLayerDrawing symbolLayerDrawing = new CIMSymbolLayerDrawing()
            {
                // This flag controls the drawing code and forces it to use defined symbol layers.
                //It must be set 'true'
                UseSymbolLayerDrawing = true
            };

            // setup the symbol layers.
            List <CIMSymbolLayerIdentifier> symbolLayers = new List <CIMSymbolLayerIdentifier>();

            // this will be a for loop that will iterate over the unique value classes and updating the symbol in each class
            int index = 0;

            foreach (CIMUniqueValueGroup nextGroup in uniqueValueRenderer.Groups)
            {
                foreach (CIMUniqueValueClass nextClass in nextGroup.Classes)
                {
                    CIMMultiLayerSymbol multiLayerSymbol = nextClass.Symbol.Symbol as CIMMultiLayerSymbol;
                    if (multiLayerSymbol == null) //This check probably is not needed
                    {
                        continue;
                    }
                    //Each group must be uniquely named
                    string uniqueName = "Group_" + index.ToString();
                    nextClass.Symbol.SymbolName = uniqueName;

                    for (int i = 0; i < multiLayerSymbol.SymbolLayers.Length; i++)
                    {
                        //Assign the unique name to all of the layers in the symbol
                        multiLayerSymbol.SymbolLayers[i].Name = uniqueName;
                    }

                    index++;
                    //Assign the name to a 'CIMSymbolLayerIdentifier'. This is the equivalent
                    //of a KeyValuePair in a Dictionary. The Names of each SymbolLayerIdentifier
                    //will be matched up in the renderer to a corresponding symbol (via nextClass.Symbol.SymbolName)
                    //So that each SymbolLayer is associated with a specific symbol for a specific value
                    CIMSymbolLayerIdentifier nextSymbolLayer = new CIMSymbolLayerIdentifier()
                    {
                        SymbolLayerName = uniqueName
                    };

                    symbolLayers.Add(nextSymbolLayer);
                }
            }
            //This is where the symbol layers get added to the feature layer definition
            symbolLayerDrawing.SymbolLayers    = symbolLayers.ToArray();
            geoFeatureLayer.SymbolLayerDrawing = symbolLayerDrawing;

            // update the featureLayer definition.
            featureLayer.SetDefinition(geoFeatureLayer as  CIMBaseLayer);
        }