旋转MapSurround,包括图例、比例尺等等

   现在要做的功能类似于Desktop中,先将Legend进行Convert to Graphics,然后Rorate。

 

 

代码如下:

                       IEnumElement pLegendEnumElement = m_GraphicsContainer.LocateElements(pt, 0.1);
                            if (pLegendEnumElement == null) return;
                            IElement pLegendElement = pLegendEnumElement.Next();
                            if (pLegendElement == null) return;
                            if (pLegendElement is IMapSurroundFrame)
                            {
                                //旋转图例的Element

                                pEnvelope = pLegendElement.Geometry.Envelope;
                                pOriginPoint = new PointClass();
                                pOriginPoint.PutCoords((pEnvelope.XMax + pEnvelope.XMin) / 2, (pEnvelope.YMax + pEnvelope.YMin) / 2);
                              
                                IGraphicsComposite pGraphicsComposite = pLegendElement as IGraphicsComposite;
                                if (pGraphicsComposite != null)
                                {
                                    IActiveView pActiveVw = this.PageLayoutCtrl.PageLayout as IActiveView;
                                    IScreenDisplay pScreenDisp = pActiveVw.ScreenDisplay;

                                    IEnumElement pEnumEle = pGraphicsComposite.get_Graphics(pScreenDisp, null);
                                    if (pEnumEle != null)
                                    {
                                        pEnumEle.Reset();
                                        IElement pElem = pEnumEle.Next();
                                        while (pElem != null)
                                        {
                                            ITransform2D pTransform = pElem as ITransform2D;
                                            pTransform.Rotate(pOriginPoint, (Math.PI / 2.0));
                                            m_GraphicsContainer.UpdateElement(pElem);
                                            pElem = pEnumEle.Next();
                                        }
                                    }
                                }
                                this.PageLayoutCtrl.Refresh(esriViewDrawPhase.esriViewGraphics, null, null);
                            }

 

      在遍历每个Element时,通过IElement接口QI到IElementProperties3接口查看它的相关Element类型。

frame外廓线:
pEleProperties3.Type
"Polygon"
标题:
pEleProperties3.Type
"Text"
每个子项:
pEleProperties3.Type
"Group"
pEleProperties3.Type
"Group"
pEleProperties3.Type
"Group"
pEleProperties3.Type
"Group"
pEleProperties3.Type
"Group"
pEleProperties3.Type
"Group"
pEleProperties3.Type
"Group"

                                     

posted @ 2009-05-12 11:07  爱图--UpdooGIS  阅读(719)  评论(1编辑  收藏  举报