您的位置:首页 > 其它

[ArcEngine地图制图系列]—添加比例文本

2015-05-11 11:18 751 查看
       private void AddScaleText(IActiveView pActiveView, IEnvelope pEnv)

        {

            try

            {

                IGraphicsContainer pGraphicsContainer = pActiveView.GraphicsContainer;

                IMapFrame pMapFrame = pGraphicsContainer.FindFrame(pActiveView.FocusMap) as IMapFrame;

                IMapSurroundFrame pMapSurroundFrame = new MapSurroundFrameClass();

                pMapSurroundFrame.MapFrame = pMapFrame;

                IStyleGalleryItem pStyleGalleryItem = SymbolUtilty.GetItemFromServerStyle("Scale Texts", "Absolute Scale");

                pMapSurroundFrame.MapSurround = (IMapSurround)pStyleGalleryItem.Item;

                IElement pElement = axPageControl.FindElementByName("ScaleText");

                if (pElement != null)

                {

                    pGraphicsContainer.DeleteElement(pElement);  //删除已经存在的比例尺

                }

                IElementProperties pElePro = null;

                pElement = (IElement)pMapSurroundFrame;

                pElement.Geometry = (IGeometry)pEnv;

                pElePro = pElement as IElementProperties;

                pElePro.Name = "ScaleText";

                pGraphicsContainer.AddElement(pElement, 0);

                pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

            }

            catch (Exception e)

            {

                MessageBox.Show(e.ToString());

            }

        }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  IScaleText ArcGISEngine