AE二次开发,通过代码向axPageLayout控件,插入图例和指北针的方法
2013-10-30 11:40
357 查看
1.插入图例的方法如下:
2.插入指北针的方法
/// <summary> /// 给页面布局控件添加图例 /// </summary> /// <param name="pageLayout"></param> public static void InsertLegend(AxPageLayoutControl axPageLayout) { IElement pElement = axPageLayout.FindElementByName("Legend"); if (pElement != null) { axPageLayout.ActiveView.GraphicsContainer.DeleteElement(pElement); //删除已经存在的图例 } IPageLayout pPageLayout = axPageLayout.PageLayout; IGraphicsContainer pGraphicsContainer = pPageLayout as IGraphicsContainer; IActiveView pActiveView = pPageLayout as IActiveView; UID pID = new UIDClass(); pID.Value = "esriCore.Legend"; IMapFrame pMapFrame = pGraphicsContainer.FindFrame(pActiveView.FocusMap) as IMapFrame; if (pMapFrame == null) return; IMapSurroundFrame pMapSurroundFrame = pMapFrame.CreateSurroundFrame(pID, null); if (pMapSurroundFrame == null) return; //设置图例范围 IEnvelope pEnv = new EnvelopeClass(); pEnv.PutCoords(2, 2, 6, 6); pElement = (IElement)pMapSurroundFrame; pElement.Geometry = pEnv; pMapSurroundFrame.MapSurround.Name = "Legend"; ILegend legend = (ILegend)pMapSurroundFrame.MapSurround; legend.Title = "图例"; //让标题居中显示 ITextSymbol txtSymbol = new TextSymbolClass(); txtSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter; txtSymbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom; legend.Format.TitleSymbol = txtSymbol; legend.Refresh(); pGraphicsContainer.AddElement(pElement, 0); }
2.插入指北针的方法
/// <summary> /// 给页面布局控件添加指北针 /// </summary> /// <param name="pageLayout"></param> public static void InsertNorth(AxPageLayoutControl axPageLayout) { IElement pElement = axPageLayout.FindElementByName("MarkerNorthArrow"); if (pElement != null) { axPageLayout.ActiveView.GraphicsContainer.DeleteElement(pElement); //删除已经存在的图例 } IPageLayout pPageLayout = axPageLayout.PageLayout; IGraphicsContainer pGraphicsContainer = pPageLayout as IGraphicsContainer; IActiveView pActiveView = pPageLayout as IActiveView; UID pID = new UIDClass(); pID.Value = "esriCore.MarkerNorthArrow"; IMapFrame pMapFrame = pGraphicsContainer.FindFrame(pActiveView.FocusMap) as IMapFrame; if (pMapFrame == null) return; IMapSurroundFrame pMapSurroundFrame = pMapFrame.CreateSurroundFrame(pID, null); if (pMapSurroundFrame == null) return; IEnvelope pEnv = new EnvelopeClass(); pEnv.PutCoords(2, 2, 6, 6); pElement = (IElement)pMapSurroundFrame; pElement.Geometry = pEnv; pMapSurroundFrame.MapSurround.Name = "MarkerNorthArrow"; INorthArrow pNorthArrow = pMapSurroundFrame.MapSurround as INorthArrow; pGraphicsContainer.AddElement(pElement, 0); }
相关文章推荐
- AE二次开发中,AxMapControl中地图复制到AxPageLayout控件中的代码
- AE二次开发中,AxMapControl中地图复制到AxPageLayout控件中的代码
- Android(安卓)开发通过NDK调用JNI,使用opencv做本地c++代码开发配置方法实现边缘检测代码(2)
- iPhone开发学习笔记001——Xib界面上的控件与代码的相互关联方法
- iPhone开发学习笔记001——Xib界面上的控件与代码的相互关联方法
- Android(安卓)开发通过NDK调用JNI,使用opencv做本地c++代码开发配置方法 边缘检测 范例代码
- iPhone开发学习笔记001——Xib界面上的控件与代码的相互关联方法
- iphone开发之通过代理模式实现自定义控件——代码示例图片库的处理
- AE二次开发,选择本地shp文件添加到AxMapControl控件中
- Android(安卓)开发通过NDK调用JNI,使用opencv做本地c++代码开发配置方法 边缘检测 范例代码
- init方法只有通过代码创建控件的时候才会调用 用加载xib视图的时候 不会调用
- [转]Android通过NDK调用JNI,使用opencv做本地c++代码开发配置方法
- iOS开发小技巧-修改SliderBar指针的样式(牢记这个方法,只能通过代码来修改)
- 通过子类化的方法定制控件
- 如何开发高质量的软件 - 通过测试集中型的软件开发方法来提高软件质量
- XMPP框架 微信项目开发之Socket聊天室发送数据——获取键盘高度,修改控件的约束值,代码滚动UITabView到指定位置
- asp快速开发方法之数据操作实例代码第1/3页
- 代码命名,代码里的命名规则:错误的和正确的对比 命名方法总结 “自我描述的源代码”用代码表达出你的思想,让其他人通过代码能明白你的意图。
- WinForm控件开发总结(六)-----控件属性类型转换器代码详解
- 通过Xfire开发web service接口和客户端调用web service接口接口方法