AnsweredAssumed Answered

Legend and Envelope in 10 SP3

Question asked by sclark98 on Dec 8, 2011
Latest reply on Dec 16, 2011 by mharol
Something has changed in programmatically creating legends in a pagelayout in SP3. In SP2, I would define an envelope and the legenditems (broken into multiple columns, if necessary) would fit into the envelope. The same code in SP3 doesn't do that anymore. This is from a custom map generator where there could be anywhere from 1 to 40+ legenditems. How do I get this to work again in SP3 where the legenditems expand/contract to the envelope?

                IGraphicsContainer graphicsContainer = pageLayout as IGraphicsContainer;
                IMapFrame mapFrame = graphicsContainer.FindFrame(map) as IMapFrame;
                ESRI.ArcGIS.esriSystem.IUID uid = new ESRI.ArcGIS.esriSystem.UIDClass();
                uid.Value = "esriCarto.Legend";
                IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame((ESRI.ArcGIS.esriSystem.UID)uid, null);
                ILegend pLegend = (ILegend)mapSurroundFrame.Object;


                ...(code to weed out legenditems and break into multiple columns)...

                IEnvelope envelope = new EnvelopeClass();
                envelope.PutCoords(8.8, 0.85, (8.8 + 5.95), (0.85 + 1.45));
                IElement pLegendElement = mapSurroundFrame as IElement; 
                pLegendElement.Geometry = envelope;
                graphicsContainer.AddElement(pLegendElement, 0);

Attachments

Outcomes