0

I have empty geodatabase file with point geometry created programmatically. I have style file with several symbols.

I basically want to add all these symbols to my shapefile before creating features/geometry in shapefile. So when user starts editing he can select any of those symbols and drop on map (basically part of Add-in).

Using IStyleGallery I loop through all the symbols:

IEnumStyleGalleryItem enumStyleGalleryItem = styleGallery.get_Items("Marker Symbols", filePath, null);
enumStyleGalleryItem.Reset();
IStyleGalleryItem styleItem = enumStyleGalleryItem.Next();

while (styleItem != null)
{
   ISymbol symbol = styleItem.Item as ISymbol;
   IUniqueValueRenderer uniqueValueRenderer = new UniqueValueRendererClass();
   uniqueValueRenderer.AddValue(name, null, symbol);

   ?????
   some code to add all these symbols to layer.
}

I have reference to IGeoFeatureLayer but that does not help in adding all these symbols to layer.

Any help?

1

I was able to achieve it by following -

IEnumStyleGalleryItem enumStyleGalleryItem = styleGallery.get_Items("Marker Symbols", filePath, null);
enumStyleGalleryItem.Reset();
IStyleGalleryItem styleItem = enumStyleGalleryItem.Next();

IGeoFeatureLayer geoFeatureLayer = (IGeoFeatureLayer)pointsFeatureLayer;
ISymbol symbol;
IUniqueValueRenderer uniqueValueRenderer = new UniqueValueRendererClass();
uniqueValueRenderer.FieldCount = 1;
uniqueValueRenderer.set_Field(0, "Tooltip");

while (styleItem != null)
 {
     symbol = styleItem.Item as ISymbol;

     uniqueValueRenderer.AddValue(styleItem.Name, null, symbol);
     geoFeatureLayer.Renderer = (IFeatureRenderer)uniqueValueRenderer;

     styleItem = enumStyleGalleryItem.Next();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.