private static IStyleGalleryItem3 ConvertMarkerItemToRep(IStyleGalleryItem3 inputItem) { IMarkerSymbol markerSymbol = inputItem.Item as IMarkerSymbol; IRepresentationRule repRule = new RepresentationRuleClass(); IRepresentationRuleInit repRuleInit = repRule as IRepresentationRuleInit; repRuleInit.InitWithSymbol((ISymbol)markerSymbol); //initialize the rep rule with the marker IRepresentationGraphics representationGraphics = new RepresentationMarkerClass(); IGraphicAttributes graphicAttributes = null; IRepresentationGraphics tempMarkerGraphics = null; IGeometry tempGraphicGeometry = null; IRepresentationRule tempRule = null; //only pull the markers out. for (int i = 0; i < repRule.LayerCount; i++) { graphicAttributes = repRule.get_Layer(i) as IGraphicAttributes; tempMarkerGraphics = graphicAttributes.get_Value((int)esriGraphicAttribute.esriGAMarker) as IRepresentationGraphics; tempMarkerGraphics.Reset(); tempMarkerGraphics.Next(out tempGraphicGeometry, out tempRule); while (tempRule != null && tempGraphicGeometry != null) { representationGraphics.Add(tempGraphicGeometry, tempRule); tempGraphicGeometry = null; tempRule = null; tempMarkerGraphics.Next(out tempGraphicGeometry, out tempRule); } } IStyleGalleryItem3 newMarkerStyleGalleryItem = new ServerStyleGalleryItemClass(); newMarkerStyleGalleryItem.Item = representationGraphics; newMarkerStyleGalleryItem.Name = inputItem.Name; newMarkerStyleGalleryItem.Category = inputItem.Category; newMarkerStyleGalleryItem.Tags = inputItem.Tags.Replace(";emf", ""); //strip emf from the tags return(newMarkerStyleGalleryItem); }
private static IStyleGalleryItem3 ConvertMarkerItemToRep(IStyleGalleryItem3 inputItem) { IMarkerSymbol markerSymbol = inputItem.Item as IMarkerSymbol; IRepresentationRule repRule = new RepresentationRuleClass(); IRepresentationRuleInit repRuleInit = repRule as IRepresentationRuleInit; repRuleInit.InitWithSymbol((ISymbol)markerSymbol); //initialize the rep rule with the marker IRepresentationGraphics representationGraphics = new RepresentationMarkerClass(); IGraphicAttributes graphicAttributes = null; IRepresentationGraphics tempMarkerGraphics = null; IGeometry tempGraphicGeometry = null; IRepresentationRule tempRule = null; //only pull the markers out. for (int i = 0; i < repRule.LayerCount; i++) { graphicAttributes = repRule.get_Layer(i) as IGraphicAttributes; tempMarkerGraphics = graphicAttributes.get_Value((int)esriGraphicAttribute.esriGAMarker) as IRepresentationGraphics; tempMarkerGraphics.Reset(); tempMarkerGraphics.Next(out tempGraphicGeometry, out tempRule); while (tempRule != null && tempGraphicGeometry != null) { representationGraphics.Add(tempGraphicGeometry, tempRule); tempGraphicGeometry = null; tempRule = null; tempMarkerGraphics.Next(out tempGraphicGeometry, out tempRule); } } IStyleGalleryItem3 newMarkerStyleGalleryItem = new ServerStyleGalleryItemClass(); newMarkerStyleGalleryItem.Item = representationGraphics; newMarkerStyleGalleryItem.Name = inputItem.Name; newMarkerStyleGalleryItem.Category = inputItem.Category; newMarkerStyleGalleryItem.Tags = inputItem.Tags.Replace(";emf", ""); //strip emf from the tags return newMarkerStyleGalleryItem; }