gshdet

Legend Position

Discussion created by gshdet on Jul 13, 2013
Latest reply on Jul 16, 2013 by gshdet
Hello,

I am hoping for some help/advice.

I am trying to get the ymax for a legend using c# but i the value returned is incorrect. The value for the width is correct though.

Please can someone explain why this does not return the correct value for ymax and how i can obtain this value?

Many thanks.


                    IGraphicsContainer graphicsContainer = mapDocument.PageLayout as IGraphicsContainer;

                    graphicsContainer.Reset();
                    IElement element = graphicsContainer.Next();

                    while (element != null)
                    {

                        if (element is IMapSurroundFrame)
                        {
                            IMapSurround mapSurround = ((IMapSurroundFrame)element).MapSurround;
                            if (mapSurround is ILegend)
                            {

                                 IEnvelope newEnvelope = new Envelope() as IEnvelope;

                                 mapSurround.QueryBounds(mapDocument.ActiveView.ScreenDisplay, element.Geometry.Envelope, newEnvelope);

                                 MessageBox.Show(newEnvelope.Envelope.YMax.ToString());
                                 MessageBox.Show(newEnvelope.Envelope.Width.ToString());

Outcomes